:root {
    --realm: #16a34a;
    --realm-soft: color-mix(in srgb, var(--realm) 14%, white);
    --realm-mid: color-mix(in srgb, var(--realm) 35%, white);
    --realm-dark: color-mix(in srgb, var(--realm) 72%, black);
    --ink: #1e1b4b;
    --text-main: #1e293b;
    --text-muted: #475569;
    --panel-bg: rgba(255, 255, 255, 0.9);
    --panel-edge: 0 6px 0 rgba(15, 23, 42, 0.1);
    --shadow-soft: 0 6px 0 rgba(15, 23, 42, 0.08), 0 18px 40px rgba(15, 23, 42, 0.16);
    --shadow-pop: 0 8px 0 rgba(15, 23, 42, 0.12), 0 24px 50px rgba(15, 23, 42, 0.28);
    --radius-lg: 26px;
    --radius-md: 16px;
    --radius-pill: 999px;
    --font-display: 'Fredoka', 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
    --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
}

body {
    font-family: var(--font-body);
    font-weight: 700;
    overflow: hidden;
    background: linear-gradient(180deg, #7dd3fc, #e0f2fe);
    color: var(--text-main);
}

button { font-family: inherit; }

#game-container,
#three-container {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
}

#three-container { z-index: 1; }

#three-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

body.ready #ui-layer { opacity: 1; }

.panel-glass {
    background: var(--panel-bg);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
}

/* ==================== TOP BAR ==================== */
#top-bar {
    position: absolute;
    top: 12px;
    left: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--panel-bg);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 3px solid #fff;
    padding: 7px 10px 7px 14px;
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-soft);
    pointer-events: auto;
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

#game-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.logo-mark {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    font-size: 1.15rem;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    box-shadow: 0 3px 0 #6d28d9;
    transform: rotate(-6deg);
}

.title-accent {
    background: linear-gradient(135deg, #f97316, #ec4899 50%, #8b5cf6);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.icon-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius-pill);
    border: none;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 900;
    font-size: 0.92rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #c7d2fe;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-pill-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 0 #c7d2fe; }
.icon-pill-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c7d2fe; }

#grade-tabs {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #f1f5f9;
    padding: 5px;
    border-radius: var(--radius-pill);
    box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.08);
}

.grade-tab {
    border: none;
    background: transparent;
    color: #64748b;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    min-width: 46px;
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.grade-tab:hover {
    color: var(--ink);
    background: #fff;
    transform: translateY(-1px);
}

.grade-tab.active {
    background: var(--realm);
    color: #fff;
    box-shadow: 0 3px 0 var(--realm-dark);
    transform: translateY(-1px);
}

#stats-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
}

.streak-chip { background: #fff7ed; color: #c2410c; box-shadow: inset 0 0 0 2px #fed7aa; }
.score-chip { background: #ecfeff; color: #0e7490; box-shadow: inset 0 0 0 2px #a5f3fc; }

.icon-circle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #fff;
    font-size: 1.05rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 2px #e2e8f0, 0 3px 0 #e2e8f0;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.icon-circle-btn:hover { transform: translateY(-2px) scale(1.05); }
.icon-circle-btn:active { transform: translateY(2px); box-shadow: inset 0 0 0 2px #e2e8f0; }

/* ==================== QUEST BANNER ==================== */
#quest-banner {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: min(600px, calc(100vw - 32px));
    background: var(--panel-bg);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 3px solid #fff;
    border-top: 7px solid var(--realm);
    border-radius: var(--radius-lg);
    padding: 8px 20px 12px;
    text-align: center;
    box-shadow: var(--shadow-soft);
    pointer-events: auto;
}

.quest-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 2px;
}

.realm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    font-weight: 900;
    padding: 3px 12px;
    border-radius: var(--radius-pill);
    background: var(--realm-soft);
    color: var(--realm-dark);
}

.quest-dots {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quest-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e2e8f0;
    box-shadow: inset 0 2px 0 rgba(15, 23, 42, 0.1);
    transition: all 0.25s ease;
}

