/* ==========================================================================
   BOXOPOLIS — Area Model Multiplication Stylesheet
   Designed for 3rd Graders: High Contrast, Playful, Responsive, Mobile-First
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=JetBrains+Mono:wght@500;700&family=Outfit:wght@400;600;800;900&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Palette */
    --bg-dark: #0b111e;
    --bg-surface: #131c31;
    --bg-card: #1b2642;
    --bg-card-hover: #233154;
    --bg-glass: rgba(19, 28, 49, 0.85);

    --border: #2c3c63;
    --border-bright: #445d99;
    --border-focus: #00e5ff;

    --cyan: #00e5ff;
    --cyan-dim: rgba(0, 229, 255, 0.15);
    --yellow: #ffb800;
    --yellow-dim: rgba(255, 184, 0, 0.15);
    --green: #00e676;
    --green-dim: rgba(0, 230, 118, 0.15);
    --pink: #ff4081;
    --pink-dim: rgba(255, 64, 129, 0.15);
    --purple: #b388ff;
    --purple-dim: rgba(179, 136, 255, 0.15);
    --orange: #ff9100;

    --text-main: #f0f4fc;
    --text-muted: #8ea3cc;
    --text-dim: #5c7099;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Fredoka', cursive, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-subtle: 0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-glow-cyan: 0 0 20px rgba(0, 229, 255, 0.35);
    --shadow-glow-yellow: 0 0 20px rgba(255, 184, 0, 0.4);
    --shadow-glow-green: 0 0 20px rgba(0, 230, 118, 0.4);
}

html, body {
    width: 100%;
    min-height: 100%;
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
}

body {
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 229, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 64, 129, 0.05) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
    background-position: 0 0, 0 0, 0 0, 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Confetti Canvas */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ==========================================================================
   App Container & Navigation Header
   ========================================================================== */
.app-wrapper {
    width: 100%;
    max-width: 1040px;
    padding: 12px 16px 80px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Top App Header */
.app-header {
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    box-shadow: var(--shadow-subtle);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.back-home {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.2s;
}

.back-home:hover {
    color: var(--cyan);
    background: var(--cyan-dim);
    border-color: var(--cyan);
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mascot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--purple));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
    animation: gentle-bob 3s ease-in-out infinite;
}

@keyframes gentle-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.brand-titles {
    display: flex;
    flex-direction: column;
}

.brand-titles h1 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.1;
    background: linear-gradient(90deg, #00e5ff, #ffb800);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.01em;
}

.brand-badge {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Header Stats */
.header-stats {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-chip {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-chip.stars span.val { color: var(--yellow); }
.stat-chip.streak span.val { color: var(--pink); }

.icon-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover, .icon-btn:active {
    background: var(--bg-card-hover);
    border-color: var(--cyan);
    transform: scale(1.05);
}

/* ==========================================================================
   Navigation Tabs
   ========================================================================== */
.main-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.main-nav::-webkit-scrollbar { display: none; }

.tab-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.tab-link .tab-icon { font-size: 1.1rem; }

.tab-link:hover {
    color: var(--text-main);
    border-color: var(--border-bright);
    background: var(--bg-card);
}

.tab-link.active {
    background: linear-gradient(135deg, rgba(0, 229, 255, 0.15), rgba(179, 136, 255, 0.15));
    border-color: var(--cyan);
    color: var(--cyan);
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.25);
}

/* ==========================================================================
   Views & Panels
   ========================================================================== */
.view-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.view-panel.active {
    display: flex;
    animation: fadeIn 0.25s ease-out;
}

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

/* ==========================================================================
   Hero & Quest Banner
   ========================================================================== */
.quest-hero {
    background: linear-gradient(135deg, #162444 0%, #1e1338 100%);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: var(--shadow-subtle);
    position: relative;
    overflow: hidden;
}

.quest-hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(0, 229, 255, 0.12) 0%, transparent 70%);
    pointer-events: none;
}

.quest-hero-text h2 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 4px;
}

