:root {
  color-scheme: dark;
  --ink: #f6ffe8;
  --muted: #c1d8b4;
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(15, 28, 21, 0.92);
  --gold: #f3c74f;
  --red: #dd4b37;
  --blue: #3b79d8;
  --field: #17763d;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  align-items: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(243, 199, 79, 0.18), transparent 30rem),
    linear-gradient(180deg, #092116 0%, #0d1612 100%);
  color: var(--ink);
  display: flex;
  font-family: "Courier New", Courier, monospace;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

button,
input {
  font: inherit;
}

.shell {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100dvh;
  justify-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  width: min(100vw, 560px);
}

.game-wrap {
  aspect-ratio: 48 / 76;
  background: #0c1f16;
  border: 4px solid #d7efc7;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  max-height: calc(100dvh - 116px);
  max-width: 100%;
  min-height: 0;
  position: relative;
  width: min(100%, 480px);
}

canvas {
  display: block;
  height: 100%;
  image-rendering: pixelated;
  width: 100%;
}

.hud {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
  left: 10px;
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 3;
}

.hud > div {
  background: rgba(6, 22, 13, 0.78);
  border: 2px solid var(--line);
  min-width: 0;
  padding: 7px 6px;
  text-align: center;
}

.hud-label {
  color: var(--muted);
  display: block;
  font-size: 11px;
  line-height: 1.1;
  text-transform: uppercase;
}

.hud strong {
  color: var(--ink);
  display: block;
  font-size: 22px;
  line-height: 1.05;
}

.overlay {
  align-items: center;
  background: linear-gradient(180deg, rgba(8, 17, 12, 0.36), rgba(8, 17, 12, 0.78));
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: absolute;
  z-index: 5;
}

.overlay.hidden {
  display: none;
}

.panel {
  background: var(--panel);
  border: 3px solid #d7efc7;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.36);
  max-width: 360px;
  padding: 22px;
  text-align: center;
  width: 100%;
}

.kicker,
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
  text-transform: uppercase;
}

h1 {
  color: var(--gold);
  font-size: clamp(34px, 10vw, 56px);
  letter-spacing: 0;
  line-height: 0.9;
  margin: 12px 0;
  text-shadow: 4px 4px 0 #163a2a;
  text-transform: uppercase;
}

.lede {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  margin: 0 0 18px;
}

.mode-picker {
  border: 0;
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin: 0 0 16px;
  padding: 0;
}

.mode-picker label {
  cursor: pointer;
  display: block;
}

.mode-picker input {
  inline-size: 1px;
  opacity: 0;
  position: absolute;
}

.mode-picker span {
  background: #173527;
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: var(--ink);
  display: block;
  padding: 10px 8px;
}

.mode-picker input:checked + span {
  background: var(--gold);
  border-color: #fff1a9;
  color: #132114;
}

.primary {
  background: var(--red);
  border: 0;
  box-shadow: 0 5px 0 #8e261c;
  color: #fff9ea;
  cursor: pointer;
  min-height: 48px;
  padding: 12px 18px;
  text-transform: uppercase;
  width: 100%;
}

.primary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #8e261c;
}

.hint {
  margin-top: 16px;
}

.toast {
  background: rgba(6, 22, 13, 0.86);
  border: 2px solid rgba(255, 255, 255, 0.18);
  bottom: 16px;
  color: var(--gold);
  display: none;
  font-size: 13px;
  left: 50%;
  padding: 8px 12px;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 4;
}

.toast.show {
  display: block;
}

.controls {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 480px);
}

.controls button {
  align-items: center;
  background: #e9f7da;
  border: 0;
  box-shadow: 0 6px 0 #8fa87a;
  color: #12301f;
  cursor: pointer;
  display: flex;
  height: 58px;
  justify-content: center;
  padding: 0;
}

.controls button:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #8fa87a;
}

.controls span {
  font-size: 46px;
  line-height: 1;
  transform: translateY(-3px);
}

@media (min-width: 780px) {
  .shell {
    grid-template-columns: minmax(0, 480px) 92px;
    grid-template-rows: minmax(0, 1fr);
    width: min(100vw, 700px);
  }

  .controls {
    align-self: center;
    grid-template-columns: 1fr;
    width: 78px;
  }

  .hud {
    grid-template-columns: repeat(5, 1fr);
  }

  .controls button {
    height: 78px;
  }
}

@media (max-height: 680px) {
  .hud strong {
    font-size: 18px;
  }

  .controls button {
    height: 50px;
  }

  .panel {
    padding: 16px;
  }
}
