:root {
  --ink: #1b1430;
  --ink-2: #120d23;
  --ink-3: #0d0918;
  --coral: #ff5a4e;
  --coral-dark: #b63838;
  --gold: #ffc247;
  --gold-dark: #a96717;
  --aqua: #3fe0c5;
  --cream: #fff3dc;
  --muted: #b8acc9;
  --line: rgba(255, 255, 255, 0.1);
  --font-display: "Arial Black", "Arial Bold", Impact, "DejaVu Sans", sans-serif;
  --font-body: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-mono: "DejaVu Sans Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--cream);
  font-family: var(--font-body);
  background:
    radial-gradient(ellipse at 12% -12%, rgba(255, 90, 78, 0.3), transparent 44%),
    radial-gradient(ellipse at 88% 0%, rgba(63, 224, 197, 0.15), transparent 38%),
    radial-gradient(ellipse at 50% 120%, rgba(255, 194, 71, 0.16), transparent 52%),
    linear-gradient(160deg, #271b46 0%, #150f29 42%, #0d0918 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse at 50% 30%, black, transparent 75%);
}

a {
  color: var(--aqua);
}

button,
input {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.page-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.page-glow::before {
  content: "";
  position: absolute;
  width: 74vmax;
  height: 74vmax;
  right: -18vmax;
  top: -38vmax;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 194, 71, 0.22), rgba(255, 90, 78, 0.1) 42%, transparent 68%);
  filter: blur(8px);
}

.page-glow::after {
  content: "";
  position: absolute;
  left: -10vw;
  right: -10vw;
  bottom: -28vh;
  height: 46vh;
  transform: rotate(-7deg);
  background:
    repeating-linear-gradient(90deg, rgba(255, 243, 220, 0.08) 0 2px, transparent 2px 86px),
    linear-gradient(180deg, rgba(255, 194, 71, 0.12), transparent 70%);
  mask-image: linear-gradient(180deg, transparent, black 30%, transparent);
}

/* Header ------------------------------------------------------------------ */

.site-header {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 56px) 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--cream);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.35));
  flex: none;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.055em;
  line-height: 1;
  white-space: nowrap;
}

.brand-title b {
  color: var(--gold);
  font-weight: 900;
}

.brand-sub {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.text-button,
.footer-link {
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.055);
  color: var(--cream);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.icon-button:hover {
  border-color: rgba(63, 224, 197, 0.55);
  background: rgba(63, 224, 197, 0.08);
  transform: translateY(-1px);
}

.icon-button .icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sound path:first-child,
.icon-muted path:first-child {
  fill: currentColor;
  stroke: none;
}

.icon-muted {
  display: none;
}

body.is-muted .icon-sound {
  display: none;
}

body.is-muted .icon-muted {
  display: block;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 8px 4px;
}

.text-button:hover {
  color: var(--cream);
}

/* Page and game shell ----------------------------------------------------- */

.page {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0 clamp(18px, 4vw, 56px) 30px;
}

.game-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1000 / 600;
  border-radius: 28px;
  background: var(--ink-3);
  box-shadow:
    0 42px 100px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 194, 71, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  isolation: isolate;
}

.stage-frame {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
}

.game-view {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #070b14;
}

.xmoto {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100% !important;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(63, 224, 197, 0.08), transparent 45%),
    #0b1020;
  touch-action: none;
}

.xmoto > canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#xmoto-debug {
  display: none !important;
}

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

.menu {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  grid-template-rows: minmax(0, 1fr);
  gap: clamp(14px, 2vw, 26px);
  padding: clamp(14px, 2.2vw, 30px);
  overflow: auto;
  background:
    radial-gradient(ellipse at 14% 4%, rgba(255, 90, 78, 0.17), transparent 38%),
    radial-gradient(ellipse at 78% 0%, rgba(63, 224, 197, 0.1), transparent 34%),
    linear-gradient(120deg, rgba(16, 11, 31, 0.985), rgba(13, 9, 24, 0.97));
  backdrop-filter: blur(8px);
  animation: menuIn 0.24s ease both;
}