.quest-hero-text p {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 540px;
}

.quest-zone-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.zone-chip {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.zone-chip.active, .zone-chip:hover {
    background: var(--yellow-dim);
    border-color: var(--yellow);
    color: var(--yellow);
}

/* Campaign Stage Cards Grid */
.quest-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    width: 100%;
}

.stage-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.stage-card:hover {
    transform: translateY(-4px);
    border-color: var(--cyan);
    box-shadow: 0 8px 20px rgba(0, 229, 255, 0.2);
}

.stage-card.locked {
    opacity: 0.55;
    cursor: not-allowed;
    filter: grayscale(0.6);
}

.stage-card.locked:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: none;
}

.stage-card.completed {
    border-color: rgba(0, 230, 118, 0.4);
    background: linear-gradient(180deg, rgba(0, 230, 118, 0.05) 0%, var(--bg-card) 100%);
}

.stage-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stage-num-badge {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.stage-stars {
    font-size: 0.85rem;
    letter-spacing: 2px;
}

.stage-icon-wrap {
    width: 54px;
    height: 54px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 2px 0;
}

.stage-title {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
}

.stage-math-pill {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--cyan);
    background: var(--cyan-dim);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    width: fit-content;
}

.stage-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* ==========================================================================
   THE PLAYGROUND / GAMEPLAY ARENA (Box Method Screen)
   ========================================================================== */
.game-arena {
    background: var(--bg-surface);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-xl);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    position: relative;
}

/* Top problem bar */
.arena-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.arena-stage-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.arena-back-btn {
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.arena-back-btn:hover {
    color: var(--cyan);
    border-color: var(--cyan);
}

.problem-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(90deg, rgba(0, 229, 255, 0.08), rgba(255, 184, 0, 0.08));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 18px;
    margin: 0 auto;
}

.math-problem-display {
    font-family: var(--font-heading);
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 900;
    letter-spacing: 0.02em;
    color: #fff;
}

.math-problem-display span.factor-a { color: var(--cyan); }
.math-problem-display span.operator { color: var(--yellow); margin: 0 4px; }
.math-problem-display span.factor-b { color: var(--pink); }
.math-problem-display span.equals { color: var(--green); margin: 0 4px; }
.math-problem-display span.target-sum { color: var(--text-main); font-family: var(--font-mono); }

/* Step Workflow Indicator */
.step-indicator-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--bg-card);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
}

.step-bubble {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
    font-family: var(--font-heading);
    font-weight: 700;
    transition: all 0.3s ease;
}

.step-bubble.current {
    color: var(--cyan);
    transform: scale(1.04);
}

.step-bubble.done {
    color: var(--green);
}

.step-circle {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.step-bubble.current .step-circle {
    background: var(--cyan);
    color: var(--bg-dark);
    font-weight: 900;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
}

.step-bubble.done .step-circle {
    background: var(--green);
    color: var(--bg-dark);
}

/* Mascot Coach Banner */
.coach-bubble {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 229, 255, 0.08);
    border-left: 4px solid var(--cyan);
    padding: 10px 14px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.92rem;
    color: var(--text-main);
    animation: popIn 0.3s ease;
}

@keyframes popIn {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.coach-avatar {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.coach-text {
    flex: 1;
    line-height: 1.35;
}

.coach-text strong {
    color: var(--yellow);
}

.coach-text .formula {
    font-family: var(--font-mono);
    color: var(--cyan);
    font-weight: 700;
}

/* ==========================================================================
   THE INTERACTIVE AREA MODEL / BOX GRID
   ========================================================================== */
.box-model-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    margin: 8px 0;
}

.box-grid-wrapper {
    display: inline-block;
    background: var(--bg-card);
    border: 2px solid var(--border-bright);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    overflow-x: auto;
}

.box-grid-table {
    display: grid;
    gap: 10px;
    align-items: center;
    justify-items: center;
}

/* Header Cells (Expanded Form Numbers) */
.grid-corner {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: var(--yellow);
    font-family: var(--font-heading);
    font-weight: 900;
}

.header-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 90px;
    min-height: 60px;
    padding: 6px;
    border-radius: var(--radius-md);
    background: rgba(0, 229, 255, 0.08);
    border: 2px dashed rgba(0, 229, 255, 0.4);
    transition: all 0.25s;
    position: relative;
}

