@charset "UTF-8";
@font-face {
  font-family: "SimKai Hanzi";
  src: url("assets/fonts/simkai-hanzi.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+3000-303F, U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF;
}

:root {
  color-scheme: dark;
  --ink: #173945;
  --cream: #f9efde;
  --teal: #073f46;
  --accent: #e9a15d;
  --muted: #afccca;
  --green: #256f57;
  --terracotta: #b7634b;
  --hanzi-ink: #c5383b;
  --pinyin-ink: #007116;
  --spanish-ink: #185dba;
  --font-hanzi: "SimKai Hanzi", "STKaiti", "KaiTi", "Noto Serif CJK SC", serif;
  --font-ui: "SimKai Hanzi", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-family: var(--font-ui);
  background: var(--teal);
  color: var(--cream);
}

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

body {
  margin: 0;
  background: radial-gradient(ellipse at 10% 70%, #0c5458 0, transparent 65%), var(--teal);
  min-height: 100vh;
  overflow-x: hidden;
}

button,
select {
  font: inherit;
  cursor: pointer;
}

button:focus-visible,
select:focus-visible {
  outline: 3px solid #ffbd70;
  outline-offset: 3px;
}

button:disabled {
  cursor: default;
}

main {
  max-width: 1440px;
  margin: auto;
  padding: 24px 32px 18px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.eyebrow {
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--muted);
  margin: 0 0 6px;
}

h1 {
  font-size: clamp(24px, 3vw, 40px);
  line-height: 1.1;
  letter-spacing: -1.2px;
  margin: 0;
  font-weight: 750;
}

.title-dot {
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
}

.score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid #5a7976;
  border-radius: 40px;
  padding: 8px 18px;
  min-width: 88px;
}

.score span {
  font-size: 22px;
}

.score strong {
  font-size: 21px;
}

.sound-button {
  background: none;
  color: var(--muted);
  border: none;
  font-size: 12px;
  padding: 10px 0;
}

/* Top Clue / Control Panel (matches character-detective & weather-slots) */
.clue-panel {
  background: var(--cream);
  color: var(--ink);
  border-radius: 12px;
  border-top: 4px solid var(--accent);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 132px;
  box-shadow: 0 6px 24px #00272c18;
}

.stamp {
  border: 2px solid var(--terracotta);
  color: var(--terracotta);
  transform: rotate(-9deg);
  font-family: "SimKai Hanzi", serif;
  font-weight: 500;
  font-synthesis: none;
  -webkit-text-stroke: 0.22px currentColor;
  font-size: 38px;
  line-height: 1;
  padding: 8px;
  flex-shrink: 0;
}

.clue-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clue-label {
  font-family: var(--font-hanzi);
  font-size: clamp(16px, 1.6vw, 21px);
  letter-spacing: 1px;
  font-weight: 500;
  font-synthesis: none;
  -webkit-text-stroke: 0.2px currentColor;
  margin: 0;
  color: #79776c;
}

.clue-label span {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 11px;
  letter-spacing: 1.4px;
  -webkit-text-stroke: 0;
  margin-left: 12px;
  color: #aaa08c;
}

/* Unit & Lesson Dropdown Bar inside .clue-copy */
.filter-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.select-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f2e5ce;
  border: 1px solid #c4b6a0;
  border-radius: 8px;
  padding: 5px 12px;
}

.select-field label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #785020;
  white-space: nowrap;
}

.select-field select {
  width: 100%;
  min-height: 28px;
  background: transparent;
  color: var(--ink);
  border: 0;
  font-size: 14px;
  font-weight: 700;
  outline: none;
}

.select-field select option {
  background: var(--cream);
  color: var(--ink);
}

/* Learning & Feedback Bar inside .clue-copy */
.mj-learn {
  min-height: 48px;
  padding: 8px 14px;
  border-radius: 8px;
  background: #f3e7d2;
  border: 1px solid #d5c7b0;
  color: var(--ink);
  display: flex;
  align-items: center;
  font-size: 14.5px;
}

