/* ============================================
   App Shell - ボトムタブ式アプリUI
   ============================================ */

:root {
    --app-tab-h: 64px;
    --app-status-h: 56px;
    --app-brand-h: 56px;
    --app-bg: linear-gradient(180deg, #faf6f1 0%, #f4ede4 100%);
    --app-card-shadow: 0 4px 20px rgba(46, 38, 34, 0.06), 0 1px 4px rgba(46, 38, 34, 0.03);
}

/* アプリモードで body をリセット */
body.app-mode {
    background: var(--app-bg);
    background-attachment: fixed;
    padding-top: calc(var(--app-brand-h) + var(--app-status-h));
    padding-bottom: calc(var(--app-tab-h) + env(safe-area-inset-bottom, 0));
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   ブランドヘッダー（最上部）
   ============================================ */

.app-brand {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--app-brand-h);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 101;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
}

.app-brand__combo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--color-text);
    transition: opacity 0.2s;
}

.app-brand__combo:hover {
    opacity: 0.85;
}

.app-brand__combo-logo {
    height: 36px;
    width: auto;
}

.app-brand__combo-no {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text-muted);
}

.app-brand__combo-name {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: var(--color-text);
    white-space: nowrap;
}

.app-brand__combo-name em {
    font-style: normal;
    color: var(--color-primary);
    font-weight: 700;
}

@media (max-width: 380px) {
    .app-brand__combo-logo {
        height: 28px;
    }
    .app-brand__combo-name {
        font-size: 0.9rem;
    }
}

/* ステータスバーをブランドの下に */
.app-status {
    top: var(--app-brand-h) !important;
}

body.app-mode .site-header,
body.app-mode .site-footer,
body.app-mode [data-header],
body.app-mode [data-footer] {
    display: none !important;
}

/* ============================================
   トップステータスバー
   ============================================ */

.app-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--app-status-h);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 100;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.app-status__level {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.app-status__level-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.03em;
    box-shadow: 0 2px 6px rgba(201, 137, 154, 0.3);
}

.app-status__level-info {
    line-height: 1.1;
}

.app-status__level-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
}

.app-status__level-name {
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

.app-status__ep-bar {
    flex: 1;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-pill);
    overflow: hidden;
    position: relative;
}

.app-status__ep-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-secondary) 100%);
    border-radius: var(--radius-pill);
    transition: width 0.6s ease;
}

.app-status__streak {
    display: flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #c9899a, #a78a6b);
    color: #fff;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

@media (max-width: 380px) {
    .app-status__level-info {
        display: none;
    }
}

/* ============================================
   ボトムタブバー
   ============================================ */

.app-tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--app-tab-h);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--color-border);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -2px 20px rgba(58, 46, 42, 0.06);
}

.app-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--color-text-muted);
    transition: color 0.2s, transform 0.2s;
    padding: 8px 0;
    position: relative;
}

.app-tab:hover {
    color: var(--color-primary);
    opacity: 1;
}

.app-tab--active {
    color: var(--color-primary);
}

.app-tab--active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 0 0 4px 4px;
}

.app-tab__icon {
    font-size: 1.5rem;
    line-height: 1;
    transition: transform 0.2s;
}

.app-tab--active .app-tab__icon {
    transform: scale(1.15);
}

.app-tab__label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.app-tab__badge {
    position: absolute;
    top: 6px;
    right: 50%;
    transform: translateX(14px);
    background: #f44336;
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 2px 6px;
    min-width: 16px;
    text-align: center;
    line-height: 1;
}

/* ============================================
   アプリコンテンツ領域
   ============================================ */

