:root {
  color-scheme: light;
  --page: #e8edf0;
  --page-soft: #f7f8f8;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #fbfcfc;
  --surface-2: #dfe6ea;
  --surface-3: #cbd4da;
  --ink: #1f2529;
  --ink-soft: #343c42;
  --muted: #68727a;
  --line: rgba(78, 91, 103, 0.24);
  --line-strong: rgba(45, 55, 63, 0.38);
  --teal: #087f86;
  --teal-dark: #045f66;
  --copper: #b66a3d;
  --champagne: #d0b675;
  --red: #b24339;
  --amber: #c48c28;
  --green: #26744e;
  --violet: #6659a8;
  --shadow-soft: 0 14px 34px rgba(31, 37, 41, 0.12);
  --shadow-lift: 0 20px 46px rgba(31, 37, 41, 0.16);
  --inner-metal: inset 0 1px 0 rgba(255, 255, 255, 0.82), inset 0 -1px 0 rgba(31, 37, 41, 0.05);
  --radius: 8px;
  --speed-fast: 140ms;
  --speed: 220ms;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  position: relative;
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(circle at 16% 14%, rgba(8, 127, 134, 0.16), transparent 28%),
    radial-gradient(circle at 78% 18%, rgba(102, 89, 168, 0.14), transparent 30%),
    radial-gradient(circle at 68% 82%, rgba(182, 106, 61, 0.14), transparent 34%),
    linear-gradient(135deg, #f8f9f9 0%, #e5ebee 35%, #f0eee8 66%, #dce4e8 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
  overscroll-behavior-y: none;
}

body.modal-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button,
input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.cell:disabled {
  cursor: default;
  opacity: 1;
}

.neural-background {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  opacity: 0.78;
}

.celebration-layer {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}

.celebration-layer[hidden] {
  display: none;
}

.celebration-piece {
  position: absolute;
  width: 9px;
  height: 18px;
  border-radius: 3px;
  background: var(--piece-color);
  box-shadow: 0 6px 16px rgba(31, 37, 41, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.72);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 950;
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: celebrationBurst var(--duration) cubic-bezier(0.16, 0.8, 0.24, 1) var(--delay) forwards;
}

.celebration-piece.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.celebration-piece.tile {
  width: 24px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 7px;
}

.success-quote-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
  pointer-events: auto;
}

.success-quote-modal[hidden] {
  display: none;
}

.success-quote-scrim {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 28%, rgba(8, 127, 134, 0.2), transparent 30%),
    rgba(31, 37, 41, 0.38);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 180ms var(--ease);
}

.success-quote-modal.outcome-fail .success-quote-scrim {
  background:
    radial-gradient(circle at 50% 28%, rgba(178, 67, 57, 0.18), transparent 30%),
    rgba(31, 37, 41, 0.38);
}

.success-quote-card {
  position: relative;
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 22px 24px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.98), rgba(230, 241, 239, 0.94) 42%, rgba(248, 243, 230, 0.96)),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(226, 235, 239, 0.92));
  box-shadow:
    0 28px 80px rgba(18, 23, 27, 0.32),
    0 8px 18px rgba(8, 127, 134, 0.12),
    var(--inner-metal);
  text-align: center;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  transition:
    opacity 220ms var(--ease),
    transform 260ms cubic-bezier(0.16, 0.9, 0.24, 1.18);
}

.success-quote-modal.outcome-fail .success-quote-card {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.98), rgba(246, 233, 229, 0.94) 42%, rgba(239, 231, 224, 0.96)),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(235, 226, 222, 0.92));
  box-shadow:
    0 28px 80px rgba(18, 23, 27, 0.32),
    0 8px 18px rgba(178, 67, 57, 0.1),
    var(--inner-metal);
}

.success-quote-modal.active .success-quote-scrim {
  opacity: 1;
}