.mj-learn p {
  margin: 0;
}

.mj-learn--warn {
  color: #8f2419;
  border-color: #df826a;
  background: #fbe4dc;
}

.mj-learn--info {
  color: var(--ink);
  border-color: #8bc6a1;
  background: #e7f4ec;
}

.mj-pair-display {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.mj-pair-copy {
  color: var(--ink);
  font-size: 15.5px;
}

.mj-pair-copy strong {
  font-family: var(--font-hanzi);
  color: var(--hanzi-ink);
  font-size: 23px;
  font-weight: 500;
  font-synthesis: none;
  -webkit-text-stroke: 0.22px currentColor;
}

.mj-pair-copy em {
  color: var(--green);
  font-style: normal;
  font-weight: 600;
}

.debug-answers {
  margin: 4px 0 0;
  color: #785020;
  font-size: 13px;
  font-weight: 700;
}

/* Right-side Clue Tools */
.clue-tools {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex-shrink: 0;
}

.clue-tools button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  color: var(--ink);
  background: transparent;
  border: 1px solid #c4b6a0;
  border-radius: 7px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 650;
  min-width: 112px;
  transition: background 0.15s;
}

.clue-tools button:hover:not(:disabled) {
  background: #efe3cd;
}

.clue-tools button:disabled {
  opacity: 0.45;
}

.clue-tools button[aria-pressed="true"] {
  background: #efe3cd;
  border-color: #927d5e;
}

.clue-tools button span {
  color: #927d5e;
}

/* Round Meta & Pair Counter */
.round-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0 12px;
  font-size: 12px;
}

.round-meta p {
  margin: 0;
  color: #e6eeea;
}