.app-screen {
    padding: 16px;
    max-width: 720px;
    margin: 0 auto;
    animation: screenFadeIn 0.4s ease-out;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Today 画面用カード
   ============================================ */

.today-greeting {
    text-align: center;
    margin: 16px 0 24px;
}

.today-greeting__date {
    font-family: var(--font-serif);
    font-size: 0.72rem;
    color: var(--color-text-muted);
    letter-spacing: 0.3em;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.today-greeting__hello {
    font-family: var(--font-serif);
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.1em;
    color: var(--color-text);
}

.today-greeting__hello small {
    display: block;
    font-family: var(--font-serif);
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-weight: 400;
    letter-spacing: 0.15em;
    margin-top: 4px;
}

/* キャラがその日のあいさつ */
.today-char-card {
    background: #fff;
    border-radius: 22px;
    padding: 22px 20px;
    box-shadow: var(--app-card-shadow);
    margin-bottom: 20px;
    display: flex;
    gap: 16px;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.today-char-card::before {
    content: """;
    position: absolute;
    top: 4px;
    left: 12px;
    font-family: var(--font-serif);
    font-size: 3.2rem;
    line-height: 1;
    color: var(--color-border);
    opacity: 0.6;
    pointer-events: none;
}

.today-char-card__img {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.today-char-card__img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(46, 38, 34, 0.1));
}

.today-char-card__content {
    flex: 1;
    position: relative;
    z-index: 1;
    padding-top: 12px;
}

.today-char-card__name {
    font-family: var(--font-serif);
    font-size: 0.78rem;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: 0.15em;
}

.today-char-card__message {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--color-text);
    letter-spacing: 0.02em;
}

/* キャラ密度UP: 反対側に小さく他キャラを表示 */
.today-char-card__friends {
    position: absolute;
    bottom: 8px;
    right: 12px;
    display: flex;
    gap: -8px;
}

.today-char-card__friend {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--color-bg-section);
    margin-left: -8px;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(46, 38, 34, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.today-char-card__friend img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0.85;
}

/* 今日のクエスト */
.quest-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.quest-card {
    background: #fff;
    border-radius: 20px;
    padding: 16px;
    box-shadow: var(--app-card-shadow);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
    color: var(--color-text);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.quest-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(58, 46, 42, 0.12);
    opacity: 1;
}

.quest-card--done {
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
}

.quest-card--done .quest-card__title {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

.quest-card__icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    background: var(--color-bg-section);
    position: relative;
}

.quest-card__icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.quest-card--done .quest-card__icon {
    background: #e8f0ea;
}

.quest-card--done .quest-card__icon img {
    filter: grayscale(0.3);
    opacity: 0.7;
}

.quest-card__content {
    flex: 1;
    min-width: 0;
}

.quest-card__title {
    font-family: var(--font-serif);
    font-size: 1.02rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
    letter-spacing: 0.04em;
    color: var(--color-text);
}

.quest-card__desc {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    letter-spacing: 0.02em;
}

.quest-card__reward {
    display: inline-block;
    background: var(--color-bg-section);
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 600;
    margin-top: 6px;
    color: var(--color-tertiary);
    letter-spacing: 0.08em;
}

.quest-card__arrow {
    color: var(--color-text-muted);
    font-size: 1.2rem;
    flex-shrink: 0;
}

.quest-card--done .quest-card__arrow {
    color: #4caf50;
}

/* セクション見出し（エディトリアル） */
.app-section-title {
    font-family: var(--font-serif);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    letter-spacing: 0.18em;
    margin: 28px 0 12px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.app-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--color-border);
    margin-left: 4px;
}

.app-section-title__emoji {
    font-size: 1.1rem;
    opacity: 0.7;
}

/* 統計サマリーカード */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 14px 8px;
    text-align: center;
    box-shadow: var(--app-card-shadow);
}

.stat-card__value {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    letter-spacing: 0.02em;
}

.stat-card__label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    margin-top: 6px;
    font-weight: 500;
    letter-spacing: 0.1em;
}

.stat-card__emoji {
    font-size: 1.1rem;
    margin-bottom: 4px;
    opacity: 0.7;
}

/* レベルアップ・報酬ポップアップ */
.app-toast {
    position: fixed;
    bottom: calc(var(--app-tab-h) + 16px);
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: linear-gradient(135deg, #fff, #fff5e6);
    border-radius: 16px;
    padding: 12px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 200;
    transition: transform 0.4s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
    border: 2px solid var(--color-primary);
}

.app-toast--show {
    transform: translateX(-50%) translateY(0);
}

.app-toast__icon {
    font-size: 1.5rem;
}

.app-toast__text {
    font-weight: 700;
    font-size: 0.9rem;
}

/* ============================================
   ブランドヒーロー（Top専用・エディトリアル風）
   ============================================ */

.brand-hero {
    text-align: center;
    padding: 36px 20px 28px;
    margin: 4px 0 16px;
    background: #ffffff;
    border-radius: 24px;
    box-shadow: var(--app-card-shadow);
    position: relative;
    overflow: hidden;
}

/* 背景の微細なテクスチャ */
.brand-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at top right, rgba(201, 137, 154, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at bottom left, rgba(201, 169, 110, 0.05) 0%, transparent 50%);
    pointer-events: none;
}

/* キャラを背景に控えめに配置（キャラ密度UPだけど邪魔しない） */
.brand-hero__char-bg {
    position: absolute;
    pointer-events: none;
    opacity: 0.13;
    z-index: 0;
    filter: blur(0.5px);
}

.brand-hero__char-bg--rink {
    top: 12px;
    left: -8px;
    width: 70px;
}

.brand-hero__char-bg--konta {
    bottom: 8px;
    right: -8px;
    width: 78px;
}

.brand-hero__char-bg--tanunee {
    top: 50%;
    right: 8px;
    width: 56px;
    transform: translateY(-50%);
    opacity: 0.1;
}

.brand-hero__top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    position: relative;
    z-index: 1;
    margin-bottom: 8px;
}

.brand-hero__logo-link {
    display: inline-block;
    text-decoration: none;
    transition: opacity 0.2s;
}

.brand-hero__logo-link:hover {
    opacity: 0.8;
}

.brand-hero__logo {
    height: 56px;
    width: auto;
}

.brand-hero__divider {
    width: 1px;
    height: 36px;
    background: var(--color-border);
}

.brand-hero__sub {
    font-family: var(--font-serif);
    font-size: 0.7rem;
    letter-spacing: 0.25em;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
}

.brand-hero__sub-jp {
    display: block;
    font-family: var(--font-serif);
    font-size: 0.65rem;
    letter-spacing: 0.4em;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.brand-hero__title {
    font-family: var(--font-serif);
    font-size: clamp(1.6rem, 5.5vw, 2.2rem);
    font-weight: 700;
    line-height: 1.3;
    margin: 12px 0 6px;
    color: var(--color-text);
    position: relative;
    z-index: 1;
    letter-spacing: 0.08em;
}

.brand-hero__title em {
    font-style: normal;
    color: var(--color-primary);
}

.brand-hero__divider-line {
    width: 40px;
    height: 1px;
    background: var(--color-text-muted);
    margin: 14px auto;
    opacity: 0.4;
    position: relative;
    z-index: 1;
}

.brand-hero__tagline {
    font-family: var(--font-serif);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    font-weight: 400;
    letter-spacing: 0.12em;
    position: relative;
    z-index: 1;
    line-height: 1.7;
}

@media (max-width: 380px) {
    .brand-hero__logo {
        height: 44px;
    }
    .brand-hero__sub {
        font-size: 0.6rem;
        letter-spacing: 0.2em;
    }
}

/* ============================================
   トップ3人組ヒーロー
   ============================================ */

.top-trio {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    margin: 16px 0 8px;
    padding: 12px 8px;
    background: linear-gradient(180deg, rgba(255, 245, 230, 0.6) 0%, rgba(255, 228, 236, 0.4) 100%);
    border-radius: 24px;
    box-shadow: var(--app-card-shadow);
    position: relative;
    overflow: hidden;
}

.top-trio::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(255, 143, 163, 0.12) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(126, 200, 227, 0.12) 0%, transparent 50%);
    pointer-events: none;
}

.top-trio__member {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--color-text);
    padding: 8px 4px;
    border-radius: 16px;
    transition: transform 0.3s, background 0.2s;
    position: relative;
    z-index: 1;
}

.top-trio__member:hover {
    transform: translateY(-6px);
    background: rgba(255, 255, 255, 0.4);
    opacity: 1;
}

.top-trio__member img {
    width: 90px;
    height: 90px;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.12));
    transition: transform 0.3s;
}

.top-trio__member:nth-child(1) img { animation: trioFloat 3s ease-in-out infinite; }
.top-trio__member:nth-child(2) img { animation: trioFloat 3s ease-in-out 0.5s infinite; }
.top-trio__member:nth-child(3) img { animation: trioFloat 3s ease-in-out 1s infinite; }

@keyframes trioFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.top-trio__name {
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
}

.top-trio__member--rink .top-trio__name { color: #ff8fa3; }
.top-trio__member--konta .top-trio__name { color: #ffb347; }
.top-trio__member--tanunee .top-trio__name { color: #c19a6b; }

@media (max-width: 380px) {
    .top-trio__member img {
        width: 72px;
        height: 72px;
    }
}

/* ============================================
   ホームに戻すリンク（記事ページ用）
   ============================================ */

.back-to-app {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: #fff;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 4px 16px rgba(255, 143, 163, 0.4);
    z-index: 50;
    text-decoration: none;
    transition: transform 0.2s;
}

.back-to-app:hover {
    transform: scale(1.1);
    opacity: 1;
    color: #fff;
}

/* ============================================
   ヒーロー（Today画面の細胞ビジュアル）小さい版
   ============================================ */

.today-hero {
    text-align: center;
    padding: 24px 0 16px;
    position: relative;
    margin-bottom: 12px;
}

.today-hero__cell {
    width: 160px;
    height: 160px;
    margin: 0 auto;
    position: relative;
}

.today-hero__core {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 235, 230, 0.95) 0%,
        rgba(232, 215, 200, 0.85) 55%,
        rgba(201, 137, 154, 0.5) 100%);
    box-shadow:
        0 0 24px rgba(201, 137, 154, 0.25),
        inset -4px -4px 12px rgba(46, 38, 34, 0.04);
    animation: cellPulse 4s ease-in-out infinite;
}

.today-hero__ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px dashed rgba(201, 137, 154, 0.35);
    transform: translate(-50%, -50%);
    animation: cellSpin 30s linear infinite;
}

/* 細胞のまわりに3キャラを配置 */
.today-hero__char {
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(46, 38, 34, 0.1);
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.today-hero__char img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.today-hero__char--rink {
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    animation: trioFloat 3s ease-in-out infinite;
}

.today-hero__char--konta {
    bottom: 24px;
    left: 8px;
    animation: trioFloat 3s ease-in-out 0.5s infinite;
}

.today-hero__char--tanunee {
    bottom: 24px;
    right: 8px;
    animation: trioFloat 3s ease-in-out 1s infinite;
}
