:root {
  --paper: #f2eddf;
  --ink: #1c2929;
  --muted: #7c857d;
  --line: #c9c6b7;
  --player: #087f72;
  --player-light: #25bba6;
  --enemy: #d74b32;
  --enemy-light: #f37a55;
  --yellow: #f3bb3a;
  --panel: #fffdf6;
  --shadow: 0 12px 32px rgba(38, 45, 40, .13);
  font-family: "Arial Narrow", "Roboto Condensed", Impact, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overscroll-behavior: none; }
body { min-height: 100svh; background: var(--paper); }
button, a { font: inherit; }
button { touch-action: none; }

.game-shell {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: 14px clamp(10px, 2vw, 24px) max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.topbar, .scoreboard, .control-deck, .hintbar { width: 100%; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 46px; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; line-height: .8; letter-spacing: .04em; }
.brand b { display: block; font-size: clamp(1.35rem, 3vw, 2rem); letter-spacing: -.03em; }
.brand small { display: block; margin-top: 7px; color: var(--muted); font-size: .62rem; letter-spacing: .16em; }
.brand-mark { width: 31px; height: 20px; border-radius: 5px 10px 3px 3px; background: var(--player); position: relative; box-shadow: inset 0 -5px rgba(0,0,0,.12); }
.brand-mark::before { content: ""; position: absolute; width: 9px; height: 9px; border-radius: 50%; background: var(--yellow); left: 11px; top: -6px; }
.brand-mark::after { content: ""; position: absolute; width: 21px; height: 4px; border-radius: 4px; background: var(--ink); left: 15px; top: -5px; transform: rotate(-13deg); transform-origin: left center; }

.quiet-button { border: 1px solid var(--line); color: var(--ink); background: transparent; padding: 9px 13px; border-radius: 6px; font-size: .72rem; font-weight: 900; letter-spacing: .1em; cursor: pointer; }
.quiet-button:hover { background: var(--panel); }

.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: end; }
.combatant { min-width: 0; }
.label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-size: .72rem; letter-spacing: .1em; }
.enemy-card .label-row { justify-content: space-between; }
.label-row span { font-weight: 900; font-size: .9rem; }
.health-track { height: 9px; border: 2px solid var(--ink); padding: 1px; background: var(--panel); transform: skewX(-12deg); }
.health-track i { display: block; width: 100%; height: 100%; background: var(--player); transition: width .25s ease; }
.enemy-card .health-track i { margin-left: auto; background: var(--enemy); }
.roundel { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--paper); font-size: .68rem; font-weight: 900; }