@keyframes menuIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.menu-hero,
.level-browser {
  position: relative;
  min-height: 0;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.016));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.menu-hero {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(22px, 3.4vw, 46px);
  overflow: hidden;
  background:
    radial-gradient(circle at 86% 20%, rgba(255, 194, 71, 0.16), transparent 36%),
    radial-gradient(circle at 10% 100%, rgba(255, 90, 78, 0.14), transparent 42%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.075), rgba(255, 255, 255, 0.015));
}

.hero-floats {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  border-radius: inherit;
}

.hero-floats::after {
  content: "";
  position: absolute;
  left: -12%;
  right: -12%;
  bottom: -34%;
  height: 58%;
  transform: rotate(-8deg);
  border-top: 2px solid rgba(255, 194, 71, 0.28);
  background:
    repeating-linear-gradient(90deg, rgba(255, 243, 220, 0.08) 0 2px, transparent 2px 46px),
    linear-gradient(180deg, rgba(255, 194, 71, 0.08), transparent 70%);
}

.float-gear {
  position: absolute;
  width: clamp(76px, 10vw, 138px);
  top: 1%;
  right: 3%;
  opacity: 0.78;
  filter: drop-shadow(0 16px 26px rgba(0, 0, 0, 0.5));
  animation: spinGear 24s linear infinite;
}

@keyframes spinGear {
  to { transform: rotate(360deg); }
}

.eyebrow {
  display: block;
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

.hero-title {
  position: relative;
  z-index: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(46px, 5.8vw, 86px);
  line-height: 0.86;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
}

.hero-line {
  display: block;
}

.hero-accent {
  color: var(--coral);
}

.hero-lead {
  position: relative;
  z-index: 1;
  max-width: 46ch;
  margin: 15px 0 0;
  color: #d8cee5;
  font-size: clamp(12px, 1.05vw, 15px);
  line-height: 1.5;
}

.hero-actions {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 20px 0 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 13px 20px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background 0.16s ease;
}

.button svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.button.primary {
  background: var(--coral);
  color: var(--ink-3);
  box-shadow: 0 7px 0 var(--coral-dark), 0 12px 26px rgba(255, 90, 78, 0.22);
}

.button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 0 var(--coral-dark), 0 16px 30px rgba(255, 90, 78, 0.26);
}

.button.primary:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 var(--coral-dark);
}

.button.ghost {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--cream);
}

.button.ghost:hover {
  border-color: rgba(63, 224, 197, 0.55);
  background: rgba(63, 224, 197, 0.09);
}

.button.big {
  padding: 16px 26px;
  font-size: 15px;
}

.button:disabled {
  opacity: 0.38;
  pointer-events: none;
}

.hero-stats {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
  padding-top: 17px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.hero-stats b {
  display: block;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: clamp(20px, 2.2vw, 30px);
  line-height: 1;
}

.hero-stats span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.controls-card {
  position: relative;
  z-index: 1;
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.22);
}

.controls-card .eyebrow {
  margin-bottom: 8px;
  color: var(--muted);
}

.key-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.key-row.muted {
  margin-top: 8px;
  opacity: 0.78;
}

.key-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #cfc4dd;
  font-size: 11px;
}

kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  margin-right: 3px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, #3a2f55, #221a38);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 10px;
}

/* Level browser ----------------------------------------------------------- */

.level-browser {
  display: flex;
  flex-direction: column;
  padding: clamp(18px, 2.4vw, 30px);
  overflow: hidden;
}

.browser-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.browser-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(24px, 2.6vw, 34px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.browser-note {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-align: right;
  text-transform: uppercase;
}

.level-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 5px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 194, 71, 0.35) transparent;
}

.level-scroll::-webkit-scrollbar {
  width: 7px;
}

.level-scroll::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: rgba(255, 194, 71, 0.32);
}

