/* =====================
   FONTS
   ===================== */
@font-face {
    font-family: 'Playfair Display';
    src: url('/res/fonts/PlayfairDisplay-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

@font-face {
    font-family: 'Lora';
    src: url('/res/fonts/Lora-VariableFont_wght.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

/* =====================
   VARIABLES — LIGHT
   ===================== */
:root {
    --bg:           #f0f5ee;
    --card:         #f8fbf6;
    --text:         #1a2e14;
    --border:       rgba(61, 92, 46, 0.18);
    --muted:        #5a7a4a;
    --action:       #3d5c2e;
    --action-text:  #ffffff;
    --outline-text: #3d5c2e;
    --moss:         #3d5c2e;
    --sprout:       #b5d99c;
    --sun:          #e8c97a;
    --terracotta:   #b85c28;
    --fern:         #8db87a;
    --green:        #3d5c2e;
    --red:          #b85c28;
}

/* =====================
   VARIABLES — DARK
   ===================== */
body.dark-mode {
    --bg:           #111a0e;
    --card:         #182413;
    --text:         #e8ddd0;
    --border:       rgba(141, 184, 122, 0.15);
    --muted:        #7aaa68;
    --action:       #6da85a;
    --action-text:  #ffffff;
    --outline-text: #ffffff;
    --moss:         #3d5c2e;
    --sprout:       #b5d99c;
    --sun:          #e8c97a;
    --terracotta:   #d4784a;
    --fern:         #8db87a;
    --green:        #6da85a;
    --red:          #d4784a;
}

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

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    transition: background 0.3s, color 0.3s;
}

/* Grain texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

/* =====================
   APP CONTAINER
   ===================== */
#app {
    width: 100%;
    max-width: 28rem;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

/* =====================
   UNLOCK SCREEN
   ===================== */
#unlockScreen {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    z-index: 999;
    overflow: hidden;
}

.unlock-wrap {
    width: 100%; max-width: 360px;
    display: flex; flex-direction: column;
    align-items: center;
    animation: riseIn 0.6s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes riseIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.unlock-logo {
    width: 88px; height: 88px;
    border-radius: 22px;
    margin-bottom: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    overflow: hidden; flex-shrink: 0;
}

.unlock-logo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.unlock-title {
    font-family: "Playfair Display", serif;
    font-size: 2rem; font-weight: 700;
    color: var(--text); letter-spacing: -0.02em;
    text-align: center; margin-bottom: 4px;
}

.unlock-subtitle {
    font-size: 0.75rem; font-style: italic;
    color: var(--muted); text-align: center; margin-bottom: 32px;
}

.unlock-card {
    width: 100%;
    background: var(--moss);
    border-radius: 24px;
    padding: 28px 24px;
    position: relative; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}

.unlock-card::before {
    content: "";
    position: absolute; right: -32px; bottom: -32px;
    width: 200px; height: 200px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.05)' stroke-width='2'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.05)' stroke-width='2' transform='rotate(40 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.05)' stroke-width='2' transform='rotate(80 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.05)' stroke-width='2' transform='rotate(120 50 70)'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}

.unlock-card-label {
    font-size: 0.58rem; letter-spacing: 0.2em;
    text-transform: uppercase; color: #a8c896;
    margin-bottom: 6px; position: relative; z-index: 1;
}

.unlock-card-title {
    font-family: "Playfair Display", serif;
    font-size: 1.15rem; font-weight: 700;
    color: #e8ddc8; margin-bottom: 18px;
    position: relative; z-index: 1;
}

.unlock-input {
    width: 100%;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 0.9rem; font-family: "Lora", serif;
    color: #e8ddc8; outline: none;
    transition: border-color 0.2s, background 0.2s;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
    display: block;
    position: relative; z-index: 1;
}

.unlock-input::placeholder { color: rgba(168,200,150,0.45); }
.unlock-input:focus { border-color: rgba(181,217,156,0.5); background: rgba(255,255,255,0.12); }

.unlock-btn {
    width: 100%;
    background: #e8ddc8; color: var(--moss);
    border: none; border-radius: 12px; padding: 14px;
    font-size: 0.85rem; font-weight: 700;
    font-family: "Lora", serif; cursor: pointer;
    letter-spacing: 0.06em; transition: all 0.2s;
    position: relative; z-index: 1;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.unlock-btn:hover { background: white; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,0.2); }
.unlock-btn:active { transform: scale(0.98); }
.unlock-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }

.unlock-error {
    font-size: 0.7rem; font-style: italic;
    color: #e8a87a; text-align: center;
    margin-top: 10px; min-height: 1rem;
    position: relative; z-index: 1;
}

.unlock-footer {
    font-size: 0.62rem; font-style: italic;
    color: var(--muted); opacity: 0.5;
    text-align: center; margin-top: 20px;
}

/* =====================
   FLOATING LEAVES
   ===================== */
.leaf {
    position: fixed;
    pointer-events: none;
    z-index: 0;
    animation: leafFloat linear infinite;
    opacity: 0;
}

@keyframes leafFloat {
    0%   { transform: translateY(100vh) rotate(0deg);   opacity: 0; }
    5%   { opacity: 0.2; }
    95%  { opacity: 0.1; }
    100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

/* =====================
   ANIMATIONS
   ===================== */
@keyframes cardIn {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes growFill {
    from { width: 0%; }
}

/* =====================
   TYPOGRAPHY
   ===================== */
h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    line-height: 1;
}

h1 em {
    font-style: italic;
    color: var(--muted);
}

/* =====================
   LAYOUT UTILITIES
   ===================== */
.flex             { display: flex; }
.flex-col         { flex-direction: column; }
.flex-wrap        { flex-wrap: wrap; }
.flex-1           { flex: 1 1 0%; }
.grid             { display: grid; }
.items-center     { align-items: center; }
.justify-between  { justify-content: space-between; }
.justify-center   { justify-content: center; }
.w-full           { width: 100%; }
.max-w-md         { max-width: 28rem; }
.h-full           { height: 100%; }
.hidden           { display: none !important; }
.cursor-pointer   { cursor: pointer; }
.whitespace-nowrap { white-space: nowrap; }
.overflow-hidden  { overflow: hidden; }

/* =====================
   TEXT UTILITIES
   ===================== */
.text-left        { text-align: left; }
.text-right       { text-align: right; }
.text-center      { text-align: center; }
.text-xs          { font-size: .75rem; }
.text-sm          { font-size: .875rem; }
.text-xl          { font-size: 1.25rem; }
.text-2xl         { font-size: 1.5rem; }
.text-3xl         { font-size: 1.875rem; }
.text-4xl         { font-size: 2.25rem; }
.text-5xl         { font-size: 3rem; }
.font-bold        { font-weight: 700; }
.font-medium      { font-weight: 500; }
.font-mono        { font-family: monospace; }
.uppercase        { text-transform: uppercase; }
.tracking-tight   { letter-spacing: -0.025em; }
.tracking-widest  { letter-spacing: 0.1em; }
.text-muted       { color: var(--muted); }
.text-red-500     { color: var(--red); }
.text-green-500   { color: var(--green); }
.opacity-50       { opacity: .5; }

/* =====================
   DIVIDERS
   ===================== */
hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 0;
}

.leaf-divider {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0 20px;
    opacity: 0.35;
}

.leaf-divider hr  { flex: 1; border-top: 1px solid var(--muted); }
.leaf-divider span { font-size: 0.8rem; color: var(--muted); }

/* =====================
   SECTION LABEL
   ===================== */
.section-label {
    font-size: 0.6rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--muted);
    opacity: 0.25;
}

