/* ========================================
   NIHONKY — Premium UI Design System
   Modern Japanese Learning Experience
   Version 2.0 · 2026
   ======================================== */

/* ========================================
   CORE VARIABLES & DESIGN TOKENS
   ======================================== */
:root {
    /* Primary Palette — Warm & Inviting */
    --rose: #D4728C;
    --rose-mid: #E8A0B4;
    --rose-pale: #F5D0DC;
    --rose-wash: #FDF0F4;
    --rose-glow: rgba(212, 114, 140, .2);
    
    --sky: #5EA0C4;
    --sky-mid: #8DC3DC;
    --sky-pale: #CCE4F0;
    --sky-wash: #EFF7FB;
    
    --wist: #8C72B0;
    --wist-mid: #B09CD0;
    --wist-pale: #D8CCE8;
    --wist-wash: #F2EEFA;
    
    --honey: #C49840;
    --honey-mid: #DEB870;
    --honey-pale: #F0DEB8;
    --honey-wash: #FDFAF0;
    
    --sage: #5CA870;
    --sage-pale: #C8E8D0;
    --coral: #C86060;
    --coral-pale: #F0D0D0;
    
    /* Neutral System */
    --ink: #1A1620;
    --ink-mid: #5A4E62;
    --ink-soft: #8E8298;
    --ink-mute: #B8AEC0;
    --ink-ghost: #DCD4E2;
    --ink-faint: #F0ECF4;
    
    /* Surfaces */
    --paper: #FBF9FC;
    --card: #FFFFFF;
    --surface: #F6F2F8;
    --depth: #ECE6F0;
    
    /* Shadows — Elevation System */
    --shadow-xs: 0 1px 2px rgba(26, 22, 32, .04);
    --shadow-sm: 0 1px 4px rgba(26, 22, 32, .06);
    --shadow-md: 0 4px 16px rgba(26, 22, 32, .08), 0 2px 4px rgba(212, 114, 140, .04);
    --shadow-lg: 0 8px 32px rgba(26, 22, 32, .10), 0 4px 8px rgba(212, 114, 140, .06);
    --shadow-xl: 0 16px 48px rgba(26, 22, 32, .12), 0 8px 16px rgba(212, 114, 140, .08);
    --shadow-inner: inset 0 1px 3px rgba(26, 22, 32, .06);
    --shadow-glow: 0 0 0 4px var(--rose-glow);
    --shadow-float: 0 8px 40px rgba(26, 22, 32, .06);
    
    /* Radius */
    --r-xs: 4px;
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-2xl: 28px;
    --r-3xl: 36px;
    --r-full: 9999px;
    
    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-jp: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
    --font-mono: 'SF Mono', 'JetBrains Mono', monospace;
    
    /* Easing */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --ease-out: cubic-bezier(0, 0, .2, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --ease-bounce: cubic-bezier(.68, -.55, .265, 1.55);
    
    /* Durations */
    --dur-fast: .12s;
    --dur: .2s;
    --dur-md: .32s;
    --dur-lg: .48s;
    --dur-xl: .64s;
    
    /* Layout */
    --nav-h: 68px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
    --max-width: 460px;
}

/* ========================================
   RESET & BASE STYLES
   ======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { text-decoration: none; color: inherit; }
button { 
    font-family: inherit;
    border: 0;
    background: none;
    cursor: pointer;
    font-size: inherit;
    color: inherit;
    -webkit-appearance: none;
    touch-action: manipulation;
}
input {
    font-family: inherit;
    font-size: inherit;
    border: 0;
    outline: 0;
    -webkit-appearance: none;
}
img, svg { display: block; }
ul, ol { list-style: none; }

::selection {
    background: var(--rose-pale);
    color: var(--ink);
}

/* Scrollbar */
::-webkit-scrollbar { 
    width: 4px;
    height: 4px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--ink-ghost);
    border-radius: var(--r-full);
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-mute); }

/* Focus */
:focus-visible {
    outline: 2.5px solid var(--rose);
    outline-offset: 2px;
}

/* ========================================
   KEYFRAMES — Motion Design System
   ======================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fadeScale {
    from { opacity: 0; transform: scale(.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes popIn {
    0% { opacity: 0; transform: scale(.6); }
    70% { transform: scale(1.05); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

@keyframes breathe {
    0%, 100% { opacity: .5; }
    50% { opacity: 1; }
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(200%); }
}

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

@keyframes floatSlow {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-4px) rotate(2deg); }
}

@keyframes driftUp {
    0% { transform: translateY(0) scale(1); opacity: .6; }
    100% { transform: translateY(-80px) scale(0.4); opacity: 0; }
}

@keyframes spin {
    from { transform: rotate(0); }
    to { transform: rotate(360deg); }
}

@keyframes ringPulse {
    0% { box-shadow: 0 0 0 0 var(--rose-glow); }
    100% { box-shadow: 0 0 0 12px transparent; }
}

@keyframes dotPop {
    0% { transform: scale(0); }
    70% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-20px) scale(.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px) scale(.95); }
}

@keyframes sakuraFall {
    0% { transform: translateY(-20px) rotate(0); opacity: 0; }
    10% { opacity: .5; }
    90% { opacity: .3; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

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

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes glowPulse {
    0%, 100% { box-shadow: 0 4px 24px var(--rose-glow); }
    50% { box-shadow: 0 6px 40px rgba(212, 114, 140, .3); }
}

@keyframes expandWidth {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes drawLine {
    to { stroke-dashoffset: 0; }
}

/* ========================================
   APP SHELL
   ======================================== */
#app {
    position: relative;
    max-width: var(--max-width);
    margin: 0 auto;
    min-height: 100dvh;
    z-index: 1;
    background: var(--paper);
}

@media (min-width: 461px) {
    #app {
        border-left: 1px solid var(--ink-faint);
        border-right: 1px solid var(--ink-faint);
        box-shadow: var(--shadow-xl);
    }
}

.screen {
    display: none;
    min-height: 100dvh;
    animation: fadeIn var(--dur-md) var(--ease);
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ========================================
   SPLASH SCREEN — First Impression
   ======================================== */
#splash-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(160deg, #FDF0F4 0%, #FEFCFD 30%, #EFF7FB 65%, #F2EEFA 100%);
    position: relative;
    overflow: hidden;
}

.splash-bg-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.splash-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.7), rgba(212,114,140,.06));
    border: 1px solid rgba(255,255,255,.2);
    filter: blur(1px);
}
.sb1 { width: 120px; height: 120px; top: -5%; left: -10%; animation: float 8s var(--ease) infinite; }
.sb2 { width: 80px; height: 80px; top: 60%; right: -5%; animation: float 10s var(--ease) infinite 1.5s; }
.sb3 { width: 50px; height: 50px; bottom: 10%; left: 15%; animation: float 9s var(--ease) infinite 3s; }

