/* Comet Destroyers — Playora shell, original arena/player colours preserved. */

* { box-sizing: border-box; }

:root {
  --bg: var(--playora-bg);
  --bg-2: var(--playora-panel-2);
  --ink: var(--playora-text);
  --dim: var(--playora-muted);
  --line: var(--playora-border);
  --accent: var(--playora-accent);
  --accent-2: var(--playora-accent);
  --danger: var(--playora-danger);
}

html, body { height: 100%; overscroll-behavior: none; }

/* Canvas to powierzchnia gry: dotyk obsługuje gra, nie przeglądarka (przewijanie, pinch, podwójne tapnięcie). */
#game { display: block; touch-action: none; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.stars {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    radial-gradient(1px 1px at 12% 22%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 68% 12%, #cfe4ff 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 82% 68%, #fff 50%, transparent 50%),
    radial-gradient(1px 1px at 32% 76%, #9fc4ff 50%, transparent 50%),
    radial-gradient(1px 1px at 55% 42%, #fff 50%, transparent 50%),
    radial-gradient(1.5px 1.5px at 8% 60%, #cfe4ff 50%, transparent 50%);
}

#app { position: relative; height: calc(100% - var(--playora-header-height)); }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: clamp(14px, 3.5vw, 40px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.screen.is-active { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
#screen-menu.is-active { text-align: center; }
#screen-game.is-active { padding: 0; overflow: hidden; }

.title {
  margin: 0 0 4px;
  font-size: clamp(30px, 6vw, 56px);
  letter-spacing: -.035em;
  font-weight: 800;
  color: #eafcff;
  text-shadow: none;
}
.tagline { margin: 0 0 8px; color: var(--dim); max-width: 42ch; }
h2 { margin: 4px 0; font-size: clamp(20px, 4.4vw, 28px); letter-spacing: 0.06em; }
h3 { margin: 4px 0 8px; font-size: clamp(17px, 4vw, 22px); }
.hint { color: var(--dim); font-size: 13px; margin: 2px 0; }
.hint.bad { color: var(--danger); }

.help {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--dim);
  font-size: 13px;
  line-height: 1.55;
  background: var(--playora-panel-2);
}
.help p { margin: 2px 0; }
kbd {
  font: inherit; font-size: 12px; padding: 1px 5px; border-radius: 5px;
  border: 1px solid var(--line); background: var(--playora-panel-2); color: #cfe4ff;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 6px 0; }

.btn {
  font: inherit; font-size: 15px; cursor: pointer;
  padding: 11px 18px; border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--playora-panel-2);
  color: var(--ink);
  transition: transform 0.08s ease, border-color 0.2s, box-shadow 0.2s;
}
.btn:hover { border-color: var(--accent-2); box-shadow: 0 0 0 1px rgba(76, 201, 240, 0.25); }
.btn:active { transform: translateY(1px); }
.btn.primary { border-color: var(--playora-accent); box-shadow: 0 0 18px rgba(85, 221, 136, 0.08) inset; }
.btn.ghost { background: transparent; color: var(--dim); }
.btn.mini { font-size: 12px; padding: 6px 10px; border-radius: 9px; }
.btn.danger { border-color: rgba(255, 92, 138, 0.55); color: #ffc6d6; }

.field { display: flex; flex-direction: column; gap: 6px; width: min(320px, 90vw); }
.field.inline { flex-direction: row; align-items: center; gap: 8px; width: auto; }
.field label { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; }
input, select {
  font: inherit; color: var(--ink);
  background: var(--playora-panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; min-width: 0;
}
input:focus-visible, select:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input#inp-code { text-transform: uppercase; letter-spacing: 0.3em; width: 9ch; text-align: center; }
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); }

.cfg-grid {
  display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center;
  width: min(420px, 92vw); padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--playora-panel-2);
}
.cfg-grid label { text-transform: none; letter-spacing: 0; font-size: 13px; color: var(--ink); }
.cfg-grid select { justify-self: end; }
.cfg-grid input[type="checkbox"] { justify-self: end; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.segmented button {
  font: inherit; padding: 9px 16px; border: 0; cursor: pointer;
  background: var(--playora-panel-2); color: var(--dim);
}
.segmented button.is-active { background: var(--playora-accent); color: #eafcff; box-shadow: 0 0 14px rgba(94, 240, 208, 0.2) inset; }

.room-list, .player-list {
  list-style: none; margin: 4px 0; padding: 4px;
  width: min(460px, 94vw); border: 1px solid var(--line); border-radius: 12px;
  background: var(--playora-panel-2); max-height: 32vh; overflow-y: auto;
}
.room-list li, .player-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; font-size: 14px;
}
.room-list li { cursor: pointer; }
.room-list li:hover { background: rgba(76, 201, 240, 0.12); }
.room-list li b { font-family: ui-monospace, monospace; letter-spacing: 0.18em; }
.room-list li span { color: var(--dim); }
.room-list li em { margin-left: auto; font-style: normal; font-size: 12px; color: var(--dim); }
.room-list li.empty { color: var(--dim); cursor: default; justify-content: center; }
.player-list li i, .board li i, .standings i {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none;
  box-shadow: 0 0 10px currentColor;
}
.player-list li span { flex: 1; }
.player-list em { font-style: normal; font-size: 11px; padding: 2px 7px; border-radius: 20px; }
.player-list em.host { background: rgba(255, 209, 102, 0.16); color: #ffd166; }
.player-list em.ok { background: rgba(155, 229, 100, 0.16); color: #9be564; }
.player-list em.wait { background: rgba(143, 160, 192, 0.16); color: var(--dim); }
.player-list em.you { color: var(--accent); font-size: 12px; }
.player-list li.out { opacity: 0.5; text-decoration: line-through; }

.code {
  font: 700 clamp(22px, 5vw, 32px)/1.2 ui-monospace, monospace; letter-spacing: 0.28em;
  padding: 8px 14px; border-radius: 12px; cursor: copy;
  border: 1px dashed rgba(94, 240, 208, 0.5); background: rgba(94, 240, 208, 0.06); color: #d9fff6;
}
.room-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: center; text-align: center; }

.chat { width: min(520px, 94vw); }
.chat-log {
  list-style: none; margin: 0 0 8px; padding: 8px;
  height: 140px; overflow-y: auto; font-size: 13px; line-height: 1.5;
  border: 1px solid var(--line); border-radius: 12px; background: var(--playora-panel-2);
}
.chat-log li { margin-bottom: 3px; word-break: break-word; }

/* ---------- ekran gry ---------- */

#stage { position: relative; width: 100%; height: 100%; }
#game { display: block; width: 100%; height: 100%; }

.hud {
  position: absolute; display: flex; align-items: center; gap: 12px;
  font-size: 13px; letter-spacing: 0.08em; color: #cfe4ff; pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
.hud#hud-top, #hud-top { top: 10px; left: 12px; right: 12px; }
#hud-top { flex-wrap: wrap; row-gap: 4px; }
#hud-top .spacer { flex: 1; }
#hud-top .dim { color: var(--dim); }
#hud-top .btn { pointer-events: auto; }

.board {
  position: absolute; top: 40px; right: 12px; flex-direction: column; gap: 4px;
  list-style: none; margin: 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(5, 9, 20, 0.55);
  font-size: 12px; letter-spacing: 0.04em; max-width: 46vw;
}
.board li { display: flex; align-items: center; gap: 6px; }
.board li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 14ch; }
.board li b { font-variant-numeric: tabular-nums; }
.board li em.out { font-style: normal; font-size: 10px; color: var(--danger); }

.feed {
  position: absolute; left: 12px; bottom: 14px; display: flex; flex-direction: column; gap: 3px;
  font-size: 12px; color: #cfe4ff; text-shadow: 0 1px 3px #000; pointer-events: none;
}
.feed-line { animation: fade-in 0.25s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }

.banner {
  position: absolute; left: 50%; top: 16%; transform: translate(-50%, -8px);
  font-size: clamp(20px, 5vw, 40px); font-weight: 800; letter-spacing: 0.16em;
  color: #eafcff; text-shadow: 0 0 16px rgba(94, 240, 208, 0.7);
  opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner.warn { color: #ffd7e3; text-shadow: 0 0 16px rgba(255, 92, 138, 0.7); }

.game-chat {
  position: absolute; right: 12px; bottom: 14px; width: min(280px, 40vw);
  height: auto; max-height: 26vh; background: rgba(5, 9, 20, 0.45);
}

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(3, 6, 15, 0.78); z-index: 5;
}
/* Rozmycie pod nakładką jest drogie nad animowanym canvasem — zostaje tylko na monitorach z myszą i pełnej jakości. */
@media (pointer: fine) {
  .overlay { backdrop-filter: blur(3px); }
}
.perf-low .overlay { backdrop-filter: none; }
.overlay[hidden] { display: none; }
.overlay-card {
  width: min(420px, 92vw); padding: 18px 20px; text-align: center;
  border: 1px solid var(--line); border-radius: 16px;
  background: var(--playora-panel);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.55);
}

.standings { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 6px; }
.standings th { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 4px; }
.standings td { padding: 5px 4px; border-top: 1px solid rgba(120, 180, 255, 0.12); }
.standings td.rk { color: var(--dim); width: 2.5ch; }
.standings td.pt { font-variant-numeric: tabular-nums; text-align: right; }
.standings td.deaths { color: var(--dim); font-size: 12px; text-align: right; }
.standings td i { margin-right: 6px; }

/*
 * Pad dotykowy: sterowanie pod dwa kciuki, więc cel na palec ma minimum 76 px (wspólne minima
 * w shared/ui/mobile-controls.css), a transfer siedzi w drugim rzędzie nad gaszaczem. Panel jest
 * uniesiony ponad safe-area, żeby kciuk nie zahaczał o systemowy pasek z „wróć”.
 */
.touch {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, auto); grid-auto-rows: auto;
  justify-content: space-between; align-content: end;
  padding: 10px 12px calc(env(safe-area-inset-bottom, 0px) + 18px);
  gap: 10px; z-index: 4;
}
.touch button {
  width: 76px; height: 76px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(12, 20, 36, 0.7); color: #d9e8ff;
  font-size: 26px; touch-action: none; user-select: none;
}
.touch button.on { background: rgba(94, 240, 208, 0.25); border-color: var(--accent); }
.touch button[data-act="fire"] { width: 84px; height: 84px; font-size: 28px; }
.touch button[data-act="left"] { grid-column: 1; grid-row: 2; }
.touch button[data-act="right"] { grid-column: 2; grid-row: 2; }
.touch button[data-act="thrust"] { grid-column: 3; grid-row: 2; width: 76px; height: 76px; }
.touch button[data-act="fire"] { grid-column: 4; grid-row: 2; }
.touch button[data-act="warp"] { grid-column: 4; grid-row: 1; }

@media (max-width: 640px) {
  .board { font-size: 11px; padding: 6px 8px; }
  .game-chat { display: none; }
  .field.inline { flex-wrap: wrap; }
  .cfg-grid { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Consistent, scrollable panels; the arena keeps the entire available viewport. */
.screen:not(#screen-game) {
  inset: 16px 0; width: min(760px, calc(100% - 32px)); margin-inline: auto;
  border: 1px solid var(--line); border-radius: 14px; background: var(--playora-panel);
  padding: clamp(16px, 3vw, 28px); justify-content: flex-start;
}
.screen:not(#screen-game) > * { flex-shrink: 0; max-width: 100%; }
#screen-menu .title { color: var(--ink); }
#screen-menu .tagline { max-width: 54ch; line-height: 1.6; }
.help { text-align: left; max-width: 62ch; padding: 16px; }
.help p + p { margin-top: 8px; }
.hint { line-height: 1.5; max-width: 60ch; }
.btn { border-radius: 7px; background: var(--playora-panel-2); }
.btn.primary { background: var(--accent); color: #07140c; box-shadow: none; font-weight: 650; }
.btn.ghost { background: transparent; }
.segmented button.is-active { color: #07140c; box-shadow: none; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .55; }
.field { width: min(320px, 100%); }
.cfg-grid { width: min(420px, 100%); }
#lobby-room, #lobby-join { width: 100%; max-width: 540px; }
#lobby-room > *, #lobby-join > * { max-width: 100%; }
.chat, .room-list, .player-list { width: 100%; }
.chat .field.inline { width: 100%; }
#inp-chat { flex: 1; width: 0; }
.code { color: var(--accent); border-color: var(--accent); }
.stars { opacity: .15; }
.touch[hidden] { display: none; }
.overlay-card { max-height: 90%; overflow-y: auto; }
@media (max-width: 640px) {
  .screen:not(#screen-game) { inset: 8px 0; width: calc(100% - 16px); }
  .playora-header { padding-inline: 14px; }
  .title { max-width: 12ch; line-height: 1.1; }
  #hud-top { gap: 6px; font-size: 11px; letter-spacing: 0; }
  .board { top: 72px; }
}

/*
 * Telefon/tablet w poziomie: tryb „tylko plansza". W trakcie lotu nagłówek Playora ustępuje pola
 * canvasowi (wyjście zostaje w HUD: „wyjdź" / Esc), a pad siada na planszy jako przeźroczysta
 * warstwa. Wspólne minima padu (shared/ui/mobile-controls.css) zostają w mocy.
 */
@media (orientation: landscape) and (pointer: coarse) {
  :root { --playora-header-height: 48px; }
  .playora-header { padding-block: 4px; }
  .playora-brand small { display: none; }
  .playora-language button { min-height: 34px; padding: 4px 10px; }
  .touch button { background: rgba(12, 20, 36, 0.45); }
  .touch button.on { background: rgba(94, 240, 208, 0.3); }
  /* Czat w kabinie wchodzi na planszę, więc zdejmuje ramkę i tło (zostaje sam tekst) oraz podnosi
     się nad dwa rzędy padu. W portrecie telefonu chowa go reguła @media (max-width: 640px). */
  .game-chat { bottom: calc(env(safe-area-inset-bottom, 0px) + 190px); max-height: 15vh; background: transparent; border-color: transparent; }
  body:has(#screen-game.is-active) { --playora-header-height: 0px; }
  body:has(#screen-game.is-active) .playora-header { display: none; }
}
