/* =====================================================================
   Cogs — styles
   Mobile-first. Pixel-art images use image-rendering: pixelated.
   Image-based pieces (page tile, 9-slice panels/buttons) are injected as
   CSS variables by game.js from the asset manifest (or placeholders).
   ===================================================================== */

:root {
  --navy-deep: #0a0f1c;
  --navy: #111a2e;
  --navy-light: #1c2842;
  --brass: #c08a2e;
  --brass-light: #f0c45a;
  --glow: #ffd86b;
  --wrong: #e0483c;
  --select: #6be3ff;
  --text: #f7ecd0;
  --text-dim: #a9a08a;
  --outline: #1a0f08;
  /* Theme banner color (set from the theme palette in the manifest). */
  --theme-accent: #f0c45a;
  /* Card plaques and dialog fill (each skin sets its own, see js/skins/). */
  --plaque-bg: #0e1526;
  --plaque-sel: #12304a;

  /* Set at runtime from the loaded pixel font (falls back to monospace). */
  --font-pixel: ui-monospace, 'SF Mono', Menlo, Consolas, 'Courier New', monospace;
  /* Set at runtime: data URLs of the page tile and 9-slice frames. */
  --page-bg: none;
  --page-bg-size: 64px;
  --panel-img: none;
  --button-img: none;
  --button-pressed-img: none;

  /* Set at runtime from the ring scale. */
  --art-px: 2px;
  --label-size: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background-color: var(--navy-deep);
  color: var(--text);
}

body {
  font-family: var(--font-pixel);
  background-image: var(--page-bg);
  background-size: var(--page-bg-size);
  background-repeat: repeat;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }
/* Chrome prefers 'pixelated'; keep it last so it wins where supported. */
img, canvas { image-rendering: pixelated; }

button { font-family: inherit; }

[hidden] { display: none !important; }

/* ---------- Loading screen ---------- */

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--navy-deep);
  z-index: 100;
  transition: opacity 0.3s steps(3);
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-title {
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 2px;
  color: var(--brass-light);
  text-shadow: 2px 2px 0 var(--outline);
}
.loading-bar {
  width: 168px;
  height: 16px;
  padding: 2px;
  border: 2px solid var(--brass);
  box-shadow: 0 0 0 2px var(--outline);
  background: var(--navy);
}
.loading-fill {
  height: 100%;
  width: 0;
  /* Chunky 8px blocks so the bar reads as pixel art. */
  background: repeating-linear-gradient(90deg, var(--glow) 0 6px, transparent 6px 8px);
}
.loading-text { font-size: 12px; color: var(--text-dim); letter-spacing: 1px; }

/* ---------- App shell ---------- */

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 8px;
}
.title {
  margin: 0;
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--brass-light);
  text-shadow: 2px 2px 0 var(--outline);
}
.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  background: var(--navy-light);
  border: 6px solid var(--brass);
  border-image: var(--button-img) 3 fill / 6px stretch;
  cursor: pointer;
}
.icon-btn:active { border-image-source: var(--button-pressed-img); }
.icon-btn img { width: 16px; height: 16px; }
.icon-btn:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
.icon-btn-text { color: var(--brass-light); font: bold 18px/1 var(--font-pixel); }

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- Banner ---------- */

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 4px 10px;
  margin: 2px 0 8px;
  text-align: center;
}
.banner-theme {
  font-size: 11px;
  padding: 3px 6px;
  color: var(--navy-deep);
  background: var(--theme-accent);
  box-shadow: 2px 2px 0 var(--outline);
  letter-spacing: 1px;
  text-transform: uppercase;
}
.banner-title { font-size: 14px; font-weight: bold; color: var(--text); letter-spacing: 1px; }
.banner-meta { font-size: 11px; color: var(--text-dim); letter-spacing: 1px; }

/* ---------- Ring ---------- */

.ring-area {
  width: 100%;
  display: flex;
  justify-content: center;
}
.ring-wrap {
  position: relative;
  line-height: 0;
}
.ring-canvas { display: block; }
.ring-cards { position: absolute; inset: 0; }

/* One button per slot, centered on its gear. Size is set from JS. */
.card {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: grab;
  touch-action: none; /* let us handle drags instead of scrolling */
  line-height: 1;
}
.card.empty { cursor: pointer; }
.card:disabled { cursor: default; }
.card:focus { outline: none; }
.card:focus-visible .plaque { outline: 2px solid var(--select); outline-offset: 2px; }