.splash-sakura {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--rose-pale);
    border-radius: 50% 0 50% 50%;
    opacity: .4;
}
.ss1 { top: 15%; right: 25%; transform: rotate(45deg); animation: sakuraFall 14s linear infinite; }
.ss2 { top: 5%; left: 20%; transform: rotate(120deg); animation: sakuraFall 18s linear infinite 4s; }
.ss3 { top: 2%; right: 10%; transform: rotate(200deg); animation: sakuraFall 22s linear infinite 8s; }

.splash-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--honey-mid);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--honey-mid);
    animation: pulse 2s var(--ease) infinite;
}
.sp1 { top: 25%; left: 12%; animation-delay: 0s; }
.sp2 { top: 70%; right: 15%; animation-delay: 1s; }

.splash-content {
    text-align: center;
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 300px;
    position: relative;
    z-index: 2;
}

.splash-mascot {
    margin-bottom: 1.2rem;
    animation: fadeScale var(--dur-lg) var(--ease-spring) both;
}

.mascot-svg {
    width: 110px;
    height: 110px;
    margin: 0 auto;
    filter: drop-shadow(0 8px 24px var(--rose-glow));
    animation: mascotBounce 3s var(--ease) infinite;
}

.splash-brand {
    animation: fadeUp var(--dur-lg) var(--ease) .12s both;
}

.splash-logo-mark {
    margin-bottom: .5rem;
    display: flex;
    justify-content: center;
}

.logo-gem {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 4px 12px var(--rose-glow));
}

.splash-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -.5px;
    color: var(--ink);
    background: linear-gradient(135deg, var(--ink), var(--rose));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.splash-sub {
    font-size: .8rem;
    color: var(--ink-soft);
    font-weight: 450;
    letter-spacing: .2px;
}

.splash-loader-area {
    margin-top: 2rem;
    animation: fadeUp var(--dur-lg) var(--ease) .24s both;
}

.splash-bar-track {
    width: 100%;
    height: 5px;
    background: var(--rose-pale);
    border-radius: var(--r-full);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-inner);
}

.splash-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--rose), var(--rose-mid));
    border-radius: var(--r-full);
    transition: width .3s var(--ease);
}

.splash-bar-shine {
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
    animation: shimmer 2s var(--ease) infinite;
}

.splash-loader-text {
    font-size: .65rem;
    color: var(--ink-mute);
    margin-top: .8rem;
    font-weight: 500;
    letter-spacing: .3px;
    animation: breathe 2s var(--ease) infinite;
}

/* ========================================
   BUTTON SYSTEM — Consistent & Accessible
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border-radius: var(--r-full);
    font-size: .85rem;
    font-weight: 600;
    transition: all var(--dur) var(--ease);
    position: relative;
    touch-action: manipulation;
    user-select: none;
    letter-spacing: .15px;
    white-space: nowrap;
}

.btn:active {
    transform: scale(.95);
    transition: transform var(--dur-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--rose), #C06480);
    color: #fff;
    box-shadow: 0 4px 16px var(--rose-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(212, 114, 140, .3);
}

.btn-primary:disabled {
    background: var(--ink-ghost);
    color: var(--ink-mute);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--card);
    color: var(--ink);
    border: 2px solid var(--ink-ghost);
    box-shadow: var(--shadow-xs);
}

.btn-secondary:hover {
    border-color: var(--rose-mid);
    color: var(--rose);
    background: var(--rose-wash);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
}

.btn-ghost:hover {
    color: var(--rose);
    background: var(--rose-wash);
}

.btn-glass {
    background: rgba(255, 255, 255, .7);
    border: 1.5px solid var(--ink-ghost);
    color: var(--ink-mid);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.btn-glass:hover {
    border-color: var(--rose);
    color: var(--rose);
    background: var(--rose-wash);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background: var(--coral);
    color: #fff;
    box-shadow: 0 4px 12px rgba(200, 96, 96, .2);
}

.btn-danger:hover {
    background: #B05050;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(200, 96, 96, .25);
}

.btn-success {
    background: var(--sage);
    color: #fff;
    box-shadow: 0 4px 12px rgba(92, 168, 112, .2);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(92, 168, 112, .25);
}

.btn-sm { padding: 8px 18px; font-size: .75rem; }
.btn-lg { padding: 14px 34px; font-size: .9rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-pill { border-radius: var(--r-full); }

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   ONBOARDING — Smooth Introduction
   ======================================== */
#onboarding-screen {
    justify-content: center;
    align-items: center;
    background: var(--paper);
    padding: 2rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.ob-bg-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.ob-cloud {
    position: absolute;
    border-radius: 100px;
    background: rgba(212, 114, 140, .03);
}
.oc1 { width: 180px; height: 80px; top: 5%; left: -20px; }
.oc2 { width: 140px; height: 60px; bottom: 10%; right: -10px; }

.ob-float {
    position: absolute;
    font-family: var(--font-jp);
    font-size: 1.5rem;
    font-weight: 700;
    opacity: .04;
    pointer-events: none;
    color: var(--ink);
}
.of1 { top: 10%; left: 8%; animation: floatSlow 12s var(--ease) infinite; }
.of2 { top: 55%; right: 5%; animation: floatSlow 14s var(--ease) infinite 2s; }
.of3 { bottom: 15%; left: 20%; animation: floatSlow 16s var(--ease) infinite 4s; }

.ob-container {
    width: 100%;
    max-width: 340px;
    text-align: center;
    position: relative;
    z-index: 1;
}

.ob-slides {
    position: relative;
    min-height: 320px;
}

.ob-slide {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    animation: fadeUp var(--dur-md) var(--ease-spring);
}

.ob-slide.active { display: flex; }

.ob-illust {
    margin-bottom: .25rem;
}

.ob-svg {
    width: 120px;
    height: 120px;
    filter: drop-shadow(0 4px 12px rgba(212, 114, 140, .1));
    animation: float 5s var(--ease) infinite;
}

.ob-title {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -.3px;
}

.ob-desc {
    font-size: .85rem;
    color: var(--ink-soft);
    line-height: 1.6;
    max-width: 270px;
}

.ob-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 1.5rem 0;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ink-ghost);
    border: 0;
    transition: all var(--dur-md) var(--ease-spring);
    cursor: pointer;
}

.dot:hover { background: var(--rose-mid); }
.dot.active {
    background: var(--rose);
    width: 28px;
    border-radius: var(--r-full);
}

.ob-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ========================================
   NAME SCREEN — Personal Onboarding
   ======================================== */
