:root {
  color-scheme: dark;
  --ink: #211e19;
  --paper: #f5e8cd;
  --muted: #c4b49a;
  --gold: #ffcd65;
  --edge: #5b4d38;
  font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  color: var(--paper);
  background: radial-gradient(ellipse at 50% 30%, #413526, #201d18 65%);
}
button { font: inherit; cursor: pointer; color: inherit; }
button:focus-visible, input:focus-visible + span { outline: 2px solid #fff1bc; outline-offset: 3px; }
.game { width: min(1220px, calc(100% - 48px)); margin: 22px auto; }
.top, .controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 20px;
  padding: 0 18px;
  background: #28241d;
  border: 1px solid var(--edge);
}
.top { min-height: 57px; border-radius: 12px 12px 0 0; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 850; letter-spacing: .12em; font-size: .88rem; }
.brand-icon { place-items: center; display: grid; width: 28px; height: 28px; background: #463820; color: var(--gold); border: 1px solid #795b31; border-radius: 6px; }
.record { margin-left: auto; color: var(--muted); font-size: .875rem; }
.record strong { margin-left: 7px; color: var(--gold); font-variant-numeric: tabular-nums; }
.small, .secondary { border: 1px solid var(--edge); border-radius: 6px; background: #332c22; padding: 5px 12px; }
.field { position: relative; isolation: isolate; overflow: hidden; border-inline: 1px solid var(--edge); background: #9c6140; }
canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; touch-action: none; }
.field.playing canvas { cursor: crosshair; }
.field.playing.placing-dynamite canvas { cursor: default; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; padding: clamp(14px, 4vw, 58px); background: linear-gradient(90deg, #201a14da, #33231c30 80%); overflow: auto; }
.panel { width: min(100%, 410px); padding: clamp(16px, 2.5vw, 30px); background: #27221bef; border: 1px solid #82623e; border-top: 3px solid var(--gold); border-radius: 9px; box-shadow: 0 15px 45px #20130d80; }
h1, h2 { margin: 0; font-family: Georgia, serif; font-weight: 900; letter-spacing: -.055em; line-height: .98; }
h1 { font-size: clamp(2.25rem, 6vw, 4.1rem); }
h1 span { color: var(--gold); }
h2 { font-size: clamp(2rem, 5vw, 3.4rem); }
p { margin: 14px 0 22px; color: var(--muted); line-height: 1.4; }
fieldset { padding: 0; margin: 0 0 16px; border: 0; min-width: 0; }
legend { padding: 0; margin: 0 0 7px; font-size: .875rem; color: var(--muted); }
.choices { display: grid; gap: 6px; }
.difficulties { grid-template-columns: repeat(3, 1fr); }
.choices label { position: relative; cursor: pointer; }
.choices input { position: absolute; opacity: 0; margin: 0; }
.choices span { display: grid; align-content: center; height: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid var(--edge); border-radius: 6px; background: #362e23; font-size: .875rem; }
.choices input:checked + span { border-color: #d9a450; background: #4b3821; color: #ffe0a0; }
.choices span:hover, .secondary:hover, .small:hover { background: #51402c; }
.difficulties span { text-align: center; }
.primary { width: 100%; padding: 11px 10px; border: 1px solid #ffe0a0; border-radius: 6px; background: var(--gold); color: #2b2113; font-weight: 850; box-shadow: 0 3px 0 #9f682c; }
.primary:hover { background: #ffdc86; }
.result { margin: auto; }
.result .secondary { width: 100%; margin-top: 12px; padding: 9px; }
.controls { min-height: 57px; justify-content: center; border-radius: 0 0 12px 12px; color: var(--muted); font-size: .875rem; padding-block: 8px; }
.controls span { white-space: nowrap; }
kbd { display: inline-block; background: #3a3227; border: 1px solid var(--edge); border-radius: 4px; color: var(--paper); font: inherit; font-size: .75rem; padding: 2px 5px; }
.hud { position: absolute; inset: 10px 10px auto; display: flex; gap: 6px; pointer-events: none; }
.plate { display: grid; gap: 2px; min-width: 98px; padding: 6px 10px; border: 1px solid #ac8557; border-radius: 6px; background: #292016ee; font-variant-numeric: tabular-nums; }
.plate span { font-size: .8rem; color: var(--muted); }
.plate strong { font-size: 1.15rem; }
.plate.score { display: flex; gap: 12px; margin-left: auto; color: var(--gold); }
.plate.score > div { display: grid; gap: 2px; align-content: start; }
.arsenal { display: flex; gap: 6px; }
.arsenal .plate { pointer-events: auto; text-align: left; min-width: 111px; touch-action: manipulation; }
.arsenal .plate kbd { padding: 0 4px; }
.arsenal .plate:hover { background: #453325; }
.arsenal .plate[aria-pressed="true"] { border-color: var(--gold); background: #49341f; color: var(--gold); }
.arsenal .plate strong { font-size: .95rem; }
#dynamite strong { color: #ffb184; }
meter { width: 72px; height: 8px; }
meter::-webkit-meter-optimum-value { background: #b6cc82; }
.objective { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); max-width: 94%; width: max-content; text-align: center; padding: 7px 12px; background: #292016ef; border: 1px solid #ac8557; border-radius: 5px; font-size: .875rem; pointer-events: none; }
.objective progress { display: block; width: 100%; height: 6px; margin-top: 6px; accent-color: var(--gold); }
.touch { display: none; }
@media (pointer: coarse) {
  .touch { display: flex; touch-action: none; position: absolute; inset: auto 8px 8px; justify-content: space-between; pointer-events: none; }
  .touch button { pointer-events: auto; touch-action: none; min-height: 38px; min-width: 38px; border: 1px solid #ab8250; border-radius: 6px; background: #2b2118ed; padding: 4px; }
  .touch-pad { display: grid; grid-template-columns: repeat(3, 38px); gap: 2px; }
  .touch-pad button:first-child { grid-column: 2; }
  .touch-pad button:nth-child(2) { grid-column: 1; }
  .touch-actions { display: flex; flex-direction: column; gap: 3px; }
  .objective { bottom: 91px; }
  .controls { display: none; }
  .field { border-bottom: 1px solid var(--edge); border-radius: 0 0 12px 12px; }
}
@media (max-width: 900px) {
  .field:not(.playing) { min-height: 440px; }
  .field:not(.playing) canvas { position: absolute; width: 100%; height: 100%; object-fit: cover; }
}
@media (max-width: 620px) {
  .game { width: calc(100% - 16px); margin: 8px auto; }
  .overlay { padding: 12px; }
  .panel { margin-inline: auto; }
  .top, .controls { gap: 7px 12px; }
  .hud { display: grid; grid-template-columns: 1fr 1fr; }
  .hud > .plate { width: max-content; }
  .arsenal { grid-column: 1 / -1; grid-row: 2; }
  .arsenal .plate { min-width: 0; flex: 1; padding-inline: 6px; }
  .field.playing canvas { margin-block: 120px 42px; }
}
@media (max-width: 620px) and (pointer: coarse) {
  .field.playing canvas { margin-bottom: 128px; }
}