.success-quote-modal.active .success-quote-card {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.success-check-wrap {
  position: relative;
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
}

.success-ring {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(8, 127, 134, 0.13);
  animation: successRing 1150ms var(--ease) infinite;
}

.success-quote-modal.outcome-fail .success-ring {
  background: rgba(178, 67, 57, 0.13);
}

.outcome-face {
  position: relative;
  width: 68px;
  height: 68px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  background: linear-gradient(145deg, #f7d46a 0%, #d99521 52%, #0a747b 100%);
  color: #2b3438;
  box-shadow:
    0 16px 32px rgba(8, 127, 134, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  animation: happyFace 980ms var(--ease) infinite;
}

.success-quote-modal.outcome-fail .outcome-face {
  background: linear-gradient(145deg, #f0c8bd 0%, #c47743 48%, #8a3b32 100%);
  color: #2d2624;
  animation: sadFace 1150ms var(--ease) infinite;
}

.outcome-eye {
  position: absolute;
  top: 22px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.outcome-eye.left {
  left: 20px;
}

.outcome-eye.right {
  right: 20px;
}

.outcome-mouth {
  position: absolute;
  left: 50%;
  top: 38px;
  width: 30px;
  height: 15px;
  border: 4px solid currentColor;
  border-top: 0;
  border-radius: 0 0 999px 999px;
  transform: translateX(-50%);
}

.success-quote-modal.outcome-fail .outcome-mouth {
  top: 43px;
  border-top: 4px solid currentColor;
  border-bottom: 0;
  border-radius: 999px 999px 0 0;
}

.outcome-tear {
  position: absolute;
  top: 31px;
  right: 14px;
  width: 7px;
  height: 12px;
  border-radius: 999px 999px 999px 2px;
  background: #d8f3ff;
  opacity: 0;
  transform: rotate(24deg) translateY(-4px);
}

.success-quote-modal.outcome-fail .outcome-tear {
  animation: sadTear 1150ms var(--ease) infinite;
}

.success-quote-label {
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.success-quote-modal.outcome-fail .success-quote-label {
  color: var(--red);
}

.success-quote-card p {
  max-width: 28ch;
  margin: 0;
  color: var(--ink);
  font-size: clamp(1.08rem, 4.8vw, 1.34rem);
  font-weight: 900;
  line-height: 1.28;
}

.outcome-next-button {
  width: min(220px, 100%);
  min-height: 52px;
  margin-top: 4px;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 0 calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
  margin-bottom: 18px;
  padding: 8px 0;
  backdrop-filter: blur(14px);
}

.top-actions {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
}

.language-button {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: linear-gradient(145deg, #343b40 0%, #20272b 55%, #0a747b 100%);
  font-size: 0.78rem;
  line-height: 1;
  box-shadow: 0 12px 26px rgba(31, 37, 41, 0.18), var(--inner-metal);
}

.language-option {
  width: 100%;
  min-height: 52px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(225, 234, 238, 0.82));
  color: var(--ink);
  text-align: left;
  font-size: 0.94rem;
  font-weight: 950;
  line-height: 1;
  box-shadow: var(--inner-metal);
}

.language-option:not(:disabled):hover {
  border-color: var(--line-strong);
  background: linear-gradient(145deg, #ffffff, #dfe8ed);
}

.language-code {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
  color: var(--teal-dark);
  font-size: 0.8rem;
  font-weight: 950;
}

.language-option.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: linear-gradient(145deg, #343b40 0%, #20272b 55%, #0a747b 100%);
  box-shadow: var(--inner-metal);
}

.language-option.active .language-code {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.16);
}

.brand {
  display: inline-flex;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand img {
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(31, 37, 41, 0.2);
}

.brand strong,
.brand small {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand strong {
  font-size: 1.08rem;
  line-height: 1;
}

.brand small {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 4px;
  font-weight: 760;
}

.install-button,
.start-button,
.icon-button,
.secondary-button,
.answer-button,
.plain-button {
  min-height: 44px;
  border-radius: var(--radius);
  font-weight: 900;
  transition:
    transform var(--speed-fast) var(--ease),
    border-color var(--speed-fast) var(--ease),
    box-shadow var(--speed-fast) var(--ease),
    background var(--speed-fast) var(--ease),
    color var(--speed-fast) var(--ease),
    opacity var(--speed-fast) var(--ease);
}

.install-button,
.start-button,
.answer-button {
  color: #fff;
  background: linear-gradient(145deg, #2d3439 0%, #1f2529 45%, #0c6f76 100%);
  box-shadow: 0 12px 26px rgba(31, 37, 41, 0.2), var(--inner-metal);
}

.install-button {
  padding: 0 16px;
  background: linear-gradient(145deg, #0b7f86, #065f66);
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(223, 232, 236, 0.8));
  color: var(--teal-dark);
  box-shadow: var(--inner-metal);
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:not(:disabled):hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
  background: linear-gradient(145deg, #ffffff, #dfe8ed);
  box-shadow: 0 10px 22px rgba(31, 37, 41, 0.12), var(--inner-metal);
}

button:not(:disabled):active {
  transform: translateY(1px) scale(0.99);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(8, 127, 134, 0.24);
  outline-offset: 3px;
}

.view {
  animation: viewIn 260ms var(--ease);
}

.view[hidden] {
  display: none;
}

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

.mode-view,
.setup-view,
.results-view {
  display: grid;
  gap: 14px;
  max-width: 800px;
  margin: 0 auto;
}

.mode-view {
  max-width: 980px;
  min-height: calc(100svh - 112px);
  align-content: center;
}

.mode-hero {
  padding: 6px 0 2px;
  text-align: center;
}

.mode-hero h1 {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: 2.65rem;
  line-height: 1.02;
}

.screen-head,
.stage {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(229, 236, 240, 0.78)),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft), var(--inner-metal);
}

.screen-head {
  padding: 20px;
}

.eyebrow {
  margin: 0;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.screen-head h1,
.game-top h1 {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: clamp(1.7rem, 5vw, 3rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.mode-picker-landing {
  align-items: stretch;
}

.mode-card {
  position: relative;
  min-height: 372px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  align-items: end;
  padding: 18px;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: var(--radius);
  background: linear-gradient(150deg, #fbfcfc 0%, #dfe8ed 42%, #293137 100%);
  backdrop-filter: blur(5px);
  color: #fff;
  text-align: left;
  box-shadow: 0 16px 34px rgba(31, 37, 41, 0.16), var(--inner-metal);
  transition:
    transform var(--speed) var(--ease),
    border-color var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease),
    background var(--speed) var(--ease),
    color var(--speed) var(--ease);
}

.mode-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.58), transparent 24%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0 1px, transparent 1px 9px);
}

.mode-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 0%, rgba(31, 37, 41, 0.18) 44%, rgba(18, 23, 27, 0.78) 100%);
}

.mode-card-easy {
  background: linear-gradient(145deg, rgba(247, 243, 217, 0.88) 0%, rgba(184, 224, 220, 0.78) 34%, rgba(8, 127, 134, 0.9) 72%, rgba(31, 37, 41, 0.96) 100%);
}

.mode-card-medium {
  background: linear-gradient(145deg, rgba(255, 247, 223, 0.9) 0%, rgba(236, 217, 137, 0.76) 34%, rgba(199, 120, 67, 0.88) 68%, rgba(31, 37, 41, 0.96) 100%);
}

.mode-card-hard {
  background: linear-gradient(145deg, rgba(241, 243, 245, 0.9) 0%, rgba(145, 136, 196, 0.78) 35%, rgba(102, 89, 168, 0.9) 68%, rgba(23, 29, 34, 0.96) 100%);
}

.mode-card:not(.active):hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.54);
  box-shadow: 0 24px 50px rgba(31, 37, 41, 0.22), var(--inner-metal);
}

.mode-card:not(:disabled):hover .mode-art {
  transform: translateY(-4px) scale(1.03);
}

.mode-art {
  position: relative;
  z-index: 1;
  width: min(68%, 168px);
  height: auto;
  justify-self: center;
  align-self: center;
  margin: 4px auto 18px;
  filter: drop-shadow(0 18px 18px rgba(31, 37, 41, 0.24));
  transition: transform var(--speed) var(--ease);
}

.mode-card span,
.mode-card strong,
.mode-card small {
  position: relative;
  z-index: 1;
  display: block;
}

.mode-card span {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

.mode-card strong {
  margin-top: 6px;
  color: #fff;
  font-size: 1.86rem;
  line-height: 1;
}

.mode-card small {
  margin-top: 7px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  font-weight: 780;
  line-height: 1.22;
}

.mode-card.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 26px 54px rgba(31, 37, 41, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.32);
}

.mode-card.active span,
.mode-card.active small {
  color: rgba(255, 255, 255, 0.86);
}

.selected-mode-panel {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(224, 233, 237, 0.84)),
    var(--surface);
  box-shadow: 0 10px 24px rgba(31, 37, 41, 0.1), var(--inner-metal);
}

.selected-mode-panel img {
  width: 76px;
  height: 76px;
  border-radius: var(--radius);
  filter: drop-shadow(0 10px 12px rgba(31, 37, 41, 0.16));
}

.selected-mode-panel span,
.selected-mode-panel strong {
  display: block;
  min-width: 0;
}

.selected-mode-panel span {
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 950;
  text-transform: uppercase;
}

.selected-mode-panel strong {
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
}

.change-mode-button {
  min-width: 126px;
}

.settings-open-button {
  width: 100%;
  min-height: 52px;
  justify-self: stretch;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(220, 228, 233, 0.9));
  color: var(--ink);
  box-shadow: var(--shadow-soft), var(--inner-metal);
}

.settings-open-button:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-lift), var(--inner-metal);
}

