/* ZeldaMaths — Hyrule Collector Edition Retro Styling */
:root {
  --bg-page-top: #0d1d1a;
  --bg-page-bottom: #111827;
  --bg-shell: #162624;
  --bg-shell-light: #1e3532;
  --bg-bezel: #222938;
  --bg-panel: #101c1b;
  --bg-panel-light: #1b2f2c;
  --border-gold: #d4a63f;
  --border-gold-soft: rgba(212, 166, 63, 0.35);
  --border-retro: #2f4b46;
  --text-main: #f8fafc;
  --text-muted: #9bb5b0;
  --accent: #facc15;
  --accent-warm: #f59e0b;
  --success: #4ade80;
  --danger: #f87171;
  --screen-bg: #0a1219;
  --dialogue-bg: rgba(11, 21, 32, 0.96);
  --dialogue-border: #eab308;
  --btn-a: #dc2626;
  --btn-b: #b91c1c;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-pixel: "Courier New", Courier, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 15%, rgba(56, 189, 248, 0.08), transparent 45%),
    radial-gradient(circle at 80% 10%, rgba(250, 204, 21, 0.09), transparent 42%),
    linear-gradient(160deg, var(--bg-page-top) 0%, var(--bg-page-bottom) 100%);
  color: var(--text-main);
  font-family: var(--font-ui);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px 12px;
}

.app-shell {
  width: 100%;
  max-width: 800px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Header */
.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, var(--bg-shell-light), var(--bg-shell));
  border: 2px solid var(--border-gold-soft);
  border-radius: 14px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

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

.brand-badge {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #fde047, #ca8a04);
  color: #14221f;
  font-weight: 900;
  font-size: 20px;
  border-radius: 10px;
  border: 1px solid #fef08a;
  box-shadow: 0 4px 12px rgba(250, 204, 21, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.25);
}