.level-category {
  margin-bottom: 18px;
}

.category-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.category-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, rgba(255, 194, 71, 0.28), transparent);
}

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

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 76px;
  padding: 11px 12px 10px;
  text-align: left;
  color: var(--cream);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.level-card:hover {
  transform: translateY(-1px);
  border-color: rgba(63, 224, 197, 0.5);
  background: rgba(63, 224, 197, 0.07);
}

.level-card.is-selected {
  border-color: rgba(255, 194, 71, 0.75);
  background: rgba(255, 194, 71, 0.09);
  box-shadow: inset 0 0 0 1px rgba(255, 194, 71, 0.2);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1.2;
  letter-spacing: 0.015em;
}

.card-best {
  flex: none;
  color: var(--aqua);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.02em;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  min-width: 0;
}

.card-gears {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  color: var(--gold);
  font-family: var(--font-mono);
  letter-spacing: 0;
}

.card-gears img {
  width: 14px;
  height: 14px;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.4));
}

.card-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* In-game HUD ------------------------------------------------------------- */

.chrono {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  min-width: 92px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 194, 71, 0.42);
  background: rgba(13, 9, 24, 0.72);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: clamp(18px, 2vw, 26px);
  line-height: 1;
  text-align: center;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.hud-level {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 46%;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(13, 9, 24, 0.62);
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.hud-eyebrow {
  color: var(--gold);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.hud-level strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(12px, 1.3vw, 16px);
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hud-gears {
  position: absolute;
  top: 81px;
  left: 16px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 7px;
  border-radius: 999px;
  border: 1px solid rgba(63, 224, 197, 0.32);
  background: rgba(13, 9, 24, 0.62);
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: 13px;
  backdrop-filter: blur(6px);
  pointer-events: none;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.hud-gears img {
  width: 22px;
  height: 22px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

.hud-gears b {
  color: var(--aqua);
  font-weight: 700;
}

.hud-gears.is-pulsing {
  transform: scale(1.08);
  border-color: rgba(63, 224, 197, 0.8);
}

.hud-gears.is-complete {
  border-color: rgba(255, 194, 71, 0.8);
  box-shadow: 0 0 20px rgba(255, 194, 71, 0.2);
}

.level-name {
  position: absolute;
  top: 24%;
  left: 50%;
  z-index: 7;
  max-width: calc(100% - 40px);
  padding: 16px 30px;
  transform: translateX(-50%);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(13, 9, 24, 0.55);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 52px);
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-align: center;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
}

.level-name.fade-out {
  animation: fadeOut 2.6s ease-in-out forwards;
}

@keyframes fadeOut {
  0% { opacity: 0.75; }
  70% { opacity: 0.55; }
  100% { opacity: 0; visibility: hidden; }
}

.game-loading {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: block;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 194, 71, 0.08), transparent 40%),
    rgba(13, 9, 24, 0.92);
  backdrop-filter: blur(4px);
}

.loading-inner {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 18px;
  width: max-content;
  max-width: calc(100% - 40px);
  transform: translate(-50%, -50%);
}

.loading-gear {
  width: clamp(48px, 7vw, 78px);
  height: auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  animation: spinGear 2.4s linear infinite;
}

.loading-inner strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(16px, 2vw, 22px);
  letter-spacing: 0.02em;
}

.loading-inner span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.game-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 8;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(13, 9, 24, 0.62);
  backdrop-filter: blur(6px);
}

.hud-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d9cfe6;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}

.hud-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cream);
}

.hud-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 84px;
  z-index: 25;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  transform: translate(-50%, 8px);
  border-radius: 999px;
  border: 1px solid rgba(255, 194, 71, 0.42);
  background: rgba(13, 9, 24, 0.9);
  color: var(--cream);
  font-size: 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Finish panel ------------------------------------------------------------ */