.mj-score {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mj-score-label {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.3px;
}

.mj-score strong {
  font-variant-numeric: tabular-nums;
  color: var(--cream);
  font-size: 14px;
  font-weight: 800;
}

.mj-progress {
  width: 110px;
  height: 6px;
  background: #0d4b52;
  border: 1px solid #49767a;
  border-radius: 6px;
  overflow: hidden;
}

.mj-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* Mahjong Table Stage (matches .slot-column surface in weather-slots) */
.table-stage {
  container-type: inline-size;
  background: #0d4b52;
  border: 2px solid #49767a;
  border-radius: 16px;
  padding: clamp(14px, 2.5vw, 26px);
  box-shadow: 0 8px 28px #00272c28;
}

.mj-board {
  --cols: 6;
  --rows: 3;
  --tw: min(132px, calc((100cqw - 20px) / (var(--cols) + 0.25)));
  --th: calc(var(--tw) * 0.58 - 2px);
  --td: calc(var(--tw) * 0.088);
  --row: var(--th);
  --lift-x: calc(var(--td) * -1);
  --lift-y: calc(var(--td) * -1);
  position: relative;
  width: calc(var(--tw) * var(--cols) + var(--td));
  height: calc(var(--row) * var(--rows) + var(--td));
  margin: calc(var(--td) * 2.4) auto calc(var(--td) * 0.8);
}

/* Wide Mahjong Tile Component matching mahjongchest.com (tile.svg + tile_shadow.png) */
.mj-tile,
.mini-tile {
  --r: calc(var(--tw) * 0.075);
  --face-bg: #f7f6f2;
  --bevel-mid: rgba(165, 164, 158, 0.18);
  --bevel-edge: rgba(125, 124, 119, 0.42);
  --bevel-inset: rgba(132, 131, 126, 0.34);
  --seam-color: #87a07d;
  --ink: var(--hanzi-ink);
  --fs: 0.32;
  font-family: var(--font-hanzi);
  user-select: none;
  -webkit-user-select: none;
  line-height: 1;
}

.mj-tile {
  position: absolute;
  left: calc(var(--tw) * var(--x));
  top: calc(var(--row) * var(--y));
  width: var(--tw);
  height: calc(var(--th) + var(--td));
  padding: 0;
  border: 0;
  background: transparent;
  transform: translate(calc(var(--lift-x) * var(--z)), calc(var(--lift-y) * var(--z)));
  transition: transform 0.15s ease, filter 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mj-tile--pinyin,
.mini-tile--pinyin {
  --ink: var(--pinyin-ink);
  font-family: var(--font-ui);
}

.mj-tile--spanish,
.mini-tile--spanish {
  --face-bg: #c2f7ba;
  --bevel-mid: rgba(108, 158, 100, 0.2);
  --bevel-edge: rgba(74, 122, 68, 0.44);
  --bevel-inset: rgba(78, 126, 72, 0.36);
  --seam-color: #6b9662;
  --ink: var(--spanish-ink);
  font-family: var(--font-ui);
}

/* Omnidirectional shadow container + 45-degree 3D green extrusion */
.tile__slab {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--tw);
  height: var(--th);
  border-radius: var(--r);
  pointer-events: none;
  box-shadow:
    -4px -4px 9px -1px rgba(0, 0, 0, 0.35),
    calc(var(--td) + 4px) calc(var(--td) + 5px) 9px 0 rgba(0, 18, 20, 0.44);
}

.mj-tile--z1 .tile__slab {
  box-shadow:
    -4px -4px 9px -1px rgba(0, 0, 0, 0.38),
    calc(var(--td) + 6px) calc(var(--td) + 7px) 12px 1px rgba(0, 14, 16, 0.52);
}

.mj-tile--z2 .tile__slab {
  box-shadow:
    -4px -4px 9px -1px rgba(0, 0, 0, 0.4),
    calc(var(--td) + 8px) calc(var(--td) + 9px) 15px 2px rgba(0, 12, 14, 0.58);
}

.tile__slab::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: calc(var(--tw) + var(--td));
  height: calc(var(--th) + var(--td));
  border-radius: var(--r);
  background: conic-gradient(
    from 0deg at calc(100% - var(--td) - var(--r) * 0.5) calc(100% - var(--td) - var(--r) * 0.5),
    #35662b 0deg,
    #3a702f 55deg,
    #3f7933 115deg,
    #3c7331 130deg,
    #274b1f 146deg,
    #24461d 175deg,
    #23431b 265deg,
    #35662b 360deg
  );
  box-shadow:
    inset -1px -1px 1px rgba(28, 54, 22, 0.9),
    inset -2px -2px 2px rgba(33, 62, 25, 0.55);
  clip-path: polygon(
    calc(var(--tw) - var(--r) * 0.28) calc(var(--r) * 0.28),
    calc(100% - var(--r) * 0.22) calc(var(--td) + var(--r) * 0.22),
    100% calc(var(--td) + var(--r) * 0.65),
    100% 100%,
    calc(var(--td) + var(--r) * 0.65) 100%,
    calc(var(--td) + var(--r) * 0.22) calc(100% - var(--r) * 0.22),
    calc(var(--r) * 0.28) calc(var(--th) - var(--r) * 0.28)
  );
}

.tile__face {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--tw);
  height: var(--th);
  padding: 0;
  border-radius: var(--r);
  background: var(--face-bg);
  box-shadow:
    1px 1px 0 var(--seam-color),
    1.5px 1.5px 1px rgba(38, 68, 30, 0.72);
}

.tile__inner {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--r);
  background:
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0) 89%,
      var(--bevel-mid) 95%,
      var(--bevel-edge) 100%
    ),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 85%,
      var(--bevel-mid) 93%,
      var(--bevel-edge) 100%
    ),
    var(--face-bg);
  box-shadow:
    inset 0.5px 0.5px 0 rgba(145, 148, 142, 0.35),
    inset -2px -2px 3px var(--bevel-inset);
  display: grid;
  place-items: center;
  padding: 2px 5px;
  overflow: hidden;
}

.tile__text {
  position: relative;
  color: var(--ink);
  font-size: calc(var(--tw) * var(--fs));
  font-weight: 560;
  white-space: nowrap;
  letter-spacing: 0.015em;
  text-align: center;
}

