/* Pełzaki: Bitwa o Grządkę — style interfejsu */
:root {
  --bg: #0d1424;
  --bg2: #16213a;
  --panel: #1b2742;
  --panel2: #24345a;
  --text: #f4f6fb;
  --muted: #c3cde3;
  --accent: #ffd23f;
  --accent-text: #1d1600;
  --focus: #7fe3ff;
  --t0: #ff9a9a;
  --t1: #8fd0ff;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(ellipse at 20% 0%, #24406e 0%, transparent 55%),
    radial-gradient(ellipse at 90% 100%, #2b5a32 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  overflow: hidden;
}
#app { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 12px; }
.screen { width: 100%; display: flex; justify-content: center; }
.screen[hidden], [hidden] { display: none !important; }

/* Karty i menu */
.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg2) 100%);
  border: 2px solid #33477a;
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 720px;
  width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  animation: pop .25s ease-out;
}
.card.wide { max-width: 1100px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }

.logo {
  margin: 0 0 8px; font-size: 64px; line-height: 1; letter-spacing: 1px;
  color: var(--accent);
  text-shadow: 3px 3px 0 #7a3b00, 6px 6px 0 rgba(0,0,0,.35);
  text-align: center;
}
.logo span { display: block; font-size: 26px; color: #ffffff; text-shadow: 2px 2px 0 #333; margin-top: 8px; letter-spacing: 2px; }
.tagline { text-align: center; color: var(--muted); margin: 10px 0 22px; }
h2 { margin: 0 0 14px; font-size: 28px; color: #fff; }
h3 { margin: 14px 0 6px; font-size: 18px; color: var(--accent); }
.sub { color: var(--muted); margin: -6px 0 16px; }
.hint { text-align: center; color: var(--muted); font-size: 14px; margin: 18px 0 0; }

.btn-col { display: flex; flex-direction: column; gap: 12px; align-items: stretch; max-width: 420px; margin: 0 auto; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin: 4px 0 14px; }

.btn {
  font: inherit; font-weight: 700; font-size: 17px;
  padding: 12px 20px; border-radius: 12px; cursor: pointer;
  background: var(--panel2); color: #fff; border: 2px solid #4a64a0;
  transition: transform .08s, background .15s;
}
.btn:hover { background: #2f4472; transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: #b48e00; }
.btn.primary:hover { background: #ffe066; }
.btn.small { padding: 7px 14px; font-size: 15px; }
.btn.back { margin-top: 20px; }

:focus { outline: none; }
:focus-visible, .btn:focus-visible, .mode-card:focus-visible, .map-card:focus-visible, .wbtn:focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(127,227,255,.25);
}
canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

kbd {
  display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px;
  background: #0c1220; border: 1px solid #5a6f9f; border-bottom-width: 3px;
  font-family: inherit; font-size: 13px; color: #fff; text-align: center;
}

.quick-help { background: rgba(0,0,0,.25); border-radius: 12px; padding: 12px 18px; margin-top: 22px; }
.quick-help h2 { font-size: 17px; margin: 0 0 6px; color: var(--accent); }
.quick-help ul { margin: 0; padding-left: 18px; color: var(--text); font-size: 15px; }
.quick-help li { margin: 4px 0; }

/* Tryby */
.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.mode-card, .map-card {
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--panel2); border: 2px solid #4a64a0; border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 6px;
  transition: transform .1s, border-color .15s, background .15s;
}
.mode-card strong { font-size: 20px; color: var(--accent); }
.mode-card span { color: var(--muted); }
.mode-card:hover, .map-card:hover { transform: translateY(-2px); border-color: var(--accent); background: #2c3f68; }

/* Plansze */
.map-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.map-card { padding: 10px; }
.map-card canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: 8px; display: block; background: #000; }
.map-card strong { font-size: 16px; color: #fff; margin-top: 4px; }
.map-card .feat { font-size: 13px; font-weight: 700; color: var(--accent); }
.map-card .desc { font-size: 13px; color: var(--muted); }

/* Instrukcja */
.help-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.help p { margin: 0 0 8px; color: var(--text); }
.keys, .weapons-help { padding-left: 18px; margin: 0; }
.keys li, .weapons-help li { margin: 5px 0; }

/* Rozgrywka */
.game-screen { flex-direction: column; align-items: center; }
#game-wrap { display: flex; flex-direction: column; gap: 6px; margin: 0 auto; }
#hud {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--panel); border: 2px solid #33477a; border-radius: 12px; padding: 6px 8px;
  font-size: 14px;
}
.hud-team {
  display: flex; flex-direction: column; justify-content: center; min-width: 140px; max-width: 175px;
  padding: 2px 8px; border-radius: 8px; background: rgba(0,0,0,.25); border: 2px solid transparent;
  position: relative; padding-left: 22px;
}
.hud-team.right { text-align: right; padding-left: 8px; padding-right: 22px; }
.hud-team .sw { position: absolute; left: 7px; top: 8px; width: 10px; height: calc(100% - 16px); border-radius: 4px; }
.hud-team.right .sw { left: auto; right: 7px; }
.hud-team .tname { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-team .thp { color: var(--text); font-size: 12px; white-space: nowrap; }
.hud-team.active { border-color: var(--accent); box-shadow: 0 0 10px rgba(255,210,63,.35); }
.hud-mid { flex: 1; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; align-items: center; }
.hud-item { display: flex; flex-direction: column; align-items: center; background: rgba(0,0,0,.25); border-radius: 8px; padding: 2px 8px; min-width: 58px; }
.hud-item.wide { min-width: 150px; }
.hud-item .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.hud-item .val { font-weight: 700; font-size: 15px; white-space: nowrap; }
#h-time.low { color: #ffb3b3; animation: blink .6s infinite alternate; }
@keyframes blink { to { color: #fff; } }
.pbar { width: 64px; height: 5px; background: #0b1120; border-radius: 3px; overflow: hidden; margin-top: 2px; }
#h-pbar { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #6fe36f, #ffd23f, #ff5a5a); }

#stage { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid #33477a; background: #000; }
#game { display: block; width: 100%; height: 100%; cursor: crosshair; }

#banner {
  position: absolute; left: 50%; top: 32%; transform: translate(-50%, -50%);
  background: rgba(10, 16, 30, .9); border: 3px solid var(--accent); border-radius: 16px;
  padding: 14px 34px; text-align: center; pointer-events: none; z-index: 4;
  animation: bannerIn .3s ease-out;
}
@keyframes bannerIn { from { transform: translate(-50%, -70%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
#banner-title { font-size: 28px; font-weight: 800; color: #fff; }
#banner-sub { font-size: 18px; color: var(--accent); margin-top: 2px; }

#toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  background: rgba(10, 16, 30, .92); color: #fff; padding: 8px 18px; border-radius: 10px;
  font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; z-index: 12;
  border: 1px solid #4a64a0;
}
#toast.show { opacity: 1; }

#pause { z-index: 10; position: absolute; inset: 0; background: rgba(5, 8, 16, .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.pause-card { max-width: 760px; padding: 20px 26px; max-height: 100%; overflow: auto; }
.pause-help { font-size: 15px; }
.pause-help ul { padding-left: 18px; margin: 4px 0; }

#weaponbar {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  background: var(--panel); border: 2px solid #33477a; border-radius: 12px; padding: 6px 8px;
}
.weapons { display: flex; gap: 8px; flex-wrap: wrap; }
.wbtn {
  font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--panel2); color: #fff; border: 2px solid #4a64a0; border-radius: 10px; padding: 6px 12px;
}
.wbtn .k { display: inline-block; background: #0c1220; border-radius: 5px; padding: 0 6px; margin-right: 6px; color: var(--accent); }
.wbtn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: #b48e00; }
.wbtn[aria-pressed="true"] .k { color: #fff; }
.wbtn:disabled { opacity: .55; cursor: not-allowed; }

/* Dźwięk */
.bar-right { display: flex; gap: 8px; }
.sound-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: rgba(0,0,0,.25); border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; }
.sound-row label { font-weight: 700; }
#sound-volume { width: 180px; accent-color: var(--accent); cursor: pointer; }
#sound-volume:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
#sound-volume-val { min-width: 42px; font-weight: 700; }
[data-sound-toggle][aria-pressed="false"] { opacity: .85; border-style: dashed; }

/* Wynik */
.result-title { text-align: center; font-size: 44px; color: var(--accent); text-shadow: 3px 3px 0 #7a3b00; }
.stats { list-style: none; padding: 0; margin: 0 auto 22px; max-width: 420px; }
.stats li { display: flex; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid #33477a; }

@media (max-width: 1150px) {
  .map-grid { grid-template-columns: repeat(3, 1fr); }
  .logo { font-size: 52px; }
  .hud-team { min-width: 120px; }
  .hud-item.wide { min-width: 140px; }
}
@media (max-width: 760px) {
  .mode-grid, .help-cols { grid-template-columns: 1fr; }
  .map-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 760px) {
  .card { padding: 18px 24px; }
  .logo { font-size: 46px; }
  .quick-help { margin-top: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