.header-cell.vertical {
    background: rgba(255, 64, 129, 0.08);
    border-color: rgba(255, 64, 129, 0.4);
    min-width: 80px;
}

.header-cell.highlight {
    border-color: var(--yellow);
    background: rgba(255, 184, 0, 0.15);
    box-shadow: 0 0 12px rgba(255, 184, 0, 0.4);
    transform: scale(1.05);
}

.header-cell.active-input {
    border-color: var(--cyan);
    border-style: solid;
    background: rgba(0, 229, 255, 0.2);
    box-shadow: 0 0 14px rgba(0, 229, 255, 0.5);
}

.header-cell.correct {
    border-color: var(--green);
    border-style: solid;
    background: rgba(0, 230, 118, 0.15);
}

.header-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.header-value-display {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

/* Interior Box / Product Cells */
.box-product-cell {
    min-width: 120px;
    min-height: 100px;
    background: #111a2e;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    user-select: none;
}

.box-product-cell:hover {
    border-color: var(--border-bright);
    background: #17233d;
}

.box-product-cell.selected {
    border-color: var(--cyan);
    border-width: 2px;
    background: #162a4d;
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.45);
    transform: scale(1.03);
    z-index: 2;
}

.box-product-cell.correct {
    border-color: var(--green);
    background: linear-gradient(135deg, #0d2822 0%, #11202b 100%);
    box-shadow: 0 0 12px rgba(0, 230, 118, 0.3);
}

.cell-mini-formula {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.box-product-cell.selected .cell-mini-formula {
    color: var(--yellow);
    background: rgba(255, 184, 0, 0.15);
}

.cell-input-box {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    min-height: 38px;
    min-width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    border-radius: var(--radius-sm);
    padding: 2px 8px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

.box-product-cell.selected .cell-input-box {
    border-color: var(--cyan);
    border-style: solid;
    background: rgba(0, 229, 255, 0.15);
}

.box-product-cell.correct .cell-input-box {
    color: var(--green);
    border: none;
    background: transparent;
    font-size: 1.5rem;
}

.cell-power-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.9rem;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.box-product-cell.correct .cell-power-badge {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   SUM ADDITION STATION (Step 3: Add Partial Products)
   ========================================================================== */
.sum-addition-station {
    width: 100%;
    max-width: 520px;
    background: var(--bg-card);
    border: 2px solid var(--border-bright);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    box-shadow: var(--shadow-subtle);
}

.sum-title {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--yellow);
    display: flex;
    align-items: center;
    gap: 6px;
}

.partial-products-equation {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
}

.partial-chip {
    padding: 4px 10px;
    background: rgba(0, 230, 118, 0.12);
    border: 1px solid var(--green);
    color: var(--green);
    border-radius: var(--radius-sm);
}

.sum-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.sum-input-target {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
    min-width: 120px;
    min-height: 48px;
    padding: 4px 14px;
    background: #0f182b;
    border: 2px solid var(--cyan);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
    cursor: pointer;
}

.sum-input-target.correct {
    border-color: var(--green);
    color: var(--green);
    box-shadow: 0 0 16px rgba(0, 230, 118, 0.4);
}

/* ==========================================================================
   CUSTOM ON-SCREEN TOUCH NUMPAD (Mobile & Desktop Friendly)
   ========================================================================== */
.numpad-container {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.num-key {
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    box-shadow: 0 3px 0 #121a2f;
}

.num-key:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #121a2f;
    background: var(--bg-card-hover);
    border-color: var(--cyan);
}

.num-key.action-del {
    background: rgba(255, 64, 129, 0.15);
    border-color: rgba(255, 64, 129, 0.4);
    color: var(--pink);
    font-size: 1.2rem;
}

.num-key.action-submit {
    background: linear-gradient(135deg, #00e5ff, #00e676);
    color: #0b111e;
    font-size: 1.4rem;
    font-weight: 900;
    border: none;
    box-shadow: 0 3px 0 #0099aa;
}

.num-key.action-submit:active {
    box-shadow: 0 1px 0 #0099aa;
}

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

.numpad-sub-btn {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.numpad-sub-btn:hover {
    color: var(--text-main);
    border-color: var(--border-bright);
}

.numpad-sub-btn.hint-btn:hover {
    color: var(--yellow);
    border-color: var(--yellow);
    background: var(--yellow-dim);
}

/* ==========================================================================
   PRACTICE MODE & SANDBOX & BLITZ VIEWS
   ========================================================================== */
.mode-header-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.mode-header-info h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 800;
    color: #fff;
}

.mode-header-info p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.practice-selector-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.practice-pill-btn {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.practice-pill-btn.active, .practice-pill-btn:hover {
    background: var(--cyan-dim);
    border-color: var(--cyan);
    color: var(--cyan);
}

/* Blitz Timer & Score Banner */
.blitz-stats-bar {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: linear-gradient(90deg, #2a1435, #14243b);
    border: 2px solid var(--pink);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    width: 100%;
}

.blitz-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.blitz-stat-label {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
}

.blitz-stat-val {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    color: #fff;
}

.blitz-stat-val.timer { color: var(--yellow); }
.blitz-stat-val.score { color: var(--cyan); }
.blitz-stat-val.combo { color: var(--pink); }

/* Sandbox Custom Inputs */
.sandbox-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.sandbox-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sandbox-input-group label {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sandbox-num-input {
    width: 90px;
    height: 44px;
    background: var(--bg-surface);
    border: 2px solid var(--border-bright);
    border-radius: var(--radius-md);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 1.2rem;
    font-weight: 700;
    text-align: center;
    outline: none;
    transition: border-color 0.2s;
}

.sandbox-num-input:focus {
    border-color: var(--cyan);
}

.btn-primary {
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--cyan), #00b0ff);
    color: var(--bg-dark);
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 0.95rem;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 229, 255, 0.4);
}

/* ==========================================================================
   CITY PANORAMA & ARCHITECT MAP
   ========================================================================== */
.city-panorama-card {
    background: linear-gradient(180deg, #0f1c38 0%, #192d52 60%, #152238 100%);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-xl);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: var(--shadow-subtle);
    position: relative;
    overflow: hidden;
}

.city-stats-summary {
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: rgba(11, 17, 30, 0.7);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}

.city-stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.city-stat-num {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 900;
    color: var(--cyan);
}

.city-stat-lbl {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.city-buildings-skyline {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    width: 100%;
}

.city-plot-item {
    background: rgba(255, 255, 255, 0.04);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    min-height: 120px;
    transition: all 0.25s;
    position: relative;
}

.city-plot-item.built {
    background: linear-gradient(180deg, rgba(0, 229, 255, 0.12) 0%, rgba(19, 28, 49, 0.9) 100%);
    border: 1px solid var(--cyan);
    box-shadow: 0 4px 14px rgba(0, 229, 255, 0.2);
}

.city-plot-item.built:hover {
    transform: translateY(-4px);
    border-color: var(--yellow);
    box-shadow: 0 8px 20px rgba(255, 184, 0, 0.3);
}

.city-plot-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.city-plot-name {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
}

.city-plot-power {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--green);
}

/* ==========================================================================
   ACADEMY / HOW TO PLAY TUTORIAL VIEW
   ========================================================================== */
.academy-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tutorial-step-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tutorial-step-card.hero-step {
    border-color: var(--cyan);
    background: linear-gradient(135deg, #132440 0%, #151c33 100%);
}

.tutorial-step-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tutorial-badge {
    padding: 4px 10px;
    background: var(--cyan);
    color: var(--bg-dark);
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 0.85rem;
    border-radius: var(--radius-sm);
}

.tutorial-step-header h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
}

.tutorial-visual-box {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.zero-trick-callout {
    background: rgba(255, 184, 0, 0.12);
    border-left: 4px solid var(--yellow);
    padding: 12px 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-size: 0.95rem;
    line-height: 1.4;
}

.zero-trick-callout strong {
    color: var(--yellow);
}

/* ==========================================================================
   TROPHY ROOM
   ========================================================================== */
.trophies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.trophy-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    transition: all 0.2s;
}

.trophy-card.unlocked {
    border-color: var(--yellow);
    background: linear-gradient(180deg, rgba(255, 184, 0, 0.08) 0%, var(--bg-card) 100%);
    box-shadow: 0 4px 14px rgba(255, 184, 0, 0.2);
}

.trophy-card.locked {
    opacity: 0.5;
    filter: grayscale(0.8);
}

.trophy-icon {
    font-size: 2.6rem;
}

.trophy-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
}

.trophy-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.trophy-status-pill {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-sm);
}

.trophy-card.unlocked .trophy-status-pill {
    background: var(--yellow-dim);
    color: var(--yellow);
}

.trophy-card.locked .trophy-status-pill {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-dim);
}

/* ==========================================================================
   MODALS (Victory, Level Complete, Hint, Help)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 17, 30, 0.85);
    backdrop-filter: blur(8px);
    z-index: 999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
    animation: modalFadeIn 0.25s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.modal-card {
    background: var(--bg-surface);
    border: 2px solid var(--border-bright);
    border-radius: var(--radius-xl);
    padding: 24px;
    max-width: 480px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    position: relative;
}

.modal-card.victory {
    border-color: var(--yellow);
    box-shadow: 0 0 30px rgba(255, 184, 0, 0.35);
}

.modal-icon-burst {
    font-size: 3.5rem;
    animation: bounce 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 900;
    color: #fff;
}

.modal-body {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.modal-stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    width: 100%;
}

.modal-stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-stat-lbl {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
}

.modal-stat-val {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--cyan);
}

.modal-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.modal-actions button {
    flex: 1;
    padding: 12px;
    font-size: 1rem;
}

/* ==========================================================================
   RESPONSIVE DESIGN (Mobile & Small Screens)
   ========================================================================== */
@media (max-width: 600px) {
    .app-wrapper {
        padding: 8px 10px 80px;
        gap: 12px;
    }

    .app-header {
        padding: 8px 12px;
    }

    .brand-titles h1 {
        font-size: 1.1rem;
    }

    .mascot-avatar {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }

    .stat-chip {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .game-arena {
        padding: 14px 10px;
        border-radius: var(--radius-lg);
    }

    .math-problem-display {
        font-size: 1.3rem;
    }

    .box-grid-wrapper {
        padding: 10px 6px;
    }

    .grid-corner {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .header-cell {
        min-width: 64px;
        min-height: 46px;
        padding: 4px;
    }

    .header-cell.vertical {
        min-width: 58px;
    }

    .header-value-display {
        font-size: 1.05rem;
    }

    .box-product-cell {
        min-width: 82px;
        min-height: 76px;
        padding: 4px;
    }

    .cell-mini-formula {
        font-size: 0.68rem;
    }

    .cell-input-box {
        font-size: 1.15rem;
        min-height: 32px;
        min-width: 48px;
    }

    .num-key {
        height: 46px;
        font-size: 1.25rem;
    }

    .sum-input-target {
        font-size: 1.3rem;
        min-width: 100px;
        min-height: 42px;
    }
}