.quest-dot.done {
    background: radial-gradient(circle at 35% 35%, #fde68a, #f59e0b);
    box-shadow: 0 2px 0 #b45309;
    transform: scale(1.1);
}

.quest-dot.current {
    background: var(--realm);
    box-shadow: 0 0 0 4px var(--realm-mid);
    animation: dot-pulse 1.4s ease-in-out infinite;
}

@keyframes dot-pulse {
    50% { box-shadow: 0 0 0 7px transparent; }
}

.problem-equation {
    font-family: var(--font-display);
    font-size: 2.3rem;
    font-weight: 700;
    color: var(--ink);
    line-height: 1.1;
    margin: 2px 0 2px;
    letter-spacing: 0.01em;
}

.problem-equation.pop-in { animation: eq-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes eq-pop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.problem-prompt {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 700;
    line-height: 1.35;
}

.live-readout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    padding: 4px 14px 4px 4px;
    border-radius: var(--radius-pill);
    font-size: 0.92rem;
    color: #334155;
    box-shadow: inset 0 0 0 2px #e2e8f0;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.readout-tag {
    font-size: 0.72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: #e2e8f0;
    color: #475569;
    padding: 3px 9px;
    border-radius: var(--radius-pill);
}

.live-readout strong { color: var(--ink); font-weight: 900; }

.live-readout.match-ready {
    background: #ecfdf5;
    box-shadow: inset 0 0 0 2px #6ee7b7, 0 0 0 5px rgba(16, 185, 129, 0.15);
    animation: ready-glow 1.2s ease-in-out infinite;
}

.live-readout.match-ready .readout-tag { background: #10b981; color: #fff; }
.live-readout.match-ready strong { color: #047857; }

@keyframes ready-glow {
    50% { box-shadow: inset 0 0 0 2px #6ee7b7, 0 0 0 9px rgba(16, 185, 129, 0.05); }
}

/* ==================== ISLAND PANEL ==================== */
#island-panel {
    position: absolute;
    top: 84px;
    left: 16px;
    width: 220px;
    background: var(--panel-bg);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 3px solid #fff;
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow-soft);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.island-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.island-grade {
    align-self: flex-start;
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: var(--realm);
    color: #fff;
    box-shadow: 0 2px 0 var(--realm-dark);
}

.island-name {
    font-family: var(--font-display);
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--ink);
}

.landmark-progress {
    background: var(--realm-soft);
    border-radius: var(--radius-md);
    padding: 8px 10px 10px;
}

.story-line {
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--realm-dark);
    margin-bottom: 6px;
}

.progress-track {
    height: 12px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.85);
    box-shadow: inset 0 2px 3px rgba(15, 23, 42, 0.12);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background:
        repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.25) 0 8px, transparent 8px 16px),
        linear-gradient(90deg, #fbbf24, #f97316);
    transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.station-row {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.station-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    border: none;
    background: #fff;
    color: var(--text-main);
    padding: 6px 10px 6px 6px;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    box-shadow: inset 0 0 0 2px #e2e8f0, 0 3px 0 #e2e8f0;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.station-chip:hover { transform: translateX(3px); box-shadow: inset 0 0 0 2px var(--realm-mid), 0 3px 0 var(--realm-mid); }
.station-chip:active { transform: translateY(2px); }

.station-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 1.25rem;
    background: var(--realm-soft);
}

.station-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.station-name {
    font-weight: 900;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-stars {
    font-size: 0.85rem;
    letter-spacing: 1px;
    color: #cbd5e1;
    line-height: 1;
}

.station-stars .on { color: #f59e0b; text-shadow: 0 1px 0 #b45309; }

.station-chip.active-station {
    background: var(--realm);
    color: #fff;
    box-shadow: 0 4px 0 var(--realm-dark);
}

.station-chip.active-station .station-icon { background: rgba(255, 255, 255, 0.25); }
.station-chip.active-station .station-stars { color: rgba(255, 255, 255, 0.45); }
.station-chip.active-station .station-stars .on { color: #fde047; text-shadow: none; }

/* ==================== FEEDBACK TOAST & HINT CARD ==================== */
.feedback-toast {
    position: absolute;
    bottom: 210px;
    left: 50%;
    transform: translateX(-50%);
    max-width: min(560px, calc(100vw - 32px));
    padding: 14px 26px;
    border-radius: 22px;
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
    pointer-events: none;
    z-index: 10;
    animation: toast-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-toast.success {
    bottom: auto;
    top: 44%;
    background: linear-gradient(135deg, #34d399, #059669);
    color: #fff;
    box-shadow: 0 6px 0 #047857, 0 20px 40px rgba(5, 150, 105, 0.35);
    text-shadow: 0 2px 0 rgba(4, 120, 87, 0.5);
}

.feedback-toast.guide {
    background: #fffbeb;
    color: #92400e;
    box-shadow: inset 0 0 0 3px #fcd34d, 0 6px 0 #f59e0b, 0 20px 40px rgba(146, 64, 14, 0.2);
}

@keyframes toast-pop {
    0% { transform: translateX(-50%) scale(0.6); opacity: 0; }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.hint-card {
    position: absolute;
    top: 84px;
    right: 16px;
    width: min(300px, calc(100vw - 32px));
    background: #fffbeb;
    border: 3px solid #fde68a;
    border-radius: 22px;
    padding: 14px 16px;
    box-shadow: 0 6px 0 #f59e0b, 0 20px 40px rgba(146, 64, 14, 0.2);
    pointer-events: auto;
    z-index: 9;
    animation: slide-in-right 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slide-in-right {
    0% { opacity: 0; transform: translateX(24px); }
    100% { opacity: 1; transform: translateX(0); }
}

.hint-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-family: var(--font-display);
    font-weight: 600;
    color: #b45309;
    font-size: 1.05rem;
    margin-bottom: 6px;
}

#hint-body {
    font-size: 0.95rem;
    line-height: 1.45;
    color: #78350f;
    font-weight: 700;
}

.mini-close-btn {
    border: none;
    background: rgba(245, 158, 11, 0.2);
    color: #92400e;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 900;
    cursor: pointer;
}

/* ==================== BOTTOM DOCK ==================== */
#bottom-dock {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: min(820px, calc(100vw - 24px));
    background: var(--panel-bg);
    backdrop-filter: blur(14px) saturate(1.3);
    -webkit-backdrop-filter: blur(14px) saturate(1.3);
    border: 3px solid #fff;
    border-radius: var(--radius-lg);
    padding: 10px 16px 8px;
    box-shadow: var(--shadow-soft);
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
}

.manipulative-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.manipulative-controls:empty { display: none; }

.ctrl-group {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--realm-soft);
    padding: 5px 7px;
    border-radius: 16px;
}

.ctrl-label {
    font-size: 0.82rem;
    font-weight: 900;
    color: var(--realm-dark);
    padding: 0 4px;
}

.ctrl-btn {
    border: none;
    border-radius: 12px;
    padding: 7px 13px;
    font-size: 0.95rem;
    font-weight: 900;
    cursor: pointer;
    background: #fff;
    color: var(--text-main);
    box-shadow: inset 0 0 0 2px #e2e8f0, 0 4px 0 #cbd5e1;
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.12s ease;
}

.ctrl-btn:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 2px #c7d2fe, 0 6px 0 #a5b4fc; }
.ctrl-btn:active { transform: translateY(3px); box-shadow: inset 0 0 0 2px #e2e8f0, 0 1px 0 #cbd5e1; }

.ctrl-btn.accent-blue { background: #eff6ff; color: #1d4ed8; box-shadow: inset 0 0 0 2px #bfdbfe, 0 4px 0 #93c5fd; }
.ctrl-btn.accent-amber { background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 2px #fde68a, 0 4px 0 #fbbf24; }
.ctrl-btn.accent-teal { background: #f0fdfa; color: #0f766e; box-shadow: inset 0 0 0 2px #99f6e4, 0 4px 0 #5eead4; }
.ctrl-btn.accent-rose { background: #fff1f2; color: #be123c; box-shadow: inset 0 0 0 2px #fecdd3, 0 4px 0 #fda4af; }

.ctrl-btn.active-choice {
    background: var(--realm);
    color: #fff;
    box-shadow: 0 4px 0 var(--realm-dark);
}

.action-buttons {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.primary-action-btn,
.secondary-action-btn,
.ghost-action-btn {
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-display);
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.12s ease;
}

.primary-action-btn {
    padding: 10px 26px;
    font-size: 1.15rem;
    color: #fff;
    background: linear-gradient(180deg, #34d399, #10b981);
    box-shadow: 0 5px 0 #047857, 0 10px 20px rgba(16, 185, 129, 0.35);
    text-shadow: 0 1px 0 rgba(4, 120, 87, 0.6);
}

.primary-action-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #047857, 0 14px 24px rgba(16, 185, 129, 0.4); filter: brightness(1.05); }
.primary-action-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #047857; }

.secondary-action-btn {
    padding: 9px 18px;
    font-size: 1rem;
    background: linear-gradient(180deg, #fde68a, #fcd34d);
    color: #78350f;
    box-shadow: 0 5px 0 #d97706;
}

.secondary-action-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #d97706; }
.secondary-action-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #d97706; }

.ghost-action-btn {
    padding: 9px 16px;
    font-size: 0.98rem;
    background: #f1f5f9;
    color: #475569;
    box-shadow: 0 5px 0 #cbd5e1;
}

.ghost-action-btn:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #cbd5e1; }
.ghost-action-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #cbd5e1; }

kbd {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.14);
    color: inherit;
    text-shadow: none;
}

.controls-footnote {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76rem;
    color: #64748b;
}

/* ==================== CONFETTI ==================== */
#confetti-layer {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 40;
}

.confetti-piece {
    position: absolute;
    top: -16px;
    width: 10px;
    height: 16px;
    border-radius: 3px;
    animation-name: confetti-fall;
    animation-timing-function: cubic-bezier(0.25, 0.6, 0.5, 1);
    animation-fill-mode: forwards;
}

.confetti-piece.round { width: 11px; height: 11px; border-radius: 50%; }

@keyframes confetti-fall {
    0% { transform: translate(0, 0) rotate(0deg); opacity: 1; }
    100% { transform: translate(var(--drift), 105vh) rotate(var(--spin)); opacity: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
    #confetti-layer { display: none; }
    .problem-equation.pop-in, .quest-dot.current, .live-readout.match-ready { animation: none; }
}

/* ==================== MODALS ==================== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at 50% 40%, rgba(49, 46, 129, 0.45), rgba(15, 23, 42, 0.7));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
    z-index: 30;
}

.hidden { display: none !important; }

.modal-panel {
    background: #fff;
    border-radius: 30px;
    padding: 26px 28px;
    box-shadow: 0 10px 0 rgba(15, 23, 42, 0.2), 0 30px 60px rgba(15, 23, 42, 0.35);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    animation: modal-pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modal-pop {
    0% { opacity: 0; transform: scale(0.85) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.map-panel { width: min(900px, 100%); }
.celebration-panel { width: min(480px, 100%); text-align: center; }
.help-panel { width: min(660px, 100%); }

.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.modal-panel h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.7rem;
    color: var(--ink);
}

.modal-subtitle {
    font-size: 0.95rem;
    color: #64748b;
    margin-top: 3px;
}

.modal-close-btn {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #f1f5f9;
    color: #334155;
    font-size: 1.05rem;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 3px 0 #cbd5e1;
}

.modal-close-btn:hover { background: #e2e8f0; }
.modal-close-btn:active { transform: translateY(2px); box-shadow: none; }

.realm-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
    gap: 14px;
}

.realm-card {
    border: none;
    border-radius: 22px;
    padding: 16px;
    background: #f8fafc;
    cursor: pointer;
    text-align: left;
    box-shadow: inset 0 0 0 2px #e2e8f0, 0 5px 0 #e2e8f0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.realm-card:hover { transform: translateY(-3px); box-shadow: inset 0 0 0 2px #a5b4fc, 0 8px 0 #c7d2fe; background: #fff; }
.realm-card.current-realm { background: #eef2ff; box-shadow: inset 0 0 0 3px #818cf8, 0 5px 0 #a5b4fc; }

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

.realm-grade-pill {
    font-size: 0.75rem;
    font-weight: 900;
    text-transform: uppercase;
    padding: 4px 11px;
    border-radius: var(--radius-pill);
    color: #fff;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

.realm-stars {
    font-family: var(--font-display);
    font-size: 1rem;
    color: #d97706;
}

.realm-card h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-main);
}

.realm-card p {
    font-size: 0.86rem;
    color: #475569;
    line-height: 1.4;
}

.mini-station-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.mini-station {
    border: none;
    background: #fff;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 900;
    padding: 4px 9px;
    cursor: pointer;
    color: #334155;
    box-shadow: inset 0 0 0 2px #e2e8f0, 0 2px 0 #e2e8f0;
}

.mini-station:hover { box-shadow: inset 0 0 0 2px #a5b4fc, 0 2px 0 #a5b4fc; }

.shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.shop-card {
    text-align: left;
    border: none;
    background: #f8fafc;
    border-radius: 18px;
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.88rem;
    color: #475569;
    box-shadow: inset 0 0 0 2px #e2e8f0, 0 4px 0 #e2e8f0;
    transition: transform 0.12s ease;
}

.shop-card:hover { transform: translateY(-2px); }
.shop-card strong { font-family: var(--font-display); font-weight: 600; color: var(--text-main); font-size: 1.05rem; }
.shop-card.owned { background: #ecfdf5; box-shadow: inset 0 0 0 2px #6ee7b7, 0 4px 0 #a7f3d0; }

.shop-balance {
    grid-column: 1 / -1;
    font-weight: 800;
    color: #334155;
    margin-top: 4px;
}

.celebration-badge {
    font-size: 3.2rem;
    margin-bottom: 6px;
    animation: badge-bounce 1.6s ease-in-out infinite;
}

@keyframes badge-bounce {
    50% { transform: translateY(-8px) rotate(-4deg); }
}

.celebration-summary {
    font-size: 1.05rem;
    color: #475569;
    margin: 8px 0 14px;
    line-height: 1.45;
}

.concept-takeaway {
    background: #eef2ff;
    border-radius: 18px;
    padding: 12px 16px;
    font-size: 0.95rem;
    color: #312e81;
    font-weight: 800;
    margin-bottom: 20px;
    line-height: 1.45;
    box-shadow: inset 0 0 0 2px #c7d2fe;
}

.modal-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.help-item {
    display: flex;
    gap: 12px;
    background: #f8fafc;
    padding: 14px;
    border-radius: 18px;
    box-shadow: inset 0 0 0 2px #e2e8f0;
}

.help-icon { font-size: 1.8rem; }

.help-item h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 4px;
}

.help-item p {
    font-size: 0.87rem;
    color: #475569;
    line-height: 1.4;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1180px) {
    #island-panel { width: 74px; padding: 8px; align-items: center; }
    .island-head, .story-line, .station-text { display: none; }
    .landmark-progress { width: 100%; padding: 6px; }
    .station-chip { padding: 5px; justify-content: center; }
    .station-icon { width: 42px; height: 42px; }
    .title-accent { display: none; }
}

@media (max-width: 900px) {
    #top-bar {
        flex-wrap: wrap;
        justify-content: center;
        border-radius: 22px;
        padding: 8px 10px;
    }

    #game-title { display: none; }
    #quest-banner { top: 112px; padding: 6px 14px 10px; }
    #island-panel { top: 116px; }
    .problem-equation { font-size: 1.7rem; }
    .controls-footnote { display: none; }
    .hint-card { top: auto; bottom: 170px; right: 12px; }
    #quest-banner { width: min(600px, calc(100vw - 120px)); left: calc(50% + 40px); }
}

@media (max-height: 820px) {
    .controls-footnote { display: none; }
}

@media (max-height: 760px) {
    #quest-banner { padding: 5px 16px 8px; }
    .problem-equation { font-size: 1.8rem; }
    .problem-prompt { font-size: 0.88rem; }
    #bottom-dock { padding: 7px 14px 6px; gap: 6px; }
    .controls-footnote { display: none; }
    .station-icon { width: 34px; height: 34px; font-size: 1.1rem; }
    #island-panel { gap: 7px; }
}
