:root {
  --bg: #fffaeb;
  --surface: #ffffff;
  --cream: #fff0c2;
  --gold: #ffd900;
  --sun: #ffa110;
  --orange: #fa520f;
  --flame: #fb6424;
  --fg: #1f1f1f;
  --muted: hsl(0 0% 24%);
  --border: rgba(31, 31, 31, 0.14);
  --success: #22a96b;
  --danger: #d43219;
  --bonus: #8b4cf6;
  --shadow: rgba(127, 99, 21, 0.12) -8px 16px 39px,
    rgba(127, 99, 21, 0.1) -33px 64px 72px,
    rgba(127, 99, 21, 0.06) -73px 144px 97px;
  --font-display: Arial, ui-sans-serif, system-ui, sans-serif;
  --font-body: Arial, ui-sans-serif, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 82% 8%, rgba(255, 217, 0, 0.34), transparent 25rem),
    linear-gradient(135deg, #fffaeb 0%, #fff0c2 42%, #ffd06a 100%);
  color: var(--fg);
}

body.dark-stage {
  background:
    radial-gradient(circle at top left, rgba(255, 161, 16, 0.32), transparent 28rem),
    linear-gradient(145deg, #2a1709 0%, #1f1f1f 58%, #4d1a09 100%);
  color: #fff;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.m-blocks {
  display: grid;
  grid-template-columns: repeat(4, 12px);
  grid-template-rows: repeat(2, 12px);
  gap: 2px;
}

.m-blocks span:nth-child(1) { background: var(--gold); }
.m-blocks span:nth-child(2) { background: #ffe295; }
.m-blocks span:nth-child(3) { background: var(--sun); }
.m-blocks span:nth-child(4) { background: #ff8105; }
.m-blocks span:nth-child(5) { background: #ffb83e; }
.m-blocks span:nth-child(6) { background: var(--sun); }
.m-blocks span:nth-child(7) { background: var(--flame); }
.m-blocks span:nth-child(8) { background: var(--orange); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-links a,
.pill {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.44);
  padding: 10px 12px;
  text-transform: uppercase;
  font-size: 13px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.95fr);
  gap: clamp(28px, 5vw, 76px);
  align-items: center;
  padding: clamp(28px, 6vw, 88px) 0 80px;
}

.eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  content: "";
  width: 34px;
  height: 8px;
  background: linear-gradient(90deg, var(--gold), var(--orange));
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.display {
  margin-bottom: 22px;
  font-family: var(--font-display);
  font-size: clamp(48px, 9vw, 102px);
  line-height: 0.92;
  letter-spacing: -2.05px;
  font-weight: 400;
  text-wrap: balance;
}

.section-title {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.96;
  font-weight: 400;
  letter-spacing: -1px;
  text-wrap: balance;
}

.lead {
  max-width: 700px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.42;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 28px;
}

.btn {
  min-height: 44px;
  border: 0;
  border-radius: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 140ms ease, opacity 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn.primary {
  background: var(--fg);
  color: #fff;
}

.btn.secondary {
  background: var(--cream);
  color: var(--fg);
}

.btn.orange {
  background: var(--orange);
  color: #fff;
}

.btn.ghost {
  border: 1px solid var(--border);
  background: transparent;
}

.panel {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.68);
}

.gold-card {
  background: var(--cream);
  box-shadow: var(--shadow);
}

.launcher-grid,
.feature-grid,
.level-grid,
.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.launcher-card,
.feature-card,
.level-card,
.score-card {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.62);
}

.launcher-card h2,
.feature-card h3,
.level-card h2,
.score-card h3 {
  font-size: 28px;
  line-height: 1.05;
  font-weight: 400;
}

.meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 340px;
  gap: 18px;
  align-items: start;
  padding-bottom: 28px;
}

.board-wrap {
  padding: clamp(12px, 2.4vw, 26px);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.board {
  --board-size: min(78vw, 660px);
  width: var(--board-size);
  max-width: 100%;
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: clamp(5px, 1vw, 10px);
  touch-action: manipulation;
}

.tile {
  position: relative;
  width: 100%;
  border: 0;
  border-radius: 10px;
  box-shadow: inset 0 -7px 0 rgba(31, 31, 31, 0.15), 0 6px 0 rgba(31, 31, 31, 0.12);
  cursor: pointer;
  overflow: hidden;
  transition: transform 130ms ease, filter 130ms ease, opacity 180ms ease;
}

.tile::after {
  content: "";
  position: absolute;
  inset: 13% 18% auto;
  height: 22%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
}

.tile:hover,
.tile.selected {
  transform: translateY(-4px) scale(1.03);
  filter: saturate(1.16);
}

.tile.pop {
  animation: pop 260ms ease forwards;
}

.tile.bomb::before,
.tile.time::before,
.tile.multiplier::before {
  position: absolute;
  inset: auto 8px 8px auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(31, 31, 31, 0.84);
  color: #fff;
  font-size: 13px;
}

.tile.bomb::before { content: "B"; }
.tile.time::before { content: "+5"; width: 30px; }
.tile.multiplier::before { content: "x2"; width: 30px; }

.hud {
  display: grid;
  gap: 14px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat {
  padding: 18px;
  background: #fff;
  border: 1px solid var(--border);
}

.stat b {
  display: block;
  font-size: 32px;
  line-height: 1;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

.tools {
  display: grid;
  gap: 10px;
}

.tool-button {
  justify-content: space-between;
  width: 100%;
  min-height: 54px;
  background: var(--cream);
  color: var(--fg);
}

.tool-button strong {
  font-weight: 400;
}

.progress {
  height: 12px;
  background: rgba(31, 31, 31, 0.1);
  overflow: hidden;
}

.progress span {
  display: block;
  width: var(--value, 50%);
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--orange));
}

.toast {
  min-height: 34px;
  color: var(--orange);
  font-size: 15px;
}

.start-card {
  min-height: min(720px, calc(100vh - 132px));
  display: grid;
  place-items: center;
  padding: 42px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 240, 194, 0.68)),
    radial-gradient(circle at 74% 24%, rgba(250, 82, 15, 0.22), transparent 20rem);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
}