/* =====================
   HOME TABS
   ===================== */
.home-tabs {
    display: flex;
    gap: 6px;
    padding: 0 1rem;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.home-tab {
    flex: 1;
    padding: 0.55rem 0;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    background: none;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
    text-align: center;
    font-family: 'Lora', serif;
}

.home-tab.active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
}

.home-tab:not(.active):hover {
    border-color: var(--text);
    color: var(--text);
}

/* =====================
   HOME SCROLL
   ===================== */
.home-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 1rem 2rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

.home-scroll::-webkit-scrollbar { width: 3px; }
.home-scroll::-webkit-scrollbar-track { background: transparent; }
.home-scroll::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; opacity: 0.4; }

/* =====================
   CARD
   ===================== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    transition: .2s;
    position: relative;
}

/* =====================
   CONTINUE / FOCAL CARD
   ===================== */
.continue-card {
    background: var(--moss);
    border-radius: 20px;
    padding: 22px 22px 18px;
    margin-bottom: 28px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1);
    animation: cardIn 0.6s ease both;
}

.continue-card::before {
    content: '';
    position: absolute;
    right: -20px; top: -20px;
    width: 140px; height: 140px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.07)' stroke-width='2'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.07)' stroke-width='2' transform='rotate(40 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.07)' stroke-width='2' transform='rotate(80 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.07)' stroke-width='2' transform='rotate(120 50 70)'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}

.continue-label {
    font-size: 0.6rem; letter-spacing: 0.2em;
    text-transform: uppercase; color: #a8c896; margin-bottom: 6px;
}

.continue-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem; font-weight: 700;
    color: #e8ddc8; margin-bottom: 2px;
}

.continue-sub {
    font-size: 0.72rem; color: #a8c896;
    font-style: italic; margin-bottom: 14px;
}

.growth-bar-wrap {
    display: flex; align-items: center;
    gap: 10px; margin-bottom: 16px;
}

.growth-bar {
    flex: 1; height: 6px;
    background: rgba(255,255,255,0.12);
    border-radius: 99px; overflow: hidden;
}

.growth-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sprout), var(--sun));
    border-radius: 99px;
    animation: growFill 1.2s cubic-bezier(0.34,1.56,0.64,1) both 0.4s;
}

.growth-pct {
    font-size: 0.7rem; color: #a8c896;
    font-family: monospace; min-width: 30px;
}

.continue-actions { display: flex; gap: 8px; }

.btn-continue-primary {
    flex: 1;
    background: #e8ddc8; color: #2c1a0e;
    border: none; border-radius: 12px;
    padding: 12px 10px; font-size: 0.8rem;
    font-weight: 700; font-family: 'Lora', serif;
    cursor: pointer; letter-spacing: 0.04em; transition: all 0.2s;
}

.btn-continue-primary:hover { background: #f0e8d0; transform: translateY(-1px); }

.btn-continue-ghost {
    flex: 1;
    background: rgba(255,255,255,0.12); color: #e8ddc8;
    border: 1px solid rgba(255,255,255,0.2); border-radius: 12px;
    padding: 12px 10px; font-size: 0.8rem;
    font-family: 'Lora', serif; cursor: pointer;
    letter-spacing: 0.04em; transition: all 0.2s;
}

.btn-continue-ghost:hover { background: rgba(255,255,255,0.2); }

.summary-actions .btn-continue-ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}

.summary-actions .btn-continue-ghost:hover {
    background: rgba(61,92,46,0.06);
    border-color: var(--muted);
}

/* =====================
   GARDEN PROGRESS
   ===================== */
.garden-progress {
    width: 100%;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px 20px;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.gp-top {
    display: flex; align-items: baseline;
    justify-content: space-between; margin-bottom: 10px;
}

.gp-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem; font-weight: 700; color: var(--text);
}

.gp-fraction { font-size: 0.65rem; font-family: monospace; color: var(--muted); }

.gp-bar-wrap {
    display: flex; gap: 2px; height: 8px;
    border-radius: 99px; overflow: hidden; margin-bottom: 10px;
}

.gp-segment {
    flex: 1; height: 100%;
    background: rgba(61,92,46,0.1); overflow: hidden;
}

body.dark-mode .gp-segment { background: rgba(141,184,122,0.1); }
.gp-segment:first-child { border-radius: 99px 0 0 99px; }
.gp-segment:last-child  { border-radius: 0 99px 99px 0; }

.gp-segment-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fern), var(--sprout));
}

.gp-bottom { display: flex; justify-content: space-between; align-items: center; }
.gp-status { font-size: 0.68rem; font-style: italic; color: var(--muted); }
.gp-pct {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem; font-weight: 700;
    color: var(--action); line-height: 1;
}

/* =====================
   NEEDS WATER
   ===================== */
.needs-water {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 16px 18px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    width: 100%;
}

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

.nw-title {
    font-size: 0.62rem; font-weight: 700;
    letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--terracotta);
}

.nw-count { font-size: 0.62rem; font-family: monospace; color: var(--muted); opacity: 0.7; }

.word-pills { display: flex; flex-wrap: wrap; gap: 8px; }

.word-pill {
    font-family: 'Amiri', serif; font-size: 1.05rem;
    background: rgba(184,92,40,0.07);
    border: 1px solid rgba(184,92,40,0.18);
    border-radius: 99px; padding: 5px 14px;
    color: var(--text); cursor: pointer; transition: all 0.18s;
}

.word-pill:hover { background: rgba(184,92,40,0.13); transform: translateY(-1px); }

.word-pills-extra {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin-top: 8px; overflow: hidden;
    max-height: 0; opacity: 0;
    transition: max-height 0.35s ease, opacity 0.3s ease;
}

.word-pills-extra.open { max-height: 600px; opacity: 1; }

.nw-toggle {
    display: flex; align-items: center; gap: 6px;
    margin-top: 12px; cursor: pointer;
    background: none; border: none; padding: 0;
    font-family: 'Lora', serif; font-size: 0.68rem;
    font-style: italic; color: var(--muted);
    transition: color 0.15s; width: 100%;
}

.nw-toggle:hover { color: var(--text); }
.nw-toggle-line { flex: 1; height: 1px; background: var(--border); }
.nw-toggle-arrow { font-style: normal; font-size: 0.6rem; transition: transform 0.25s ease; }
.nw-toggle.expanded .nw-toggle-arrow { transform: rotate(180deg); }