#name-screen {
    justify-content: center;
    align-items: center;
    background: var(--paper);
    padding: 2rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.nm-bg-art {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.nm-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.6), rgba(212,114,140,.04));
    border: 1px solid rgba(255,255,255,.15);
}
.nb1 { width: 100px; height: 100px; top: 5%; right: -10%; animation: float 8s var(--ease) infinite; }
.nb2 { width: 60px; height: 60px; bottom: 10%; left: -5%; animation: float 10s var(--ease) infinite 2s; }

.nm-container {
    width: 100%;
    max-width: 340px;
    text-align: center;
    position: relative;
    z-index: 1;
    animation: fadeUp var(--dur-md) var(--ease);
}

.nm-logo svg {
    width: 44px;
    height: 44px;
    margin: 0 auto 1.25rem;
    filter: drop-shadow(0 4px 12px var(--rose-glow));
}

.nm-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: .15rem;
    letter-spacing: -.3px;
}

.nm-sub {
    font-size: .8rem;
    color: var(--ink-soft);
    margin-bottom: 1.5rem;
}

.nm-input-wrap {
    position: relative;
    margin-bottom: 1.5rem;
}

.nm-input {
    width: 100%;
    padding: 14px 20px;
    background: var(--card);
    border: 2px solid var(--ink-ghost);
    border-radius: var(--r-lg);
    font-size: .9rem;
    font-weight: 500;
    color: var(--ink);
    text-align: center;
    transition: all var(--dur) var(--ease);
    box-shadow: var(--shadow-xs);
}

.nm-input:focus {
    border-color: var(--rose);
    box-shadow: var(--shadow-glow), var(--shadow-md);
}

.nm-input::placeholder {
    color: var(--ink-mute);
    font-weight: 400;
}

.nm-input-glow {
    position: absolute;
    inset: -4px;
    border-radius: calc(var(--r-lg) + 4px);
    background: var(--rose-glow);
    opacity: 0;
    transition: opacity var(--dur) var(--ease);
    pointer-events: none;
    z-index: -1;
}

.nm-input:focus ~ .nm-input-glow { opacity: 1; }

.nm-jlpt-area {
    margin-bottom: 1.5rem;
}

.nm-jlpt-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--ink-mid);
    margin-bottom: .6rem;
    letter-spacing: .3px;
}

/* ========================================
   PILL BUTTONS — Toggle Selection
   ======================================== */
.pill-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.pill-row-sm .pill-btn {
    padding: 6px 14px;
    font-size: .7rem;
}

.pill-btn {
    padding: 8px 18px;
    border-radius: var(--r-full);
    font-size: .78rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--ink-mid);
    border: 2px solid transparent;
    transition: all var(--dur-md) var(--ease-spring);
    box-shadow: var(--shadow-xs);
    touch-action: manipulation;
}

.pill-btn:hover {
    background: var(--rose-wash);
    color: var(--rose);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pill-btn:active {
    transform: scale(.92);
}

.pill-btn.active {
    background: linear-gradient(135deg, var(--rose), #C06480);
    color: #fff;
    border-color: var(--rose);
    box-shadow: 0 4px 12px var(--rose-glow);
}

/* ========================================
   GAME HEADER — Navigation Bar
   ======================================== */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    padding-top: calc(10px + var(--safe-t));
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--ink-faint);
    position: sticky;
    top: 0;
    z-index: 50;
}

.gh-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gh-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.avatar-ring {
    position: absolute;
    inset: 0;
    animation: spin 10s linear infinite;
    animation-play-state: paused;
}

.gh-avatar:hover .avatar-ring {
    animation-play-state: running;
}

.avatar-face {
    position: absolute;
    inset: 5px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--rose-wash);
    border: 2px solid var(--card);
}

.avatar-face svg {
    width: 100%;
    height: 100%;
}

.gh-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.gh-name {
    font-size: .72rem;
    color: var(--ink-soft);
    font-weight: 500;
}

.gh-lvl {
    font-size: .8rem;
    font-weight: 800;
    letter-spacing: -.2px;
}

.gh-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.gh-xp-gem {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: var(--honey-wash);
    border: 1.5px solid var(--honey-pale);
    border-radius: var(--r-full);
    font-size: .72rem;
    font-weight: 700;
    color: var(--honey);
    transition: all var(--dur) var(--ease);
}

.gh-xp-gem:hover {
    transform: scale(1.04);
    box-shadow: var(--shadow-sm);
}

.xp-star {
    width: 14px;
    height: 14px;
}

.gh-btn-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--ink-soft);
    transition: all var(--dur) var(--ease);
}

.gh-btn-icon:hover {
    background: var(--rose-wash);
    color: var(--rose);
}

.gh-btn-icon:active {
    transform: scale(.88);
}

.gh-btn-icon svg {
    width: 18px;
    height: 18px;
}

/* ========================================
   HOME SCREEN — Main Dashboard
   ======================================== */
#home-screen {
    position: relative;
    background: var(--paper);
}

.home-bg-art {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
    max-width: var(--max-width);
    margin: 0 auto;
}

.hbg-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(170deg,
        rgba(245, 208, 220, .12) 0%,
        transparent 35%,
        rgba(204, 228, 240, .08) 60%,
        rgba(216, 204, 232, .06) 100%
    );
}

.hbg-cloud {
    position: absolute;
    background: rgba(212, 114, 140, .03);
    border-radius: 100px;
}
.hc1 { width: 200px; height: 60px; top: 6%; left: -20px; }
.hc2 { width: 160px; height: 50px; top: 40%; right: -30px; }

.hbg-sakura {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--rose-pale);
    border-radius: 50% 0 50% 50%;
    opacity: .25;
}
.hs1 { top: 10%; right: 12%; transform: rotate(45deg); animation: sakuraFall 18s linear infinite; }
.hs2 { top: 4%; left: 20%; transform: rotate(120deg); animation: sakuraFall 22s linear infinite 6s; }
.hs3 { top: 2%; right: 30%; transform: rotate(200deg); animation: sakuraFall 26s linear infinite 12s; }

.hbg-bubble {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.5), rgba(212,114,140,.02));
    border: 1px solid rgba(255,255,255,.1);
}
.hb1 { width: 60px; height: 60px; top: 22%; left: 3%; animation: float 12s var(--ease) infinite; }
.hb2 { width: 40px; height: 40px; top: 55%; right: 5%; animation: float 14s var(--ease) infinite 4s; }
.hb3 { width: 30px; height: 30px; bottom: 20%; left: 12%; animation: float 16s var(--ease) infinite 8s; }