.level-ladder-panel {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(226, 235, 239, 0.82)),
    var(--surface);
  box-shadow: var(--shadow-soft), var(--inner-metal);
  overflow: hidden;
}

.level-ladder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.level-ladder-head strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.28rem;
  line-height: 1.05;
}

.level-unlock-pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid rgba(8, 127, 134, 0.24);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(218, 231, 235, 0.82));
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 950;
  white-space: nowrap;
  box-shadow: var(--inner-metal);
}

.level-ladder {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px 8px;
  padding: 6px;
  --level-node-size: 44px;
}

.level-path {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.level-path-line,
.level-path-progress {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.level-path-line {
  stroke: rgba(78, 91, 103, 0.16);
  stroke-width: 4;
}

.level-path-progress {
  stroke: rgba(8, 127, 134, 0.34);
  stroke-width: 5;
}

.level-node {
  position: relative;
  z-index: 1;
  width: var(--level-node-size);
  height: var(--level-node-size);
  justify-self: center;
  display: grid;
  place-items: center;
  border: 1px solid rgba(8, 127, 134, 0.26);
  border-radius: 999px;
  background: linear-gradient(145deg, #ffffff, #dfe8ed);
  color: var(--teal-dark);
  font-size: 0.86rem;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(31, 37, 41, 0.1), var(--inner-metal);
  transition:
    transform var(--speed-fast) var(--ease),
    border-color var(--speed-fast) var(--ease),
    box-shadow var(--speed-fast) var(--ease),
    background var(--speed-fast) var(--ease);
}

.level-node.complete {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.34);
  background: linear-gradient(145deg, #0a747b, #045f66);
}

.level-node.current {
  border-color: rgba(198, 141, 40, 0.5);
  box-shadow: 0 0 0 4px rgba(216, 170, 64, 0.14), 0 12px 24px rgba(31, 37, 41, 0.14), var(--inner-metal);
}

.level-node.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.5);
  background: linear-gradient(145deg, #343b40 0%, #20272b 55%, #0a747b 100%);
  box-shadow: 0 0 0 5px rgba(8, 127, 134, 0.18), 0 14px 28px rgba(31, 37, 41, 0.22), var(--inner-metal);
}

.level-node.locked {
  color: rgba(104, 114, 122, 0.7);
  border-color: rgba(78, 91, 103, 0.16);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.56), rgba(213, 222, 227, 0.58));
  box-shadow: var(--inner-metal);
}