/* =====================
   VOICE WARNING
   ===================== */
.voice-warning {
    width: 100%;
    background: rgba(184,92,40,0.07);
    border: 1px solid rgba(184,92,40,0.18);
    border-radius: 14px; padding: 10px 14px;
    font-size: 0.72rem; color: var(--text);
    display: flex; align-items: center;
    justify-content: space-between; gap: 8px;
    margin-bottom: 0.75rem; font-family: 'Lora', serif;
}

.voice-warning strong { font-weight: 700; }

.voice-warning-dismiss {
    background: none; border: none; cursor: pointer;
    font-size: 0.7rem; color: var(--muted);
    padding: 2px 4px; flex-shrink: 0;
    opacity: 0.6; transition: opacity 0.15s;
}

.voice-warning-dismiss:hover { opacity: 1; }

/* =====================
   LESSON CARDS
   ===================== */
.lesson-card {
    background: var(--card);
    border-radius: 18px;
    padding: 18px 18px 14px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    transition: all 0.25s;
    animation: cardIn 0.5s ease both;
}

.lesson-card:not(.locked):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.lesson-card.locked { opacity: 0.45; animation: none;}

.lesson-card.custom { border-left: 3px solid var(--green); }

.lesson-top {
    display: flex; justify-content: space-between;
    align-items: flex-start; margin-bottom: 12px;
}

.lesson-num {
    font-size: 0.75rem; color: var(--muted);
    margin-right: 6px; font-family: monospace;
}

.lesson-name {
    font-family: 'Playfair Display', serif;
    font-size: 1rem; font-weight: 700;
    color: var(--text); flex: 1;
}

.lesson-status {
    font-size: 0.65rem; color: var(--muted);
    font-style: italic; white-space: nowrap; padding-left: 8px;
}

.custom-badge { color: var(--green); font-size: 0.9rem; }

.plant-bar-wrap { margin-bottom: 14px; }

.plant-bar {
    height: 4px;
    background: rgba(61,92,46,0.1);
    border-radius: 99px; overflow: visible; position: relative;
}

body.dark-mode .plant-bar { background: rgba(141,184,122,0.1); }

.plant-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fern), var(--sprout));
    border-radius: 99px; position: relative;
    transition: width 1s cubic-bezier(0.34,1.56,0.64,1);
}

.plant-fill::after {
    content: '🌱'; position: absolute;
    right: -8px; top: -10px; font-size: 0.9rem;
    transform: translateX(50%);
}

.plant-fill.full::after { content: '🍂'; }

.lesson-actions { display: flex; gap: 8px; }

.btn-harvest {
    flex: 1; background: var(--action); color: var(--action-text);
    border: none; border-radius: 10px; padding: 10px 6px;
    font-size: 0.72rem; font-weight: 700; font-family: 'Lora', serif;
    cursor: pointer; letter-spacing: 0.04em; transition: all 0.2s;
}

.btn-harvest:hover { filter: brightness(1.1); transform: translateY(-1px); }

.btn-outline {
    flex: 1; background: transparent; color: var(--outline-text);
    border: 1px solid var(--border); border-radius: 10px; padding: 10px 6px;
    font-size: 0.72rem; font-family: 'Lora', serif; cursor: pointer;
    letter-spacing: 0.04em; transition: all 0.2s;
}

.btn-outline:hover { border-color: var(--action); color: var(--action); background: rgba(61,92,46,0.05); }

.locked .btn-harvest,
.locked .btn-outline { pointer-events: none; }

.btn-new-category {
    width: 100%; margin-top: 14px; padding: 0.85rem;
    border-radius: 1rem; border: 2px dashed var(--border);
    background: none; color: var(--muted);
    font-size: 0.95rem; font-weight: 600;
    cursor: pointer; transition: 0.2s;
}

.btn-new-category:hover {
    border-color: var(--green); color: var(--green);
    background: rgba(61,92,46,0.04);
}

/* =====================
   GAME — LAYOUT
   ===================== */
.game-layout {
    display: flex; flex-direction: column;
    height: 100%; height: 100dvh;
    padding: 0 1rem; overflow-y: auto; overflow-x: hidden; gap: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

.game-layout::-webkit-scrollbar { width: 3px; }
.game-layout::-webkit-scrollbar-track { background: transparent; }
.game-layout::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.game-header    { flex-shrink: 0; padding: 16px 0 8px; }
.game-word-card { flex-shrink: 0; }

.game-options-wrap {
    overflow-y: auto; overflow-x: hidden;
    padding: 10px 10px 8px; -webkit-overflow-scrolling: touch;
    display: flex; align-items: flex-start; align-content: flex-start;
    background: rgba(61,92,46,0.04);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
    margin: 4px 0 8px;
    min-height: 100px;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

body.dark-mode .game-options-wrap {
    background: rgba(141,184,122,0.04);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.15);
}

.game-options-wrap::-webkit-scrollbar { width: 4px; }
.game-options-wrap::-webkit-scrollbar-track { background: transparent; }
.game-options-wrap::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }
.game-footer { flex-shrink: 0; padding: 8px 0 16px; }

/* =====================
   GAME — HEADER BUTTONS
   ===================== */
.header-container {
    display: grid; grid-template-columns: 1fr auto 1fr;
    align-items: center; width: 100%; margin-bottom: 1rem;
}

.header-left  { display: flex; justify-content: flex-start; }
.header-center { display: flex; justify-content: center; text-align: center; }
.header-right { display: flex; justify-content: flex-end; }

.game-return-btn {
    font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--muted);
    background: none; border: none; cursor: pointer;
    font-family: 'Lora', serif; padding: 4px 0;
}

.game-hint-btn {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted);
    background: none; border: 1px solid var(--border);
    border-radius: 99px; padding: 5px 12px; cursor: pointer;
    font-family: 'Lora', serif; transition: 0.2s;
}

.game-hint-btn:hover { border-color: var(--muted); }
.game-hint-btn:disabled { cursor: not-allowed; }

/* =====================
   GAME — WORD CARD
   ===================== */
.word-card {
    background: var(--moss); border-radius: 24px;
    margin-bottom: 1rem; position: relative; overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}

.word-card:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0,0,0,0.18); }
.word-card:active { transform: scale(0.98); }