.hbg-sparkle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--honey-mid);
    border-radius: 50%;
    animation: pulse 3s var(--ease) infinite;
}
.hsp1 { top: 18%; right: 22%; animation-delay: 0s; }
.hsp2 { top: 42%; left: 12%; animation-delay: 1.5s; }
.hsp3 { bottom: 30%; right: 30%; animation-delay: 3s; }

.hbg-float-char {
    position: absolute;
    font-family: var(--font-jp);
    font-weight: 700;
    color: var(--ink);
    opacity: .03;
    pointer-events: none;
    font-size: 2.5rem;
}
.hfc1 { top: 5%; left: 5%; animation: floatSlow 16s var(--ease) infinite; }
.hfc2 { top: 40%; right: 3%; animation: floatSlow 20s var(--ease) infinite 4s; }
.hfc3 { bottom: 15%; left: 15%; animation: floatSlow 22s var(--ease) infinite 8s; }

.hbg-pattern {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(circle at 1px 1px, rgba(212, 114, 140, .02) 1px, transparent 0);
    background-size: 30px 30px;
}

/* ========================================
   HOME MAIN — Scrollable Content
   ======================================== */
.home-main {
    flex: 1;
    position: relative;
    z-index: 1;
    padding: 16px 16px;
    padding-bottom: calc(var(--nav-h) + 20px + var(--safe-b));
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow-y: auto;
}

.sec-title {
    font-size: .88rem;
    font-weight: 800;
    letter-spacing: -.15px;
    color: var(--ink);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ========================================
   MASCOT CARD — Daily Greeting
   ======================================== */
.mascot-card {
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    overflow: hidden;
    animation: fadeUp var(--dur-md) var(--ease) both;
}

.mascot-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--rose), var(--wist), var(--sky));
}

.mc-mascot {
    flex-shrink: 0;
}

.mc-svg {
    width: 56px;
    height: 56px;
    animation: mascotBounce 3.5s var(--ease) infinite;
}

.mc-content {
    flex: 1;
    min-width: 0;
}

.mc-speech {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 6px;
}

.mc-streak-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mc-streak-badge {
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 3px 12px;
    background: var(--rose-wash);
    border-radius: var(--r-full);
    border: 1.5px solid var(--rose-pale);
}

.mc-streak-num {
    font-size: .9rem;
    font-weight: 900;
    color: var(--rose);
}

.mc-streak-text {
    font-size: .58rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.mc-streak-dots {
    display: flex;
    gap: 3px;
}

.streak-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--surface);
    border: 1.5px solid var(--ink-ghost);
    transition: all var(--dur-md) var(--ease-spring);
}

.streak-dot.filled {
    background: var(--rose);
    border-color: var(--rose);
    animation: dotPop var(--dur-md) var(--ease-spring) both;
}

/* ========================================
   STATS PANEL — Circular Progress
   ======================================== */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    animation: fadeUp var(--dur-md) var(--ease) .05s both;
}

.sp-item {
    background: var(--card);
    border-radius: var(--r-lg);
    padding: 14px 6px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: all var(--dur) var(--ease);
}

.sp-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sp-ring {
    position: relative;
    width: 48px;
    height: 48px;
    margin: 0 auto 4px;
}

.sp-ring svg {
    width: 100%;
    height: 100%;
}

.sp-ring-val {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .7rem;
    font-weight: 900;
}

.sp-label {
    font-size: .55rem;
    font-weight: 700;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* ========================================
   PLAY BUTTON — Hero CTA
   ======================================== */
.play-area {
    animation: fadeUp var(--dur-md) var(--ease) .1s both;
}

.play-btn {
    width: 100%;
    padding: 0;
    border: 0;
    cursor: pointer;
    border-radius: var(--r-2xl);
    position: relative;
    overflow: hidden;
    height: 76px;
    animation: glowPulse 3s var(--ease) infinite;
    transition: transform var(--dur) var(--ease);
    touch-action: manipulation;
}

.play-btn:hover {
    transform: translateY(-2px) scale(1.01);
}

.play-btn:active {
    transform: scale(.97);
    animation: none;
}

.play-btn-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--rose), #C06480, var(--rose-mid));
    background-size: 200% 200%;
    animation: gradientShift 4s var(--ease) infinite;
    border-radius: var(--r-2xl);
}

.play-btn-shine {
    position: absolute;
    top: 0;
    left: -60%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.15), transparent);
    animation: shimmer 3.5s var(--ease) infinite;
}

.play-btn-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    height: 100%;
    color: #fff;
}

.play-icon {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.play-label {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: .5px;
}

.play-sub {
    font-size: .65rem;
    opacity: .8;
    font-weight: 500;
}

/* ========================================
   CATEGORY CARDS — Learning Paths
   ======================================== */
.cat-section {
    animation: fadeUp var(--dur-md) var(--ease) .14s both;
}

.cat-scroll {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card);
    border-radius: var(--r-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-xs);
    transition: all var(--dur) var(--ease);
    border: 2px solid transparent;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
}

.cat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--rose-pale);
}

.cat-card:active {
    transform: scale(.97);
}

.cc-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--dur-md) var(--ease-spring);
}

.cat-card:hover .cc-icon {
    transform: scale(1.06) rotate(-2deg);
}

.cc-rose { background: var(--rose-wash); }
.cc-sky { background: var(--sky-wash); }
.cc-wist { background: var(--wist-wash); }
.cc-honey { background: var(--honey-wash); }

.cc-char {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-jp);
}
.cc-rose .cc-char { color: var(--rose); }
.cc-sky .cc-char { color: var(--sky); }
.cc-wist .cc-char { color: var(--wist); }
.cc-honey .cc-char { color: var(--honey); }

.cc-body {
    flex: 1;
    min-width: 0;
}

.cc-name {
    display: block;
    font-size: .8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.cc-bar {
    width: 100%;
    height: 4px;
    background: var(--surface);
    border-radius: var(--r-full);
    overflow: hidden;
}

.cc-fill {
    height: 100%;
    border-radius: var(--r-full);
    width: 0%;
    transition: width .8s var(--ease-out);
}
.cc-fill-rose { background: var(--rose); }
.cc-fill-sky { background: var(--sky); }
.cc-fill-wist { background: var(--wist); }
.cc-fill-honey { background: var(--honey); }

.cc-arrow {
    flex-shrink: 0;
    color: var(--ink-ghost);
    transition: all var(--dur) var(--ease);
}
.cc-arrow svg { width: 14px; height: 14px; }
.cat-card:hover .cc-arrow {
    color: var(--rose);
    transform: translateX(3px);
}

/* ========================================
   JLPT GEM BUTTONS — Level Selector
   ======================================== */
.jlpt-section {
    animation: fadeUp var(--dur-md) var(--ease) .18s both;
}

.jlpt-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.jlpt-gem {
    background: var(--card);
    border-radius: var(--r-md);
    padding: 12px 4px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: all var(--dur-md) var(--ease-spring);
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.jlpt-gem::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,.2), transparent);
    pointer-events: none;
}

