[hidden] {
  display: none !important;
}

.destructive-action { color: #a13930; }
#profileSyncStatus { min-height: 2.8em; margin: 4px 0; }
#removeProfileDialog p { line-height: 1.5; }

:root {
  --bg: #0b2d36;
  --panel: #103b46;
  --panel-strong: #17505a;
  --ink: #f4f7f3;
  --muted: #b7cfcc;
  --line: rgba(222, 241, 238, 0.18);
  --accent: #55dcc3;
  --accent-strong: #2bc5ad;
  --warn: #efc45f;
  --danger: #ee6b68;
  --violet: #b89cff;
  --sky: #70d9ff;
  --paper: #f8f7ec;
  --paper-2: #e8efdf;
  --field-ink: #12383d;
  --page-background: linear-gradient(155deg, #163f4c 0%, #1a5960 56%, #484757 100%);
  --board-background: linear-gradient(145deg, #287f9e 0%, #1b8b75 58%, #55794d 100%);
  --tile-hidden: #58d7a0;
  --tile-hidden-2: #1da5b4;
  --tile-open: #fffbea;
  --tile-open-alt: #edf7df;
  --tile-text: #1f3350;
  --surface-background: linear-gradient(180deg, rgba(13, 57, 67, 0.94), rgba(9, 42, 51, 0.94));
  --control-background: linear-gradient(180deg, rgba(18, 67, 78, 0.98), rgba(10, 43, 54, 0.98));
  --popover-background: rgba(8, 38, 47, 0.98);
  --hud-background: rgba(9, 44, 54, 0.88);
  --primary-background: linear-gradient(180deg, #61e4cc, #2bc5ad);
  color-scheme: dark;
  --display-font: Aptos, "Segoe UI Variable Display", "Segoe UI", sans-serif;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overscroll-behavior: none;
}

body {
  position: relative;
  margin: 0;
  background: var(--page-background);
  color: var(--ink);
  overflow: hidden;
  touch-action: manipulation;
}

body::before {
  content: none;
}

body[data-theme="neon"] {
  --bg: #070d12;
  --panel: #111827;
  --panel-strong: #182238;
  --accent: #2ee9ff;
  --accent-strong: #28c4d9;
  --warn: #f7d84a;
  --danger: #ff4d8d;
  --tile-hidden: #162033;
  --tile-hidden-2: #0d1423;
  --tile-open: #dceaff;
  --tile-open-alt: #c9dcf8;
  --page-background: linear-gradient(150deg, #081222 0%, #10223d 54%, #321b4a 100%);
  --board-background: linear-gradient(145deg, #0d1830 0%, #122a3b 56%, #291a45 100%);
  --surface-background: linear-gradient(180deg, rgba(20, 30, 51, 0.97), rgba(10, 18, 33, 0.96));
  --control-background: linear-gradient(180deg, rgba(25, 39, 66, 0.98), rgba(11, 22, 42, 0.98));
  --popover-background: rgba(10, 18, 33, 0.98);
  --hud-background: rgba(15, 27, 46, 0.92);
  --primary-background: linear-gradient(180deg, #4cecff, #22bed4);
}

body[data-theme="terminal"] {
  --bg: #080d08;
  --panel: #101810;
  --panel-strong: #152315;
  --ink: #eaffdf;
  --muted: #9fba9b;
  --accent: #74ff66;
  --accent-strong: #44d53a;
  --warn: #d6ff70;
  --danger: #ff6464;
  --tile-hidden: #162316;
  --tile-hidden-2: #0d170d;
  --tile-open: #dff5d9;
  --tile-open-alt: #cce8c8;
  --page-background: linear-gradient(150deg, #071008 0%, #102512 58%, #16210c 100%);
  --board-background: linear-gradient(145deg, #09170a 0%, #153019 58%, #1d2812 100%);
  --surface-background: linear-gradient(180deg, rgba(20, 33, 20, 0.98), rgba(9, 18, 10, 0.98));
  --control-background: linear-gradient(180deg, rgba(24, 42, 24, 0.98), rgba(9, 22, 10, 0.98));
  --popover-background: rgba(8, 18, 9, 0.98);
  --hud-background: rgba(14, 27, 15, 0.94);
  --primary-background: linear-gradient(180deg, #8aff79, #45d83d);
}

body[data-theme="cavern"] {
  --bg: #101019;
  --panel: #1b1a28;
  --panel-strong: #25223a;
  --accent: #7bd7ff;
  --accent-strong: #55b6e5;
  --warn: #f0d37a;
  --danger: #ff6685;
  --tile-hidden: #29253d;
  --tile-hidden-2: #1c1a2b;
  --tile-open: #e3edf5;
  --tile-open-alt: #d2dfeb;
  --page-background: linear-gradient(150deg, #131526 0%, #262242 54%, #183a4d 100%);
  --board-background: linear-gradient(145deg, #191a30 0%, #302950 58%, #173849 100%);
  --surface-background: linear-gradient(180deg, rgba(35, 32, 57, 0.98), rgba(19, 19, 37, 0.98));
  --control-background: linear-gradient(180deg, rgba(42, 37, 68, 0.98), rgba(21, 23, 44, 0.98));
  --popover-background: rgba(22, 21, 39, 0.98);
  --hud-background: rgba(29, 27, 48, 0.94);
  --primary-background: linear-gradient(180deg, #8de1ff, #50b4df);
}

body[data-tile-finish="moss"] {
  --tile-hidden: #31483a;
  --tile-hidden-2: #1f3229;
}

body[data-tile-finish="copper"] {
  --tile-hidden: #4a392d;
  --tile-hidden-2: #2d2822;
}

body[data-tile-finish="glacier"] {
  --tile-hidden: #253c45;
  --tile-hidden-2: #172b34;
}

body[data-tile-finish="metal"] {
  --tile-open: #e6efe3;
  --tile-open-alt: #d4e4d0;
  --tile-text: #17201d;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.48;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100svh;
  max-height: 100svh;
  min-height: 100svh;
  overflow: hidden;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 4px 0 10px;
}

.storage-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid #e5b66b;
  border-radius: 6px;
  background: #302d25;
  color: #fff1d5;
  font-size: 0.8rem;
}

.storage-notice[hidden],
.leaderboard-rules-field[hidden] {
  display: none;
}

.storage-notice span {
  flex: 1;
  min-width: 0;
}

.storage-notice button {
  flex: none;
  min-height: 42px;
}

.leaderboard-rules-field {
  display: grid;
  gap: 6px;
  margin-block: 10px;
}

.brand-lockup {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-lockup > div:last-child {
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgba(213, 243, 237, 0.2);
  border-radius: 7px;
  background: rgba(7, 39, 49, 0.84);
  padding: 4px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 8px 20px rgba(5, 26, 33, 0.24);
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.brand-loop,
.brand-flag-pole {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-loop {
  stroke-width: 3.4;
}

.brand-flag-pole {
  stroke: var(--paper);
  stroke-width: 2.2;
}

.brand-flag {
  fill: var(--danger);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: 62vw;
  overflow: hidden;
  font-size: 1rem;
  font-family: var(--display-font);
  font-weight: 760;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-lockup p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.top-actions {
  position: relative;
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.top-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 8;
  display: grid;
  width: min(242px, calc(100vw - 24px));
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--popover-background);
  padding: 8px;
  box-shadow: 0 22px 52px rgba(11, 32, 52, 0.42);
}

.top-menu-popover[hidden],
.top-menu-popover button[hidden] {
  display: none;
}

.top-menu-popover button {
  display: flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 54%),
    rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
  padding: 0 11px;
  text-align: left;
}

.top-menu-popover button:hover,
.top-menu-popover button:focus-visible {
  border-color: rgba(72, 214, 170, 0.42);
  background: rgba(72, 214, 170, 0.12);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--control-background);
  font-weight: 900;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -2px 0 rgba(0, 0, 0, 0.22);
}

.icon-button.primary {
  border-color: rgba(67, 232, 185, 0.44);
  background: linear-gradient(180deg, #35e8b6, var(--accent-strong));
  color: #061310;
}

.top-symbol {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
}

.top-symbol-menu::before {
  position: absolute;
  top: 3px;
  left: 1px;
  width: 16px;
  height: 2px;
  content: "";
  border-radius: 999px;
  background: currentColor;
  box-shadow:
    0 6px 0 currentColor,
    0 12px 0 currentColor;
}

.top-symbol-daily {
  border: 2px solid currentColor;
  border-radius: 4px;
}

.top-symbol-daily::before {
  position: absolute;
  top: 3px;
  left: 0;
  width: 100%;
  height: 2px;
  content: "";
  background: currentColor;
}

.top-symbol-daily::after {
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 4px;
  height: 4px;
  content: "";
  border-radius: 50%;
  background: currentColor;
}

.top-symbol-settings {
  border: 2px solid currentColor;
  border-radius: 50%;
}

.top-symbol-settings::before,
.top-symbol-settings::after {
  position: absolute;
  top: 7px;
  left: -3px;
  width: 20px;
  height: 2px;
  content: "";
  border-radius: 999px;
  background: currentColor;
}

.top-symbol-settings::after {
  transform: rotate(90deg);
}

.top-symbol-new::before,
.top-symbol-new::after {
  position: absolute;
  top: 8px;
  left: 2px;
  width: 14px;
  height: 2px;
  content: "";
  border-radius: 999px;
  background: currentColor;
}

.top-symbol-new::after {
  transform: rotate(90deg);
}

.screen {
  min-height: 0;
  overflow: hidden;
}

.screen[hidden] {
  display: none;
}

.menu-screen,
.mode-screen,
.panel-screen,
.tutorial-screen {
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding-bottom: 8px;
}

.game-layout {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.menu-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(96px, 0.6fr);
  gap: 8px;
}

.menu-hero[hidden],
.menu-actions[hidden],
.mission-strip[hidden] {
  display: none;
}

.menu-hero > *,
.screen-heading,
.mode-tab,
.menu-list-button,
.run-strip > *,
.progress-strip > *,
.seed-strip {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-background);
  box-shadow: 0 12px 28px rgba(14, 35, 54, 0.2);
}

.menu-hero > * {
  display: grid;
  gap: 4px;
  padding: 14px;
}

.menu-hero span,
.run-strip span,
.seed-strip span {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-hero strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 1.2rem;
  line-height: 1.05;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-actions .primary-action {
  grid-column: 1 / -1;
}

.menu-action {
  min-height: 54px;
}

.main-menu-list {
  display: grid;
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 38, 47, 0.54);
  box-shadow: 0 18px 42px rgba(5, 28, 35, 0.2);
}

.menu-list-spaced {
  margin-top: 14px;
  border-top: 1px solid rgba(222, 241, 238, 0.26) !important;
}

.menu-list-button {
  position: relative;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 55px;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid rgba(222, 241, 238, 0.11);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--display-font);
  font-size: 0.98rem;
  font-weight: 720;
  padding: 6px 15px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: none;
  transition:
    background 120ms ease,
    color 120ms ease;
}

.menu-list-button:last-child {
  border-bottom: 0;
}

.menu-list-button > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  color: var(--muted);
}

.mode-icon svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.menu-list-button.is-active {
  background: rgba(85, 220, 195, 0.1);
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.menu-list-button.is-active .mode-icon {
  color: var(--accent);
}

.menu-list-button:hover,
.menu-list-button:focus-visible {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.menu-list-button:focus-visible {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

.screen-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  box-shadow: 0 12px 28px rgba(6, 31, 39, 0.18);
}

.screen-heading h2 {
  min-width: 0;
  overflow: hidden;
  font-family: var(--display-font);
  font-size: 1rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.help-action {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-weight: 950;
}

.help-action:hover,
.help-action:focus-visible {
  border-color: rgba(72, 214, 170, 0.42);
  color: var(--accent);
}

.compact-action {
  min-height: 34px;
  padding: 0 14px;
}

.wide-action {
  width: 100%;
  min-height: 50px;
}

.mode-tabs,
.menu-mode-list {
  display: grid;
  gap: 6px;
}

.mode-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-tab {
  display: grid;
  gap: 4px;
  min-width: 0;
  min-height: 70px;
  overflow: hidden;
  color: var(--muted);
  font-weight: 900;
  padding: 10px;
  text-overflow: ellipsis;
  text-align: left;
}

.mode-tab.is-active {
  background: var(--accent-strong);
  color: #061310;
}

.mode-tab strong,
.mode-tab span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mode-tab strong {
  font-size: 0.92rem;
}

.mode-tab span {
  font-size: 0.7rem;
}

.mode-option-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.difficulty-launcher {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mode-option-action {
  min-height: 50px;
}

.tutorial-panel {
  position: relative;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(13, 68, 72, 0.74);
  padding: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.tutorial-panel[hidden],
.tutorial-lesson-menu[hidden] {
  display: none;
}

.tutorial-lesson-menu {
  display: grid;
  gap: 8px;
}

.tutorial-lesson-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-background);
  color: var(--ink);
  padding: 0 14px;
  text-align: left;
}

.tutorial-lesson-button strong {
  font-family: var(--display-font);
  font-size: 1rem;
}

.tutorial-lesson-button span {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.tutorial-lesson-button:hover,
.tutorial-lesson-button:focus-visible {
  border-color: rgba(67, 232, 185, 0.58);
  background: linear-gradient(180deg, rgba(42, 103, 119, 0.98), rgba(27, 77, 91, 0.94));
}

.tutorial-stage {
  position: relative;
  display: grid;
  gap: 10px;
  width: min(100%, 430px);
}

.control-tutorial-stage {
  display: grid;
  gap: 10px;
  width: min(100%, 430px);
}

.control-tutorial-viewport {
  --control-grid-size: 40px;
  --control-grid-x: 0px;
  --control-grid-y: 0px;
  position: relative;
  width: 100%;
  height: clamp(300px, 48vh, 390px);
  overflow: hidden;
  border-radius: 6px;
  background-color: var(--tile-hidden-2);
  background-image:
    linear-gradient(rgba(9, 83, 91, 0.34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(9, 83, 91, 0.34) 1px, transparent 1px),
    linear-gradient(145deg, var(--tile-hidden), var(--tile-hidden-2));
  background-position:
    0 var(--control-grid-y),
    var(--control-grid-x) 0,
    0 0;
  background-size:
    var(--control-grid-size) var(--control-grid-size),
    var(--control-grid-size) var(--control-grid-size),
    100% 100%;
  box-shadow:
    0 0 0 1px rgba(67, 232, 185, 0.22),
    0 16px 28px rgba(0, 0, 0, 0.16);
  touch-action: none;
  user-select: none;
}

.control-tutorial-board {
  --control-tile-size: 40px;
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(31, var(--control-tile-size));
  grid-template-rows: repeat(31, var(--control-tile-size));
  width: 1240px;
  height: 1240px;
  transform-origin: center;
  will-change: transform;
}

.control-tutorial-board.is-snapping {
  transition: transform 260ms ease;
}

.control-tutorial-tile {
  width: var(--control-tile-size);
  height: var(--control-tile-size);
  min-width: 0;
  min-height: 0;
  font-size: 1.12rem;
}

.tutorial-dialog {
  position: relative;
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-top: 2px solid var(--accent);
  border-radius: 8px;
  background: rgba(17, 28, 34, 0.94);
  padding: 12px;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  z-index: 5;
}

.tutorial-dialog[hidden] {
  display: none;
}

.tutorial-dialog.can-advance {
  cursor: pointer;
}

.tutorial-progress {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tutorial-prompt {
  min-height: 0;
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 900;
  line-height: 1.35;
}

.tutorial-prompt.is-attention {
  animation: tutorial-guide-shake 360ms ease both;
}

.tutorial-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--tutorial-size, 6), minmax(0, 1fr));
  grid-template-rows: repeat(var(--tutorial-size, 6), minmax(0, 1fr));
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: rgba(15, 55, 72, 0.72);
  box-shadow:
    0 0 0 1px rgba(67, 232, 185, 0.18),
    0 16px 28px rgba(0, 0, 0, 0.16);
}

.tutorial-tile {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  border: 1px solid rgba(8, 77, 87, 0.5);
  background: linear-gradient(150deg, var(--tile-hidden) 0%, var(--tile-hidden) 34%, var(--tile-hidden-2) 100%);
  background-position: center;
  background-size: 100% 100%;
  color: var(--tile-text);
  font-size: clamp(1rem, 8vw, 1.65rem);
  font-weight: 950;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    filter 140ms ease,
    opacity 140ms ease;
}

.tutorial-board.is-focused .tutorial-tile:not(.is-context) {
  opacity: 0.58;
  filter: brightness(0.84) saturate(0.72);
}

.tutorial-tile.revealed {
  border-color: rgba(78, 101, 61, 0.2);
  background: linear-gradient(180deg, var(--tile-open), var(--tile-open-alt));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.74),
    inset 0 -1px 0 rgba(23, 32, 29, 0.14);
}

.tutorial-tile.flagged {
  border-color: rgba(142, 86, 24, 0.38);
  background: linear-gradient(150deg, #ffe17a, #ffb33f);
  color: #3d2b1e;
}

.tutorial-tile.flagged::before {
  position: absolute;
  top: 23%;
  left: 32%;
  display: block;
  width: 4px;
  height: 55%;
  content: "";
  border-radius: 999px;
  background: #6c5142;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

.tutorial-tile.flagged::after {
  position: absolute;
  top: 22%;
  left: 40%;
  display: block;
  width: 39%;
  height: 30%;
  content: "";
  border-radius: 3px 7px 7px 2px;
  background: linear-gradient(180deg, #ff6870, #de2846);
  clip-path: polygon(0 0, 100% 14%, 78% 52%, 100% 88%, 0 76%);
  box-shadow: 0 3px 6px rgba(145, 20, 38, 0.26);
}

.tutorial-tile.is-target,
.tutorial-flag-button.is-target,
.control-tutorial-controls .is-target {
  border-color: rgba(255, 222, 106, 0.95);
  outline: 3px solid rgba(255, 222, 106, 0.84);
  outline-offset: -5px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.5),
    0 0 0 3px rgba(255, 222, 106, 0.18),
    0 0 22px rgba(255, 190, 85, 0.6);
  transform: scale(0.96);
  animation: tutorial-target-pulse 1100ms ease-in-out infinite;
  z-index: 2;
}

.tutorial-tile.is-number-target {
  color: #135fef;
  filter: saturate(1.18);
}

.tutorial-tile.is-clue-number:not(.is-target) {
  box-shadow:
    inset 0 0 0 2px rgba(85, 205, 247, 0.58),
    0 0 14px rgba(85, 205, 247, 0.3);
  color: #135fef;
  filter: saturate(1.08);
  z-index: 1;
}

.tutorial-tile.is-neighbor:not(.is-target) {
  box-shadow:
    inset 0 0 0 2px rgba(85, 205, 247, 0.52),
    0 0 12px rgba(85, 205, 247, 0.26);
  z-index: 1;
}

.tutorial-tile.is-possible:not(.is-target) {
  border-color: rgba(85, 205, 247, 0.98);
  outline: 3px solid rgba(85, 205, 247, 0.88);
  outline-offset: -5px;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.28),
    0 0 0 3px rgba(85, 205, 247, 0.2),
    0 0 22px rgba(85, 205, 247, 0.55);
  animation: tutorial-possible-pulse 1250ms ease-in-out infinite;
  filter: brightness(1.12) saturate(1.12);
  z-index: 2;
}

.tutorial-tile.is-cleared {
  animation: tutorial-clear-pop 540ms ease both;
}

.tutorial-tile.number-1 {
  color: #1976e8;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.76);
}

.tutorial-tile.number-2 {
  color: #159447;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.72);
}

.tutorial-tile.number-3 {
  color: #d33a2c;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.68);
}

.tutorial-tile.number-4 {
  color: #7b3fe4;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.66);
}

.tutorial-tile.number-5 {
  color: #a64a2c;
}

.tutorial-tile.number-6 {
  color: #008697;
}

.tutorial-tile.number-7 {
  color: #242635;
}

.tutorial-tile.number-8 {
  color: #687482;
}

@keyframes tutorial-clear-pop {
  0% {
    transform: scale(0.86);
    filter: brightness(1.2);
  }
  55% {
    transform: scale(1.04);
    filter: brightness(1.08);
  }
  100% {
    transform: scale(1);
    filter: none;
  }
}

@keyframes tutorial-guide-shake {
  0%,
  100% {
    color: var(--ink);
    text-shadow: none;
    transform: translateX(0);
  }

  18% {
    transform: translateX(-5px);
  }

  36% {
    color: var(--warn);
    text-shadow: 0 0 14px rgba(255, 210, 87, 0.36);
    transform: translateX(5px);
  }

  54% {
    transform: translateX(-3px);
  }

  72% {
    transform: translateX(3px);
  }
}

@keyframes tutorial-target-pulse {
  0%,
  100% {
    filter: brightness(1) saturate(1.1);
  }

  50% {
    filter: brightness(1.16) saturate(1.25);
  }
}

@keyframes tutorial-possible-pulse {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.28),
      0 0 0 3px rgba(85, 205, 247, 0.2),
      0 0 18px rgba(85, 205, 247, 0.44);
  }

  50% {
    box-shadow:
      inset 0 0 0 2px rgba(255, 255, 255, 0.38),
      0 0 0 4px rgba(85, 205, 247, 0.32),
      0 0 28px rgba(85, 205, 247, 0.74);
  }
}

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

.tutorial-controls [hidden] {
  display: none;
}

#tutorialFlagButton[hidden] + #tutorialSkipButton {
  grid-column: 1 / -1;
}

.tutorial-controls .tutorial-finish-action {
  grid-column: 1 / -1;
}

.control-tutorial-controls .tutorial-finish-action {
  grid-column: 1 / -1;
}

.tutorial-next-button {
  min-height: 42px;
}

.difficulty-start-button {
  --risk-color: var(--accent);
  display: grid;
  grid-template-areas:
    "label meter"
    "detail meter";
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 14px;
  min-height: 58px;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 38, 47, 0.66);
  color: var(--ink);
  padding: 10px 13px;
  text-align: left;
  box-shadow: 0 8px 20px rgba(5, 27, 34, 0.13);
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    box-shadow 120ms ease;
}

.difficulty-meter {
  grid-area: meter;
  display: flex;
  width: 70px;
  height: 16px;
  align-self: center;
  align-items: end;
  gap: 4px;
}

.difficulty-meter i {
  display: block;
  height: 2px;
  flex: 1 1 0;
  border-radius: 1px;
  background: rgba(222, 241, 238, 0.18);
}

.difficulty-meter i.is-active {
  background: var(--risk-color);
}

.difficulty-start-button[data-risk-level="2"] {
  --risk-color: #49aeb3;
}

.difficulty-start-button[data-risk-level="3"] {
  --risk-color: #dfbd66;
}

.difficulty-start-button[data-risk-level="4"] {
  --risk-color: #e88952;
}

.difficulty-start-button[data-risk-level="5"] {
  --risk-color: #e86661;
}

.difficulty-start-button .difficulty-label,
.difficulty-start-button .difficulty-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.difficulty-start-button .difficulty-label {
  grid-area: label;
  font-family: var(--display-font);
  font-size: 0.96rem;
  font-weight: 750;
}

.difficulty-start-button .difficulty-detail {
  grid-area: detail;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
}

.difficulty-start-button:hover,
.difficulty-start-button:focus-visible {
  border-color: var(--risk-color);
  transform: translateY(-1px);
}

.difficulty-start-button.is-selected {
  border-color: rgba(85, 220, 195, 0.72);
  background: rgba(85, 220, 195, 0.09);
  box-shadow:
    inset 3px 0 0 var(--accent),
    0 9px 22px rgba(5, 27, 34, 0.16);
}

#modeContinueButton:not([hidden]) {
  border-color: rgba(85, 220, 195, 0.58);
  background: var(--primary-background);
  color: #082f34;
}

.mode-rule-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 69, 82, 0.74);
  padding: 11px;
}

.mode-rule-card h3,
.mode-rule-card p,
.mode-rule-card dl,
.mode-rule-card dd {
  margin: 0;
}

.mode-rule-card h3 {
  font-size: 0.94rem;
}

.mode-rule-card p {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.35;
}

.mode-rule-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mode-rule-card dl div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px;
}

.mode-rule-card dt {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-rule-card dd {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.hud-stat {
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--hud-background);
  padding: 9px 8px;
  box-shadow: 0 10px 24px rgba(5, 27, 34, 0.17);
}

.hud-stat span {
  color: var(--accent);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud-stat strong {
  overflow: hidden;
  font-family: var(--display-font);
  font-size: clamp(0.9rem, 4vw, 1.18rem);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-strip {
  display: grid;
  gap: 8px;
}

.run-strip[hidden] {
  display: none;
}

.run-strip > * {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.run-strip > [hidden] {
  display: none;
}

.timer-duration-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.timer-duration-button {
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 950;
}

.timer-duration-button.is-active {
  border-color: rgba(67, 232, 185, 0.62);
  background: var(--accent);
  color: #061310;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.14);
}

.timer-duration-button:focus-visible {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

select {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--ink);
  font-weight: 800;
  outline: 1px solid transparent;
  padding: 5px 6px;
}

.run-strip strong {
  font-size: 0.98rem;
}

.mission-strip {
  min-width: 0;
}

.mission-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.mission-item {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 69, 82, 0.72);
  padding: 7px;
}

.mission-item > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
}

.mission-item span,
.mission-item strong {
  overflow: hidden;
  font-size: 0.66rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mission-item span {
  color: var(--muted);
}

.mission-item.is-complete span,
.mission-item.is-complete strong {
  color: var(--accent);
}

.mission-item i {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.mission-item i::after {
  display: block;
  width: var(--mission-progress);
  height: 100%;
  content: "";
  border-radius: inherit;
  background: var(--accent);
}

.board-frame {
  position: relative;
  display: block;
  min-height: 0;
  padding: 6px 8px;
  overflow: hidden;
  /* The camera uses transforms; focus must not create a second, native camera. */
  overflow: clip;
  border: 1px solid rgba(85, 205, 247, 0.24);
  border-radius: 8px;
  background: var(--board-background);
  box-shadow:
    inset 0 0 34px rgba(255, 255, 255, 0.08),
    inset 0 -22px 48px rgba(22, 52, 85, 0.32),
    0 20px 42px rgba(14, 35, 54, 0.28);
  touch-action: none;
}

.board-frame.run-ended {
  animation: board-result-glow 820ms ease both;
}

.pb-notice {
  position: absolute;
  z-index: 20;
  top: 12px;
  right: 12px;
  left: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 226, 122, 0.78);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(37, 86, 100, 0.98), rgba(20, 56, 75, 0.98));
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(4, 25, 39, 0.42);
  animation: pb-notice-in 420ms cubic-bezier(0.18, 0.9, 0.3, 1.12) both;
}

.pb-notice[hidden] {
  display: none;
}

.pb-notice div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.pb-notice span {
  color: #ffe27a;
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pb-notice strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pb-notice button {
  flex: 0 0 auto;
  min-height: 36px;
  border: 1px solid rgba(67, 232, 185, 0.52);
  border-radius: 7px;
  background: var(--accent);
  color: #061310;
  font-weight: 950;
  padding: 7px 12px;
}

body[data-tile-finish="metal"] .board-frame {
  border-color: rgba(85, 205, 247, 0.24);
  background: linear-gradient(150deg, rgba(33, 56, 86, 0.98), rgba(19, 57, 69, 0.98) 58%, rgba(38, 36, 66, 0.98));
  box-shadow:
    inset 0 0 36px rgba(0, 0, 0, 0.32),
    0 20px 40px rgba(0, 0, 0, 0.24);
}

.board {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 0;
  touch-action: none;
  transform-origin: 0 0;
  user-select: none;
  will-change: transform;
}

.tile {
  position: relative;
  display: grid;
  width: var(--tile-size);
  height: var(--tile-size);
  place-items: center;
  border: 1px solid transparent;
  border-radius: max(2px, calc(var(--tile-size) * 0.045));
  font-size: calc(var(--tile-size) * 0.48);
  font-weight: 950;
  line-height: 1;
  outline: 0;
  image-rendering: auto;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    box-shadow 120ms ease;
}

.tile.hidden {
  border-color: rgba(7, 76, 86, 0.5);
  background: linear-gradient(150deg, var(--tile-hidden) 0%, var(--tile-hidden) 34%, var(--tile-hidden-2) 100%);
  background-position: center;
  background-size: 100% 100%;
  box-shadow:
    inset 0 1px 0 rgba(220, 255, 235, 0.2),
    inset 0 -1px 0 rgba(0, 65, 76, 0.2);
}

.tile.hidden:active {
  transform: scale(0.94);
}

.tile.origin.hidden::after {
  position: absolute;
  width: 8px;
  height: 8px;
  content: "";
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.78;
}

.tile.revealed {
  border-color: rgba(75, 96, 58, 0.18);
  border-radius: max(1px, calc(var(--tile-size) * 0.025));
  background: linear-gradient(180deg, var(--tile-open), var(--tile-open-alt));
  color: var(--tile-text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.64),
    inset 0 0 0 1px rgba(91, 116, 70, 0.06);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.58);
}

.tile:focus-visible {
  z-index: 4;
  outline: max(2px, calc(var(--tile-size) * 0.08)) solid #1da5b4;
  outline-offset: -2px;
}

.tile.flagged {
  border-color: rgba(142, 86, 24, 0.4);
  background: linear-gradient(150deg, #ffe17a, #ffb33f);
  background-position: center;
  background-size: 100% 100%;
  color: #3d2b1e;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 0 0 1px rgba(255, 210, 87, 0.38);
}

.tile.flagged::before {
  position: absolute;
  top: 23%;
  left: 32%;
  display: block;
  width: max(3px, calc(var(--tile-size) * 0.09));
  height: 55%;
  content: "";
  border-radius: 999px;
  background: #6c5142;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28);
}

.tile.flagged::after,
.tile.flagged.origin.hidden::after {
  position: absolute;
  top: 22%;
  left: 40%;
  display: block;
  width: 39%;
  height: 30%;
  content: "";
  border-radius: 3px 7px 7px 2px;
  background: linear-gradient(180deg, #ff6870, #de2846);
  clip-path: polygon(0 0, 100% 14%, 78% 52%, 100% 88%, 0 76%);
  box-shadow: 0 3px 6px rgba(145, 20, 38, 0.26);
}

.tile.pending {
  box-shadow:
    inset 0 0 0 2px var(--warn),
    0 0 0 2px rgba(255, 190, 85, 0.22);
}

.tile.touch-preview {
  box-shadow:
    inset 0 0 0 2px var(--accent),
    0 0 0 2px rgba(50, 209, 162, 0.24);
  transform: scale(0.94);
}

.tile.flag-preview {
  box-shadow:
    inset 0 0 0 2px var(--warn),
    0 0 0 2px rgba(255, 190, 85, 0.34);
}

.tile.mine {
  border-color: rgba(113, 24, 42, 0.44);
  background: linear-gradient(150deg, #ff8b78, #d74467);
  color: #fff4ef;
}

.tile.mine::before {
  position: absolute;
  z-index: 1;
  display: block;
  width: 42%;
  height: 42%;
  content: "";
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.38), transparent 17%),
    #2d2631;
  box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.24);
}

.tile.mine::after {
  position: absolute;
  z-index: 0;
  display: block;
  width: 68%;
  height: 68%;
  content: "";
  background:
    linear-gradient(0deg, transparent 46%, #2d2631 47% 53%, transparent 54%),
    linear-gradient(90deg, transparent 46%, #2d2631 47% 53%, transparent 54%),
    linear-gradient(45deg, transparent 47%, #2d2631 48% 52%, transparent 53%),
    linear-gradient(-45deg, transparent 47%, #2d2631 48% 52%, transparent 53%);
}

.tile.correct-flag {
  border-color: rgba(10, 111, 69, 0.46);
  background: linear-gradient(150deg, #a6ff91, #2fd382);
  color: transparent;
  box-shadow:
    inset 0 0 0 1px rgba(208, 255, 228, 0.66),
    0 0 0 1px rgba(72, 214, 170, 0.32),
    0 0 12px rgba(72, 214, 170, 0.28);
}

.tile.correct-flag::before {
  position: absolute;
  top: 23%;
  left: 32%;
  display: block;
  width: max(3px, calc(var(--tile-size) * 0.09));
  height: 55%;
  content: "";
  border-radius: 999px;
  background: #315948;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.32);
}

.tile.correct-flag::after {
  position: absolute;
  top: 22%;
  left: 40%;
  display: block;
  width: 39%;
  height: 30%;
  content: "";
  border-radius: 3px 7px 7px 2px;
  background: linear-gradient(180deg, #fff5bd, #ffd057);
  clip-path: polygon(0 0, 100% 14%, 78% 52%, 100% 88%, 0 76%);
  box-shadow: 0 3px 6px rgba(30, 89, 61, 0.24);
}

.tile.exploded {
  animation: blast 520ms ease both;
  background:
    radial-gradient(circle, #fff7c7 0 18%, #ffbe55 19% 42%, #ef5f5f 43% 70%, #331516 71%);
  color: #1a0c0c;
}

.tile.wrong-flag {
  color: #fff;
  border-color: rgba(123, 26, 46, 0.42);
  background: linear-gradient(150deg, #ffb7ad, #e65370);
}

.tile.wrong-flag::before,
.tile.wrong-flag::after {
  position: absolute;
  display: block;
  width: 54%;
  height: max(4px, calc(var(--tile-size) * 0.11));
  content: "";
  border-radius: 999px;
  background: #fff4ef;
  box-shadow: 0 0 8px rgba(239, 95, 95, 0.36);
}

.tile.wrong-flag::before {
  transform: rotate(45deg);
}

.tile.wrong-flag::after {
  transform: rotate(-45deg);
}

.tile.just-revealed {
  z-index: 2;
  animation: tile-reveal 340ms cubic-bezier(0.2, 0.82, 0.26, 1) both;
  animation-delay: var(--tile-effect-delay, 0ms);
}

.tile.just-flagged {
  z-index: 3;
  animation: flag-set 300ms cubic-bezier(0.18, 0.9, 0.3, 1.2) both;
  animation-delay: var(--tile-effect-delay, 0ms);
}

.tile.just-unflagged {
  animation: flag-lift 240ms ease both;
}

.tile.just-verified {
  z-index: 3;
  animation: verified-pop 440ms cubic-bezier(0.18, 0.9, 0.3, 1.2) both;
  animation-delay: var(--tile-effect-delay, 0ms);
}

.tile.just-wrong {
  z-index: 3;
  animation: wrong-shake 420ms ease both;
  animation-delay: var(--tile-effect-delay, 0ms);
}

.tile.exploded.just-exploded {
  z-index: 4;
  animation: mine-hit 560ms ease both;
}

.tile.mine.just-revealed-mine {
  z-index: 2;
  animation: mine-reveal 480ms cubic-bezier(0.18, 0.8, 0.3, 1.12) both;
  animation-delay: var(--tile-effect-delay, 0ms);
}

body[data-tile-finish="metal"] .tile.hidden {
  background:
    linear-gradient(160deg, rgba(67, 232, 185, 0.13), rgba(11, 31, 27, 0.42)),
    url("./assets/button-art/hidden-tile.png"),
    linear-gradient(160deg, #25473c, #18342e);
  background-position: center;
  background-size: 100% 100%;
  background-blend-mode: color, normal, normal;
}

body[data-tile-finish="metal"] .tile.flagged {
  background:
    url("./assets/button-art/flag-tile.png"),
    linear-gradient(180deg, #fff7e8, #dce8d8);
  background-position: center;
  background-size: 100% 100%;
  color: transparent;
}

body[data-tile-finish="metal"] .tile.flagged::before,
body[data-tile-finish="metal"] .tile.flagged::after,
body[data-tile-finish="metal"] .tile.flagged.origin.hidden::after {
  display: none;
}

body[data-tile-finish="metal"] .tile.mine {
  background:
    url("./assets/button-art/mine.png"),
    linear-gradient(180deg, #ff7d70, #82262a);
  background-position: center;
  background-size: 100% 100%;
  color: transparent;
}

body[data-tile-finish="metal"] .tile.mine::before,
body[data-tile-finish="metal"] .tile.mine::after {
  display: none;
}

body[data-tile-finish="metal"] .tile.correct-flag {
  background:
    url("./assets/button-art/correct-flag.png"),
    linear-gradient(180deg, #c8ffb9, #52d956);
  background-position: center;
  background-size: 100% 100%;
  color: transparent;
}

body[data-tile-finish="metal"] .tile.correct-flag::before,
body[data-tile-finish="metal"] .tile.correct-flag::after {
  display: none;
}

body[data-tile-finish="metal"] .tile.wrong-flag {
  background:
    url("./assets/button-art/wrong-flag.png"),
    linear-gradient(180deg, #ffe3e0, #e86b6b);
  background-position: center;
  background-size: 100% 100%;
  color: transparent;
}

body[data-tile-finish="metal"] .tile.wrong-flag::before,
body[data-tile-finish="metal"] .tile.wrong-flag::after {
  display: none;
}

.tile.revealed.number-1 {
  color: #1976e8;
}

.tile.revealed.number-2 {
  color: #1d944d;
}

.tile.revealed.number-3 {
  color: #df3f36;
}

.tile.revealed.number-4 {
  color: #7057db;
}

.tile.revealed.number-5 {
  color: #b45a26;
}

.tile.revealed.number-6 {
  color: #008d95;
}

.tile.revealed.number-7 {
  color: #2e3038;
}

.tile.revealed.number-8 {
  color: #697584;
}

body.high-contrast-numbers .tile.revealed,
body.high-contrast-numbers .tutorial-tile.revealed {
  font-weight: 1000;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.95),
    0 0 1px rgba(13, 23, 33, 0.72);
}

body.high-contrast-numbers .tile.revealed.number-1,
body.high-contrast-numbers .tutorial-tile.number-1 {
  color: #0049b8;
}

body.high-contrast-numbers .tile.revealed.number-2,
body.high-contrast-numbers .tutorial-tile.number-2 {
  color: #006b3c;
}

body.high-contrast-numbers .tile.revealed.number-3,
body.high-contrast-numbers .tutorial-tile.number-3 {
  color: #c51a2e;
}

body.high-contrast-numbers .tile.revealed.number-4,
body.high-contrast-numbers .tutorial-tile.number-4 {
  color: #5b36b5;
}

body.high-contrast-numbers .tile.revealed.number-5,
body.high-contrast-numbers .tutorial-tile.number-5 {
  color: #783b00;
}

body.high-contrast-numbers .tile.revealed.number-6,
body.high-contrast-numbers .tutorial-tile.number-6 {
  color: #00636d;
}

body.high-contrast-numbers .tile.revealed.number-7,
body.high-contrast-numbers .tutorial-tile.number-7 {
  color: #111827;
}

body.high-contrast-numbers .tile.revealed.number-8,
body.high-contrast-numbers .tutorial-tile.number-8 {
  color: #4b5563;
}

.control-dock {
  display: grid;
  grid-template-columns: minmax(76px, 1.1fr) minmax(76px, 1.1fr) repeat(3, minmax(70px, 0.8fr));
  gap: 8px;
  align-items: stretch;
}

.control-dock [hidden] {
  display: none;
}

.control-dock.is-reviewing {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.control-dock.is-reviewing #endRetryButton,
.control-dock.is-reviewing #summaryButton {
  grid-column: span 3;
}

.control-dock.is-reviewing #endMenuButton,
.control-dock.is-reviewing #endDifficultyButton,
.control-dock.is-reviewing #endLeaderboardButton {
  grid-column: span 2;
}

#endRetryButton {
  order: 1;
}

#summaryButton {
  order: 2;
}

#endMenuButton {
  order: 3;
}

#endDifficultyButton {
  order: 4;
}

#endLeaderboardButton {
  order: 5;
}

.control-button,
.d-pad button,
.primary-action,
.secondary-action {
  border: 1px solid rgba(230, 249, 248, 0.22);
  border-radius: 8px;
  background: var(--control-background);
  color: var(--ink);
  font-weight: 740;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 7px 18px rgba(5, 27, 34, 0.18);
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background 120ms ease;
}

.control-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  font-family: var(--display-font);
}

.control-button:active:not(:disabled),
.primary-action:active:not(:disabled),
.secondary-action:active:not(:disabled) {
  transform: scale(0.985);
}

.control-button.is-active {
  border-color: rgba(85, 220, 195, 0.7);
  background: var(--primary-background);
  color: #082f34;
}

.small-control {
  gap: 6px;
  font-size: 0.82rem;
}

.control-icon {
  display: block;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.control-icon-flag {
  color: #ff737c;
}

.control-button.is-active .control-icon-flag {
  color: #a52f43;
}

.control-icon-location {
  color: #7be6da;
}

.d-pad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 22px);
  gap: 2px;
}

.d-pad button {
  min-width: 34px;
  min-height: 22px;
  padding: 0;
}

#panUp {
  grid-area: up;
}

#panLeft {
  grid-area: left;
}

#panRight {
  grid-area: right;
}

#panDown {
  grid-area: down;
}

.progress-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.leaderboard-screen-grid {
  grid-template-columns: 1fr;
}

.leaderboard-screen-grid > * {
  min-height: 0;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  padding: 12px 2px;
}

.leaderboard-screen-grid > :first-child {
  border-top: 0;
  padding-top: 0;
}

.leaderboard-panel,
.leaderboard-filter-panel,
.history-panel,
.stats-panel,
.achievement-panel,
.store-panel {
  min-height: 86px;
  padding: 9px;
}

.leaderboard-panel h2,
.history-panel h2,
.stats-panel h2,
.achievement-panel h2,
.store-panel h2 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.leaderboard-filter-panel[hidden],
.leaderboard-filter-panel label[hidden] {
  display: none;
}

.leaderboard-filter-panel label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.leaderboard-filter-panel span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-filter-panel select:disabled {
  color: var(--muted);
  opacity: 1;
}

.panel-subtitle {
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
}

.leaderboard-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
}

.leaderboard-controls[hidden] {
  display: none;
}

.leaderboard-view {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 950;
}

.leaderboard-view.is-active {
  background: var(--accent-strong);
  color: #061310;
}

.leaderboard-archive-field {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.leaderboard-archive-field[hidden] {
  display: none;
}

.leaderboard-archive-field span {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.leaderboard-panel ol,
.history-panel ol {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-panel li,
.history-panel li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.leaderboard-copy,
.leaderboard-panel li span,
.history-panel li span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-copy {
  display: grid;
  gap: 2px;
}

.leaderboard-copy small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-panel li strong,
.history-panel li strong {
  color: var(--ink);
  flex: 0 0 auto;
}

.history-panel button {
  flex: 0 0 auto;
  border: 1px solid rgba(72, 214, 170, 0.28);
  border-radius: 6px;
  background: rgba(72, 214, 170, 0.1);
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 900;
  padding: 3px 6px;
}

.stats-panel dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  margin: 0;
}

.stats-panel dt,
.stats-panel dd {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 800;
}

.stats-panel dt {
  color: var(--muted);
}

.stats-panel dd {
  color: var(--ink);
}

.unlock-summary div {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.achievement-screen-panel {
  min-height: 160px;
}

.achievement-list {
  display: grid;
  gap: 8px;
}

.achievement-item {
  display: grid;
  grid-template-areas:
    "title state"
    "detail state";
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 9px;
}

.achievement-item strong,
.achievement-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.achievement-item strong {
  grid-area: title;
  color: var(--ink);
  font-size: 0.78rem;
}

.achievement-item span {
  grid-area: detail;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.35;
}

.achievement-item em {
  grid-area: state;
  align-self: center;
  border: 1px solid rgba(72, 214, 170, 0.28);
  border-radius: 6px;
  color: var(--accent);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 950;
  padding: 4px 6px;
  text-transform: uppercase;
}

.achievement-item.is-locked {
  opacity: 0.82;
}

.achievement-item.is-locked em {
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

.store-panel {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

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

.store-status-card {
  display: grid;
  gap: 4px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.store-status-card span,
.cosmetic-item em {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.store-status-card strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.store-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin-top: 10px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  padding: 14px 0 0;
}

.premium-section,
.earn-section {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.store-section h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.86rem;
}

.store-section p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.35;
}

.store-section .compact-action {
  min-width: 112px;
  min-height: 40px;
}

.store-section .compact-action:disabled {
  opacity: 0.68;
}

.cosmetic-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.cosmetic-preview {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  background: linear-gradient(145deg, #58d7a0, #1da5b4);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.34),
    inset 0 -3px 0 rgba(0, 45, 55, 0.18);
}

.cosmetic-item[data-cosmetic-finish="moss"] .cosmetic-preview {
  background: linear-gradient(145deg, #4f7159, #253d31);
}

.cosmetic-item[data-cosmetic-finish="copper"] .cosmetic-preview {
  background: linear-gradient(145deg, #93684d, #49352b);
}

.cosmetic-item[data-cosmetic-finish="glacier"] .cosmetic-preview {
  background: linear-gradient(145deg, #7bc8d8, #315969);
}

.cosmetic-item[data-cosmetic-finish="metal"] .cosmetic-preview {
  background: linear-gradient(145deg, #aebdba, #526866);
}

.cosmetic-item.is-selected {
  border-color: rgba(72, 214, 170, 0.5);
  background: rgba(72, 214, 170, 0.1);
}

.cosmetic-item > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.cosmetic-item strong,
.cosmetic-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cosmetic-item strong {
  font-size: 0.82rem;
}

.cosmetic-item span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.cosmetic-item button {
  min-width: 82px;
  min-height: 36px;
  border: 1px solid rgba(72, 214, 170, 0.28);
  border-radius: 8px;
  background: rgba(72, 214, 170, 0.1);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 950;
  padding: 0 10px;
}

.cosmetic-item button:disabled {
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.unlock-summary div span {
  border: 1px solid rgba(72, 214, 170, 0.28);
  border-radius: 6px;
  background: rgba(72, 214, 170, 0.1);
  color: var(--accent);
  padding: 3px 6px;
}

.seed-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
}

.seed-strip strong {
  min-width: 0;
  overflow: hidden;
  color: var(--accent);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-overlay,
.reset-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(4, 7, 6, 0.58);
  backdrop-filter: blur(10px);
}

.mode-help-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(4, 7, 6, 0.56);
  backdrop-filter: blur(10px);
}

.tutorial-invite-overlay {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: max(18px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: rgba(4, 7, 6, 0.62);
  backdrop-filter: blur(10px);
}

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 7, 6, 0.52);
  backdrop-filter: blur(10px);
}

.settings-overlay[hidden] {
  display: none;
}

.run-overlay[hidden],
.reset-confirm-overlay[hidden] {
  display: none;
}

.mode-help-overlay[hidden] {
  display: none;
}

.tutorial-invite-overlay[hidden] {
  display: none;
}

.run-dialog,
.settings-dialog,
.mode-help-dialog,
.tutorial-invite-dialog,
.reset-confirm-dialog {
  width: min(420px, 100%);
  flex: 0 0 auto;
  margin: auto 0;
  border: 1px solid var(--line);
  border-top: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--popover-background);
  padding: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.46);
}

.run-dialog:focus,
.mode-help-dialog:focus,
.tutorial-invite-dialog:focus,
.reset-confirm-dialog:focus {
  outline: none;
}

.reset-confirm-dialog p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.4;
}

.reset-confirm-dialog .dialog-actions {
  margin-top: 18px;
}

.dialog-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tutorial-invite-dialog h2 {
  margin-bottom: 8px;
}

.tutorial-invite-dialog p {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 760;
  line-height: 1.45;
}

.tutorial-invite-actions {
  margin-top: 18px;
}

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

.mode-help-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-help-dialog h2 {
  font-size: 1.08rem;
}

.mode-help-copy {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mode-help-dialog p {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.4;
}

.settings-grid {
  display: grid;
  gap: 18px;
  margin-top: 2px;
}

.settings-section {
  display: grid;
  gap: 0;
}

.settings-section h3 {
  margin: 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  padding: 0 2px 7px;
  text-transform: uppercase;
}

.settings-grid label {
  display: grid;
  gap: 5px;
  min-height: 54px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 0;
  background: transparent;
  padding: 10px 2px;
}

.settings-grid label > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-grid input[type="text"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  padding: 10px;
}

.audio-settings-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 7px; }
.audio-settings-heading h3 { border: 0; padding: 0 2px; letter-spacing: 0; }
.audio-mute-button { width: 108px; min-width: 108px; min-height: 44px; padding: 6px 10px; }
.audio-mute-button[aria-pressed="true"] { color: var(--warn); border-color: currentColor; }
.audio-speaker-muted, .audio-mute-button[aria-pressed="true"] .audio-speaker-waves { display: none; }
.audio-mute-button[aria-pressed="true"] .audio-speaker-muted { display: block; }
.settings-grid .audio-volume-row { grid-template-columns: minmax(0, 1fr) 4ch; gap: 0 12px; padding: 8px 2px 2px; }
.settings-grid .audio-volume-row > span { align-self: center; letter-spacing: 0; text-transform: none; font-size: .85rem; }
.audio-volume-row output { text-align: right; font-size: .8rem; font-variant-numeric: tabular-nums; }
.audio-volume-row input[type="range"] { grid-column: 1 / -1; width: 100%; min-width: 0; height: 44px; margin: 0; padding: 0; cursor: pointer; accent-color: var(--accent); touch-action: pan-y; }
.audio-volume-row input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.toggle-row input {
  position: relative;
  width: 46px;
  height: 28px;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(6, 24, 31, 0.44);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.toggle-row input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  content: "";
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 140ms ease, background-color 140ms ease;
}

.toggle-row input:checked {
  border-color: rgba(67, 232, 185, 0.72);
  background: var(--accent-strong);
}

.toggle-row input:checked::after {
  background: #fffdf4;
  transform: translateX(18px);
}

.toggle-row input:focus-visible {
  outline: 2px solid var(--warn);
  outline-offset: 2px;
}

.settings-build {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 48px;
  border-top: 1px solid var(--line);
  padding: 10px 2px;
}

.settings-build span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.settings-build strong {
  color: var(--accent);
  font-size: 0.98rem;
}

.run-dialog h2 {
  font-size: 1.05rem;
}

.summary-mode {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.share-preview {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: contain;
}

.share-card-details { margin-top: 16px; border-top: 1px solid var(--line); }
.share-card-details summary { padding: 14px 0; cursor: pointer; font-size: 14px; font-weight: 600; }
.share-card-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.achievement-item { grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "badge title state" "badge detail state"; align-items: center; }
.achievement-badge { grid-area: badge; width: 52px; height: 52px; color: #356c67; }
.achievement-badge circle { fill: #f2ddb0; stroke: #bd9562; stroke-width: 2; }
.achievement-badge use { fill: none; stroke: currentColor; stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.is-locked .achievement-badge { filter: grayscale(1); opacity: .6; }
.cosmetic-board-preview {
  --tile-size: 26px;
  display: grid;
  grid-template-columns: repeat(3, var(--tile-size));
  grid-template-rows: repeat(3, var(--tile-size));
  width: 78px; height: 78px;
  border: 0; border-radius: 3px; background: none !important; box-shadow: none;
  overflow: hidden; pointer-events: none;
}
.cosmetic-item[data-cosmetic-finish="classic"] { --tile-hidden: #58d7a0; --tile-hidden-2: #1da5b4; }
.cosmetic-item[data-cosmetic-finish="moss"] { --tile-hidden: #31483a; --tile-hidden-2: #1f3229; }
.cosmetic-item[data-cosmetic-finish="copper"] { --tile-hidden: #4a392d; --tile-hidden-2: #2d2822; }
.cosmetic-item[data-cosmetic-finish="glacier"] { --tile-hidden: #253c45; --tile-hidden-2: #172b34; }
.cosmetic-item[data-cosmetic-finish="metal"] .tile.hidden { background: url("./assets/button-art/hidden-tile.png") center / cover; }
@media (max-width: 420px) {
  .cosmetic-item { grid-template-columns: 78px minmax(0, 1fr); gap: 8px 12px; }
  .cosmetic-item .cosmetic-preview { grid-row: span 2; }
  .cosmetic-item button { grid-column: 2; justify-self: stretch; min-height: 44px; }
  .achievement-item { grid-template-columns: 48px minmax(0, 1fr); grid-template-areas: "badge title" "badge detail" "badge state"; }
  .achievement-item em { justify-self: start; padding: 2px 0; border: 0; }
  .achievement-badge { width: 48px; height: 48px; }
}

.summary-score {
  display: grid;
  gap: 2px;
  margin: 16px 0;
}

.summary-score span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-score strong {
  color: var(--accent);
  font-size: 2.4rem;
  line-height: 1;
}

.run-overlay:not([hidden]) .summary-score {
  animation: result-score-pop 480ms cubic-bezier(0.18, 0.9, 0.3, 1.18) both;
}

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

.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px;
}

.summary-grid dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-grid dd {
  margin: 2px 0 0;
  font-size: 1.16rem;
  font-weight: 900;
}

.unlock-summary {
  display: grid;
  gap: 6px;
  margin-top: 14px;
}

.unlock-summary > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pb-comment-panel {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.pb-comment-panel[hidden] {
  display: none;
}

.pb-comment-panel label,
.pb-comment-actions span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pb-comment-panel textarea {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 750;
  line-height: 1.35;
  padding: 10px;
}

.pb-comment-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}

.primary-action,
.secondary-action {
  min-height: 46px;
}

.primary-action {
  border-color: rgba(85, 220, 195, 0.58);
  background: var(--primary-background);
  color: #082f34;
  font-family: var(--display-font);
}

@keyframes blast {
  0% {
    transform: scale(0.92);
  }
  45% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tile-reveal {
  0% {
    opacity: 0.35;
    transform: scale(0.78);
  }
  62% {
    opacity: 1;
    transform: scale(1.04);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes flag-set {
  0% {
    transform: translateY(-16%) scale(0.78);
    filter: brightness(1.18);
  }
  58% {
    transform: translateY(2%) scale(1.08);
  }
  100% {
    transform: translateY(0) scale(1);
    filter: none;
  }
}

@keyframes flag-lift {
  0% {
    transform: scale(0.88);
    filter: brightness(1.16);
  }
  100% {
    transform: scale(1);
    filter: none;
  }
}

@keyframes verified-pop {
  0% {
    transform: scale(0.82);
    filter: brightness(1.22) saturate(1.18);
  }
  60% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
    filter: none;
  }
}

@keyframes wrong-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  22% {
    transform: translateX(-12%);
  }
  44% {
    transform: translateX(10%);
  }
  66% {
    transform: translateX(-6%);
  }
  82% {
    transform: translateX(4%);
  }
}

@keyframes mine-hit {
  0% {
    transform: scale(0.84) rotate(-3deg);
    filter: brightness(1.2);
  }
  38% {
    transform: scale(1.22) rotate(3deg);
  }
  68% {
    transform: scale(0.96) rotate(-1deg);
  }
  100% {
    transform: scale(1) rotate(0);
    filter: none;
  }
}

@keyframes mine-reveal {
  0% {
    opacity: 0;
    transform: scale(0.72);
    filter: brightness(1.3);
  }
  58% {
    opacity: 1;
    transform: scale(1.09);
  }
  100% {
    opacity: 1;
    transform: scale(1);
    filter: none;
  }
}

@keyframes board-result-glow {
  0%,
  100% {
    border-color: rgba(85, 205, 247, 0.24);
  }
  45% {
    border-color: rgba(255, 226, 122, 0.82);
    box-shadow:
      inset 0 0 34px rgba(255, 255, 255, 0.1),
      0 0 0 3px rgba(255, 203, 87, 0.16),
      0 20px 42px rgba(14, 35, 54, 0.28);
  }
}

@keyframes pb-notice-in {
  0% {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes result-score-pop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  70% {
    opacity: 1;
    transform: translateY(-2px) scale(1.04);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (min-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell {
    width: min(560px, 100%);
    margin: 0 auto;
  }
}

@media (max-width: 520px) {
  .top-bar {
    gap: 8px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  h1 {
    max-width: calc(100vw - 118px);
  }

  .top-actions {
    gap: 5px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }

  .game-hud {
    gap: 6px;
  }

  .hud-stat {
    padding-inline: 6px;
  }

  .control-dock {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  #flagModeButton,
  #resetRunButton {
    grid-column: span 2;
  }

  #zoomLockButton,
  #lastFlagButton {
    grid-column: span 1;
  }

  #centerButton {
    grid-column: span 2;
  }

  .mode-list {
    grid-template-columns: 1fr;
  }

  .run-strip {
    grid-template-columns: 1fr;
  }

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

  .menu-actions .primary-action {
    grid-column: auto;
  }

  .mission-list {
    grid-template-columns: 1fr;
  }

  .progress-strip {
    grid-template-columns: 1fr;
  }

  .premium-section,
  .earn-section {
    grid-template-columns: 1fr;
  }

  .store-section .compact-action {
    width: 100%;
  }

  .control-button,
  .d-pad button {
    min-height: 42px;
  }

  .small-control {
    gap: 5px;
    min-height: 42px;
    font-size: 0.78rem;
  }

  .control-icon {
    width: 20px;
    height: 20px;
  }
}

@media (max-height: 740px) and (max-width: 520px) {
  .control-tutorial-viewport {
    height: clamp(280px, 43vh, 320px);
  }
}

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

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.01ms !important;
}
