:root {
  --ink: #1f1710;
  --panel: rgba(255, 250, 240, 0.96);
  --line: #e0d4c2;
  --accent: #3aaa5c;
  --accent-ink: #fff;
  --hud: rgba(20, 15, 10, 0.62);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #5fb0ea; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; }
#game { position: fixed; inset: 0; width: 100vw; height: 100vh; touch-action: none; display: block; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; user-select: none; -webkit-user-select: none; }
#hud > * { pointer-events: auto; }
.hud-top { position: absolute; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; pointer-events: none; }
.hud-top > * { pointer-events: auto; }
.hud-turn { display: flex; align-items: center; gap: 8px; background: var(--hud); color: #fff; padding: 6px 10px; border-radius: 12px; }
.team-chip { font-weight: 700; font-size: 14px; padding: 2px 8px; border-radius: 8px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.4); white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; min-width: 2ch; text-align: right; }
.timer.low { color: #ff6b6b; }
.message { flex: 1; text-align: center; color: #fff; font-weight: 800; font-size: 18px; text-shadow: 0 2px 4px rgba(0,0,0,.5); padding-top: 6px; pointer-events: none !important; }
.hud-wind { display: flex; flex-direction: column; align-items: center; gap: 3px; background: var(--hud); color: #fff; padding: 6px 10px; border-radius: 12px; font-size: 11px; }
.wind-bar { position: relative; width: 90px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.2); overflow: hidden; }
.hud-wind[data-level="hard"] #wind-fill { background: #ff9e3d; }
.hud-wind[data-level="storm"] #wind-fill { background: #ff4d4d; }
.hud-wind[data-level="storm"] { box-shadow: 0 0 0 2px rgba(255,77,77,.6); }
.wind-bar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: rgba(255,255,255,.6); }
#wind-fill { position: absolute; top: 0; height: 100%; background: #ffd54f; width: 0; left: 50%; }
.hud-teams { position: absolute; top: calc(52px + var(--safe-t)); left: 8px; display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
.hud-teams .trow { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
.hud-teams .tname { width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.hud-teams .tbar { width: 110px; height: 8px; border-radius: 4px; background: rgba(0,0,0,.4); overflow: hidden; }
.hud-teams .tbar > div { height: 100%; }
.hud-teams .trow.dead { opacity: .45; }

.weapons { position: absolute; right: 8px; top: calc(52px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; }
.weapons button { width: 52px; height: 44px; border: 2px solid transparent; border-radius: 10px; background: var(--hud); color: #fff; font-size: 20px; display: grid; place-items: center; line-height: 1; cursor: pointer; }
.weapons button small { font-size: 9px; opacity: .8; }
.weapons button { position: relative; }
.weapons .ammo { position: absolute; top: 2px; right: 3px; font-size: 9px; font-weight: 800; background: #ffd54f; color: #1f1710; border-radius: 8px; padding: 0 4px; line-height: 12px; }
.weapons .ammo:empty { display: none; }
.weapons button.sel { border-color: #ffd54f; background: rgba(60,45,20,.85); }
.weapons button:disabled { opacity: .4; cursor: default; }

.touch { position: absolute; bottom: calc(14px + var(--safe-b)); display: flex; gap: 10px; }
.touch.left { left: 14px; }
.touch.right { right: 14px; }
.tbtn { width: 62px; height: 62px; border-radius: 50%; border: none; background: rgba(255,255,255,.28); color: #fff; font-size: 24px; font-weight: 800; backdrop-filter: blur(4px); cursor: pointer; touch-action: none; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
.tbtn:active, .tbtn.down { background: rgba(255,255,255,.55); }
.tbtn.fire { width: 84px; height: 84px; background: rgba(226,69,60,.75); font-size: 15px; }
.tbtn.fire.down { background: rgba(255,120,80,.95); }
@media (hover: hover) and (pointer: fine) { .touch { opacity: .55; } .touch:hover { opacity: 1; } }

.hud-btns { display: flex; gap: 6px; }
.icon-btn.off { opacity: .6; }
.icon-btn { width: 38px; height: 34px; border: none; border-radius: 10px; background: var(--hud); color: #fff; font-size: 16px; cursor: pointer; flex: none; }
@media (max-width: 600px) {
  .message { position: absolute; left: 0; right: 0; top: 96px; font-size: 16px; padding: 0 70px; }
  .hud-teams { top: calc(48px + var(--safe-t)); }
  .hud-teams .tname { width: 74px; }
  .hud-teams .tbar { width: 80px; }
  .hud-wind { padding: 4px 8px; }
  .wind-bar { width: 64px; }
  .touch { gap: 6px; bottom: calc(10px + var(--safe-b)); }
  .touch.left { left: 8px; }
  .touch.right { right: 8px; }
  .tbtn { width: 52px; height: 52px; font-size: 20px; }
  .tbtn.fire { width: 70px; height: 70px; font-size: 13px; }
  .weapons { top: calc(112px + var(--safe-t)); }
  .weapons button { width: 44px; height: 38px; font-size: 17px; }
}
/* short screens (phone landscape): eight weapons in two columns */
@media (max-height: 520px) {
  .weapons { flex-direction: row; flex-wrap: wrap; width: 96px; justify-content: flex-end; gap: 4px; }
  .weapons button { width: 46px; height: 36px; font-size: 16px; }
}

/* ---------- Tutorial ---------- */
.tutorial { position: absolute; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%); width: min(460px, 60vw); background: rgba(255,250,240,.95); color: var(--ink); border-radius: 14px; padding: 10px 14px 12px; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.tut-head { display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: #8a7a6a; font-weight: 700; margin-bottom: 4px; }
.tut-btn { font: inherit; font-size: 11px; font-weight: 700; border: none; background: #efe6d6; color: var(--ink); border-radius: 8px; padding: 4px 10px; cursor: pointer; letter-spacing: 0; text-transform: none; }
.tut-text { font-size: 14px; line-height: 1.4; }
@media (max-width: 600px) { .tutorial { left: 8px; right: 66px; bottom: auto; top: calc(150px + var(--safe-t)); transform: none; width: auto; } }

/* ---------- Snigelpost ---------- */
.online { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.online h2 { margin: 0 0 4px; font-size: 20px; }
.online .blurb { margin: 0 0 12px; color: #6a5a4a; font-size: 14px; }
.online .row { align-items: flex-end; }
.online-list { display: flex; flex-direction: column; gap: 6px; }
.mrow { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; }
.mrow .mname { font-weight: 700; }
.mrow .mstate { font-size: 12px; color: #6a5a4a; }
.mrow.turn { border-color: var(--accent); background: #eef8f0; }
.mrow button { font: inherit; font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 8px; border: none; cursor: pointer; background: #efe6d6; color: var(--ink); }
.mrow button.play { background: var(--accent); color: #fff; }
.invite { display: flex; gap: 8px; margin: 8px 0 14px; flex-wrap: wrap; }
.invite input { flex: 1; min-width: 200px; }
.pushbox { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 0 0 14px; }
.pushbox .hint { margin: 0; }
.replaybar { position: absolute; top: calc(52px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; gap: 10px; align-items: center; background: rgba(255,250,240,.95); color: var(--ink); border-radius: 12px; padding: 6px 10px 6px 14px; font-weight: 700; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.notice { position: absolute; bottom: calc(110px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: rgba(226,69,60,.92); color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 700; max-width: 80vw; text-align: center; }

/* ---------- Overlays ---------- */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at top, rgba(191,227,255,.85), rgba(20,50,30,.75)); padding: 16px; overflow: auto; }
.panel { width: min(640px, 100%); background: var(--panel); border-radius: 18px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); border: 1px solid var(--line); }
.panel h1 { margin: 0 0 4px; font-size: 30px; display: flex; align-items: center; gap: 12px; }
.panel h2 { margin: 0 0 12px; }
.logo { display: inline-block; width: 44px; height: 44px; background: url("../icons/icon.svg") center/contain no-repeat; }
.tagline { margin: 0 0 16px; color: #6a5a4a; }
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 700; color: #6a5a4a; }
.row.rules label.volume { justify-content: flex-end; }
input[type=range] { width: 130px; accent-color: var(--accent); margin: 8px 0; }
select, input[type=text] { font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); }
.team-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.team-row { display: grid; grid-template-columns: 22px 1fr auto auto; gap: 8px; align-items: center; }
.team-row .swatch { width: 22px; height: 22px; border-radius: 6px; border: 2px solid rgba(0,0,0,.15); }
.team-row input { min-width: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
button.primary, button.secondary, a.secondary { font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 10px; border: none; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary { background: var(--accent); color: var(--accent-ink); }
button.secondary, a.secondary { background: #efe6d6; color: var(--ink); }
button.danger { color: #b3261e; }
.series { margin: -6px 0 12px; font-weight: 700; color: #3aaa5c; }
.daily { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.daily h2 { display: flex; align-items: baseline; gap: 10px; }
.daily-day { font-size: 13px; font-weight: 400; color: #8a7a6a; }
.daily .actions { margin: 8px 0; }
.board { margin: 8px 0 0; padding-left: 22px; columns: 2; column-gap: 24px; font-size: 13px; }
.board li { break-inside: avoid; display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.board li.me { font-weight: 700; color: #3aaa5c; }
.board.one { columns: 1; }
.boards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .boards { grid-template-columns: 1fr; } }
.badge { display: inline-block; padding: 1px 8px; border-radius: 8px; background: #fff3c4; color: #7a5200; font-size: 11px; font-weight: 700; margin: 2px 4px 2px 0; }
.tier { display: inline-block; padding: 1px 7px; border-radius: 8px; background: #efe6d6; font-size: 11px; font-weight: 700; margin-left: 4px; }
.board .bname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile { margin-top: 4px; }
.pickers { display: flex; flex-wrap: wrap; gap: 16px; margin: 6px 0; }
.plabel { font-size: 12px; font-weight: 700; color: #6a5a4a; display: block; margin-bottom: 4px; }
.picker { display: flex; flex-wrap: wrap; gap: 6px; }
.picker button { width: 74px; height: 74px; padding: 2px; border: 2px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; display: grid; grid-template-rows: 1fr auto; place-items: center; font-size: 9px; line-height: 1.1; color: #6a5a4a; overflow: hidden; }
.picker button span { max-width: 100%; text-align: center; }
.picker button canvas { width: 48px; height: 44px; }
.picker button.sel { border-color: var(--accent); background: #eaf7ee; }
.picker button.locked { opacity: .55; cursor: default; }
.picker button.buy { opacity: 1; cursor: pointer; border-color: #f2c94c; }
.picker button.buy canvas { filter: none; }
.picker button.buy span { color: #a06a00; font-weight: 700; }
.picker button.locked canvas { filter: grayscale(1); }
.account { margin-top: 12px; border-top: 1px dashed var(--line); padding-top: 8px; }
.account .row { margin: 6px 0; align-items: flex-end; }
.account .row label { flex: 1 1 180px; }
button.small { padding: 6px 12px; font-size: 12px; }
.hint { font-size: 12px; color: #8a7a6a; margin: 12px 0 0; min-height: 1em; }
.panel ul { padding-left: 18px; line-height: 1.5; margin: 0 0 12px; }
.panel li { margin-bottom: 6px; }

/* maker's mark at the bottom of the menu */
.brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: #8a7a6a; }
.brand img { width: 64px; height: 50px; border-radius: 8px; box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.brand a { color: inherit; font-weight: 700; text-decoration: none; }
.brand a:hover { text-decoration: underline; }