.jlpt-gem:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--rose-pale);
}

.jlpt-gem.active {
    border-color: var(--rose);
    background: var(--rose-wash);
    box-shadow: 0 4px 12px var(--rose-glow);
}

.jlpt-gem:active {
    transform: scale(.92);
}

.jg-num {
    display: block;
    font-size: .9rem;
    font-weight: 900;
    position: relative;
}

.jg-tag {
    display: block;
    font-size: .45rem;
    color: var(--ink-mute);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
    position: relative;
}

/* ========================================
   MASTERY PANEL — Skill Breakdown
   ======================================== */
.mastery-panel {
    animation: fadeUp var(--dur-md) var(--ease) .22s both;
}

.mp-card {
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mp-row {
    display: grid;
    grid-template-columns: 72px 1fr 40px;
    align-items: center;
    gap: 10px;
}

.mp-label {
    font-size: .72rem;
    font-weight: 700;
    color: var(--ink-mid);
}

.mp-bar {
    height: 7px;
    background: var(--surface);
    border-radius: var(--r-full);
    overflow: hidden;
    box-shadow: var(--shadow-inner);
}

.mp-fill {
    height: 100%;
    border-radius: var(--r-full);
    transition: width 1s var(--ease-out);
    position: relative;
}

.mp-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,.3), transparent);
    border-radius: var(--r-full);
}

.mp-fill-rose { background: linear-gradient(90deg, var(--rose), var(--rose-mid)); }
.mp-fill-sky { background: linear-gradient(90deg, var(--sky), var(--sky-mid)); }
.mp-fill-wist { background: linear-gradient(90deg, var(--wist), var(--wist-mid)); }
.mp-fill-honey { background: linear-gradient(90deg, var(--honey), var(--honey-mid)); }

.mp-pct {
    font-size: .65rem;
    font-weight: 800;
    color: var(--ink-mid);
    text-align: right;
}

/* ========================================
   DETAIL STATS — Quick Numbers
   ======================================== */
.detail-section {
    animation: fadeUp var(--dur-md) var(--ease) .26s both;
}

.ds-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.ds-card {
    background: var(--card);
    border-radius: var(--r-md);
    padding: 14px 8px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    transition: all var(--dur) var(--ease);
}

.ds-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.ds-num {
    display: block;
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1.1;
}

.ds-tag {
    display: block;
    font-size: .5rem;
    color: var(--ink-mute);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

.ds-correct .ds-num { color: var(--sage); }
.ds-wrong .ds-num { color: var(--coral); }

/* ========================================
   FLOATING NAV — Bottom Navigation
   ======================================== */
.float-nav {
    position: fixed;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 28px);
    max-width: calc(var(--max-width) - 28px);
    height: var(--nav-h);
    padding-bottom: var(--safe-b);
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(20px) saturate(1.5);
    -webkit-backdrop-filter: blur(20px) saturate(1.5);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, .5);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 100;
}

.fn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    border-radius: var(--r-md);
    transition: all var(--dur) var(--ease);
    color: var(--ink-mute);
    min-width: 48px;
    position: relative;
    touch-action: manipulation;
}

.fn-item svg {
    width: 20px;
    height: 20px;
    transition: transform var(--dur-md) var(--ease-spring);
}

.fn-item span {
    font-size: .5rem;
    font-weight: 700;
    letter-spacing: .3px;
}

.fn-item:hover {
    color: var(--rose);
}

.fn-item:hover svg {
    transform: translateY(-1px);
}

.fn-item.active {
    color: var(--rose);
}

.fn-item.active::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 3px;
    background: var(--rose);
    border-radius: 0 0 var(--r-full) var(--r-full);
}

.fn-center {
    padding: 0;
}

.fn-center span { display: none; }

.fn-center-btn {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--rose), #C06480);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 16px var(--rose-glow);
    transition: all var(--dur) var(--ease);
    margin-top: -16px;
    border: 3px solid var(--card);
}

.fn-center-btn svg {
    width: 20px;
    height: 20px;
}

.fn-center:hover .fn-center-btn {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(212, 114, 140, .35);
}

.fn-center:active .fn-center-btn {
    transform: scale(.92);
}

/* ========================================
   MODAL SYSTEM
   ======================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 22, 32, .4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn var(--dur-md) var(--ease);
}

.modal-panel {
    background: var(--card);
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    width: 100%;
    max-width: var(--max-width);
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp var(--dur-md) var(--ease-spring);
    padding-bottom: var(--safe-b);
    box-shadow: 0 -8px 40px rgba(26, 22, 32, .08);
}

.modal-sm {
    border-radius: var(--r-2xl);
    max-width: 340px;
    margin: auto;
    animation: popIn var(--dur-md) var(--ease-spring);
}

.modal-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--ink-faint);
}

.modal-top h2 {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.2px;
}

.modal-body {
    padding: 16px 20px 24px;
}

.st-item {
    padding: 14px 0;
    border-bottom: 1px solid var(--ink-faint);
}

.st-item:last-child {
    border-bottom: 0;
}

.st-label {
    display: block;
    font-size: .78rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.st-danger {
    text-align: center;
    padding-top: 16px;
}

/* Toggle Switch */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.toggle-row span:first-child {
    font-size: .78rem;
    font-weight: 700;
}

.toggle-inp {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-knob {
    width: 44px;
    height: 26px;
    background: var(--ink-ghost);
    border-radius: var(--r-full);
    position: relative;
    flex-shrink: 0;
    transition: background var(--dur) var(--ease);
    box-shadow: var(--shadow-inner);
}

.toggle-knob::after {
    content: '';
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 3px;
    left: 3px;
    transition: transform var(--dur-md) var(--ease-spring);
    box-shadow: var(--shadow-sm);
}

.toggle-inp:checked + .toggle-knob {
    background: var(--rose);
}

.toggle-inp:checked + .toggle-knob::after {
    transform: translateX(18px);
}

/* Confirm Dialog */
.confirm-row {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 1.25rem;
}

#confirm-title {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: .3rem;
}

#confirm-message {
    font-size: .78rem;
    color: var(--ink-soft);
    line-height: 1.5;
}

/* ========================================
   TOAST SYSTEM
   ======================================== */
.toast-area {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 100%;
    max-width: var(--max-width);
    padding: 0 16px;
}

.toast {
    background: var(--card);
    border-radius: var(--r-md);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    font-size: .78rem;
    font-weight: 600;
    pointer-events: auto;
    border-left: 4px solid var(--rose);
    animation: toastIn var(--dur-md) var(--ease-spring);
}

