: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; }
.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; } }

.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; }
}

/* ---------- 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; }
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); }
.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; }