.mj-tile--hanzi .tile__text,
.mini-tile--hanzi .tile__text {
  font-family: var(--font-hanzi);
  font-weight: 500;
  font-synthesis: none;
  -webkit-text-stroke: 0.22px currentColor;
  letter-spacing: 0.04em;
}

.mj-tile--spanish .tile__text {
  white-space: normal;
  line-height: 1.1;
  font-weight: 560;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tile states */
.mj-tile.is-blocked {
  cursor: not-allowed;
}

@media (hover: hover) {
  .mj-tile.is-free:hover {
    transform: translate(calc(var(--lift-x) * var(--z)), calc(var(--lift-y) * var(--z) - var(--td) * 0.35));
    filter: brightness(1.02);
  }
}

.mj-tile:focus-visible {
  outline: none;
}

.mj-tile:focus-visible .tile__face {
  box-shadow:
    1px 1px 0 var(--seam-color),
    0 0 0 3px #ffbd70;
}

.mj-tile.is-selected {
  transform: translate(calc(var(--lift-x) * var(--z)), calc(var(--lift-y) * var(--z) - var(--td) * 0.85));
}

.mj-tile.is-selected .tile__inner::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 242, 0, 0.34);
  pointer-events: none;
}

.mj-tile.is-selected .tile__face {
  box-shadow:
    1px 1px 0 var(--seam-color),
    0 0 0 2.5px #e9a15d,
    0 0 14px 2px rgba(255, 215, 64, 0.55);
}

.mj-tile.is-hint .tile__face {
  box-shadow:
    1px 1px 0 var(--seam-color),
    0 0 0 3px #8bc6a1,
    0 0 18px 3px rgba(139, 198, 161, 0.85);
}

.mj-tile.is-shake {
  animation: 0.24s nudge ease;
}

.mini-tile {
  --tw: 62px;
  --th: calc(var(--tw) * 0.58 - 2px);
  --td: calc(var(--tw) * 0.088);
  position: relative;
  display: inline-block;
  width: calc(var(--tw) + var(--td));
  height: calc(var(--th) + var(--td));
  flex: none;
}

/* Celebration, Setup, and Footer (matches character-detective & weather-slots) */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: #073f4660;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

.celebration > div {
  background: var(--cream);
  color: var(--ink);
  padding: 30px 65px;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: 0 20px 70px #001c3570;
  animation: arrive 0.2s ease-out;
}

.celebration span {
  font-size: 65px;
}

.celebration strong {
  font-size: 25px;
}

.celebration small {
  font-family: var(--font-hanzi);
  color: #8a6b40;
  font-size: 20px;
}

.setup {
  max-width: 650px;
  margin: 45px auto 65px;
  text-align: center;
  background: #10525a;
  padding: 30px;
  border-radius: 12px;
  border: 1px solid #427277;
}

.setup p {
  color: #d2dfda;
  line-height: 1.7;
  font-size: 14px;
}

.setup-icon {
  font-family: var(--font-hanzi);
  font-size: 60px;
  color: var(--accent);
}

code {
  font-size: 12px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #9dbbb6;
  font-size: 10px;
  letter-spacing: 0.3px;
  padding-top: 18px;
}

.footer-separator {
  margin: 0 9px;
  color: #6c9691;
}

[hidden] {
  display: none !important;
}

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

@keyframes nudge {
  25% {
    transform: translate(calc(var(--lift-x) * var(--z) - 4px), calc(var(--lift-y) * var(--z)));
  }
  75% {
    transform: translate(calc(var(--lift-x) * var(--z) + 4px), calc(var(--lift-y) * var(--z)));
  }
}