.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  font-family: var(--font-pixel);
  letter-spacing: 0.8px;
  color: #fef08a;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.subtitle {
  margin: 1px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.btn-tool {
  background: linear-gradient(180deg, #213a36, #162826);
  color: var(--text-main);
  border: 1.5px solid var(--border-retro);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn-tool:hover {
  border-color: var(--border-gold);
  box-shadow: 0 4px 12px rgba(212, 166, 63, 0.22);
  transform: translateY(-1px);
}

.btn-tool:active {
  transform: translateY(1px);
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-family: var(--font-pixel);
  font-weight: 700;
  background: rgba(0, 0, 0, 0.4);
  color: var(--accent);
  border: 1px solid rgba(250, 204, 21, 0.3);
  border-radius: 4px;
}

/* Console Frame */
.console-frame {
  background: linear-gradient(165deg, #1d322f 0%, #132120 100%);
  border: 2px solid var(--border-gold-soft);
  border-radius: 18px 18px 42px 18px;
  padding: 14px;
  box-shadow:
    0 20px 45px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -4px 12px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* HUD */
.hud-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: linear-gradient(180deg, #0d1817, #122120);
  border: 1.5px solid var(--border-retro);
  border-radius: 10px;
  padding: 7px 14px;
  font-family: var(--font-pixel);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.hud-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.hud-zone-name {
  font-weight: 700;
  font-size: 1rem;
  color: #fef9c3;
}

.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-pixel);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: #1d4ed8;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
}

.level-badge.lvl-6e { background: linear-gradient(135deg, #16a34a, #15803d); }
.level-badge.lvl-5e { background: linear-gradient(135deg, #0284c7, #0369a1); }
.level-badge.lvl-4e { background: linear-gradient(135deg, #d97706, #b45309); }
.level-badge.lvl-3e { background: linear-gradient(135deg, #9333ea, #7e22ce); }
.level-badge.inline { font-size: 0.72rem; padding: 1px 6px; }

.topic-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.14);
  color: var(--accent);
  border: 1px solid rgba(250, 204, 21, 0.35);
  margin-left: 4px;
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-pill {
  font-size: 0.84rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 3px 9px;
  border-radius: 7px;
}

.hud-status-dot {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(250, 204, 21, 0.15);
  color: var(--accent);
  border: 1px solid rgba(250, 204, 21, 0.55);
}

.hud-status-dot.solved {
  background: rgba(74, 222, 128, 0.16);
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.65);
}

/* Screen Bezel (Game Boy Color inspired) */
.screen-bezel {
  position: relative;
  background: linear-gradient(180deg, #273043, #19202e);
  padding: 12px 14px 14px 32px;
  border-radius: 14px 14px 30px 14px;
  border: 2px solid #0f172a;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.06);
}

.bezel-led {
  position: absolute;
  left: 8px;
  top: 38%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.led-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px #4ade80, 0 0 14px rgba(74, 222, 128, 0.75);
}

.led-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-size: 0.54rem;
  font-family: var(--font-pixel);
  letter-spacing: 1px;
  color: #64748b;
  font-weight: 700;
}

.screen-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--screen-bg);
  border: 3px solid #090e17;
  border-radius: 7px;
  overflow: hidden;
  user-select: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Zone entrance banner */
.zone-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 21, 32, 0.92);
  color: #f8fafc;
  border: 2px solid var(--border-gold);
  border-radius: 10px;
  padding: 7px 16px;
  text-align: center;
  pointer-events: none;
  font-family: var(--font-pixel);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  z-index: 4;
}

.zone-banner strong {
  display: block;
  font-size: 0.96rem;
  color: #fef08a;
}

.zone-banner span {
  font-size: 0.76rem;
  color: #cbd5e1;
}

/* Interact Hint */
.interact-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(11, 21, 32, 0.92);
  color: #fef9c3;
  border: 2px solid var(--border-gold);
  border-radius: 9px;
  padding: 5px 11px;
  font-size: 0.82rem;
  font-weight: 700;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  z-index: 4;
}

.hint-key-touch {
  display: none;
}

@media (hover: none) and (pointer: coarse), (max-width: 680px) {
  .hint-key-desktop {
    display: none;
  }

  .hint-key-touch {
    display: inline-block;
  }
}

/* Retro Zelda Dialogue Box */
.dialogue-box {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: var(--dialogue-bg);
  color: #f8fafc;
  border: 3px solid var(--dialogue-border);
  outline: 2px solid #020617;
  border-radius: 10px;
  padding: 11px 15px;
  font-family: var(--font-pixel);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.7);
  z-index: 5;
}

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

.dialogue-speaker {
  font-weight: 700;
  color: #fde047;
  font-size: 0.92rem;
}

.dialogue-clue-tag {
  font-size: 0.74rem;
  font-weight: 700;
  background: linear-gradient(135deg, #4ade80, #22c55e);
  color: #052e16;
  padding: 2px 8px;
  border-radius: 999px;
}

.dialogue-text {
  margin: 0 0 9px;
  font-size: 0.94rem;
  line-height: 1.45;
  min-height: 2.8em;
}

.dialogue-visual {
  margin: 4px 0 8px;
  display: flex;
  justify-content: center;
}

.dialogue-visual svg {
  width: 100%;
  max-width: 290px;
  height: auto;
  max-height: 155px;
  border-radius: 6px;
}

.dialogue-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialogue-page {
  font-size: 0.76rem;
  color: #94a3b8;
}

.btn-dialogue-next {
  background: linear-gradient(135deg, #fde047, #eab308);
  color: #0f172a;
  border: none;
  border-radius: 7px;
  padding: 5px 13px;
  font-family: var(--font-pixel);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.btn-dialogue-next:hover {
  background: #fef08a;
}

/* Controls Area */
.controls-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 10px;
}

.controls-legend {
  flex: 1;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.controls-legend p {
  margin: 2px 0;
}

.asset-credit {
  font-size: 0.72rem;
  opacity: 0.85;
}

.asset-credit a {
  color: var(--accent);
  text-decoration: none;
}

.asset-credit a:hover {
  text-decoration: underline;
}

.marker-ex {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  color: #111827;
  font-weight: 900;
  font-size: 0.78rem;
}

.touch-dpad {
  display: grid;
  grid-template-columns: repeat(3, 36px);
  grid-template-rows: repeat(3, 36px);
  gap: 2px;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.dpad-btn {
  background: linear-gradient(180deg, #273244, #141a24);
  color: #e2e8f0;
  border: 1.5px solid #475569;
  border-radius: 7px;
  font-size: 0.88rem;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active,
.dpad-btn.active {
  background: var(--accent);
  color: #0f172a;
  border-color: #fef08a;
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; background: #141a24; border-radius: 4px; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

.touch-ab {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gb-round-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: radial-gradient(circle at 35% 30%, #ef4444, #991b1b);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 #5b1010, 0 8px 14px rgba(0, 0, 0, 0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s ease;
}

.gb-round-btn.btn-b {
  background: radial-gradient(circle at 35% 30%, #dc2626, #7f1d1d);
  margin-top: 16px;
}

.gb-round-btn small {
  font-size: 0.62rem;
  font-weight: 600;
  opacity: 0.92;
}

.gb-round-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #5b1010;
}

/* Native Modal Dialogs (Modern Web Guidance compliant) */
dialog {
  padding: 0;
  border: 2px solid var(--border-gold);
  border-radius: 16px;
  background: linear-gradient(180deg, #162624, #101b22);
  color: #f1f5f9;
  width: min(750px, calc(100vw - 24px));
  max-height: calc(100dvh - 28px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), 0 0 0 1px rgba(250, 204, 21, 0.15);
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

dialog:modal {
  overscroll-behavior: contain;
}

dialog::backdrop {
  background: rgba(4, 10, 14, 0.78);
  backdrop-filter: blur(3px);
  overflow: hidden;
  overscroll-behavior: contain;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1.5px solid var(--border-gold-soft);
  background: linear-gradient(180deg, #1b312d, #132221);
}

.dialog-header h2 {
  margin: 5px 0 0;
  font-size: 1.18rem;
  color: #fef9c3;
}

.dialog-sub {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.btn-icon-close {
  background: rgba(255, 255, 255, 0.08);
  color: #f1f5f9;
  border: 1px solid var(--border-retro);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  cursor: pointer;
}

.btn-icon-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.dialog-body {
  padding: 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Problem Modal Layout */
.problem-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.problem-visual,
.problem-solve {
  min-width: 0;
}

.svg-stage {
  background: #0b1520;
  border: 1.5px solid #2b4252;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.svg-stage svg {
  width: 100%;
  height: auto;
  max-height: 220px;
}

/* Zelda-style Fairy Help Panel */
.fairy-panel {
  background: linear-gradient(180deg, #0c1824, #0a141d);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 12px;
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.45);
}

.fairy-invoke {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  min-height: 150px;
  padding: 8px;
}

.fairy-sprite {
  position: relative;
  width: 46px;
  height: 36px;
  display: grid;
  place-items: center;
  animation: fairy-float 2.2s ease-in-out infinite;
}

.fairy-core {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 15%, #7dd3fc 55%, #0284c7 100%);
  box-shadow: 0 0 12px #38bdf8, 0 0 24px rgba(56, 189, 248, 0.75);
  z-index: 2;
}

.fairy-wing {
  position: absolute;
  top: 4px;
  width: 16px;
  height: 22px;
  background: rgba(224, 242, 254, 0.8);
  border: 1px solid #7dd3fc;
  border-radius: 50% 50% 35% 35%;
  z-index: 1;
}

.fairy-wing.left {
  left: 3px;
  transform-origin: right center;
  animation: wing-left 0.35s ease-in-out infinite alternate;
}

.fairy-wing.right {
  right: 3px;
  transform-origin: left center;
  animation: wing-right 0.35s ease-in-out infinite alternate;
}

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

@keyframes wing-left {
  from { transform: rotate(-18deg) scaleX(0.95); }
  to { transform: rotate(-42deg) scaleX(0.75); }
}

@keyframes wing-right {
  from { transform: rotate(18deg) scaleX(0.95); }
  to { transform: rotate(42deg) scaleX(0.75); }
}

.fairy-prompt {
  margin: 0;
  font-size: 0.84rem;
  color: #bae6fd;
}

.btn-fairy {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  color: #0f172a;
  border: 2px solid #e0f2fe;
  border-radius: 999px;
  padding: 8px 15px;
  font-weight: 800;
  font-size: 0.84rem;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.btn-fairy:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.65);
}

.fairy-bubble {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 0.8rem;
  color: #bae6fd;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 8px;
  padding: 6px 9px;
  margin-bottom: 8px;
  line-height: 1.35;
}

.fairy-mini {
  flex-shrink: 0;
}

/* Notepad-styled Clues Box inside Problem Modal */
.clues-box {
  margin-top: 12px;
  background:
    linear-gradient(90deg, transparent 28px, rgba(220, 38, 38, 0.28) 28px, rgba(220, 38, 38, 0.28) 29.5px, transparent 29.5px),
    #fdf6e3;
  color: #1e293b;
  border: 2px solid #92400e;
  border-top: 6px solid #78350f;
  border-radius: 4px 10px 10px 4px;
  padding: 10px 14px 12px 38px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.clues-box h3 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: #78350f;
  font-family: "Georgia", serif;
  border-bottom: 1.5px solid rgba(120, 53, 15, 0.28);
  padding-bottom: 5px;
}

.clues-list {
  margin: 0;
  padding-left: 16px;
  font-size: 0.85rem;
  line-height: 24px;
  color: #1e293b;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 23px,
    rgba(100, 116, 139, 0.28) 23px,
    rgba(100, 116, 139, 0.28) 24px
  );
  background-position: 0 0;
}

.clues-list li {
  margin: 0;
  padding: 0;
}

.clues-list li.clue-missing {
  color: #78716c;
  font-style: italic;
}

.problem-story {
  margin: 0 0 12px;
  font-size: 0.93rem;
  line-height: 1.55;
  color: #d1e3df;
}

.problem-question {
  margin: 0 0 15px;
  font-size: 0.98rem;
  font-weight: 700;
  color: #fef08a;
  background: rgba(250, 204, 21, 0.11);
  border-left: 4px solid var(--accent);
  padding: 9px 12px;
  border-radius: 0 8px 8px 0;
}

.answer-form label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.answer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.answer-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: var(--font-pixel);
  font-weight: 700;
  background: #0a141b;
  color: #f8fafc;
  border: 2px solid var(--border-retro);
  border-radius: 9px;
}

.answer-row input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.18);
}

.answer-unit {
  font-weight: 700;
  font-family: var(--font-pixel);
  color: #cbd5e1;
  white-space: nowrap;
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border: none;
  border-radius: 9px;
  padding: 10px 15px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #fde047, #eab308);
  color: #0f172a;
  box-shadow: 0 3px 10px rgba(234, 179, 8, 0.28);
}

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

.btn-secondary {
  background: #1f3533;
  color: #f1f5f9;
  border: 1px solid var(--border-retro);
}

.btn-secondary:hover {
  border-color: var(--border-gold);
}

.btn-danger {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #fff;
}

.btn-danger:hover {
  filter: brightness(1.1);
}

.feedback-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.feedback-box.success {
  background: rgba(34, 197, 94, 0.16);
  border: 1px solid #4ade80;
  color: #bbf7d0;
}

.feedback-box.error {
  background: rgba(248, 113, 113, 0.16);
  border: 1px solid #f87171;
  color: #fecaca;
}

.hint-actions {
  margin-top: 12px;
}

.btn-fairy-hint {
  border-color: rgba(56, 189, 248, 0.5);
  color: #bae6fd;
}

.btn-fairy-hint:hover {
  border-color: #7dd3fc;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.28);
}

.method-hint-box {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1.5px solid rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
  font-size: 0.86rem;
  line-height: 1.45;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.fairy-sprite-sm {
  width: 30px;
  height: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.fairy-sprite-sm .fairy-core {
  width: 11px;
  height: 11px;
}

.fairy-sprite-sm .fairy-wing {
  width: 11px;
  height: 15px;
  top: 2px;
}

.fairy-hint-body {
  min-width: 0;
}

.fairy-hint-name {
  display: block;
  font-size: 0.8rem;
  color: #7dd3fc;
  margin-bottom: 2px;
}

.fairy-hint-body p {
  margin: 0;
}

/* World Map Grid (5x4 Overhead Bird's-Eye Kingdom Map) */
.world-map-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  background: #174973;
  border: 3px solid var(--border-gold);
  border-radius: 12px;
  padding: 6px;
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.45);
}

.map-ocean-cell {
  aspect-ratio: 4 / 3;
  background: radial-gradient(circle at 50% 45%, #2b88c9, #1f6ca6);
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: rgba(186, 230, 253, 0.45);
  font-size: 0.9rem;
  user-select: none;
}

.map-card.map-aerial {
  position: relative;
  padding: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 7px;
  border: 2px solid #0f172a;
  background: #1e293b;
  cursor: pointer;
  display: block;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.map-mini-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.map-aerial-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.35) 0%, transparent 45%, rgba(15, 23, 42, 0.78) 100%);
  pointer-events: none;
}

.map-aerial-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.map-aerial-top .level-badge {
  font-size: 0.65rem;
  padding: 1px 5px;
}

.map-solved-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #22c55e;
  color: #052e16;
  font-weight: 900;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.map-here-pin {
  align-self: center;
  background: rgba(220, 38, 38, 0.94);
  color: #fef9c3;
  border: 1.5px solid #fde047;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.64rem;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  animation: here-pulse 1.2s ease-in-out infinite;
}

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

.map-aerial-title {
  font-family: var(--font-pixel);
  font-size: 0.74rem;
  font-weight: 800;
  color: #fef9c3;
  text-shadow: 0 1px 3px #000, 0 0 4px #000;
  text-align: center;
  line-height: 1.15;
}

.map-card.map-aerial:hover {
  transform: scale(1.04);
  z-index: 3;
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
}

.map-card.map-aerial.current {
  border-color: #fde047;
  box-shadow: 0 0 0 2px #fde047, 0 4px 14px rgba(250, 204, 21, 0.45);
  z-index: 2;
}

.map-card.map-aerial.solved {
  border-color: #4ade80;
}

.map-card.map-aerial.locked {
  filter: saturate(0.45) brightness(0.72);
  border-color: #475569;
}

.map-lock-icon {
  font-size: 0.72rem;
}

.map-locked-pin {
  align-self: center;
  background: rgba(15, 23, 42, 0.88);
  color: #cbd5e1;
  border: 1px solid #64748b;
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.62rem;
  font-weight: 700;
  white-space: nowrap;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dot-legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 5px;
}

.dot-legend.current { background: var(--accent); }
.dot-legend.solved { background: #4ade80; }
.dot-legend.open { background: #64748b; }

/* Notebook Booklet / Notepad */
.notebook-dialog-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.booklet-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.btn-book-nav {
  padding: 6px 12px;
  font-size: 0.84rem;
}

.booklet-page-indicator {
  font-family: var(--font-pixel);
  font-size: 0.86rem;
  color: #fef08a;
  font-weight: 700;
}

.booklet-frame {
  background: linear-gradient(135deg, #6b3b1e, #4a2511);
  border: 3px solid #3b1c0b;
  border-radius: 10px 14px 14px 10px;
  padding: 10px 12px 10px 18px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), inset 4px 0 10px rgba(0, 0, 0, 0.35);
  position: relative;
}

/* Spiral / leather binding rings on the left */
.booklet-frame::before {
  content: "";
  position: absolute;
  left: 6px;
  top: 16px;
  bottom: 16px;
  width: 8px;
  background: repeating-linear-gradient(
    180deg,
    #d4a63f 0px,
    #d4a63f 6px,
    transparent 6px,
    transparent 22px
  );
  border-radius: 4px;
}

.booklet-page {
  position: relative;
  background:
    linear-gradient(90deg, transparent 32px, rgba(220, 38, 38, 0.3) 32px, rgba(220, 38, 38, 0.3) 33.5px, transparent 33.5px),
    #fdf6e3;
  color: #1e293b;
  border-radius: 3px 9px 9px 3px;
  padding: 14px 18px 18px 44px;
  min-height: 235px;
  box-shadow: inset 6px 0 12px rgba(120, 53, 15, 0.14), 2px 3px 0 #e7dcc2;
}

.booklet-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 2px solid rgba(120, 53, 15, 0.3);
  padding-bottom: 8px;
  margin-bottom: 10px;
}

.booklet-page-head h3 {
  margin: 0;
  font-family: "Georgia", serif;
  font-size: 1.08rem;
  color: #451a03;
}

.booklet-stamp {
  font-family: var(--font-pixel);
  font-size: 0.72rem;
  font-weight: 800;
  color: #15803d;
  border: 2px solid #15803d;
  border-radius: 5px;
  padding: 1px 7px;
  transform: rotate(-4deg);
  display: inline-block;
}

.booklet-notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    transparent 25px,
    rgba(100, 116, 139, 0.28) 25px,
    rgba(100, 116, 139, 0.28) 26px
  );
  background-position: 0 0;
}

.booklet-notes li {
  font-size: 0.88rem;
  line-height: 26px;
  color: #1e293b;
  position: relative;
  padding-left: 20px;
  margin: 0;
}

.booklet-notes li::before {
  content: "✎";
  position: absolute;
  left: 0;
  top: 0;
  color: #b45309;
  font-weight: 700;
}

.booklet-notes li.clue-missing {
  color: #78716c;
  font-style: italic;
}

.booklet-notes li.clue-missing::before {
  content: "○";
  color: #a8a29e;
}

.booklet-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
}

.booklet-tab {
  background: #1a2d2b;
  color: #cbd5e1;
  border: 1px solid var(--border-retro);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.booklet-tab:hover {
  border-color: var(--border-gold);
}

.booklet-tab.active {
  background: #fdf6e3;
  color: #451a03;
  border-color: var(--border-gold);
  font-weight: 800;
}

.booklet-tab.solved {
  border-color: #4ade80;
}

/* Save Modal */
.save-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.save-summary {
  background: rgba(11, 22, 24, 0.75);
  border: 1px solid var(--border-retro);
  border-radius: 10px;
  padding: 11px 13px;
  font-size: 0.88rem;
  line-height: 1.55;
}

.save-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.save-code-group label {
  display: block;
  font-size: 0.84rem;
  margin-bottom: 6px;
  color: #cbd5e1;
}

.save-code-row {
  display: flex;
  gap: 8px;
}

.save-code-row input {
  flex: 1;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border-retro);
  background: #0a141b;
  color: #f8fafc;
  font-family: var(--font-pixel);
  font-size: 0.82rem;
}

.save-divider {
  border: none;
  border-top: 1px solid var(--border-retro);
  margin: 4px 0;
}

.danger-zone {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.84rem;
  color: #cbd5e1;
}

/* Help & Victory */
.help-steps {
  margin: 0 0 14px;
  padding-left: 20px;
  line-height: 1.55;
  font-size: 0.9rem;
}

.help-steps li {
  margin-bottom: 8px;
}

.help-shortcuts {
  background: rgba(11, 22, 24, 0.75);
  border: 1px solid var(--border-retro);
  border-radius: 10px;
  padding: 11px 14px;
}

.help-shortcuts h3 {
  margin: 0 0 8px;
  font-size: 0.92rem;
  color: var(--accent);
}

.help-shortcuts ul {
  margin: 0;
  padding-left: 18px;
  font-size: 0.86rem;
  line-height: 1.65;
}

.victory-body {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.victory-trophy {
  font-size: 3.2rem;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(250, 204, 21, 0.65);
}

@media (max-width: 680px) {
  body {
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) 0;
    align-items: stretch;
  }

  .app-shell {
    max-width: none;
    min-height: 100dvh;
    gap: 6px;
    padding: 6px;
  }

  .top-bar {
    padding: 4px 8px;
    border-radius: 9px;
    gap: 4px;
  }

  .brand {
    gap: 6px;
  }

  .brand-badge {
    width: 24px;
    height: 24px;
    font-size: 13px;
    border-radius: 6px;
  }

  .brand h1 {
    font-size: 0.86rem;
    letter-spacing: 0.3px;
  }

  .subtitle,
  .btn-tool kbd {
    display: none;
  }

  .top-actions {
    gap: 4px;
  }

  .btn-tool {
    padding: 4px 7px;
    font-size: 0.72rem;
    gap: 3px;
    border-radius: 7px;
  }

  .console-frame {
    flex: 1;
    border-radius: 14px;
    padding: 6px;
    gap: 6px;
    justify-content: space-between;
  }

  .hud-bar {
    padding: 4px 8px;
    gap: 4px;
  }

  .hud-zone {
    gap: 6px;
  }

  .hud-zone-name {
    font-size: 0.8rem;
  }

  .level-badge {
    font-size: 0.66rem;
    padding: 1px 6px;
  }

  .hud-stats {
    gap: 4px;
  }

  .hud-pill,
  .hud-status-dot {
    font-size: 0.7rem;
    padding: 2px 6px;
  }

  .zone-banner {
    padding: 4px 10px;
    top: 6px;
  }

  .zone-banner strong {
    font-size: 0.78rem;
  }

  .zone-banner span {
    font-size: 0.66rem;
  }

  .map-card-title {
    font-size: 0.8rem;
  }

  .screen-bezel {
    padding: 6px;
    border-radius: 10px;
  }

  .bezel-led {
    display: none;
  }

  .controls-area {
    padding: 8px 10px 6px;
    margin-top: auto;
  }

  .touch-dpad {
    grid-template-columns: repeat(3, 46px);
    grid-template-rows: repeat(3, 46px);
    gap: 3px;
  }

  .gb-round-btn {
    width: 62px;
    height: 62px;
  }

  .problem-layout,
  .notebook-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  dialog {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 12px;
  }

  .dialog-header {
    padding: 10px 12px;
  }

  .dialog-header h2 {
    font-size: 1rem;
  }

  .dialog-body {
    padding: 12px;
  }

  .btn-fairy {
    max-width: 100%;
    white-space: normal;
    text-align: center;
    font-size: 0.8rem;
    padding: 7px 12px;
  }

  .answer-row {
    flex-wrap: wrap;
  }

  .answer-row input {
    min-width: 90px;
    padding: 8px 10px;
    font-size: 0.95rem;
  }

  .answer-row .btn-primary {
    padding: 8px 12px;
  }

  .world-map-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
  }

  .map-ocean-cell {
    display: none;
  }

  .map-card {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .map-here-pin {
    font-size: 0.56rem;
    padding: 1px 4px;
  }

  .controls-legend {
    display: none;
  }
}

/* Mobile landscape: handheld console layout (D-pad left, Screen center, A/B right) */
@media (max-height: 520px) and (orientation: landscape) {
  body {
    padding: 4px env(safe-area-inset-right) 4px env(safe-area-inset-left);
  }

  .app-shell {
    max-width: none;
    height: 100dvh;
    gap: 4px;
  }

  .top-bar {
    padding: 4px 10px;
  }

  .subtitle,
  .bezel-led,
  .controls-legend {
    display: none;
  }

  .console-frame {
    flex: 1;
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto 1fr;
    align-items: center;
    padding: 6px 10px;
    gap: 6px 12px;
    border-radius: 14px;
  }

  .hud-bar {
    grid-column: 1 / -1;
    padding: 4px 10px;
  }

  .screen-bezel {
    grid-column: 2;
    grid-row: 2;
    padding: 5px;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .screen-container {
    height: 100%;
    width: auto;
    max-width: 100%;
  }

  .controls-area {
    display: contents;
  }

  .touch-dpad {
    grid-column: 1;
    grid-row: 2;
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
  }

  .touch-ab {
    grid-column: 3;
    grid-row: 2;
    flex-direction: column;
    gap: 10px;
  }

  .gb-round-btn.btn-b {
    margin-top: 0;
  }
}