.toast-success { border-left-color: var(--sage); }
.toast-error { border-left-color: var(--coral); }
.toast-info { border-left-color: var(--sky); }

.toast-out {
    animation: toastOut .25s var(--ease) forwards;
}

/* ========================================
   OFFLINE INDICATOR
   ======================================== */
.offline-pill {
    position: fixed;
    bottom: calc(var(--nav-h) + 28px + var(--safe-b));
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 8px 24px;
    border-radius: var(--r-full);
    font-size: .65rem;
    font-weight: 700;
    z-index: 150;
    box-shadow: var(--shadow-lg);
    letter-spacing: .3px;
    animation: fadeUp .4s var(--ease-spring) both;
}

/* ========================================
   FEATURE ENTRY BUTTONS
   ======================================== */
.essay-entry-section,
.sound-entry-section,
.kb-entry-section,
.battle-entry-section {
    animation: fadeUp var(--dur-md) var(--ease) .13s both;
}

.essay-entry-btn,
.sound-entry-btn,
.kb-entry-btn,
.battle-entry-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 16px 18px;
    box-shadow: var(--shadow-xs);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    text-align: left;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}

.essay-entry-btn::before,
.sound-entry-btn::before,
.kb-entry-btn::before,
.battle-entry-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.essay-entry-btn::before { background: linear-gradient(90deg, var(--wist), var(--rose)); }
.sound-entry-btn::before { background: linear-gradient(90deg, var(--sky), var(--wist)); }
.kb-entry-btn::before { background: linear-gradient(90deg, var(--honey), var(--rose), var(--sky)); }
.battle-entry-btn::before { background: linear-gradient(90deg, var(--coral), var(--rose), var(--honey)); }

.essay-entry-btn:hover,
.sound-entry-btn:hover,
.kb-entry-btn:hover,
.battle-entry-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.essay-entry-btn:active,
.sound-entry-btn:active,
.kb-entry-btn:active,
.battle-entry-btn:active {
    transform: scale(.97);
}

.eeb-icon,
.seb-icon,
.kb-entry-icon,
.battle-entry-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform var(--dur-md) var(--ease-spring);
}

.eeb-icon { background: var(--wist-wash); color: var(--wist); }
.seb-icon { background: var(--sky-wash); color: var(--sky); }
.kb-entry-icon { background: var(--honey-wash); color: var(--honey); }
.battle-entry-icon { background: var(--coral-pale); color: var(--coral); }

.essay-entry-btn:hover .eeb-icon,
.sound-entry-btn:hover .seb-icon,
.kb-entry-btn:hover .kb-entry-icon,
.battle-entry-btn:hover .battle-entry-icon {
    transform: scale(1.06) rotate(-2deg);
}

.eeb-icon svg,
.seb-icon svg,
.kb-entry-icon svg,
.battle-entry-icon svg {
    width: 22px;
    height: 22px;
}
.battle-entry-icon svg { width: 24px; height: 24px; }

.eeb-content,
.seb-content,
.kb-entry-content,
.battle-entry-content {
    flex: 1;
    min-width: 0;
}

.eeb-title,
.seb-title,
.kb-entry-title,
.battle-entry-title {
    display: block;
    font-size: .82rem;
    font-weight: 800;
    margin-bottom: 2px;
}
.kb-entry-title,
.battle-entry-title { font-family: var(--font-jp); }

.eeb-desc,
.seb-desc,
.kb-entry-desc,
.battle-entry-desc {
    display: block;
    font-size: .65rem;
    color: var(--ink-mute);
    line-height: 1.3;
}
.battle-entry-desc { font-size: .62rem; }

/* ========================================
   REFERENCE CARDS (Home Screen)
   ======================================== */
.ref-section {
    animation: fadeUp var(--dur-md) var(--ease) .12s both;
}

.ref-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.ref-card {
    display: flex;
    flex-direction: column;
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 16px;
    box-shadow: var(--shadow-xs);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.ref-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.ref-card-rose::before { background: var(--rose); }
.ref-card-sky::before { background: var(--sky); }
.ref-card-wist::before { background: var(--wist); }

.ref-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.ref-card:active {
    transform: scale(.97);
}

.ref-card-top {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.ref-card-char {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: var(--font-jp);
    position: relative;
    overflow: hidden;
}

.ref-card-char::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255,255,255,.4), transparent);
    pointer-events: none;
}

.ref-card-rose .ref-card-char { background: var(--rose-wash); color: var(--rose); }
.ref-card-sky .ref-card-char { background: var(--sky-wash); color: var(--sky); }
.ref-card-wist .ref-card-char { background: var(--wist-wash); color: var(--wist); }

.ref-card-char2 { opacity: .7; }
.ref-card-char3 { opacity: .4; }

.ref-card-title {
    font-size: .82rem;
    font-weight: 800;
    margin-bottom: 2px;
}

.ref-card-desc {
    font-size: .65rem;
    color: var(--ink-mute);
    line-height: 1.3;
}

/* ========================================
   REFERENCE SCREEN — Kana/ Kanji Browser
   ======================================== */
#ref-screen {
    background: var(--paper);
}

.ref-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-t));
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-bottom: 1px solid var(--ink-faint);
    position: sticky;
    top: 0;
    z-index: 50;
}

.ref-header-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -.2px;
}

.ref-header-count {
    font-size: .68rem;
    font-weight: 700;
    color: var(--ink-mute);
    padding: 4px 12px;
    background: var(--surface);
    border-radius: var(--r-full);
}

.ref-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 52px;
    z-index: 40;
    background: var(--paper);
    scrollbar-width: none;
}

.ref-tabs::-webkit-scrollbar { display: none; }

.ref-tab {
    flex-shrink: 0;
    padding: 7px 16px;
    border-radius: var(--r-full);
    font-size: .68rem;
    font-weight: 700;
    color: var(--ink-mute);
    background: var(--surface);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    white-space: nowrap;
    touch-action: manipulation;
}

.ref-tab:hover {
    background: var(--rose-wash);
    color: var(--rose);
}

.ref-tab.active {
    background: var(--rose);
    color: #fff;
    border-color: var(--rose);
    box-shadow: 0 4px 12px var(--rose-glow);
}

.ref-main {
    flex: 1;
    padding: 12px 16px 20px;
    overflow-y: auto;
}

.ref-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ref-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 6px;
}

.ref-cell {
    background: var(--card);
    border-radius: var(--r-md);
    padding: 10px 4px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    cursor: pointer;
    transition: all .15s var(--ease);
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    min-height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    touch-action: manipulation;
}