@keyframes arrive {
  from {
    transform: translateY(8px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

@media (max-width: 900px) {
  main {
    padding: 16px 14px;
  }
  .masthead {
    margin-bottom: 14px;
  }
  .clue-panel {
    gap: 14px;
    padding: 14px 16px;
  }
  .stamp {
    font-size: 28px;
    padding: 6px;
  }
}

@media (max-width: 680px) {
  .stamp {
    display: none;
  }
  .clue-panel {
    align-items: stretch;
    flex-direction: column;
  }
  .filter-bar {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .clue-tools {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .clue-tools button {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }
  .round-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  footer {
    flex-direction: column;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* The table owns the available viewport; the learning dock stays in reach. */
main {
  max-width: 1600px;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto minmax(240px, 1fr) auto auto;
  gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.masthead { margin: 0; gap: 12px; }
h1 { font-size: clamp(21px, 2.4vw, 30px); }
.header-actions { gap: 12px; }
.score { height: 44px; padding: 0 12px; min-width: 72px; gap: 8px; flex-shrink: 0; line-height: 1; }
.score span { font-size: 21px; }
.score strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.sound-button { min-height: 44px; padding: 8px; }
.clue-panel {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--cream);
  box-shadow: none;
  gap: 16px;
}
.clue-label { flex: none; }
.clue-label span { margin: 0; color: var(--muted); font-size: 10px; }
.filter-bar { flex: 1; gap: 8px; }
.select-field { padding: 0 10px; background: #0d4b52; border-color: #49767a; }
.select-field label { color: var(--muted); font-size: 10px; }
.select-field select { min-height: 44px; min-width: 0; color: var(--cream); font-size: 13px; }
.round-meta { margin: 0; gap: 8px; }
.table-stage {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 240px;
  padding: 24px 14px;
  background: radial-gradient(ellipse at center, #165c60, #0d4b52 75%);
  border: 1px solid #49767a;
  box-shadow: inset 0 0 45px #00272c40, 0 4px 14px #00272c28;
}
.mj-board { --tw: min(180px, calc((100cqw - 20px) / (var(--cols) + 0.25))); }
.play-dock {
  padding: 10px;
  border-radius: 14px;
  background: var(--cream);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -4px 24px #00272c20;
}
.mj-learn { min-height: 70px; padding: 10px 12px; }
.mj-pair-display { gap: 8px; width: 100%; }
.mj-pair-copy { flex: 1; min-width: 140px; line-height: 1.5; overflow-wrap: anywhere; }
.clue-tools { flex-direction: row; gap: 8px; margin-top: 8px; }
.clue-tools button { flex: 1; min-width: 0; min-height: 44px; justify-content: center; gap: 8px; background: #f2e5ce; }
#new-game-btn { background: var(--ink); border-color: var(--ink); color: var(--cream); }
#new-game-btn:hover { background: #28545f; }
footer { padding: 0; font-size: 10px; }

@media (max-width: 680px) {
  main { gap: 8px; padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right)); }
  .clue-panel { flex-direction: row; align-items: center; gap: 8px; }
  .clue-label { display: none; }
  .filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .select-field { flex-direction: column; align-items: stretch; gap: 0; padding: 4px 8px 0; }
  .select-field label { font-size: 9px; }
  .select-field select { min-height: 34px; font-size: 12px; }
  .round-meta { flex-direction: row; align-items: center; }
  #instruction { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .mj-score { width: 100%; }
  .mj-progress { flex: 1; }
  .table-stage { padding: 20px 2px; border-radius: 12px; }
  .mj-board { --th: calc(var(--tw) * 0.78 - 2px); }
  .play-dock { padding: 8px; }
  .mj-learn { font-size: 13px; min-height: 88px; }
  .mj-pair-display > .mini-tile { display: none; }
  .mj-pair-copy { font-size: 14px; min-width: 0; }
  .mj-pair-copy strong { font-size: 25px; }
  .clue-tools { flex-wrap: nowrap; }
  .clue-tools button { flex: 1; padding: 8px 4px; }
  footer { display: none; }
  .celebration > div { padding: 24px; max-width: calc(100vw - 32px); }
}

@media (orientation: landscape) and (max-height: 600px) {
  main { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(190px, 1fr) auto; gap: 8px; }
  .masthead { grid-column: 1 / -1; }
  .clue-panel { grid-column: 2; grid-row: 2; }
  .clue-label { display: none; }
  .filter-bar { grid-template-columns: 1fr; }
  .select-field { padding: 0 8px; flex-direction: row; align-items: center; }
  .select-field select { min-height: 36px; font-size: 12px; }
  .round-meta { grid-column: 1; grid-row: 2; }
  #instruction { display: none; }
  .mj-score, .mj-progress { flex: 1; }
  .table-stage { grid-column: 1; grid-row: 3; min-height: 190px; padding: 16px 4px; }
  .mj-board { --tw: min(100px, calc((100cqw - 20px) / (var(--cols) + 0.25))); --th: calc(var(--tw) * 0.58 - 2px); }
  .play-dock { grid-column: 1; grid-row: 4; align-self: stretch; }
  .mj-learn { flex: 1; font-size: 13px; }
  .mj-pair-display > .mini-tile { display: none; }
  .mj-pair-copy { min-width: 0; font-size: 14px; }
  .clue-tools { flex-wrap: wrap; }
  .clue-tools button { flex: 1 1 40%; }
  footer { display: none; }
}

/* Frequent actions stay by the score; configuration lives off the table. */
.masthead { gap: 4px; }
.masthead > div:first-of-type { flex: 1; min-width: 0; }
.masthead h1 { font-size: clamp(16px, 2.4vw, 30px); letter-spacing: -0.6px; }
.header-actions { gap: 2px; }
.icon-button {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: var(--cream);
  font-size: 21px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.icon-button:hover:not(:disabled) { background: #ffffff12; border-color: #49767a; }
.icon-button:disabled { opacity: 0.3; }
.icon-button[aria-pressed="false"] { color: var(--muted); }
.game-menu {
  width: min(420px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  margin: auto;
  padding: 20px;
  border: 1px solid #49767a;
  border-top: 3px solid var(--accent);
  border-radius: 18px;
  color: var(--cream);
  background: var(--teal);
  box-shadow: 0 24px 80px #001f28aa;
}
.game-menu::backdrop { background: #001f28b8; backdrop-filter: blur(4px); }
.menu-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-heading h2 { margin: 0; font-size: 23px; }
.menu-description { color: var(--muted); font-size: 14px; line-height: 1.6; margin: 12px 0 20px; }
.game-menu .clue-label { display: block; margin: 0 0 12px; }
.game-menu .filter-bar { grid-template-columns: 1fr; gap: 12px; }
.game-menu .select-field { flex-direction: column; align-items: stretch; padding: 8px 12px; gap: 4px; }
.game-menu .select-field select { min-height: 44px; font-size: 15px; }
.menu-restart, .menu-done { width: 100%; min-height: 48px; border-radius: 10px; font-weight: 700; }
#new-game-btn.menu-restart { margin-top: 24px; background: var(--cream); color: var(--ink); border: 0; }
#new-game-btn.menu-restart:hover { background: #efe3cd; }
.menu-done { margin-top: 10px; color: var(--cream); border: 1px solid #49767a; background: transparent; }
.menu-done:hover { background: #0d4b52; }
.games-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.menu-version {
  margin: 18px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 380px) {
  .masthead { flex-wrap: wrap; }
  .masthead > div:first-of-type { flex-basis: calc(100% - 48px); }
  .header-actions { width: 100%; justify-content: flex-end; }
}

.orientation-notice { display: none; }

/* Ask for native landscape orientation without rotating or clipping the UI. */
@media (orientation: portrait) {
  main, .game-menu { display: none; }
  .orientation-notice {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
    text-align: center;
  }
  .orientation-icon { color: var(--accent); font-size: 72px; }
  .orientation-notice h2 { margin: 16px 0 0; }
  .orientation-notice p {
    max-width: 32ch;
    color: var(--muted);
    line-height: 1.6;
  }
  .orientation-notice a {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    color: var(--cream);
  }
}