.arena-wrap { position: relative; width: 100%; aspect-ratio: 20 / 13; min-height: 260px; max-height: calc(100svh - 255px); border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; background: #dbe5dc; box-shadow: var(--shadow); }
#battlefield { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.turn-banner { position: absolute; top: 12px; left: 50%; transform: translateX(-50%) skewX(-8deg); padding: 7px 16px; border: 2px solid var(--ink); border-radius: 4px; background: rgba(255,253,246,.9); font-size: clamp(.65rem, 2vw, .82rem); font-weight: 900; letter-spacing: .14em; pointer-events: none; white-space: nowrap; }
.turn-banner.player { background: var(--player); color: white; }
.turn-banner.enemy { background: var(--enemy); color: white; }
.toast { position: absolute; top: 54px; left: 50%; transform: translate(-50%, -5px); opacity: 0; padding: 7px 12px; border-radius: 5px; color: var(--ink); background: var(--yellow); font-size: .76rem; font-weight: 900; letter-spacing: .09em; transition: .2s ease; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.camera-controls { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 4px; padding: 4px; border: 2px solid var(--ink); border-radius: 6px; background: rgba(255,253,246,.9); box-shadow: 3px 3px 0 rgba(28,41,41,.25); }
.camera-controls button { min-width: 31px; height: 28px; padding: 0 7px; border: 0; border-radius: 3px; color: var(--ink); background: transparent; font-size: .62rem; font-weight: 900; letter-spacing: .05em; cursor: pointer; }
.camera-controls button:hover, .camera-controls button:focus-visible { color: white; background: var(--ink); outline: none; }
#zoom-out, #zoom-in { font-size: 1rem; }
.edge-pan { position: absolute; z-index: 2; top: 50%; width: 46px; height: 78px; border: 2px solid var(--ink); color: var(--ink); background: rgba(255,253,246,.9); font: 900 2rem/1 system-ui, sans-serif; cursor: pointer; transform: translateY(-50%); box-shadow: 3px 3px 0 rgba(28,41,41,.25); }
.edge-pan:hover, .edge-pan:focus-visible, .edge-pan:active { color: white; background: var(--ink); outline: none; }
.edge-pan-left { left: 8px; border-radius: 6px 12px 12px 6px; }
.edge-pan-right { right: 8px; border-radius: 12px 6px 6px 12px; }

.game-over { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(28,41,41,.68); backdrop-filter: blur(4px); }
.game-over[hidden] { display: none; }
.game-over-panel { width: min(460px, 100%); padding: clamp(24px, 5vw, 46px); text-align: center; border: 3px solid var(--ink); border-radius: 10px; background: var(--panel); box-shadow: 8px 8px 0 var(--ink); }
.game-over-panel p { margin: 0 0 10px; color: var(--muted); font-size: .72rem; font-weight: 900; letter-spacing: .16em; }
.game-over-panel h1 { margin: 0 0 12px; font-size: clamp(2.4rem, 9vw, 4.6rem); line-height: .9; letter-spacing: -.04em; }
.result-actions { display: flex; gap: 8px; justify-content: center; margin-top: 24px; }
.primary-button, .secondary-button { border: 2px solid var(--ink); border-radius: 5px; padding: 12px 17px; font-weight: 900; letter-spacing: .07em; cursor: pointer; }
.primary-button { color: white; background: var(--player); box-shadow: 3px 3px 0 var(--ink); }
.secondary-button { color: var(--ink); background: transparent; }

.control-deck { display: grid; grid-template-columns: 1fr; gap: 10px; }
.weapon-panel { border: 2px solid var(--ink); border-radius: 8px; background: var(--panel); }
.weapon-panel { padding: 8px; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; font-size: .62rem; font-weight: 900; letter-spacing: .12em; }
.panel-heading { margin: 0 4px 7px; color: var(--muted); }
.panel-heading strong { color: var(--ink); }
.weapon-list { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 1px; }
.weapon-list::-webkit-scrollbar { display: none; }
.weapon-button { flex: 0 0 auto; min-width: 84px; border: 1px solid var(--line); border-radius: 5px; background: #f4f1e7; color: var(--ink); padding: 7px 8px 6px; text-align: left; cursor: pointer; }
.weapon-button b, .weapon-button small { display: block; }
.weapon-button b { font-size: .7rem; letter-spacing: .04em; }
.weapon-button small { margin-top: 3px; color: var(--muted); font: 700 .58rem/1 system-ui, sans-serif; }
.weapon-button.selected { color: white; background: var(--ink); border-color: var(--ink); }
.weapon-button.selected small { color: #dcdacf; }
.weapon-button.special { border-color: #d38a20; background: #fff1a8; }
.weapon-button.special.selected { color: var(--ink); border-color: var(--ink); background: var(--yellow); }
.weapon-button.special.selected small { color: #5e522d; }
.weapon-button:disabled { opacity: .36; cursor: not-allowed; }


.hintbar { display: flex; justify-content: center; gap: clamp(12px, 4vw, 34px); color: var(--muted); font: 600 .65rem/1.2 system-ui, sans-serif; }
.hintbar b { color: var(--ink); }
#seed-label { margin-left: auto; font-weight: 800; letter-spacing: .08em; }

@media (max-width: 680px) {
  .game-shell { gap: 7px; padding-top: 8px; }
  .topbar { min-height: 38px; }
  .brand small { display: none; }
  .arena-wrap { max-height: none; min-height: 0; }
  .control-deck { grid-template-columns: 1fr; gap: 7px; }
  .weapon-button { min-width: 78px; }
  .hintbar span { display: none; }
  .hintbar span:first-child, .hintbar #seed-label { display: inline; }
  #seed-label { margin-left: auto; }
  .game-over-panel { box-shadow: 5px 5px 0 var(--ink); }
  .camera-controls { right: 6px; bottom: 6px; gap: 2px; padding: 3px; }
  .camera-controls button { min-width: 28px; height: 26px; padding: 0 5px; font-size: .55rem; }
  .edge-pan { width: 36px; height: 64px; font-size: 1.65rem; }
  .edge-pan-left { left: 5px; }
  .edge-pan-right { right: 5px; }
}

@media (max-height: 700px) and (orientation: landscape) {
  .game-shell { display: grid; grid-template-columns: minmax(0, 1fr) 260px; grid-template-rows: auto auto 1fr auto; max-width: 1200px; }
  .topbar, .scoreboard, .hintbar { grid-column: 1 / 3; }
  .arena-wrap { grid-column: 1; grid-row: 3; max-height: calc(100svh - 135px); }
  .control-deck { grid-column: 2; grid-row: 3; grid-template-columns: 1fr; align-content: start; }
  .weapon-list { flex-wrap: wrap; overflow: visible; }
  .weapon-button { flex: 1 1 74px; }
}