.word-card::before {
    content: ''; position: absolute; right: -24px; top: -24px;
    width: 160px; height: 160px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(40 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(80 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(120 50 70)'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}

.word-card::after {
    content: ''; position: absolute; left: -16px; bottom: -16px;
    width: 100px; height: 100px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='30' rx='6' ry='24' fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='2'/%3E%3Cellipse cx='50' cy='30' rx='6' ry='24' fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='2' transform='rotate(60 50 30)'/%3E%3Cellipse cx='50' cy='30' rx='6' ry='24' fill='none' stroke='rgba(255,255,255,0.04)' stroke-width='2' transform='rotate(120 50 30)'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}

.word-card-inner {
    padding: 0; position: relative; z-index: 1;
    text-align: center; display: flex; flex-direction: column;
}

.word-card-label {
    font-size: 0.58rem; letter-spacing: 0.2em;
    text-transform: uppercase; color: #a8c896;
    padding: 1rem 1.5rem 0;
}

.word-card-word {
    font-family: 'Playfair Display', serif;
    font-size: 2.6rem; font-weight: 700; color: #e8ddc8;
    line-height: 1.1; letter-spacing: -0.02em;
    padding: 1.2rem 1.5rem;
}

.word-card-word.arabic-text {
    font-family: 'Amiri', serif;
    font-size: 2.8rem;
}

.word-card-tap {
    font-size: 0.6rem; letter-spacing: 0.18em;
    text-transform: uppercase; color: #a8c896;
    opacity: 0.7; padding: 0 1.5rem 0.8rem;
}

.word-xp {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 10px 20px 12px; position: relative; z-index: 1;
}

.word-xp-top {
    display: flex; justify-content: space-between;
    align-items: center; margin-bottom: 6px;
}

.word-xp-status { font-size: 0.62rem; font-style: italic; color: #a8c896; letter-spacing: 0.04em; }
.word-xp-num   { font-size: 0.62rem; color: #a8c896; font-family: monospace; }

.xp-bar-track {
    height: 5px; background: rgba(255,255,255,0.1);
    border-radius: 99px; overflow: hidden;
}

.xp-bar-fill {
    height: 100%; border-radius: 99px;
    background: linear-gradient(90deg, var(--fern), var(--sprout));
    transition: width 0.4s cubic-bezier(0.34,1.56,0.64,1);
}

/* =====================
   GAME — OPTIONS
   ===================== */
.game-options {
    display: flex; flex-wrap: wrap;
    gap: 10px; margin-bottom: 1rem;
}

.option-btn {
    flex: 1 1 calc(50% - 5px); min-height: 68px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 12px 10px;
    font-family: 'Lora', serif; color: var(--text);
    cursor: pointer; display: flex; align-items: center;
    justify-content: center; text-align: center;
    line-height: 1.2; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: all 0.18s; position: relative; overflow: hidden;
}

.option-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.08); border-color: var(--fern); }
.option-btn:active { transform: scale(0.97); }

.option-btn.correct {
    background: var(--moss); border-color: var(--moss); color: #e8ddc8;
    box-shadow: 0 4px 16px rgba(61,92,46,0.3);
    animation: bloomIn 0.3s ease;
}

.option-btn.wrong {
    background: var(--terracotta); border-color: var(--terracotta); color: #fff5ee;
    box-shadow: 0 4px 16px rgba(184,92,40,0.3);
    animation: shakeWrong 0.35s ease;
}

@keyframes bloomIn {
    0%   { transform: scale(0.95); }
    60%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

@keyframes shakeWrong {
    0%   { transform: translateX(0); }
    20%  { transform: translateX(-6px); }
    40%  { transform: translateX(6px); }
    60%  { transform: translateX(-4px); }
    80%  { transform: translateX(4px); }
    100% { transform: translateX(0); }
}

/* =====================
   GAME — FIELD PROGRESS
   ===================== */
.field-progress { width: 100%; }

.field-progress-top {
    display: flex; align-items: center;
    justify-content: space-between; margin-bottom: 6px;
}

.field-progress-label {
    font-size: 0.58rem; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--muted);
}

.field-progress-pct { font-size: 0.62rem; color: var(--muted); font-family: monospace; }

.field-progress-bar-wrap { display: flex; align-items: center; gap: 8px; }

.field-progress-bar {
    flex: 1; height: 6px; background: rgba(61,92,46,0.1);
    border-radius: 99px; overflow: visible; position: relative;
}

body.dark-mode .field-progress-bar { background: rgba(141,184,122,0.1); }

.field-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fern), var(--sprout));
    border-radius: 99px; position: relative;
    transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1);
}

.field-progress-fill::after {
    content: '🌾'; position: absolute;
    right: -8px; top: -10px; font-size: 0.85rem;
    transform: translateX(50%);
}

/* =====================
   GAME — DEATH MODAL
   ===================== */
.death-overlay {
    position: fixed; inset: 0;
    background: rgba(10,18,8,0.75);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 200; display: flex; align-items: center;
    justify-content: center; padding: 1.5rem;
    animation: fadeOverlay 0.25s ease;
}

@keyframes fadeOverlay { from { opacity: 0; } to { opacity: 1; } }