.level-node:disabled {
  opacity: 0.72;
}

.level-node:not(:disabled):hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 14px 28px rgba(31, 37, 41, 0.16), var(--inner-metal);
}

.settings-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.setting-card {
  min-height: 88px;
  display: grid;
  gap: 10px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.94), rgba(226, 235, 239, 0.88));
  box-shadow: 0 8px 20px rgba(31, 37, 41, 0.08), var(--inner-metal);
}

.toggle-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.setting-title {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.setting-label {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.setting-card strong {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 1.48rem;
  line-height: 1;
}

.slider-card {
  gap: 12px;
}

.range-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-head strong {
  margin-top: 0;
  color: var(--teal-dark);
  font-size: 1rem;
  white-space: nowrap;
}

.info-wrap {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
}

.info-button {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(8, 127, 134, 0.28);
  border-radius: 999px;
  background: linear-gradient(145deg, #ffffff, #dbe5e9);
  color: var(--teal-dark);
  box-shadow: var(--inner-metal);
  font-size: 0.75rem;
  font-weight: 950;
  line-height: 1;
}

.tooltip {
  position: absolute;
  left: -8px;
  bottom: calc(100% + 9px);
  z-index: 30;
  width: min(246px, calc(100vw - 32px));
  padding: 10px 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #252d32, #11171a);
  color: #f7faf9;
  box-shadow: 0 16px 34px rgba(31, 37, 41, 0.28), var(--inner-metal);
  font-size: 0.78rem;
  font-weight: 760;
  line-height: 1.34;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px);
  transition:
    opacity var(--speed-fast) var(--ease),
    transform var(--speed-fast) var(--ease),
    visibility var(--speed-fast) var(--ease);
  visibility: hidden;
}

.tooltip::after {
  content: "";
  position: absolute;
  left: 14px;
  bottom: -6px;
  width: 10px;
  height: 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: #11171a;
  transform: rotate(45deg);
}

.info-wrap:hover .tooltip,
.info-wrap:focus-within .tooltip {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
}

input[type="range"] {
  width: 100%;
  height: 36px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 9px;
  border: 1px solid rgba(45, 55, 63, 0.2);
  border-radius: 999px;
  background: linear-gradient(90deg, #b8c2c9, #f9faf9 50%, #b6c0c7);
  box-shadow: inset 0 1px 3px rgba(31, 37, 41, 0.14);
}

input[type="range"]::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -10.5px;
  border: 3px solid #f8faf9;
  border-radius: 999px;
  background: linear-gradient(145deg, #e8f0f1, #06737b 48%, #044d52);
  box-shadow: 0 5px 14px rgba(31, 37, 41, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.64);
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 9px;
  border: 1px solid rgba(45, 55, 63, 0.2);
  border-radius: 999px;
  background: linear-gradient(90deg, #b8c2c9, #f9faf9 50%, #b6c0c7);
  box-shadow: inset 0 1px 3px rgba(31, 37, 41, 0.14);
}

input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: 3px solid #f8faf9;
  border-radius: 999px;
  background: linear-gradient(145deg, #e8f0f1, #06737b 48%, #044d52);
  box-shadow: 0 5px 14px rgba(31, 37, 41, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.64);
}

.toggle-card input {
  width: 26px;
  height: 26px;
  accent-color: var(--teal);
}

.switch-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.result-grid {
  display: grid;
  gap: 10px;
}

.result-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(224, 233, 237, 0.84));
  box-shadow: 0 8px 18px rgba(31, 37, 41, 0.07), var(--inner-metal);
  padding: 12px;
}

.result-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 900;
}

.result-grid strong {
  display: block;
  min-width: 0;
  margin-top: 5px;
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.motivation-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 7px;
  border: 1px solid rgba(8, 127, 134, 0.28);
  border-radius: var(--radius);
  padding: 14px 16px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(225, 239, 238, 0.9) 48%, rgba(247, 240, 222, 0.92)),
    radial-gradient(circle at 88% 22%, rgba(217, 149, 33, 0.18), transparent 32%);
  box-shadow: 0 14px 30px rgba(31, 37, 41, 0.1), var(--inner-metal);
}