.ref-cell::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, rgba(255,255,255,.3), transparent);
    pointer-events: none;
}

.ref-cell:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
    border-color: var(--rose-pale);
}

.ref-cell:active {
    transform: scale(.95);
}

.ref-cell-char {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: var(--font-jp);
    line-height: 1;
    position: relative;
}

.ref-cell-rom {
    font-size: .52rem;
    font-weight: 700;
    color: var(--ink-mute);
    letter-spacing: .3px;
    position: relative;
}

.ref-cell[data-ctype="basic"] .ref-cell-char { color: var(--ink); }
.ref-cell[data-ctype="dakuten"] .ref-cell-char { color: var(--rose); }
.ref-cell[data-ctype="handakuten"] .ref-cell-char { color: var(--sky); }
.ref-cell[data-ctype="youon"] .ref-cell-char { color: var(--wist); }
.ref-cell[data-ctype="foreign"] .ref-cell-char { color: var(--honey); }

.ref-cell[data-ctype="dakuten"] { border-color: rgba(212,114,140,.1); }
.ref-cell[data-ctype="handakuten"] { border-color: rgba(94,160,196,.1); }
.ref-cell[data-ctype="youon"] { border-color: rgba(140,114,176,.1); }

.ref-cell.mastered::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    background: var(--sage);
    border-radius: 50%;
    box-shadow: 0 0 0 2px var(--card);
}

.ref-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 22, 32, .4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn var(--dur-md) var(--ease);
}

.ref-detail-card {
    background: var(--card);
    border-radius: var(--r-2xl);
    padding: 32px 24px 24px;
    width: 100%;
    max-width: 340px;
    text-align: center;
    box-shadow: var(--shadow-xl);
    animation: popIn .4s var(--ease-spring);
    position: relative;
    overflow: hidden;
}

.ref-detail-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(180deg, rgba(255,255,255,.2), transparent);
    pointer-events: none;
}

.ref-detail-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    color: var(--ink-mute);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    border: 0;
    background: 0;
    z-index: 2;
}

.ref-detail-close:hover {
    background: var(--rose-wash);
    color: var(--rose);
}

.ref-detail-char {
    font-size: 5rem;
    font-weight: 700;
    font-family: var(--font-jp);
    line-height: 1;
    margin-bottom: 6px;
    position: relative;
}

.ref-detail-romaji {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--rose);
    margin-bottom: 4px;
    position: relative;
    letter-spacing: .5px;
}

.ref-detail-type {
    display: inline-block;
    padding: 4px 14px;
    border-radius: var(--r-full);
    font-size: .6rem;
    font-weight: 700;
    color: var(--ink-mute);
    background: var(--surface);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 14px;
    position: relative;
}

.ref-detail-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
    position: relative;
}

.ref-detail-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    background: var(--surface);
    border-radius: var(--r-md);
    font-size: .72rem;
}

.ref-detail-info-label {
    font-weight: 700;
    color: var(--ink-mid);
}

.ref-detail-info-value {
    font-weight: 800;
    font-family: var(--font-jp);
}

.ref-detail-examples {
    margin-bottom: 16px;
    position: relative;
}

.ref-detail-example {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: var(--rose-wash);
    border-radius: var(--r-md);
    margin-bottom: 4px;
}

.ref-detail-example:last-child { margin-bottom: 0; }

.rde-word {
    font-size: .9rem;
    font-weight: 700;
    font-family: var(--font-jp);
}

.rde-meaning {
    font-size: .7rem;
    color: var(--ink-soft);
    flex: 1;
}

.rde-romaji {
    font-size: .6rem;
    font-weight: 700;
    color: var(--rose);
}

.ref-detail-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    position: relative;
}

.ref-detail-nav .btn {
    font-size: .72rem;
    padding: 8px 16px;
}

/* Responsive Reference */
@media (max-width: 380px) {
    .ref-row { grid-template-columns: repeat(4, 1fr); }
    .ref-cell { min-height: 56px; padding: 8px 3px; }
    .ref-cell-char { font-size: 1.2rem; }
    .ref-detail-char { font-size: 4rem; }
}

@media (max-width: 320px) {
    .ref-row { grid-template-columns: repeat(3, 1fr); }
}

/* ========================================
   PROGRESS DASHBOARD
   ======================================== */
.progress-dashboard {
    animation: fadeUp var(--dur-md) var(--ease) .23s both;
}

.pd-filter {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
    scrollbar-width: none;
}

.pd-filter::-webkit-scrollbar { display: none; }

.pd-filter-btn {
    flex-shrink: 0;
    padding: 7px 16px;
    border-radius: var(--r-full);
    font-size: .68rem;
    font-weight: 700;
    color: var(--ink-mute);
    background: var(--surface);
    border: 2px solid transparent;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--dur) var(--ease);
    touch-action: manipulation;
}

.pd-filter-btn:hover {
    background: var(--rose-wash);
    color: var(--rose);
}

.pd-filter-btn.active {
    background: var(--rose);
    color: #fff;
    border-color: var(--rose);
    box-shadow: 0 4px 12px var(--rose-glow);
}

.pd-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 14px;
}

.pd-sum-card {
    background: var(--card);
    border-radius: var(--r-md);
    padding: 14px 6px;
    text-align: center;
    box-shadow: var(--shadow-xs);
    position: relative;
    overflow: hidden;
    transition: all var(--dur) var(--ease);
}

.pd-sum-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.pd-sum-streak::before { background: var(--rose); }
.pd-sum-xp::before { background: var(--honey); }
.pd-sum-lessons::before { background: var(--sky); }
.pd-sum-improve::before { background: var(--sage); }

.pd-sum-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pd-sum-num {
    display: block;
    font-size: 1.1rem;
    font-weight: 900;
    line-height: 1.1;
}

.pd-sum-label {
    display: block;
    font-size: .48rem;
    font-weight: 700;
    color: var(--ink-mute);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

.pd-heatmap-card {
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
}

.pd-heatmap-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--rose), var(--wist), var(--sky));
}

.pd-heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pd-heatmap-title {
    font-size: .78rem;
    font-weight: 800;
}

.pd-heatmap-total {
    font-size: .65rem;
    font-weight: 700;
    color: var(--ink-mute);
    padding: 3px 12px;
    background: var(--surface);
    border-radius: var(--r-full);
}

.pd-heatmap-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -4px;
    padding: 0 4px;
}

.pd-heatmap-scroll::-webkit-scrollbar { height: 3px; }
.pd-heatmap-scroll::-webkit-scrollbar-thumb {
    background: var(--rose-pale);
    border-radius: var(--r-full);
}

.pd-heatmap-wrap {
    display: flex;
    gap: 6px;
    min-width: min-content;
}

