:root {
  color-scheme: dark;
  --ink: #f8f4e8;
  --muted: #b9b2a1;
  --panel: #1e1b18;
  --panel-2: #29241f;
  --line: rgba(248, 244, 232, 0.16);
  --shadow: rgba(0, 0, 0, 0.42);
  --aqua: #48e0c2;
  --sun: #ffd166;
  --rose: #ff5d7d;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(72, 224, 194, 0.14), transparent 28rem),
    radial-gradient(circle at 88% 88%, rgba(255, 209, 102, 0.12), transparent 26rem),
    linear-gradient(145deg, #11100f 0%, #211c18 48%, #141311 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  min-height: 2.75rem;
  border: 1px solid rgba(248, 244, 232, 0.22);
  border-radius: 8px;
  background: #f8f4e8;
  color: #1d1915;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.45);
}

button:focus-visible {
  outline: 3px solid rgba(72, 224, 194, 0.55);
  outline-offset: 3px;
}

.app-shell {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100svh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(320px, 720px) minmax(260px, 340px);
  align-items: center;
  gap: clamp(18px, 4vw, 42px);
  padding: 28px 0;
}

.board-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  max-height: calc(100svh - 56px);
  border: 1px solid rgba(248, 244, 232, 0.14);
  border-radius: 8px;
  overflow: hidden;
  background: #171513;
  box-shadow: 0 24px 70px var(--shadow);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.side-panel {
  display: grid;
  gap: 16px;
  align-content: center;
}

.brand p,
.block-title span,
.run-meta span,
.stats span,
.result p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

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

.stats div,
.goals-block,
.run-meta,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(30, 27, 24, 0.88);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.18);
}

.stats div {
  min-width: 0;
  padding: 12px;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.15rem, 3vw, 1.55rem);
  line-height: 1;
  white-space: nowrap;
}

.goals-block {
  padding: 14px;
}

.block-title,
.run-meta div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.block-title strong {
  color: var(--sun);
  font-size: 1.25rem;
}

.goals {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.goal {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
}

.goal i {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.52);
  box-shadow: inset 0 4px 8px rgba(255, 255, 255, 0.22);
}

.goal span {
  min-width: 0;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(248, 244, 232, 0.12);
}

.goal b {
  display: block;
  width: var(--goal-fill, 0%);
  max-width: 100%;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
}

.goal strong,
.run-meta strong {
  font-size: 0.95rem;
  white-space: nowrap;
}

.run-meta {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.run-meta strong {
  color: var(--aqua);
}

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

.controls button:last-child {
  background: transparent;
  color: var(--ink);
}

.result {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 16, 15, 0.62);
  backdrop-filter: blur(10px);
}

.result.is-hidden {
  display: none;
}

.result-panel {
  width: min(340px, 100%);
  padding: 24px;
  text-align: center;
}

.result h2 {
  margin: 6px 0 8px;
  font-size: clamp(2rem, 6vw, 3.1rem);
  line-height: 0.95;
}

.result button {
  width: 100%;
  margin-top: 18px;
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 620px);
    grid-template-columns: 1fr;
    align-content: start;
    padding: 10px 0 18px;
  }

  .board-shell {
    max-height: none;
  }

  .side-panel {
    order: -1;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .brand {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
  }

  .brand h1 {
    font-size: clamp(2rem, 12vw, 3.3rem);
  }
}

@media (max-width: 460px) {
  .stats div,
  .goals-block,
  .run-meta {
    padding: 10px;
  }

  .goal {
    grid-template-columns: 20px 1fr auto;
  }

  .goal i {
    width: 20px;
    height: 20px;
  }
}