.motivation-card[hidden] {
  display: none;
}

.motivation-card::before {
  content: "";
  position: absolute;
  inset: -45% auto -45% -38%;
  width: 38%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  transform: rotate(12deg);
}

.motivation-card span,
.motivation-card p {
  position: relative;
  z-index: 1;
}

.motivation-card span {
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.motivation-card p {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 820;
  line-height: 1.36;
}

.results-view.celebrating .screen-head {
  animation: successPulse 620ms var(--ease);
}

.results-view.celebrating .motivation-card {
  animation: successRise 700ms var(--ease);
}

.results-view.celebrating .motivation-card::before {
  animation: successSheen 900ms var(--ease) 90ms;
}

.settings-modal,
.language-modal,
.guide-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 37, 41, 0.42);
  backdrop-filter: blur(10px);
}

.settings-modal[hidden],
.language-modal[hidden],
.guide-modal[hidden] {
  display: none;
}

.settings-modal-panel,
.language-modal-panel,
.guide-modal-panel {
  width: min(620px, 100%);
  max-height: min(720px, calc(100svh - 40px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(229, 236, 240, 0.94)),
    var(--surface-solid);
  box-shadow: 0 28px 70px rgba(18, 23, 27, 0.34), var(--inner-metal);
  animation: modalIn 180ms var(--ease);
}

.language-modal-panel {
  width: min(360px, 100%);
}

.settings-modal-panel {
  width: min(620px, 100%);
}

.settings-modal-head,
.language-modal-head,
.guide-modal-head {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.settings-modal-head h2,
.language-modal-head h2,
.guide-modal-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.22rem;
  line-height: 1.1;
}

.settings-modal-close,
.language-modal-close,
.guide-modal-close {
  width: 40px;
  height: 40px;
  min-height: 40px;
  flex-basis: 40px;
}

.settings-modal-content {
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}

.settings-modal-content .settings-panel {
  grid-template-columns: 1fr;
}

.language-list {
  display: grid;
  gap: 8px;
  padding: 14px;
  overflow-y: auto;
}

.guide-content {
  display: grid;
  gap: 0;
  padding: 0 18px 18px;
  animation: guideIn 180ms var(--ease);
}

.guide-modal-content {
  min-height: 0;
  overflow-y: auto;
}

.guide-content div {
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.guide-content strong {
  display: block;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.2;
}

.guide-content p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.42;
}

.privacy-link {
  justify-self: center;
  color: var(--teal-dark);
  font-size: 0.88rem;
  font-weight: 900;
  text-decoration: none;
}

.privacy-link:hover,
.privacy-link:focus-visible {
  text-decoration: underline;
}

.start-button {
  width: 100%;
  min-height: 58px;
  padding: 0 18px;
  background: linear-gradient(145deg, #c47743 0%, #a95632 38%, #22292d 100%);
  font-size: 1.04rem;
}

.start-button:not(:disabled):hover,
.answer-button:not(:disabled):hover,
.install-button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift), var(--inner-metal);
}

.game-view {
  display: grid;
  gap: 8px;
}

.game-top {
  display: grid;
  grid-template-columns: 74px 1fr 74px;
  gap: 8px;
  align-items: center;
}

body[data-view="game"] .topbar {
  margin-bottom: 6px;
  padding-top: 4px;
  padding-bottom: 4px;
}

body[data-view="game"] .brand img {
  width: 36px;
  height: 36px;
}

body[data-view="game"] .brand small {
  display: none;
}

.plain-button {
  padding: 0 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(220, 228, 233, 0.9));
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--inner-metal);
}

.plain-button:not(:disabled):hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 20px rgba(31, 37, 41, 0.1), var(--inner-metal);
}

.plain-button.danger {
  color: #fff;
  background: linear-gradient(145deg, #c45245, #96372f);
  border-color: rgba(150, 55, 47, 0.72);
}

.game-top h1 {
  margin-top: 2px;
  font-size: clamp(1.08rem, 3.6vw, 1.7rem);
  text-align: center;
}

.game-top .eyebrow {
  text-align: center;
}

.game-title-block {
  min-width: 0;
  text-align: center;
}

.session-status {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--muted);
}

.session-status span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 8px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(222, 231, 236, 0.84));
  box-shadow: var(--inner-metal);
  white-space: nowrap;
}

.session-status strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.stage {
  min-height: min(620px, calc(100svh - 126px));
  padding: 14px;
}

.stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stage-head h2 {
  margin: 5px 0 0;
  font-size: clamp(1.42rem, 4vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.cue-chip {
  min-width: 84px;
  min-height: 84px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #f2d890 0%, var(--champagne) 42%, #936432 100%);
  color: #191c1f;
  border: 1px solid rgba(52, 60, 66, 0.42);
  box-shadow: 0 14px 28px rgba(31, 37, 41, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.58);
  font-size: 2.75rem;
  font-weight: 950;
  animation: cueIn 240ms var(--ease);
}

.prompt-line,
.feedback-line {
  min-height: 28px;
  margin-top: 9px;
  color: var(--muted);
  font-weight: 820;
  line-height: 1.35;
  transition: color var(--speed-fast) var(--ease), transform var(--speed-fast) var(--ease);
}

.feedback-line {
  color: var(--ink);
}

.feedback-line.correct {
  color: var(--green);
  animation: feedbackPop 220ms var(--ease);
}

.feedback-line.wrong {
  color: var(--red);
  animation: feedbackPop 220ms var(--ease);
}

.grid-wrap {
  display: grid;
  place-items: center;
  min-height: min(420px, calc(100svh - 260px));
  padding: 10px 0 6px;
}

.memory-grid {
  --grid-size: 3;
  width: min(100%, 520px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-size), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: clamp(7px, 1.6vw, 12px);
}

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(45, 55, 63, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(145deg, #fbfcfc, #d9e1e6 58%, #eef2f4);
  color: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82), inset 0 -1px 0 rgba(31, 37, 41, 0.06), 0 5px 12px rgba(31, 37, 41, 0.06);
  font-size: clamp(1rem, calc(7vw / var(--grid-size)), 2.4rem);
  font-weight: 950;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform var(--speed-fast) var(--ease),
    border-color var(--speed-fast) var(--ease),
    background var(--speed-fast) var(--ease),
    box-shadow var(--speed-fast) var(--ease),
    color var(--speed-fast) var(--ease);
}

.cell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.62), transparent 42%, rgba(31, 37, 41, 0.05));
  opacity: 0.72;
}

.cell:not(:disabled):hover,
.cell:not(:disabled):focus-visible {
  outline: none;
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: 0 12px 22px rgba(8, 127, 134, 0.16), var(--inner-metal);
}

.cell.filled {
  border-color: rgba(31, 37, 41, 0.38);
  background: linear-gradient(145deg, #ffffff, #e3eaee 52%, #f7f8f8);
  animation: cellReveal 230ms var(--ease);
}

.cell .symbol {
  position: relative;
  z-index: 1;
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.54);
}