.finish-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 15;
  width: min(480px, calc(100% - 32px));
  padding: 28px;
  transform: translate(-50%, -50%);
  border-radius: 22px;
  border: 1px solid rgba(255, 194, 71, 0.5);
  background: linear-gradient(160deg, rgba(27, 20, 48, 0.97), rgba(13, 9, 24, 0.99));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.65);
  text-align: center;
  backdrop-filter: blur(12px);
  animation: finishIn 0.3s cubic-bezier(0.2, 0.8, 0.25, 1) both;
}

@keyframes finishIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.finish-checkers {
  height: 14px;
  margin: -28px -28px 20px;
  border-radius: 22px 22px 0 0;
  background-image: repeating-conic-gradient(var(--cream) 0 25%, var(--ink) 0 50%);
  background-size: 28px 28px;
  opacity: 0.9;
}

.finish-panel .eyebrow {
  margin-bottom: 4px;
}

.finish-panel h2 {
  margin: 0;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: clamp(36px, 5vw, 54px);
  line-height: 1;
  letter-spacing: -0.03em;
}

.finish-level {
  margin-top: 8px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.finish-time {
  margin-top: 12px;
  color: var(--cream);
  font-family: var(--font-mono);
  font-size: clamp(38px, 5.4vw, 56px);
  line-height: 1;
}

.finish-best {
  min-height: 18px;
  margin-top: 5px;
  color: var(--aqua);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.finish-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
}

.finish-actions .button {
  padding: 11px 16px;
  font-size: 11px;
}

/* Touch controls ---------------------------------------------------------- */

.touch-controls {
  display: none;
}

body.has-touch .touch-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 9;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.touch-cluster {
  display: flex;
  gap: 8px;
  pointer-events: none;
}

.touch-button {
  width: clamp(50px, 9vw, 64px);
  height: clamp(50px, 9vw, 64px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(13, 9, 24, 0.64);
  color: var(--cream);
  font-family: var(--font-display);
  font-size: 18px;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  backdrop-filter: blur(4px);
}

.touch-button.gas {
  border-color: rgba(63, 224, 197, 0.6);
  background: rgba(63, 224, 197, 0.18);
}

.touch-button.brake {
  border-color: rgba(255, 90, 78, 0.6);
  background: rgba(255, 90, 78, 0.16);
}

.touch-button.flip {
  border-color: rgba(255, 194, 71, 0.6);
  background: rgba(255, 194, 71, 0.14);
}

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

.touch-button.is-pressed {
  transform: scale(0.94);
  filter: brightness(1.3);
}

body.has-touch .game-controls {
  right: 10px;
  bottom: auto;
  top: 78px;
}

body.has-touch .hud-button span {
  display: none;
}

body.has-touch .hud-button {
  padding: 7px;
}

body.has-touch .toast {
  bottom: 100px;
}

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

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 20px clamp(18px, 4vw, 56px) 0;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.site-footer a {
  color: var(--aqua);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-decoration: underline;
  cursor: pointer;
}

/* Credits ----------------------------------------------------------------- */

.credits-dialog {
  width: min(560px, calc(100% - 28px));
  padding: 30px;
  border: 1px solid rgba(255, 194, 71, 0.4);
  border-radius: 20px;
  background: var(--ink-2);
  color: var(--cream);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  line-height: 1.6;
}

.credits-dialog::backdrop {
  background: rgba(7, 5, 14, 0.72);
  backdrop-filter: blur(4px);
}

.credits-dialog h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: -0.02em;
}

.credits-dialog p {
  margin: 0 0 12px;
  color: #d8cee5;
  font-size: 13px;
}

.credits-small {
  color: var(--muted) !important;
  font-size: 11px !important;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover {
  color: var(--cream);
  background: rgba(255, 255, 255, 0.12);
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ink-3);
  color: var(--cream);
  font-family: var(--font-body);
  text-align: center;
}

/* Fullscreen -------------------------------------------------------------- */

#game-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}

#game-shell:fullscreen .stage-frame {
  border-radius: 0;
}

