:root {
  color-scheme: dark;
  --ink: #171614;
  --paper: #fff2d3;
  --muted: #c5b88f;
  --gold: #f4b64b;
  --leaf: #77c37b;
  --teal: #57b8a3;
  --coral: #ee6d5c;
  --shadow: rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  color: var(--paper);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
  user-select: none;
}

button {
  font: inherit;
}

#app {
  position: fixed;
  inset: 0;
  min-width: 280px;
  min-height: 420px;
  background: #171614;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
  text-shadow: 0 2px 10px var(--shadow);
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: clamp(19px, 4.8vw, 30px);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1;
}

.state-label {
  min-height: 1.25em;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: clamp(12px, 3.3vw, 15px);
  font-weight: 650;
}

.stats {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(56px, max-content);
  gap: 7px;
  align-items: center;
}

.stats span {
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 242, 211, 0.2);
  border-radius: 8px;
  background: rgba(23, 22, 20, 0.6);
  color: var(--paper);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  backdrop-filter: blur(9px);
}

.stats b {
  font-size: 18px;
}

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

.overlay {
  position: absolute;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  gap: 8px;
  width: min(300px, calc(100vw - 32px));
  min-height: 86px;
  padding: 15px 18px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 242, 211, 0.26);
  border-radius: 8px;
  background: rgba(23, 22, 20, 0.74);
  box-shadow: 0 18px 50px var(--shadow);
  color: var(--paper);
  text-align: left;
  backdrop-filter: blur(11px);
}

.overlay[hidden] {
  display: none;
}

.overlay span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.overlay strong {
  color: var(--paper);
  font-size: clamp(27px, 8vw, 40px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.92;
}

.overlay:active {
  transform: translateX(-50%) translateY(1px) scale(0.99);
}

@media (max-width: 520px) {
  .hud {
    align-items: stretch;
  }

  .stats {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    width: 74px;
  }

  .stats span {
    min-height: 30px;
    padding: 6px 7px;
    font-size: 12px;
  }
}

@media (max-height: 560px) {
  .overlay {
    bottom: 14px;
    min-height: 72px;
    padding: 12px 14px;
  }
}