.cell.active-position {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  background: linear-gradient(145deg, #13a1a9, #087f86 45%, #064f55);
  box-shadow: 0 14px 26px rgba(8, 127, 134, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.34);
  animation: pulseCue 680ms var(--ease);
}

.cell.has-stack {
  grid-template-rows: 1fr auto;
  gap: 5px;
  padding: 8px;
}

.cell.answer-correct {
  background: linear-gradient(145deg, rgba(231, 247, 236, 0.98), rgba(177, 220, 190, 0.92));
  border-color: var(--green);
  box-shadow: 0 12px 22px rgba(38, 116, 78, 0.18), var(--inner-metal);
}

.cell.answer-wrong {
  background: linear-gradient(145deg, rgba(254, 236, 233, 0.98), rgba(227, 178, 170, 0.92));
  border-color: var(--red);
  box-shadow: 0 12px 22px rgba(178, 67, 57, 0.16), var(--inner-metal);
}

.cell.answer-picked {
  box-shadow: inset 0 0 0 4px rgba(8, 127, 134, 0.26), 0 10px 18px rgba(31, 37, 41, 0.08);
}

.cell .dot {
  position: relative;
  z-index: 1;
  width: 38%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: currentColor;
  box-shadow: inset 0 0 0 3px rgba(31, 37, 41, 0.16), 0 4px 10px rgba(31, 37, 41, 0.12);
}

.cell.has-stack .dot {
  width: 28%;
  min-width: 14px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  min-height: 58px;
}

.action-row:empty {
  display: none;
}

.answer-button,
.secondary-button {
  flex: 1 1 140px;
  min-height: 52px;
  padding: 0 16px;
}

.answer-button {
  background: linear-gradient(145deg, #0b8790, #065f66);
}

.answer-button.negative {
  background: linear-gradient(145deg, #454d53, #1f2529);
}

.secondary-button {
  color: var(--ink);
  background: linear-gradient(145deg, #ffffff, #dfe7eb);
  border: 1px solid var(--line);
  box-shadow: var(--inner-metal);
}

.result-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.result-grid div {
  min-height: 86px;
}

.result-grid strong {
  font-size: 1.58rem;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.next-stage-button {
  grid-column: 1 / -1;
}

.result-actions.has-next-stage #playAgainButton {
  color: var(--ink);
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #ffffff, #dfe7eb);
  box-shadow: var(--inner-metal);
}

.legal-page {
  display: grid;
  gap: 14px;
  max-width: 820px;
  margin: 0 auto;
}

.legal-updated {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 820;
}

.legal-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(229, 236, 240, 0.78)),
    var(--surface);
  box-shadow: var(--shadow-soft), var(--inner-metal);
}

.legal-card h2 {
  margin: 8px 0 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.legal-card h2:first-child {
  margin-top: 0;
}

.legal-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 760;
  line-height: 1.5;
}

@keyframes cellReveal {
  from {
    opacity: 0.75;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseCue {
  0% {
    transform: scale(0.96);
  }
  50% {
    transform: scale(1.025);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes cueIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes feedbackPop {
  from {
    transform: translateY(3px);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes successPulse {
  0% {
    transform: translateY(0) scale(1);
  }
  38% {
    transform: translateY(-2px) scale(1.018);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes successRise {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes successSheen {
  from {
    left: -38%;
  }
  to {
    left: 112%;
  }
}

@keyframes successRing {
  0% {
    opacity: 0.72;
    transform: scale(0.86);
  }
  70% {
    opacity: 0;
    transform: scale(1.2);
  }
  100% {
    opacity: 0;
    transform: scale(1.2);
  }
}

@keyframes happyFace {
  0%,
  100% {
    transform: translateY(0) rotate(0deg) scale(1);
  }
  42% {
    transform: translateY(-5px) rotate(-3deg) scale(1.04);
  }
  68% {
    transform: translateY(1px) rotate(2deg) scale(0.99);
  }
}

@keyframes sadFace {
  0%,
  100% {
    transform: translateX(0) rotate(0deg);
  }
  28% {
    transform: translateX(-2px) rotate(-2deg);
  }
  56% {
    transform: translateX(2px) rotate(2deg);
  }
}

@keyframes sadTear {
  0%,
  32% {
    opacity: 0;
    transform: rotate(24deg) translateY(-4px);
  }
  45% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(24deg) translateY(14px);
  }
}

@keyframes celebrationBurst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(0, 0) scale(0.5) rotate(0deg);
  }
  12% {
    opacity: 1;
  }
  46% {
    opacity: 1;
    transform: translate(-50%, -50%) translate(var(--mid-x), var(--mid-y)) scale(1) rotate(var(--mid-rot));
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) translate(var(--x), var(--y)) scale(0.86) rotate(var(--rot));
  }
}

@keyframes guideIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .topbar {
    margin-bottom: 10px;
  }

  .top-actions {
    flex: 1 1 auto;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .brand strong {
    font-size: 1rem;
  }

  .brand small {
    font-size: 0.72rem;
  }

  .install-button {
    min-height: 40px;
    padding: 0 12px;
    font-size: 0.9rem;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    min-height: 40px;
    flex-basis: 40px;
  }

  .screen-head {
    padding: 15px;
  }

  .screen-head h1 {
    font-size: clamp(1.55rem, 8vw, 2.22rem);
  }

  .mode-view {
    min-height: calc(100svh - 94px);
    align-content: center;
    gap: 10px;
  }

  .mode-hero {
    padding-top: 2px;
  }

  .mode-hero h1 {
    font-size: 1.72rem;
  }

  .mode-picker {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mode-card {
    min-height: 118px;
    display: grid;
    grid-template-columns: 92px 1fr;
    grid-template-rows: auto auto auto;
    gap: 2px 12px;
    align-items: center;
    padding: 12px;
  }

  .mode-art {
    grid-row: 1 / span 3;
    width: 86px;
    margin: 0;
  }

  .mode-card span {
    color: rgba(255, 255, 255, 0.86);
  }

  .mode-card strong {
    margin-top: 0;
    font-size: 1.36rem;
  }

  .mode-card small {
    margin-top: 0;
    font-size: 0.84rem;
  }

  .selected-mode-panel {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 10px;
    min-height: 96px;
    padding: 10px;
  }

  .selected-mode-panel img {
    width: 66px;
    height: 66px;
  }

  .selected-mode-panel strong {
    font-size: 1.28rem;
  }

  .change-mode-button {
    grid-column: 1 / -1;
    width: 100%;
    min-height: 42px;
  }

  .settings-panel {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .setting-card {
    min-height: 80px;
    padding: 10px;
  }

  .setting-card strong {
    font-size: 1.3rem;
  }

  .range-head {
    gap: 8px;
  }

  .setting-title {
    gap: 6px;
  }

  .info-button {
    width: 22px;
    height: 22px;
  }

  .toggle-card {
    grid-column: 1 / -1;
  }

  .level-ladder-panel {
    padding: 12px;
  }

  .level-ladder-head {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .level-ladder {
    gap: 8px 6px;
    --level-node-size: 40px;
  }

  .level-node {
    font-size: 0.82rem;
  }

  .start-button {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 5;
    min-height: 58px;
  }

  .game-top {
    grid-template-columns: 64px 1fr 64px;
    gap: 6px;
  }

  .plain-button {
    min-height: 38px;
    padding: 0 7px;
    font-size: 0.84rem;
  }

  .game-top h1 {
    font-size: 1.08rem;
  }

  .session-status {
    gap: 5px;
    margin-top: 4px;
    font-size: 0.68rem;
  }

  .session-status span {
    min-height: 24px;
    padding: 0 6px;
  }

  .stage {
    min-height: 0;
    padding: 10px;
  }

  .stage-head {
    align-items: flex-start;
    gap: 8px;
  }

  .stage-head h2 {
    margin-top: 0;
    font-size: clamp(1.14rem, 5.4vw, 1.55rem);
  }

  .stage-head .eyebrow {
    display: none;
  }

  .cue-chip {
    flex: 0 0 52px;
    min-width: 52px;
    min-height: 52px;
    font-size: 1.55rem;
  }

  .prompt-line,
  .feedback-line {
    min-height: 22px;
    margin-top: 6px;
    font-size: 0.88rem;
  }

  .grid-wrap {
    min-height: 0;
    padding: 8px 0 4px;
  }

  .memory-grid {
    width: min(100%, 92vw, calc(100svh - 220px), 430px);
    gap: clamp(5px, 1.7vw, 8px);
  }

  .cell {
    font-size: clamp(0.9rem, calc(15vw / var(--grid-size)), 1.65rem);
  }

  .cell:not(:disabled):hover {
    transform: none;
  }

  .cell:not(:disabled):active {
    transform: scale(0.97);
  }

  .cell.has-stack {
    gap: 3px;
    padding: 5px;
  }

  .cell.answer-picked {
    box-shadow: inset 0 0 0 3px rgba(8, 127, 134, 0.26), 0 8px 16px rgba(31, 37, 41, 0.08);
  }

  .action-row {
    position: sticky;
    bottom: calc(8px + env(safe-area-inset-bottom));
    z-index: 5;
    gap: 8px;
    min-height: 62px;
    margin: 10px -4px -4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(247, 250, 250, 0.92);
    box-shadow: 0 12px 30px rgba(31, 37, 41, 0.18), var(--inner-metal);
    backdrop-filter: blur(12px);
  }

  .action-row > button {
    flex: 1 1 112px;
    min-height: 52px;
    padding: 0 12px;
    font-size: 0.94rem;
  }

  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .result-grid strong {
    font-size: 1.34rem;
  }

  .result-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .settings-panel {
    grid-template-columns: 1fr;
  }

  .toggle-card {
    grid-column: auto;
  }
}

@media (max-width: 390px) {
  .app-shell {
    width: 100%;
    padding-right: 8px;
    padding-left: 8px;
  }

  .topbar {
    gap: 6px;
  }

  .top-actions {
    flex: 0 0 auto;
    gap: 5px;
  }

  .brand {
    gap: 7px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 0.94rem;
  }

  .brand small {
    font-size: 0.66rem;
    margin-top: 2px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
    min-height: 34px;
    flex-basis: 34px;
    border-radius: 7px;
  }

  .icon-button svg {
    width: 19px;
    height: 19px;
  }

  .language-button {
    font-size: 0.7rem;
  }

  .install-button {
    min-height: 34px;
    padding: 0 9px;
    border-radius: 7px;
    font-size: 0.78rem;
  }

  .settings-panel {
    grid-template-columns: 1fr;
  }

  .toggle-card {
    grid-column: auto;
  }

  .level-ladder {
    gap: 7px 4px;
    padding: 3px;
    --level-node-size: 36px;
  }

  .level-node {
    font-size: 0.78rem;
  }

  .stage-head {
    display: flex;
  }

  .cue-chip {
    margin-top: 0;
  }
}

@media (max-width: 340px) {
  .topbar {
    gap: 4px;
  }

  .top-actions {
    gap: 4px;
  }

  .brand {
    gap: 5px;
  }

  .brand img {
    width: 31px;
    height: 31px;
  }

  .brand strong {
    font-size: 0.86rem;
  }

  .brand small {
    font-size: 0.6rem;
  }

  .icon-button {
    width: 31px;
    height: 31px;
    min-height: 31px;
    flex-basis: 31px;
  }

  .icon-button svg {
    width: 17px;
    height: 17px;
  }

  .install-button {
    min-height: 31px;
    padding: 0 7px;
    font-size: 0.72rem;
  }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 940px) {
  .app-shell {
    width: min(100% - 20px, 920px);
  }

  .setup-view {
    max-width: 920px;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .setup-view .screen-head,
  .setup-view .start-button {
    grid-column: 1 / -1;
  }

  .mode-view {
    min-height: 0;
    max-width: 920px;
  }

  .mode-picker-landing {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-card {
    min-height: 210px;
  }

  .mode-art {
    width: min(62%, 120px);
  }

  .game-view {
    grid-template-columns: 240px minmax(0, 1fr);
    align-items: start;
  }

  .game-top {
    grid-column: 1;
  }

  .stage {
    grid-column: 2;
    grid-row: 1 / span 3;
  }

  .grid-wrap {
    padding: 8px 0 4px;
  }

  .memory-grid {
    width: min(100%, calc(100svh - 118px), 420px);
  }
}

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