.pd-heatmap-days {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 18px;
    flex-shrink: 0;
    width: 24px;
}

.pd-heatmap-days span {
    height: 11px;
    line-height: 11px;
    font-size: .5rem;
    font-weight: 700;
    color: var(--ink-mute);
    text-align: right;
    padding-right: 4px;
}

.pd-heatmap-body {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.pd-heatmap-months {
    display: flex;
    gap: 0;
    height: 16px;
    margin-bottom: 2px;
}

.pd-heatmap-month-label {
    font-size: .5rem;
    font-weight: 700;
    color: var(--ink-mute);
    text-align: left;
    line-height: 16px;
}

.pd-heatmap-grid {
    display: flex;
    gap: 2px;
}

.pd-heatmap-col {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pd-heatmap-cell {
    width: 11px;
    height: 11px;
    border-radius: var(--r-xs);
    background: var(--depth);
    cursor: pointer;
    transition: all .12s var(--ease);
    position: relative;
}

.pd-heatmap-cell:hover {
    transform: scale(1.5);
    z-index: 5;
    box-shadow: 0 0 0 2px var(--card), 0 0 0 3px var(--ink-ghost);
}

.pd-heatmap-cell[data-level="0"] { background: var(--depth); }
.pd-heatmap-cell[data-level="1"] { background: rgba(212,114,140,.15); }
.pd-heatmap-cell[data-level="2"] { background: rgba(212,114,140,.35); }
.pd-heatmap-cell[data-level="3"] { background: rgba(212,114,140,.6); }
.pd-heatmap-cell[data-level="4"] { background: rgba(212,114,140,.85); }

.pd-heatmap-cell[data-future="true"] {
    background: transparent;
    border: 1.5px dashed var(--ink-ghost);
    cursor: default;
}

.pd-heatmap-cell[data-future="true"]:hover {
    transform: none;
    box-shadow: none;
}

.pd-heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 10px;
}

.pd-legend-label {
    font-size: .5rem;
    font-weight: 700;
    color: var(--ink-mute);
}

.pd-legend-boxes {
    display: flex;
    gap: 2px;
}

.pd-legend-box {
    width: 11px;
    height: 11px;
    border-radius: var(--r-xs);
}

.pd-legend-box[data-level="0"] { background: var(--depth); }
.pd-legend-box[data-level="1"] { background: rgba(212,114,140,.15); }
.pd-legend-box[data-level="2"] { background: rgba(212,114,140,.35); }
.pd-legend-box[data-level="3"] { background: rgba(212,114,140,.6); }
.pd-legend-box[data-level="4"] { background: rgba(212,114,140,.85); }

.pd-tooltip {
    position: absolute;
    padding: 6px 12px;
    background: var(--ink);
    color: #fff;
    border-radius: var(--r-sm);
    font-size: .62rem;
    font-weight: 600;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 1px;
    transform: translate(-50%, -100%);
    margin-top: -8px;
}

.pd-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--ink);
}

.pd-trend-card {
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.pd-trend-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--sky), var(--wist));
}

.pd-trend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.pd-trend-title {
    font-size: .78rem;
    font-weight: 800;
}

.pd-trend-chart-wrap {
    position: relative;
    height: 160px;
}

.pd-trend-svg {
    width: 100%;
    height: 140px;
    display: block;
}

.pd-trend-grid line {
    stroke: var(--depth);
    stroke-width: .5;
}

.pd-trend-y-labels text {
    fill: var(--ink-mute);
    font-size: 8px;
    font-weight: 600;
    font-family: var(--font);
}

.pd-trend-area {
    fill: url(#trendGradient);
    opacity: .25;
    transition: d .6s var(--ease);
}

.pd-trend-line {
    fill: none;
    stroke: var(--sky);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: d .6s var(--ease);
}

.pd-trend-line.animate {
    stroke-dasharray: 2000;
    stroke-dashoffset: 2000;
    animation: drawLine 1.2s var(--ease) forwards;
}

.pd-trend-dots circle {
    fill: var(--card);
    stroke: var(--sky);
    stroke-width: 2.5;
    r: 4;
    cursor: pointer;
    transition: r .15s var(--ease), stroke-width .15s var(--ease);
}

.pd-trend-dots circle:hover {
    r: 6;
    stroke-width: 3;
    filter: drop-shadow(0 2px 6px rgba(94,160,196,.3));
}

.pd-trend-x-labels {
    display: flex;
    justify-content: space-between;
    padding: 4px 30px 0 40px;
}

.pd-trend-x-label {
    font-size: .5rem;
    font-weight: 700;
    color: var(--ink-mute);
}

.pd-trend-tooltip {
    position: absolute;
    padding: 8px 14px;
    background: var(--ink);
    color: #fff;
    border-radius: var(--r-sm);
    font-size: .62rem;
    pointer-events: none;
    z-index: 20;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transform: translate(-50%, -100%);
    margin-top: -12px;
}

.pd-trend-tooltip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--ink);
}

/* ========================================
   INSTALL CARD — PWA Prompt
   ======================================== */
.install-card {
    background: var(--card);
    border-radius: var(--r-xl);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 2px solid var(--rose-pale);
    animation: fadeUp var(--dur-md) var(--ease) both;
}

.install-card p {
    font-size: .78rem;
    color: var(--ink-mid);
    flex: 1;
    font-weight: 500;
    line-height: 1.4;
}

.install-card .btn {
    flex-shrink: 0;
}

/* ========================================
   RESPONSIVE — Mobile First Adjustments
   ======================================== */
@media (max-width: 380px) {
    .jlpt-row { grid-template-columns: repeat(3, 1fr); }
    .stats-panel { grid-template-columns: repeat(2, 1fr); }
    .ds-grid { grid-template-columns: repeat(2, 1fr); }
    .pd-summary { grid-template-columns: repeat(2, 1fr); }
    .pd-heatmap-cell { width: 9px; height: 9px; }
    .pd-legend-box { width: 9px; height: 9px; }
    .pd-trend-chart-wrap { height: 140px; }
    .pd-trend-svg { height: 120px; }
    .mascot-card { padding: 14px; }
    .mc-svg { width: 44px; height: 44px; }
    .splash-title { font-size: 1.5rem; }
}

@media (max-width: 320px) {
    .ds-grid { grid-template-columns: 1fr 1fr; }
    .ref-row { grid-template-columns: repeat(3, 1fr); }
    .pd-filter-btn { padding: 5px 12px; font-size: .6rem; }
    .play-btn { height: 64px; }
    .play-label { font-size: .9rem; }
}

@media (display-mode: standalone) {
    .install-card { display: none !important; }
    .float-nav { bottom: var(--safe-b); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}