.mini-board {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 26px auto;
}

.mini-board i {
  aspect-ratio: 1;
  display: block;
  border-radius: 10px;
  box-shadow: inset 0 -5px 0 rgba(31, 31, 31, 0.12);
}

.level-card {
  min-height: 260px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.level-card.locked {
  opacity: 0.54;
  filter: grayscale(0.2);
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 13px;
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid var(--border);
}

.device-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 30px 14px;
}

.phone {
  width: min(390px, 100%);
  min-height: 844px;
  border: 12px solid #161616;
  border-radius: 48px;
  background: #fffaeb;
  color: var(--fg);
  box-shadow: rgba(31, 31, 31, 0.28) 0 30px 90px;
  overflow: hidden;
  position: relative;
}

.phone.android {
  width: min(412px, 100%);
  min-height: 900px;
  border-radius: 34px;
  border-width: 10px;
}

.island,
.camera {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #111;
}

.island {
  width: 118px;
  height: 32px;
  border-radius: 999px;
}

.camera {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

.phone-screen {
  min-height: 820px;
  padding: 58px 18px 24px;
}

.android .phone-screen {
  min-height: 880px;
  padding-top: 44px;
}

.phone .board {
  --board-size: 100%;
  gap: 6px;
}

.phone .tile {
  border-radius: 9px;
}

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

.mobile-hud .stat {
  padding: 10px;
}

.mobile-hud b {
  font-size: 22px;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.home-indicator {
  width: 134px;
  height: 5px;
  border-radius: 999px;
  background: #111;
  margin: 18px auto 0;
}

.android-nav {
  display: flex;
  justify-content: center;
  gap: 34px;
  padding: 17px 0 2px;
  color: #111;
}

.footer-band {
  margin-top: 80px;
  padding: 64px 0;
  background: linear-gradient(180deg, var(--sun), var(--fg) 45%);
  color: #fff;
}

@keyframes pop {
  0% { transform: scale(1); opacity: 1; }
  70% { transform: scale(1.22) rotate(4deg); opacity: 0.38; }
  100% { transform: scale(0.1); opacity: 0; }
}

@media (max-width: 1040px) {
  .hero,
  .game-layout {
    grid-template-columns: 1fr;
  }

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

  .launcher-grid,
  .feature-grid,
  .level-grid,
  .result-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 22px, 1180px);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .display {
    font-size: clamp(38px, 13vw, 56px);
    letter-spacing: -1px;
  }

  .start-card {
    padding: 24px 16px;
  }

  .hud,
  .stat-row,
  .launcher-grid,
  .feature-grid,
  .level-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .board {
    gap: 5px;
  }

  .tile {
    border-radius: 8px;
  }
}

@media (max-width: 380px) {
  .nav-links a,
  .pill,
  .btn {
    width: 100%;
  }

  .actions {
    width: 100%;
  }

  .board {
    gap: 4px;
  }
}