.death-card {
    background: linear-gradient(135deg, #2c1a0e, #3d2410);
    border-radius: 24px; padding: 32px 28px; text-align: center;
    position: relative; overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    width: 100%; max-width: 360px;
    animation: slideUpCard 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes slideUpCard {
    from { opacity: 0; transform: translateY(24px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.death-icon { font-size: 2.5rem; margin-bottom: 12px; display: block; }
.death-title { font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; color: #e8ddc8; margin-bottom: 6px; }
.death-sub { font-size: 0.75rem; color: #a8967a; font-style: italic; margin-bottom: 6px; }
.death-answer-label { font-size: 0.58rem; letter-spacing: 0.16em; text-transform: uppercase; color: #7a6a58; margin-bottom: 4px; margin-top: 16px; }
.death-answer { font-family: 'Playfair Display', serif; font-size: 1.1rem; color: #c8b896; margin-bottom: 20px; }

.death-btn {
    width: 100%; background: #e8ddc8; color: #2c1a0e;
    border: none; border-radius: 12px; padding: 14px;
    font-size: 0.85rem; font-weight: 700;
    font-family: 'Lora', serif; cursor: pointer;
    letter-spacing: 0.04em; transition: 0.2s;
    position: relative; z-index: 1;
}

.death-btn:hover { background: white; transform: translateY(-1px); }

/* =====================
   STREAK
   ===================== */
.streak-badge {
    font-size: 0.72rem; font-weight: 700; font-family: 'Lora', serif;
    color: var(--terracotta);
    background: rgba(184,92,40,0.1); border: 1px solid rgba(184,92,40,0.2);
    border-radius: 99px; padding: 3px 9px; letter-spacing: 0.02em;
    animation: badgePop 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

body.dark-mode .streak-badge { background: rgba(212,120,74,0.12); border-color: rgba(212,120,74,0.25); }

@keyframes badgePop {
    from { transform: scale(0.7); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* =====================
   STUDY VIEW
   ===================== */
.study-layout {
    display: flex; flex-direction: column;
    height: 100%; height: 100dvh; overflow: hidden;
}

.study-header-fixed { flex-shrink: 0; padding: 0 1rem; }

.study-body-scroll {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 0 1rem 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}
.study-body-scroll::-webkit-scrollbar { width: 3px; }
.study-body-scroll::-webkit-scrollbar-track { background: transparent; }
.study-body-scroll::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.study-header-card {
    background: var(--moss); border-radius: 24px;
    margin-bottom: 1.25rem; position: relative; overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15); width: 100%;
}

.study-header-card::before {
    content: ''; position: absolute; right: -24px; top: -24px;
    width: 160px; height: 160px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(40 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(80 50 70)'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(120 50 70)'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}

.study-header-inner { padding: 20px 20px 16px; position: relative; z-index: 1; }

.study-back-btn {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: #a8c896;
    background: none; border: none; cursor: pointer;
    font-family: 'Lora', serif; padding: 0;
    margin-bottom: 10px; display: block; transition: opacity 0.2s;
}

.study-back-btn:hover { opacity: 0.7; }
.study-header-label { font-size: 0.58rem; letter-spacing: 0.2em; text-transform: uppercase; color: #a8c896; margin-bottom: 4px; }
.study-header-title { font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 700; color: #e8ddc8; line-height: 1.1; margin-bottom: 2px; }
.study-header-sub { font-size: 0.7rem; color: #a8c896; font-style: italic; }

.study-overall-bar-wrap { margin-top: 14px; display: flex; align-items: center; gap: 8px; }
.study-overall-bar { flex: 1; height: 5px; background: rgba(255,255,255,0.12); border-radius: 99px; overflow: hidden; }
.study-overall-fill { height: 100%; background: linear-gradient(90deg, var(--fern), var(--sprout)); border-radius: 99px; }
.study-overall-pct { font-size: 0.65rem; color: #a8c896; font-family: monospace; min-width: 28px; }

.study-table-wrap {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; overflow: hidden; margin-bottom: 1.25rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04); width: 100%;
}

.study-row {
    display: flex; align-items: center; padding: 14px 16px;
    cursor: pointer; border-top: 1px solid var(--border);
    transition: background 0.15s; gap: 12px;
}

.study-row:first-child { border-top: none; }
.study-row:hover { background: rgba(61,92,46,0.04); }
body.dark-mode .study-row:hover { background: rgba(141,184,122,0.05); }

.study-row-left { flex: 1; min-width: 0; }
.study-row-word-line { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.study-row-word { font-family: 'Playfair Display', serif; font-size: 1rem; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.study-row-word.arabic { font-family: 'Amiri', serif; font-size: 1.15rem; }
.study-row-harvested { font-size: 0.75rem; flex-shrink: 0; }
.study-row-xp { display: flex; align-items: center; gap: 6px; }
.study-row-status { font-size: 0.58rem; font-style: italic; color: var(--muted); min-width: 56px; }
.study-row-bar { flex: 1; height: 3px; background: rgba(61,92,46,0.12); border-radius: 99px; overflow: hidden; min-width: 48px; max-width: 80px; }
body.dark-mode .study-row-bar { background: rgba(141,184,122,0.12); }
.study-row-bar-fill { height: 100%; background: linear-gradient(90deg, var(--fern), var(--sprout)); border-radius: 99px; }
.study-row-num { font-size: 0.58rem; font-family: monospace; color: var(--muted); opacity: 0.5; flex-shrink: 0; }
.study-row-right { text-align: right; flex-shrink: 0; max-width: 45%; }
.study-row-translation { font-family: 'Amiri', serif; font-size: 1.1rem; color: var(--text); opacity: 0.45; direction: rtl; line-height: 1.2; }
.study-row-translation.non-arabic { font-family: 'Lora', serif; font-size: 0.9rem; direction: ltr; }

.study-harvest-btn {
    width: 100%; background: var(--action); color: white;
    border: none; border-radius: 14px; padding: 16px;
    font-size: 0.85rem; font-weight: 700; font-family: 'Lora', serif;
    cursor: pointer; letter-spacing: 0.05em; transition: all 0.2s;
    box-shadow: 0 4px 16px rgba(61,92,46,0.25);
}

.study-harvest-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* =====================
   SETTINGS VIEW
   ===================== */
.settings-scroll {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 0 1rem 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}
.settings-scroll::-webkit-scrollbar { width: 3px; }
.settings-scroll::-webkit-scrollbar-track { background: transparent; }
.settings-scroll::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.settings-header {
    background: var(--moss); border-radius: 24px;
    margin-bottom: 1.25rem; position: relative; overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15); width: 100%;
    flex-shrink: 0;
}

.settings-header::before {
    content: ''; position: absolute; right: -24px; top: -24px;
    width: 160px; height: 160px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2'/%3E%3Cellipse cx='50' cy='70' rx='8' ry='30' fill='none' stroke='rgba(255,255,255,0.06)' stroke-width='2' transform='rotate(40 50 70)'/%3E%3C/svg%3E") center/contain no-repeat;
    pointer-events: none;
}

.settings-header-inner { padding: 20px 20px 18px; position: relative; z-index: 1; }

.settings-back {
    font-size: 0.65rem; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: #a8c896;
    background: none; border: none; cursor: pointer;
    font-family: 'Lora', serif; padding: 0;
    margin-bottom: 10px; display: block; transition: opacity 0.2s;
}

.settings-back:hover { opacity: 0.7; }
.settings-header-label { font-size: 0.58rem; letter-spacing: 0.2em; text-transform: uppercase; color: #a8c896; margin-bottom: 4px; }
.settings-header-title { font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 700; color: #e8ddc8; line-height: 1.1; }

.settings-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; overflow: hidden; margin-bottom: 1rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04); width: 100%;
}

.settings-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px; cursor: pointer; border-top: 1px solid var(--border);
    transition: background 0.15s; gap: 16px;
}

.settings-row:first-child { border-top: none; }
.settings-row:hover { background: rgba(61,92,46,0.04); }
body.dark-mode .settings-row:hover { background: rgba(141,184,122,0.05); }
.settings-row-left { display: flex; flex-direction: column; gap: 2px; }
.settings-row-title { font-family: 'Playfair Display', serif; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.settings-row-desc { font-size: 0.68rem; font-style: italic; color: var(--muted); }

.toggle {
    width: 44px; height: 24px; background: rgba(61,92,46,0.15);
    border-radius: 99px; position: relative; flex-shrink: 0;
    transition: background 0.25s; border: 1px solid var(--border);
}

.toggle.on { background: var(--action); border-color: var(--action); }

.toggle::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; background: white; border-radius: 99px;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle.on::after { transform: translateX(20px); }

.danger-card {
    background: var(--card); border: 1px solid rgba(184,92,40,0.2);
    border-radius: 18px; overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04); width: 100%;
}

.danger-label { font-size: 0.55rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--terracotta); opacity: 0.7; padding: 14px 20px 0; }
.danger-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px 16px; cursor: pointer; gap: 16px; transition: background 0.15s; }
.danger-row:hover { background: rgba(184,92,40,0.04); }
.danger-row-left { display: flex; flex-direction: column; gap: 2px; }
.danger-row-title { font-family: 'Playfair Display', serif; font-size: 0.95rem; font-weight: 700; color: var(--terracotta); }
.danger-row-desc { font-size: 0.68rem; font-style: italic; color: var(--muted); }
.danger-icon { font-size: 1.1rem; flex-shrink: 0; opacity: 0.7; }
.settings-footer { text-align: center; font-size: 0.62rem; font-style: italic; color: var(--muted); opacity: 0.5; margin-top: 1.5rem; width: 100%; }

/* =====================
   SUMMARY VIEW
   ===================== */
.summary-scroll {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
    padding: 0 1rem 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}
.summary-scroll::-webkit-scrollbar { width: 3px; }
.summary-scroll::-webkit-scrollbar-track { background: transparent; }
.summary-scroll::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.summary-wrap {
    width: 100%; display: flex; flex-direction: column;
    align-items: center; padding: 2rem 0 3rem;
    animation: cardIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

.summary-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.summary-title { font-family: 'Playfair Display', serif; font-size: 1.8rem; font-weight: 700; color: var(--text); margin-bottom: 0.25rem; }
.summary-sub { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 2rem; font-family: 'Lora', serif; font-style: italic; }

.summary-stats {
    display: flex; align-items: center;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 20px; padding: 1.5rem 1rem;
    width: 100%; margin-bottom: 1.75rem;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

.summary-stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.summary-stat-val { font-family: 'Playfair Display', serif; font-size: 2rem; font-weight: 700; color: var(--action); line-height: 1; }
.summary-stat-label { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-family: 'Lora', serif; }
.summary-stat-divider { width: 1px; height: 40px; background: var(--border); }

.summary-progress-wrap { width: 100%; margin-bottom: 2rem; }
.summary-progress-label { display: flex; justify-content: space-between; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.summary-bar { height: 8px; background: rgba(61,92,46,0.1); border-radius: 99px; overflow: hidden; }
.summary-bar-fill { height: 100%; background: linear-gradient(90deg, var(--fern), var(--sprout)); border-radius: 99px; transition: width 0.8s cubic-bezier(0.34,1.56,0.64,1); }
.summary-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; }

/* =====================
   PRODUCTION — LAYOUT
   ===================== */
.prod-layout {
    display: flex; flex-direction: column;
    height: 100%; height: 100dvh;
    padding: 0 1rem; overflow-y: auto; overflow-x: hidden; gap: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

.prod-layout::-webkit-scrollbar { width: 3px; }
.prod-layout::-webkit-scrollbar-track { background: transparent; }
.prod-layout::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.prod-header    { flex-shrink: 0; padding: 16px 0 8px; }
.prod-word-card { flex-shrink: 0; }
.prod-input-area { flex-shrink: 0; padding: 6px 0; }
.prod-divider   { flex-shrink: 0; }

.prod-tile-area {
    min-height: 100px; /* always show at least one tile row */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px 8px;
    /* scroll area feel */
    background: rgba(61,92,46,0.04);
    border-radius: 14px;
    border: 1px solid var(--border);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
    margin: 4px 0 8px;
    /* themed scrollbar */
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

body.dark-mode .prod-tile-area {
    background: rgba(141,184,122,0.04);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.15);
}

.prod-tile-area::-webkit-scrollbar { width: 4px; }
.prod-tile-area::-webkit-scrollbar-track { background: transparent; }
.prod-tile-area::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; opacity: 0.5; }

.prod-footer { flex-shrink: 0; padding: 4px 0 12px; }

/* =====================
   PRODUCTION — TILES
   ===================== */
.input-bed-label,
.tile-pool-label {
    font-size: 0.58rem; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--muted);
    margin-bottom: 8px; width: 100%;
}

.input-bed {
    background: rgba(61,92,46,0.07);
    border: 1px dashed rgba(61,92,46,0.25);
    border-radius: 16px; padding: 14px 12px;
    min-height: 60px; width: 100%;
    display: flex; flex-wrap: wrap; gap: 8px;
    align-items: center; justify-content: center;
    margin-bottom: 8px; transition: background 0.2s, border-color 0.2s;
}

body.dark-mode .input-bed { background: rgba(141,184,122,0.06); border-color: rgba(141,184,122,0.18); }
.input-bed.has-selected { background: rgba(61,92,46,0.11); border-color: rgba(61,92,46,0.4); }
.input-bed-empty { font-size: 0.7rem; font-style: italic; color: var(--muted); opacity: 0.5; pointer-events: none; }

.placed-tile {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 14px;
    font-size: 1.1rem; font-family: 'Lora', serif; color: var(--text);
    cursor: pointer; transition: all 0.15s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    user-select: none; position: relative;
}

.placed-tile:hover { border-color: var(--terracotta); box-shadow: 0 2px 8px rgba(184,92,40,0.15); transform: translateY(-1px); }

.placed-tile.selected {
    background: var(--action); border-color: var(--action); color: white;
    box-shadow: 0 4px 14px rgba(61,92,46,0.35);
    transform: scale(1.08) translateY(-2px);
}

.placed-tile::after {
    content: '↩'; position: absolute; top: -6px; right: -6px;
    font-size: 0.55rem; background: var(--terracotta); color: white;
    border-radius: 99px; width: 14px; height: 14px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s; pointer-events: none; line-height: 1;
}

.placed-tile:hover::after { opacity: 1; }
.placed-tile.selected::after { display: none; }

.tile-pool {
    display: flex; flex-wrap: wrap; gap: 8px;
    justify-content: center; min-height: 52px; width: 100%;
}

.pool-tile {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 16px;
    font-size: 1.15rem; font-family: 'Lora', serif; color: var(--text);
    cursor: pointer; transition: all 0.18s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    user-select: none;
}

.pool-tile:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,0.1); border-color: var(--fern); }
.pool-tile:active { transform: scale(0.95); }

.prod-actions { display: flex; gap: 10px; margin-bottom: 1rem; width: 100%; }

.btn-submit {
    flex: 2; background: var(--action); color: white; border: none;
    border-radius: 12px; padding: 14px; font-size: 0.82rem; font-weight: 700;
    font-family: 'Lora', serif; cursor: pointer; letter-spacing: 0.04em;
    transition: all 0.2s; box-shadow: 0 4px 14px rgba(61,92,46,0.25);
}

.btn-submit:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-submit:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-reset {
    flex: 1; background: transparent; color: var(--text);
    border: 1px solid var(--border); border-radius: 12px; padding: 14px;
    font-size: 0.82rem; font-family: 'Lora', serif; cursor: pointer;
    letter-spacing: 0.04em; transition: all 0.2s;
}

.btn-reset:hover { border-color: var(--muted); }
.btn-reset:disabled { opacity: 0.4; cursor: not-allowed; }

.feedback-banner {
    border-radius: 12px; padding: 10px 16px; text-align: center;
    font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em;
    margin-bottom: 0.75rem; width: 100%;
    animation: bannerIn 0.25s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes bannerIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.feedback-banner.correct { background: rgba(61,92,46,0.1); border: 1px solid rgba(61,92,46,0.2); color: var(--action); }
body.dark-mode .feedback-banner.correct { background: rgba(109,168,90,0.15); color: #a8d896; }
.feedback-banner.wrong { background: rgba(184,92,40,0.08); border: 1px solid rgba(184,92,40,0.2); color: var(--terracotta); }

/* =====================
   IMPORT / EXPORT
   ===================== */
.io-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 18px; overflow: hidden;
    margin-bottom: 1rem; width: 100%;
}

.io-label {
    font-size: 0.55rem; letter-spacing: 0.2em; text-transform: uppercase;
    color: var(--muted); opacity: 0.7;
    padding: 16px 20px 16px;
    display: flex; align-items: center; min-height: 48px;
    border-bottom: 1px solid var(--border);
}

.io-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; cursor: pointer; border-top: 1px solid var(--border);
    transition: background 0.15s; gap: 16px;
}

.io-row:first-of-type { border-top: none; }
.io-row:hover { background: rgba(61,92,46,0.04); }
.io-row-left { display: flex; flex-direction: column; gap: 2px; }
.io-row-title { font-family: 'Playfair Display', serif; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.io-row-desc { font-size: 0.68rem; font-style: italic; color: var(--muted); }
.io-icon { font-size: 1.1rem; flex-shrink: 0; opacity: 0.7; }
.io-message { font-size: 0.72rem; font-style: italic; padding: 0 20px 12px; min-height: 1.2rem; transition: color 0.2s; }
.io-message.success { color: var(--green); }
.io-message.error   { color: var(--red); }

/* =====================
   CATEGORY EDITOR
   ===================== */
.editor-section { width: 100%; margin-bottom: 1.25rem; }

.editor-section-label {
    font-size: 0.6rem; font-weight: 700; letter-spacing: 0.16em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 0.5rem;
}

.editor-section-desc { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.5rem; }
.editor-section-desc code { background: rgba(61,92,46,0.08); padding: 1px 5px; border-radius: 4px; font-size: 0.75rem; }

.editor-input {
    width: 100%; padding: 0.7rem 0.9rem; border-radius: 0.75rem;
    border: 1px solid var(--border); background: var(--card);
    color: var(--text); font-size: 0.95rem; font-family: inherit;
    outline: none; transition: border-color 0.15s;
}

.editor-input:focus { border-color: var(--green); }

.editor-pair { display: flex; gap: 8px; }

.editor-textarea {
    width: 100%; min-height: 120px; padding: 0.7rem 0.9rem;
    border-radius: 0.75rem; border: 1px solid var(--border);
    background: var(--card); color: var(--text);
    font-size: 0.88rem; font-family: inherit; resize: vertical;
    outline: none; transition: border-color 0.15s; line-height: 1.6;
}

.editor-textarea:focus { border-color: var(--green); }

.editor-word-list {
    display: flex; flex-direction: column;
    border: 1px solid var(--border); border-radius: 0.75rem; overflow: hidden;
}

.editor-word-row {
    display: flex; align-items: center;
    padding: 0.6rem 0.9rem; gap: 8px;
    border-top: 1px solid var(--border);
}

.editor-word-row:first-child { border-top: none; }
.editor-word-en { flex: 1; font-size: 0.9rem; }
.editor-word-ar { flex: 1; font-size: 1rem; text-align: right; direction: rtl; }

.editor-word-del {
    width: 28px; height: 28px; display: flex;
    align-items: center; justify-content: center;
    border-radius: 50%; font-size: 0.75rem; color: var(--muted);
    background: none; border: none; cursor: pointer; transition: 0.15s; flex-shrink: 0;
}

.editor-word-del:hover { background: rgba(184,92,40,0.1); color: var(--red); }

.editor-delete-btn {
    width: 100%; padding: 0.85rem; border-radius: 1rem;
    border: 1px solid rgba(184,92,40,0.3); background: none;
    color: var(--red); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: 0.2s;
}

.editor-delete-btn:hover { background: rgba(184,92,40,0.06); }

/* =====================
   ARABIC TEXT
   ===================== */
.arabic-text {
    font-family: 'Amiri', serif;
    font-size: 1.2em;
    direction: rtl;
}

/* =====================
   BUTTONS — BASE
   ===================== */
button {
    cursor: pointer; border: none;
    font-family: 'Lora', serif;
    transition: .2s; background: none; color: inherit;
}

button:active { transform: scale(.96); }
button:disabled { cursor: not-allowed; }

/* =====================
   SEARCH TAB
   ===================== */
.search-input-wrap {
    display: flex; align-items: center; gap: 10px;
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 12px 16px;
    margin-bottom: 16px; margin-top: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrap:focus-within {
    border-color: var(--fern);
    box-shadow: 0 0 0 3px rgba(141,184,122,0.15), 0 2px 8px rgba(0,0,0,0.04);
}

.search-icon { font-size: 1rem; opacity: 0.45; flex-shrink: 0; }

.search-input {
    flex: 1; background: none; border: none; outline: none;
    font-size: 0.95rem; font-family: 'Lora', serif;
    color: var(--text); min-width: 0;
}

.search-input::placeholder { color: var(--muted); opacity: 0.55; font-style: italic; }

/* Hide browser default clear button */
.search-input::-webkit-search-cancel-button { display: none; }

.search-clear {
    background: none; border: none; cursor: pointer;
    font-size: 0.7rem; color: var(--muted); opacity: 0.5;
    padding: 2px 4px; flex-shrink: 0; transition: opacity 0.15s;
}
.search-clear:hover { opacity: 1; }

/* Empty / placeholder state */
.search-empty {
    display: flex; flex-direction: column; align-items: center;
    padding: 3rem 1rem; text-align: center; gap: 8px;
}

.search-empty-icon { font-size: 2.5rem; margin-bottom: 4px; opacity: 0.6; }
.search-empty-title { font-family: 'Playfair Display', serif; font-size: 1.1rem; font-weight: 700; color: var(--text); }
.search-empty-sub { font-size: 0.78rem; font-style: italic; color: var(--muted); max-width: 240px; }

/* Results meta */
.search-results-meta {
    font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 14px; opacity: 0.7;
}

/* Group = category card + its word list */
.search-group { margin-bottom: 22px; }

.search-cat-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 16px 16px 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.search-cat-card.custom { border-left: 3px solid var(--green); }
.search-cat-card.locked { opacity: 0.45; }

.search-cat-top {
    display: flex; justify-content: space-between;
    align-items: flex-start; margin-bottom: 10px;
}

.search-cat-name {
    font-family: 'Playfair Display', serif;
    font-size: 1rem; font-weight: 700; color: var(--text); flex: 1;
}

/* Word list under category */
.search-word-list {
    display: flex; flex-wrap: wrap; gap: 8px;
}

/* Individual word pill */
.search-word-pill {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 10px 14px;
    cursor: pointer; transition: all 0.18s; text-align: left;
    display: flex; flex-direction: column; gap: 5px;
    min-width: 100px; flex: 1 1 calc(50% - 4px); max-width: calc(50% - 4px);
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.search-word-pill:hover {
    border-color: var(--fern); transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}

.swp-top { display: flex; flex-direction: column; gap: 3px; }

.swp-ar {
    font-family: 'Amiri', serif; font-size: 1.15rem;
    color: var(--text); line-height: 1.2; direction: rtl;
}

.swp-en {
    font-size: 0.72rem; color: var(--muted); font-style: italic;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.swp-bar {
    height: 3px; background: rgba(61,92,46,0.1);
    border-radius: 99px; overflow: hidden; width: 100%;
}
body.dark-mode .swp-bar { background: rgba(141,184,122,0.1); }
.swp-bar-fill { height: 100%; background: linear-gradient(90deg, var(--fern), var(--sprout)); border-radius: 99px; }

/* Search highlight */
mark.search-hl {
    background: rgba(232,201,122,0.4); color: inherit;
    border-radius: 3px; padding: 0 2px;
}

body.dark-mode mark.search-hl { background: rgba(232,201,122,0.25); }

/* =====================
   WORD ACTION POPUP
   ===================== */
.word-popup-overlay {
    position: fixed; inset: 0;
    background: rgba(10,18,8,0.6);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    z-index: 300; display: flex; align-items: flex-end; justify-content: center;
    animation: fadeOverlay 0.2s ease;
}

.word-popup-sheet {
    width: 100%; max-width: 28rem;
    background: var(--card); border-radius: 28px 28px 0 0;
    padding: 12px 24px 40px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 -8px 40px rgba(0,0,0,0.2);
}

.word-popup-sheet.open { transform: translateY(0); }

.word-popup-handle {
    width: 36px; height: 4px; border-radius: 99px;
    background: var(--border); margin: 0 auto 20px;
}

.word-popup-word {
    font-family: 'Amiri', serif; font-size: 2.8rem;
    font-weight: 700; color: var(--text);
    text-align: center; direction: rtl; line-height: 1.1;
    margin-bottom: 6px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 10px;
}

.word-popup-speaker { font-size: 1.2rem; opacity: 0.4; font-style: normal; }
.word-popup-word:hover .word-popup-speaker { opacity: 0.9; }

.word-popup-translation {
    text-align: center; font-family: 'Lora', serif;
    font-size: 1rem; color: var(--muted); font-style: italic;
    margin-bottom: 16px;
}

.word-popup-xp { margin-bottom: 6px; }
.word-popup-xp-top {
    display: flex; justify-content: space-between;
    font-size: 0.65rem; color: var(--muted); margin-bottom: 5px;
}
.word-popup-status { font-style: italic; }
.word-popup-xp-num { font-family: monospace; }
.word-popup-xp-bar {
    height: 5px; background: rgba(61,92,46,0.1);
    border-radius: 99px; overflow: hidden;
}
body.dark-mode .word-popup-xp-bar { background: rgba(141,184,122,0.1); }
.word-popup-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--fern), var(--sprout));
    border-radius: 99px;
    transition: width 0.6s cubic-bezier(0.34,1.56,0.64,1);
}

.word-popup-cat-label {
    text-align: center; font-size: 0.62rem; font-style: italic;
    letter-spacing: 0.1em; color: var(--muted); opacity: 0.6;
    margin-bottom: 20px; text-transform: uppercase;
}

.word-popup-actions {
    display: flex; gap: 10px; margin-bottom: 14px;
}

.word-popup-btn {
    flex: 1; background: var(--card); border: 1px solid var(--border);
    border-radius: 16px; padding: 14px 8px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    cursor: pointer; transition: all 0.18s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.word-popup-btn:hover {
    border-color: var(--fern); transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.word-popup-btn.primary {
    background: var(--moss); border-color: var(--moss);
    box-shadow: 0 4px 16px rgba(61,92,46,0.25);
}

.word-popup-btn.primary:hover { filter: brightness(1.1); }

.wpb-icon { font-size: 1.4rem; }
.wpb-label {
    font-family: 'Lora', serif; font-size: 0.78rem; font-weight: 700;
    color: var(--text);
}
.word-popup-btn.primary .wpb-label { color: #e8ddc8; }
.wpb-desc { font-size: 0.6rem; color: var(--muted); font-style: italic; }
.word-popup-btn.primary .wpb-desc { color: #a8c896; }

.word-popup-dismiss {
    width: 100%; padding: 12px; border-radius: 12px;
    border: 1px solid var(--border); background: none;
    color: var(--muted); font-family: 'Lora', serif;
    font-size: 0.8rem; cursor: pointer; transition: 0.15s;
    letter-spacing: 0.04em;
}
.word-popup-dismiss:hover { background: rgba(61,92,46,0.05); border-color: var(--muted); }
/* =====================
   IMPORT CONFLICT UI
   ===================== */

.conflict-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex; align-items: flex-end; justify-content: center;
}

.conflict-sheet {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 1.5rem 1.5rem 0 0;
    width: 100%; max-width: 480px;
    max-height: 90vh;
    display: flex; flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

.conflict-sheet.open { transform: translateY(0); }

.conflict-handle {
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 99px;
    margin: 12px auto 0;
    flex-shrink: 0;
}

.conflict-header {
    padding: 16px 20px 12px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border);
}

.conflict-title {
    font-size: 1rem; font-weight: 700;
    margin-bottom: 4px;
}

.conflict-sub {
    font-size: 0.8rem; color: var(--muted);
    line-height: 1.4;
}

.conflict-body {
    overflow-y: auto;
    flex: 1;
    padding: 12px 16px;
    display: flex; flex-direction: column; gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

.conflict-body::-webkit-scrollbar { width: 3px; }
.conflict-body::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.cfl-row {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.cfl-row-title {
    font-weight: 700; font-size: 0.9rem;
    margin-bottom: 10px;
}

.cfl-cols {
    display: flex; gap: 10px;
    margin-bottom: 12px;
}

/* Stack on very narrow screens */
@media (max-width: 380px) {
    .cfl-cols { flex-direction: column; }
}

.cfl-col {
    flex: 1; min-width: 0;
}

.cfl-col-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 6px;
}

.cfl-word-list {
    max-height: 140px;
    overflow-y: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--fern) transparent;
}

.cfl-word-list::-webkit-scrollbar { width: 3px; }
.cfl-word-list::-webkit-scrollbar-thumb { background: var(--fern); border-radius: 99px; }

.cfl-word {
    font-size: 0.8rem;
    padding: 2px 0;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cfl-word:last-child { border-bottom: none; }

.cfl-options {
    display: flex; gap: 6px; flex-wrap: wrap;
}

.cfl-option {
    display: flex; align-items: center; gap: 5px;
    font-size: 0.82rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 4px 10px;
    cursor: pointer;
    transition: 0.15s;
}

.cfl-option:has(input:checked) {
    background: var(--fern);
    color: white;
    border-color: var(--fern);
}

.cfl-option input[type="radio"] { display: none; }

.conflict-actions {
    padding: 12px 16px 20px;
    display: flex; gap: 10px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
}

.conflict-actions .btn-continue-primary,
.conflict-actions .btn-continue-ghost { flex: 1; }