@font-face { font-family: "Press"; src: url(fonts/PressStart2P-Regular.ttf); }
@font-face { font-family: "VT"; src: url(fonts/VT323-Regular.ttf); }
@font-face { font-family: "Silk"; src: url(fonts/Silkscreen-Bold.ttf); }

:root {
  --iron: #1c1410; --iron2: #2a1f18; --iron3: #3a2b20;
  --brass: #c9932f; --brass-hi: #f2c45a; --brass-lo: #7a5418;
  --copper: #b8693a; --copper-hi: #e08a4a; --copper-lo: #6b3517;
  --steam: #efe9e0; --ink: #1a120c; --teal: #2a5a62; --red: #c0392b; --green: #60b054;
  --px: 4px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background-color: var(--iron);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(201,147,47,.10), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(184,105,58,.12), transparent 45%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.18) 0 2px, transparent 2px 4px);
  color: var(--steam); font: 22px/1.15 "VT", monospace; -webkit-font-smoothing: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 1180px; margin: 0 auto; padding: 12px; display: grid; gap: 12px;
  grid-template-columns: 1fr; grid-template-areas: "brand" "stage" "panel"; }
@media (min-width: 900px) {
  #app { grid-template-columns: 1.15fr 1fr; grid-template-areas: "brand brand" "stage panel"; align-items: start; padding: 18px; }
}

/* ---------- brand ---------- */
.brand { grid-area: brand; text-align: center; }
.brand h1 { margin: 6px 0 6px; font: 34px/1 "Press"; letter-spacing: 6px; color: var(--brass-hi);
  text-shadow: 3px 3px 0 var(--copper-lo), 6px 6px 0 rgba(0,0,0,.45); }
.brand p { margin: 0; font-size: 22px; color: #d9c7a8; }
@media (min-width: 900px) { .brand h1 { font-size: 46px; } .brand p { font-size: 26px; } }

/* ---------- riveted plates ---------- */
.plate, #panel, #tally {
  background: linear-gradient(180deg, var(--iron3), var(--iron2));
  border: var(--px) solid var(--ink);
  box-shadow: inset 0 0 0 var(--px) var(--brass-lo), inset 0 0 0 calc(var(--px) * 2) var(--brass), inset 0 0 0 calc(var(--px) * 3) var(--brass-lo), 0 6px 0 rgba(0,0,0,.45);
  image-rendering: pixelated;
}

/* ---------- globe stage ---------- */
#stage { grid-area: stage; position: relative; display: grid; place-items: center; padding: 18px 0 10px; }
.ring { position: relative; width: min(88vw, 54vh, 560px); aspect-ratio: 1; border-radius: 50%; padding: calc(var(--px) * 3);
  background: conic-gradient(from 20deg, var(--brass-hi), var(--brass), var(--brass-lo), var(--brass), var(--brass-hi), var(--brass-lo), var(--brass-hi));
  box-shadow: 0 0 0 var(--px) var(--ink), 0 10px 0 rgba(0,0,0,.45); }
