:root {
  --ink: #151311;
  --espresso: #2a211b;
  --cream: #f5efe3;
  --paper: #fffaf1;
  --gold: #c79a55;
  --khaki: #90936f;
  --rose: #c99a91;
  --walnut: #7a573a;
  --line: rgba(21, 19, 17, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(90deg, rgba(21, 19, 17, 0.06) 1px, transparent 1px),
    linear-gradient(rgba(21, 19, 17, 0.05) 1px, transparent 1px),
    var(--cream);
  background-size: 28px 28px;
}

button {
  border: 0;
  color: var(--paper);
  background: var(--ink);
  font: inherit;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.game-panel {
  width: min(760px, calc(100vw - 48px));
  max-width: 100%;
  min-width: 0;
}

.scorebar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: rgba(255, 250, 241, 0.92);
}

.scorebar > div {
  min-width: 0;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  background: var(--paper);
}

.label {
  display: block;
  margin-bottom: 3px;
  color: rgba(21, 19, 17, 0.62);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scorebar strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(16px, 3vw, 24px);
  line-height: 1;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 672 / 544;
  border: 1px solid var(--line);
  background: #1b1814;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-width: 0;
  image-rendering: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--paper);
  background: rgba(21, 19, 17, 0.78);
}

.overlay[hidden] {
  display: none;
}

.overlay h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(42px, 11vw, 96px);
  font-weight: 500;
  line-height: 0.92;
}

.overlay p {
  margin: 0;
  color: rgba(255, 250, 241, 0.82);
  font-size: clamp(14px, 3vw, 18px);
}

.overlay button {
  min-width: 126px;
  min-height: 42px;
  padding: 0 22px;
  border: 1px solid rgba(255, 250, 241, 0.28);
  background: var(--gold);
  color: var(--ink);
  font-weight: 800;
}

.controls {
  display: none;
  grid-template-rows: 48px 48px;
  justify-content: center;
  gap: 6px;
  padding-top: 12px;
}

.controls div {
  display: flex;
  gap: 6px;
}

.controls button {
  width: 54px;
  height: 48px;
  border: 1px solid rgba(255, 250, 241, 0.18);
  background: var(--espresso);
  font-size: 22px;
  line-height: 1;
}

@media (pointer: coarse), (max-width: 760px) {
  .shell {
    align-content: start;
    padding: 12px;
  }

  .game-panel {
    width: calc(100vw - 24px);
  }

  .controls {
    display: grid;
  }

  .scorebar {
    padding: 6px;
    gap: 6px;
  }

  .scorebar > div {
    padding: 8px;
  }
}

@media (max-width: 520px) {
  .game-panel {
    width: min(calc(100vw - 24px), 360px);
  }
}