#game-shell:fullscreen .game-view,
#game-shell:fullscreen .xmoto {
  inset: 0;
  width: 100%;
  height: 100% !important;
  aspect-ratio: auto;
  transform: none;
}

/* Responsive -------------------------------------------------------------- */

@media (max-width: 1050px) {
  .menu {
    grid-template-columns: 1fr;
    grid-template-rows: none;
    overflow: auto;
  }

  .game-shell {
    aspect-ratio: auto;
    height: min(calc(100svh - 170px), 780px);
    min-height: 560px;
  }

  body.is-playing .game-shell {
    width: min(100%, calc((100vh - 20px) / 0.6));
    width: min(100%, calc((100svh - 20px) / 0.6));
    height: auto;
    min-height: 0;
    margin: 0 auto;
    aspect-ratio: 5 / 3;
  }

  body.is-playing .game-view {
    inset: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    transform: none;
  }

  .finish-panel {
    position: fixed;
    width: min(460px, calc(100vw - 24px));
    max-height: calc(100svh - 24px);
    overflow: auto;
  }

  .game-view {
    top: 50%;
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: auto;
    aspect-ratio: 1000 / 600;
    transform: translateY(-50%);
  }

  .menu-hero {
    justify-content: flex-start;
    min-height: 420px;
  }

  .level-browser {
    min-height: 480px;
  }

  .level-scroll {
    max-height: 54vh;
  }

  .hero-title {
    font-size: clamp(48px, 9vw, 78px);
  }

  .float-gear {
    width: 110px;
    opacity: 0.72;
  }
}

@media (max-width: 700px) {
  .site-header {
    padding-top: 16px;
  }

  .float-gear {
    display: none;
  }

  .brand-sub {
    display: none;
  }

  .brand-title {
    font-size: 15px;
  }

  .page {
    padding-bottom: 20px;
  }

  .game-shell {
    height: min(calc(100svh - 140px), 720px);
    min-height: 520px;
    border-radius: 22px;
  }

  .stage-frame {
    border-radius: inherit;
  }

  .menu {
    padding: 10px;
    gap: 10px;
  }

  .menu-hero,
  .level-browser {
    border-radius: 16px;
    padding: 18px;
  }

  .menu-hero {
    min-height: 360px;
  }

  .hero-lead {
    margin-top: 12px;
    font-size: 12px;
  }

  .hero-actions {
    margin-top: 16px;
  }

  .button.big {
    padding: 14px 20px;
    font-size: 13px;
  }

  .hero-stats {
    margin-top: 20px;
    padding-top: 16px;
  }

  .controls-card {
    margin-top: 14px;
    padding: 11px 12px;
  }

  .key-row {
    gap: 6px 12px;
  }

  .category-grid {
    grid-template-columns: 1fr;
  }

  .level-browser {
    min-height: 420px;
  }

  .level-scroll {
    max-height: 48vh;
  }

  .hud-level {
    max-width: 52%;
  }

  .hud-gears {
    top: 76px;
  }

  .chrono {
    top: 12px;
    right: 12px;
    min-width: 78px;
    padding: 8px 10px;
  }

  .hud-level {
    top: 12px;
    left: 12px;
  }

  .hud-gears {
    top: 72px;
    left: 12px;
  }

  .game-controls {
    bottom: 12px;
    right: 12px;
  }

  .hud-button span {
    display: none;
  }

  .finish-panel {
    padding: 22px;
  }

  .finish-checkers {
    margin: -22px -22px 16px;
  }

  .site-footer {
    justify-content: center;
    text-align: center;
  }
}

@media (max-height: 640px) and (min-width: 1051px) {
  .hero-title {
    font-size: clamp(44px, 5.4vw, 72px);
  }

  .controls-card {
    display: none;
  }

  .hero-lead {
    font-size: 12px;
  }
}

@media (max-width: 1250px) and (min-width: 1051px) {
  .menu-hero {
    padding: 24px 28px;
  }

  .float-gear {
    display: none;
  }

  .key-row.muted {
    display: none;
  }
}