.ring::after { content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, transparent 0 calc(50% - 10px), rgba(0,0,0,.0) 50%),
              repeating-conic-gradient(from 0deg, var(--ink) 0 2deg, transparent 2deg 30deg);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 7px), #000 calc(50% - 6px), #000 calc(50% - 3px), transparent calc(50% - 2px));
          mask: radial-gradient(circle, transparent calc(50% - 7px), #000 calc(50% - 6px), #000 calc(50% - 3px), transparent calc(50% - 2px)); }
#globe { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: grab; border-radius: 50%; background: #120d0a; }
#globe:active { cursor: grabbing; }

.gear { position: absolute; width: 96px; height: 96px; image-rendering: pixelated; animation: spin 6s steps(12) infinite; opacity: .95; }
.gear::before { content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle, var(--iron) 0 14%, var(--copper) 14% 30%, var(--copper-lo) 30% 33%, var(--copper) 33% 52%, transparent 52%),
    repeating-conic-gradient(var(--copper) 0 18deg, transparent 18deg 36deg);
  -webkit-mask: radial-gradient(circle, #000 0 64%, transparent 64%); mask: radial-gradient(circle, #000 0 64%, transparent 64%);
  filter: drop-shadow(4px 4px 0 rgba(0,0,0,.5)); }
.g1 { left: max(0px, calc(50% - min(44vw, 27vh, 280px) - 64px)); top: 4px; }
.g2 { right: max(0px, calc(50% - min(44vw, 27vh, 280px) - 60px)); bottom: 30px; width: 70px; height: 70px; animation-direction: reverse; animation-duration: 4.4s; }
.g2::before { background:
    radial-gradient(circle, var(--iron) 0 16%, var(--brass) 16% 32%, var(--brass-lo) 32% 35%, var(--brass) 35% 52%, transparent 52%),
    repeating-conic-gradient(var(--brass) 0 22deg, transparent 22deg 45deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.steam { position: absolute; width: 16px; height: 16px; background: var(--steam); box-shadow: 8px -8px 0 var(--steam), -6px -14px 0 rgba(239,233,224,.7), 4px -24px 0 rgba(239,233,224,.45);
  opacity: 0; animation: steam 3.2s steps(8) infinite; image-rendering: pixelated; }
.s1 { left: max(30px, calc(50% - min(44vw, 27vh, 280px) - 20px)); top: 70px; }
.s2 { right: max(26px, calc(50% - min(44vw, 27vh, 280px) - 24px)); bottom: 100px; animation-delay: 1.6s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(0) scale(.6); } 20% { opacity: .9; } 100% { opacity: 0; transform: translateY(-46px) scale(1.2); } }

#tally { margin-top: 14px; padding: 10px 18px; display: flex; align-items: baseline; gap: 10px; }
#tally .lbl { font: 12px "Press"; color: var(--brass); letter-spacing: 2px; }
#area { font: 22px "Press"; color: var(--brass-hi); text-shadow: 2px 2px 0 var(--copper-lo); }
#tally .unit { font-size: 22px; color: #d9c7a8; }

/* ---------- panel ---------- */
#panel { grid-area: panel; padding: 22px 24px; position: relative; }
#panel::before, #panel::after { content: ""; position: absolute; width: 8px; height: 8px; background: var(--brass-hi); box-shadow: 0 0 0 4px var(--ink); top: 18px; }
#panel::before { left: 18px; } #panel::after { right: 18px; }

#squad { list-style: none; margin: 0 0 14px; padding: 8px 0 0; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.soldier { position: relative; container-type: inline-size; display: grid; justify-items: center; gap: 2px; }
.soldier canvas { width: 100%; max-width: 76px; height: auto; aspect-ratio: 1; image-rendering: pixelated; }
.soldier .nm { font: min(9px, 10.5cqi) "Press"; color: #a99678; letter-spacing: .5cqi; white-space: nowrap; }
.soldier.current .nm { color: var(--brass-hi); }
.soldier.won .nm { color: var(--green); } .soldier.lost .nm { color: var(--red); text-decoration: line-through; }
.soldier.current::after { content: "▼"; position: absolute; top: -12px; font: 10px "Press"; color: var(--brass-hi); animation: blinkp 1s steps(2) infinite; }
@keyframes blinkp { 50% { opacity: 0; } }
.bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--steam); color: var(--ink);
  font: 9px/1.3 "Press"; padding: 5px 6px; box-shadow: 0 0 0 3px var(--ink); z-index: 3; }
.bubble::after { content: ""; position: absolute; top: 100%; left: 50%; margin-left: -3px; border: 4px solid transparent; border-top-color: var(--ink); }

#order { border-top: var(--px) solid var(--brass-lo); padding-top: 12px; }
.who { margin: 0; font: 11px "Press"; color: var(--copper-hi); letter-spacing: 1px; text-align: center; }
.trait { margin: 12px 0 16px; font: 15px/1.5 "Press"; color: var(--steam); text-align: center; text-wrap: balance; text-shadow: 2px 2px 0 rgba(0,0,0,.5); }
@media (min-width: 900px) { .trait { font-size: 17px; } }
.mode { margin: 0 0 12px; text-align: center; color: #c8b08a; font-size: 20px; }
#claim { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; }
#q { font: 24px "VT"; padding: 10px 12px; min-width: 0; color: var(--ink); background: var(--steam); border: var(--px) solid var(--ink);
  box-shadow: inset 4px 4px 0 #c8bfae; border-radius: 0; }
#q:focus { outline: var(--px) solid var(--brass-hi); outline-offset: 0; }
button { font: 13px "Press"; letter-spacing: 1px; color: var(--ink); cursor: pointer; border-radius: 0; padding: 12px 14px;
  background: var(--brass); border: var(--px) solid var(--ink); box-shadow: inset -4px -4px 0 var(--brass-lo), inset 4px 4px 0 var(--brass-hi); }
button:active { box-shadow: inset 4px 4px 0 var(--brass-lo), inset -4px -4px 0 var(--brass-hi); }
button:disabled { filter: grayscale(.7) brightness(.7); cursor: default; }
#next, #share { width: 100%; margin-top: 12px; background: var(--copper); box-shadow: inset -4px -4px 0 var(--copper-lo), inset 4px 4px 0 var(--copper-hi); color: var(--steam); }
#sugg { position: absolute; z-index: 10; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 0; list-style: none; background: var(--steam); color: var(--ink);
  border: var(--px) solid var(--ink); max-height: 42vh; overflow: auto; }
#sugg:empty { display: none; }
#sugg li { padding: 8px 10px; display: flex; justify-content: space-between; gap: 8px; cursor: pointer; font-size: 22px; border-bottom: 2px solid #d8cfbe; }
#sugg li .meta { color: #6b5a44; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sugg li[aria-selected=true], #sugg li:hover { background: var(--brass-hi); }

#verdict:not(:empty) { margin-top: 12px; }
#verdict .head { font: 13px/1.5 "Press"; }
#verdict .head.ok { color: var(--brass-hi); } #verdict .head.no { color: #ff7b63; }
#verdict .why { margin-top: 6px; color: #d9c7a8; font-size: 22px; }
#verdict .why b { color: var(--steam); font-weight: normal; }

#summary h2 { font: 16px "Press"; color: var(--brass-hi); text-align: center; margin: 4px 0 10px; }
#sumlist { margin: 0; padding-left: 1.4em; } #sumlist li { margin: 8px 0; font-size: 21px; }
#sumlist b { color: var(--brass-hi); font-weight: normal; } #sumlist .best { display: block; color: #a99678; font-size: 19px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* phone: never wider than the screen */
#app > * { min-width: 0; }
@media (max-width: 480px) {
  body { font-size: 20px; }
  .brand h1 { font-size: 28px; letter-spacing: 4px; }
  .brand p { font-size: 19px; }
  #panel { padding: 20px 18px; }
  .trait { font-size: 13px; }
  button { font-size: 11px; padding: 10px 10px; }
  #q { font-size: 22px; padding: 8px 10px; }
  .gear.g1 { width: 64px; height: 64px; left: 2px; } .gear.g2 { width: 48px; height: 48px; right: 2px; }
}
