/* Layout idea: one screen, phone on a table. Score chips on top, the board fills
   whatever height is left, one status line and two buttons underneath. */
:root {
  color-scheme: dark;
  --bg: #0f2129;          /* pond at night */
  --surface: #173039;
  --tile: #1f434d;
  --tile-edge: #2b5a66;
  --rock: #0a171c;
  --ink: #eaf6f2;
  --muted: #8fb3b8;
  --accent: #7de2c3;
  --p0: #4aa8ff;          /* niebieski */
  --p1: #ff7ab8;          /* różowy */
  --p2: #ffd23f;          /* żółty */
  --p3: #63d471;          /* zielony */
  --font-display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app {
  height: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  line-height: 1;
  margin: 0;
  letter-spacing: 0.01em;
}
.round { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

/* score chips */
.scores { display: flex; gap: 8px; }
.chip {
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 8px 8px 6px;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  transition: border-color .15s, opacity .15s;
}
.chip .dot { width: 22px; height: 22px; border-radius: 48% 52% 50% 50% / 56% 50% 50% 44%; background: var(--c); }
.chip .count { font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }
.chip .meta { grid-column: 1 / -1; font-size: 12px; line-height: 1.25; color: var(--muted); margin-top: 4px; }
.chip.turn { border-color: var(--c); }
.chip.out { opacity: .4; }

/* board */
.stage { flex: 1 1 auto; min-height: 220px; container-type: size; display: grid; place-items: center; }
.board {
  --w: 6; --h: 6;
  width: min(100cqw, calc(100cqh * var(--w) / var(--h)));
  aspect-ratio: var(--w) / var(--h);
  display: grid;
  grid-template-columns: repeat(var(--w), 1fr);
  gap: 5px;
  padding: 6px;
  background: var(--surface);
  border-radius: 18px;
}
.cell {
  position: relative;
  border: 0;
  padding: 0;
  border-radius: 22%;
  background: var(--tile);
  box-shadow: inset 0 -3px 0 var(--tile-edge);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.cell.block { background: var(--rock); box-shadow: inset 0 3px 0 #000; cursor: default; }
.cell.block::after { content: ""; width: 38%; height: 38%; border-radius: 40% 60% 55% 45%; background: #14272e; }

.blob {
  --c: var(--p0);
  width: 76%; height: 76%;
  border-radius: 46% 54% 52% 48% / 58% 54% 46% 42%;
  background: radial-gradient(circle at 32% 26%, rgba(255,255,255,.55) 0 9%, transparent 10%), var(--c);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18);
  position: relative;
}
.blob::before, .blob::after {
  content: "";
  position: absolute; top: 40%;
  width: 20%; height: 24%;
  border-radius: 50%;
  background: radial-gradient(circle at 55% 60%, #10222b 0 42%, #fff 44%);
}
.blob::before { left: 24%; } .blob::after { right: 24%; }
.cell.sel .blob { outline: 3px solid var(--ink); outline-offset: 3px; }
.cell.pop .blob { animation: pop .28s cubic-bezier(.3,1.6,.5,1); }
@keyframes pop { from { transform: scale(.35); } to { transform: scale(1); } }

.mark { width: 34%; height: 34%; border-radius: 50%; }
.cell.t-clone .mark { background: var(--c); opacity: .9; }
.cell.t-jump .mark { border: 3px dashed var(--c); width: 46%; height: 46%; }
.cell.last { box-shadow: inset 0 -3px 0 var(--tile-edge), inset 0 0 0 2px rgba(234,246,242,.28); }

/* status + controls */
.status { min-height: 48px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.status strong { font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.15; }
.status .who { color: var(--c); }
.status small { color: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 16px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--muted); }
.legend i.j { background: none; border: 2px dashed var(--muted); }

.bar { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  flex: 1 1 140px;
  min-height: 46px;
  border: 0; border-radius: 12px;
  background: var(--surface);
  font-weight: 700;
  cursor: pointer;
  padding: 0 16px;
}
.btn.primary { background: var(--accent); color: #0b2a24; }
.btn:active { transform: translateY(1px); }

/* settings dialog */
dialog {
  background: var(--surface); color: var(--ink);
  border: 0; border-radius: 18px;
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(5,12,15,.7); }
dialog h2 { font-family: var(--font-display); font-weight: 800; font-size: 22px; margin: 0 0 12px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .field > span { font-size: 13px; color: var(--muted); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; min-height: 42px; border: 2px solid var(--tile-edge); background: none; border-radius: 10px; cursor: pointer; font-weight: 700; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.seat { display: grid; grid-template-columns: 20px 1fr 1.3fr; gap: 8px; align-items: center; }
.seat i { width: 18px; height: 18px; border-radius: 50%; background: var(--c); }
.seat[hidden] { display: none; }
select { min-height: 42px; background: var(--bg); border: 2px solid var(--tile-edge); border-radius: 10px; padding: 0 10px; width: 100%; }
.note { font-size: 13px; color: var(--muted); margin: 0 0 14px; }

@media (max-width: 400px) {
  h1 { font-size: 22px; }
  .chip { padding: 6px; column-gap: 6px; }
  .chip .count { font-size: 22px; }
  .chip .dot { width: 18px; height: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .cell.pop .blob { animation: none; }
  .btn:active { transform: none; }
}

/* ---------- views ---------- */
.view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.view[hidden], .btn[hidden] { display: none; }
.panel { background: var(--surface); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.panel h2 { font-family: var(--font-display); font-weight: 800; font-size: 20px; margin: 0; }
.lead { color: var(--muted); margin: 0; max-width: 46ch; }
.row { display: flex; gap: 8px; }
.row > input { flex: 1 1 0; min-width: 0; }
.row > .btn { flex: 0 0 auto; }
input[type="text"] {
  min-height: 46px; background: var(--bg); border: 2px solid var(--tile-edge); border-radius: 12px;
  padding: 0 12px; font: inherit; color: inherit; width: 100%;
}
#inp-code { text-transform: uppercase; letter-spacing: .2em; font-weight: 700; }
label.cap { font-size: 13px; color: var(--muted); }
.msg { min-height: 20px; font-size: 14px; color: var(--p1); margin: 0; }
.code { font-family: var(--font-display); font-weight: 800; font-size: 44px; letter-spacing: .12em; line-height: 1; }
.link { font-size: 13px; color: var(--muted); word-break: break-all; margin: 0; }
.seats-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.seats-list li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; min-height: 40px; }
.seats-list i { width: 22px; height: 22px; border-radius: 48% 52% 50% 50% / 56% 50% 50% 44%; background: var(--c); }
.seats-list .tag { font-size: 13px; color: var(--muted); }
.seats-list button { min-height: 36px; border: 2px solid var(--tile-edge); background: none; border-radius: 10px; padding: 0 10px; cursor: pointer; }
.seats-list li.free i { background: none; border: 2px dashed var(--tile-edge); }
.seats-list li.free span { color: var(--muted); }
.conn { font-size: 13px; color: var(--muted); }
.chip.off .dot { opacity: .35; }

#view-home, #view-lobby { overflow-y: auto; }
.panel, .view > .bar, .view > .lead { flex: 0 0 auto; }
.panel > .btn { flex: 0 0 auto; }
.top h1 { white-space: nowrap; }
.top .round { text-align: right; }