/* Word plaque that sits on top of each gear. */
.plaque {
  display: block;
  white-space: nowrap;
  font-size: var(--label-size);
  font-weight: bold;
  letter-spacing: 0.5px;
  color: var(--text);
  background: var(--plaque-bg);
  border: var(--art-px) solid var(--brass);
  border-image: var(--panel-img) 3 fill / calc(var(--art-px) * 2) stretch;
  padding: calc(var(--art-px) * 2) calc(var(--art-px) * 2.5);
  /* 1px pixel outline for contrast over the gear art. */
  text-shadow:
    1px 0 0 var(--outline), -1px 0 0 var(--outline),
    0 1px 0 var(--outline), 0 -1px 0 var(--outline);
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
.card.empty .plaque {
  color: var(--text-dim);
  border: var(--art-px) dashed var(--text-dim);
  border-image: none;
  background: var(--plaque-bg);
  opacity: 0.9;
}
.card.player .plaque, .card-ghost.player .plaque { color: var(--select); }
.card.selected .plaque { background: var(--plaque-sel); }
.card.drop-target .plaque { background: var(--plaque-sel); }
.card.dragging .plaque { opacity: 0.25; }

.card-ghost {
  position: absolute;
  z-index: 5;
  transform: translate(-50%, -50%);
  pointer-events: none;
  line-height: 1;
}

/* ---------- Controls ---------- */

.controls {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  margin-top: 8px;
}

.word-form { display: flex; gap: 8px; }
.word-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 16px; /* >=16px stops iOS zooming on focus */
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  background: var(--plaque-bg);
  border: 6px solid var(--brass);
  border-image: var(--panel-img) 3 fill / 6px stretch;
  border-radius: 0;
  outline: none;
}
.word-input::placeholder { color: #6f6a5c; }
.word-input:focus-visible { box-shadow: 0 0 0 2px var(--select); }

.word-status {
  font-size: 13px;
  text-align: center;
  color: var(--text-dim);
  letter-spacing: 1px;
}
.word-status strong { color: var(--select); }

.link-btn {
  background: none;
  border: 0;
  padding: 4px;
  color: var(--brass-light);
  text-decoration: underline;
  font-size: 12px;
  cursor: pointer;
}

.message {
  min-height: 1.5em;
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
  color: var(--text);
}
.message.bad { color: #ff9a80; }
.message.good { color: var(--glow); }

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

.btn {
  min-height: 44px;
  min-width: 88px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--text);
  background: var(--navy-light);
  border: 6px solid var(--brass);
  border-image: var(--button-img) 3 fill / 6px stretch;
  cursor: pointer;
  text-shadow: 1px 1px 0 var(--outline);
}
.btn:active:not(:disabled) { border-image-source: var(--button-pressed-img); }
.btn:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { color: var(--glow); flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn-primary img { width: 16px; height: 16px; }

.help {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}

.attempts {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
}
.attempts .pip {
  width: 12px;
  height: 12px;
  background: var(--brass-light);
  box-shadow: 0 0 0 2px var(--outline), inset -2px -2px 0 var(--brass);
}
.attempts .pip.used { background: var(--navy-light); box-shadow: 0 0 0 2px var(--outline), inset 2px 2px 0 #0b1120; }
/* A try spent on a hint: dark like a used pip, with a lit centre (the bulb). */
.attempts .pip.used.hint {
  background: var(--navy-light) linear-gradient(var(--select), var(--select)) center / 4px 4px no-repeat;
}
/* A try spent on a wrong missing word: same, with a red centre. */
.attempts .pip.used.word {
  background: var(--navy-light) linear-gradient(var(--wrong), var(--wrong)) center / 4px 4px no-repeat;
}

.btn-hint { display: inline-flex; align-items: center; gap: 6px; }
.btn-hint img { width: 16px; height: 16px; }
.btn-hint .cost { color: #ff9a80; font-size: 11px; }

.hint-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.hint-list:empty { display: none; }
.hint-list li {
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 8px;
  color: var(--glow);
  background: rgba(14, 21, 38, 0.9);
  border-left: 4px solid var(--brass);
}
.hint-note {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--text-dim);
  text-align: center;
}

/* ---------- Dialogs ---------- */

.panel-dialog {
  max-width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 16px;
  color: var(--text);
  background: var(--plaque-bg);
  border: 6px solid var(--brass);
  border-image: var(--panel-img) 3 fill / 6px stretch;
  font-family: var(--font-pixel);
}
.panel-dialog::backdrop { background: rgba(5, 8, 16, 0.75); }
.panel-dialog h2 { margin: 0 0 12px; font-size: 16px; color: var(--brass-light); letter-spacing: 2px; }
.panel-dialog form { margin-top: 12px; text-align: right; }
.credits-text {
  margin: 0;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 55vh;
  overflow: auto;
}

.results-dialog { width: min(520px, calc(100vw - 32px)); overflow: auto; position: relative; }
.results-dialog h2 { padding-right: 36px; }
.results-dialog h3 { margin: 14px 0 6px; font-size: 12px; color: var(--brass-light); letter-spacing: 2px; }

/* Small ✕ close in the corner (saves a full row on phones). */
.panel-dialog form.dialog-x { position: absolute; top: 10px; right: 10px; margin: 0; }
.dialog-x button {
  width: 32px;
  height: 32px;
  padding: 0;
  font: bold 16px/1 var(--font-pixel);
  color: var(--brass-light);
  background: var(--navy-light);
  border: 0;
  box-shadow: 0 0 0 2px var(--brass);
  cursor: pointer;
}
.dialog-x button:focus-visible { outline: 2px solid var(--select); outline-offset: 2px; }

.solution-details summary {
  cursor: pointer;
  font-size: 11px;
  color: var(--text-dim);
  text-decoration: underline;
  margin-bottom: 4px;
}
.solution-details[open] summary { margin-bottom: 6px; }
.results-dialog section { margin: 0; }
.results-dialog .actions { margin-top: 12px; }
.results-sub { margin: 0; font-size: 13px; color: var(--text); }
.small { margin: 6px 0 0; font-size: 11px; line-height: 1.5; color: var(--text-dim); }


.solution-chain { margin: 0 0 6px; font-size: 12px; font-weight: bold; color: var(--glow); line-height: 1.6; }
.solution-list { margin: 0; padding-left: 20px; font-size: 12px; line-height: 1.5; }
.solution-list li { margin-bottom: 4px; }
.solution-list strong { color: var(--text); }
.fun-fact { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--text); }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat { text-align: center; padding: 6px 2px; background: var(--navy); box-shadow: inset 0 0 0 2px var(--navy-light); }
.stat-value { font-size: 16px; font-weight: bold; color: var(--glow); }
.stat-label { font-size: 10px; color: var(--text-dim); margin-top: 2px; }
.stats-dist { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.dist-row { display: flex; align-items: center; gap: 6px; font-size: 10px; line-height: 1.2; }
.dist-key { width: 12px; text-align: right; color: var(--text-dim); }
.dist-bar { background: var(--brass); color: var(--navy-deep); font-weight: bold; text-align: right; padding: 1px 4px; min-width: 18px; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Footer ---------- */

.footer {
  padding: 12px 0 16px;
  text-align: center;
  font-size: 11px;
}
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--brass-light); }
.footer .copyright,
.footer .privacy { margin: 6px 0 0; color: var(--text-dim); font-size: 10px; }

.noscript { padding: 16px; text-align: center; }

/* ---------- How to play ---------- */

.tutorial-dialog { width: min(420px, calc(100vw - 32px)); position: relative; }
.tutorial-step p { margin: 0 0 10px; font-size: 12px; line-height: 1.6; }
.tutorial-step strong { color: var(--glow); font-weight: normal; }
.tutorial-step-count { position: absolute; top: 16px; right: 16px; margin: 0; font-size: 10px; color: var(--text-dim); }
.tut-example { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 0; margin: 14px 0 6px; }
.tut-card {
  display: inline-block;
  padding: 4px 8px;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text);
  background: var(--navy-light);
  box-shadow: 0 0 0 2px var(--brass);
}
.tut-card.tut-empty { color: var(--select); box-shadow: 0 0 0 2px var(--select); padding: 0 6px; }
.tut-link { display: inline-block; width: 18px; height: 4px; }
.tut-link.ok { background: var(--glow); }
.tut-link.bad { background: var(--wrong); }
.tut-link.dead { background: #f0901e; }
.tut-key { display: inline-block; width: 8px; height: 8px; margin: 0 2px 0 6px; vertical-align: middle; }
.tut-key.ok { background: var(--glow); }
.tut-key.dead { background: #f0901e; }
.tut-key.bad { background: var(--wrong); }
.tut-caption { text-align: center; font-size: 10px !important; color: var(--text-dim); }
.tutorial-nav { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.tutorial-nav .btn-primary { flex: 0 0 auto; margin-left: auto; }
.tutorial-dots { display: flex; gap: 6px; flex: 1; justify-content: center; }
.tut-dot { width: 6px; height: 6px; background: var(--navy-light); box-shadow: 0 0 0 1px var(--outline); }
.tut-dot.on { background: var(--brass-light); }
.tutorial-skip {
  display: block;
  margin: 10px auto 0;
  padding: 4px 8px;
  background: none;
  border: 0;
  color: var(--text-dim);
  font: 10px var(--font-pixel);
  text-decoration: underline;
  cursor: pointer;
}
.tutorial-skip:hover { color: var(--brass-light); }

/* ---------- More puzzles ---------- */

.footer #more-puzzles-link { margin-right: 14px; }
.puzzles-dialog { width: min(440px, calc(100vw - 32px)); }
.puzzles-list { position: relative; list-style: none; margin: 8px 0 0; padding: 0 2px; max-height: 55vh; overflow: auto; }
.puzzles-list li + li { margin-top: 6px; }
.puzzle-day {
  padding: 8px 10px;
  background: var(--navy-light);
  box-shadow: 0 0 0 2px var(--outline);
}
.puzzle-day.current { box-shadow: 0 0 0 2px var(--select); }
.puzzle-row-top { display: flex; gap: 8px; align-items: baseline; font-size: 11px; color: var(--text); text-decoration: none; }
.puzzle-num { color: var(--brass-light); min-width: 28px; }
.puzzle-date { color: var(--text-dim); }
.puzzle-tag { color: var(--select); font-size: 10px; }
.puzzle-levels { display: flex; gap: 6px; margin-top: 6px; }
.puzzle-level {
  flex: 1;
  padding: 4px 0;
  text-align: center;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--navy);
  box-shadow: 0 0 0 1px var(--navy-line, #26355a);
}
.puzzle-level:hover, .puzzle-level:focus-visible { color: var(--text); box-shadow: 0 0 0 1px var(--brass); outline: none; }
.puzzle-level.status-solved { color: var(--glow); }
.puzzle-level.status-failed { color: var(--wrong); }
.puzzle-level.status-started { color: var(--select); }
.banner-practice { color: var(--select); }

/* ---------- Level tabs (three puzzles a day) ---------- */

.level-tabs { display: flex; gap: 6px; justify-content: center; width: 100%; margin-bottom: 6px; }
.level-tab {
  flex: 0 1 96px;
  padding: 5px 0;
  text-align: center;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-decoration: none;
  background: var(--navy);
  box-shadow: 0 0 0 2px var(--navy-light);
}
.level-tab:hover, .level-tab:focus-visible { color: var(--text); box-shadow: 0 0 0 2px var(--brass); outline: none; }
.level-tab.current { color: var(--glow); box-shadow: 0 0 0 2px var(--brass-light); background: var(--navy-light); }
.level-tab.status-solved .level-mark { color: var(--glow); }
.level-tab.status-failed .level-mark { color: var(--wrong); }
.level-tab.status-started .level-mark { color: var(--select); }

/* "Next: MEDIUM" sits on its own full-width row above Share. */
.results-dialog .actions { flex-wrap: wrap; }
.btn-next { flex-basis: 100%; order: -1; text-decoration: none; }

/* ---------- Feedback ---------- */

.rating-row { display: flex; gap: 6px; }
.rating-btn {
  flex: 1;
  padding: 7px 2px;
  font: 11px var(--font-pixel);
  letter-spacing: 1px;
  color: var(--text);
  background: var(--navy);
  border: 0;
  box-shadow: 0 0 0 2px var(--navy-light);
  cursor: pointer;
}
.rating-btn:hover:not(:disabled), .rating-btn:focus-visible { box-shadow: 0 0 0 2px var(--brass); outline: none; }
.rating-btn:disabled { cursor: default; opacity: 0.55; }
.rating-btn.chosen { opacity: 1; color: var(--glow); box-shadow: 0 0 0 2px var(--brass-light); background: var(--navy-light); }
.feedback-more { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.feedback-text {
  width: 100%;
  box-sizing: border-box;
  padding: 8px;
  font: 12px/1.4 var(--font-pixel);
  color: var(--text);
  background: var(--navy);
  border: 0;
  box-shadow: inset 0 0 0 2px var(--navy-light);
  resize: vertical;
}
.feedback-text:focus { outline: 2px solid var(--select); outline-offset: 0; }
.feedback-dialog { width: min(440px, calc(100vw - 32px)); position: relative; }
.feedback-dialog h2 { padding-right: 36px; }
.feedback-dialog .feedback-text { margin-top: 10px; }
.footer #feedback-link { margin-right: 14px; }


/* ---------- Theme picker ---------- */

.skins-dialog { width: min(420px, calc(100vw - 32px)); }
.skins-note { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); }
.skins-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.skin-option {
  width: 100%;
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px;
  color: var(--text);
  text-align: left;
  background: var(--navy-light);
  border: 0;
  box-shadow: 0 0 0 2px var(--outline);
  cursor: pointer;
}
.skin-option:hover, .skin-option:focus-visible { box-shadow: 0 0 0 2px var(--brass-light); outline: none; }
.skin-option.in-use { box-shadow: 0 0 0 2px var(--glow); }
.skin-option:disabled { opacity: 0.5; cursor: default; }
/* 48x40 art pixels shown at exactly 2x. */
.skin-art { width: 96px; height: 80px; image-rendering: pixelated; box-shadow: 0 0 0 2px var(--outline); }
.skin-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.skin-name { font-size: 14px; font-weight: bold; letter-spacing: 1px; color: var(--brass-light); }
.skin-tagline { font-size: 11px; color: var(--text-dim); line-height: 1.4; }
.skin-tag {
  font-size: 10px;
  padding: 3px 5px;
  letter-spacing: 1px;
  color: var(--navy-deep);
  background: var(--text-dim);
}
.skin-option.in-use .skin-tag { background: var(--glow); }
@media (max-width: 400px) {
  .skin-option { grid-template-columns: 96px 1fr; }
  .skin-tag { grid-column: 2; justify-self: start; }
}

/* ---------- Menu ---------- */

.topbar-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.menu-dialog {
  /* A panel that slides in from the left edge. */
  position: fixed;
  inset: 0 auto 0 0;
  width: min(300px, 86vw);
  height: 100%;
  max-height: none;
  margin: 0;
  /* Smooth slide (the panel is UI, not pixel art, so it doesn't need stepped motion). */
  animation: menu-in 0.16s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.menu-dialog::backdrop { animation: menu-fade 0.16s ease-out; }
@keyframes menu-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes menu-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .menu-dialog, .menu-dialog::backdrop { animation: none; } }
.menu-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 10px;
  font: bold 13px/1 var(--font-pixel);
  letter-spacing: 1px;
  color: var(--text);
  text-align: left;
  background: var(--navy-light);
  border: 0;
  box-shadow: 0 0 0 2px var(--outline);
  cursor: pointer;
}
.menu-item img { width: 16px; height: 16px; image-rendering: pixelated; }
.menu-glyph { width: 16px; text-align: center; color: var(--brass-light); font-size: 15px; }
.menu-item:hover, .menu-item:focus-visible { box-shadow: 0 0 0 2px var(--brass-light); outline: none; color: var(--brass-light); }
.menu-note { margin-left: auto; font-size: 10px; color: var(--text-dim); font-weight: normal; }
.menu-foot { margin: 16px 0 0; font-size: 10px; color: var(--text-dim); }

/* Phones: the top bar keeps menu, title, help and sound; the rest live in the menu. */
@media (max-width: 599px) {
  .desktop-only { display: none; }
}

/* ---------- Desktop: scene on the left, puzzle panel on the right ---------- */

@media (min-width: 900px) and (min-height: 560px) {
  .app { max-width: 1180px; padding: 0 32px; }
  .topbar { padding: 16px 0 12px; border-bottom: 2px solid var(--navy-line, #26355a); margin-bottom: 16px; }
  .title { font-size: 26px; letter-spacing: 3px; }
  .main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "ring banner"
      "ring controls";
    column-gap: 40px;
    align-items: start;
  }
  .ring-area { grid-area: ring; align-self: center; }
  .banner {
    grid-area: banner;
    justify-content: flex-start;
    text-align: left;
    padding: 14px 16px;
    margin: 0;
    background: var(--plaque-bg);
    border: 6px solid var(--brass);
    border-image: var(--panel-img) 3 fill / 6px stretch;
  }
  .banner .level-tabs { width: 100%; justify-content: flex-start; }
  .banner-title { font-size: 18px; }
  .controls {
    grid-area: controls;
    max-width: none;
    margin-top: 16px;
    padding: 16px;
    background: var(--plaque-bg);
    border: 6px solid var(--brass);
    border-image: var(--panel-img) 3 fill / 6px stretch;
  }
  .message { min-height: 3em; }
  .help { text-align: left; }
  .footer { text-align: left; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 0; margin-top: 16px; border-top: 2px solid var(--navy-line, #26355a); }
  .footer .privacy { margin-left: auto; }
  .footer .copyright { width: 100%; }
  /* Hover feedback is a desktop thing. */
  .btn:hover:not(:disabled), .icon-btn:hover { filter: brightness(1.15); }
}
