/* ==========================================================================
   Familiada — arkusz stylów
   Zasady: jeden rozmiar kontrolek (--fm-control), przyciski w grupach zawsze
   równej szerokości i wysokości, spójne odstępy (skala 4/8/12/16/24/32).
   ========================================================================== */
:root {
  color-scheme: dark;
  --fm-bg: #050d1a;
  --fm-panel: #0d2038;
  --fm-panel-2: #15314f;
  --fm-blue: #2a7bd1;
  --fm-red: #e23a4a;
  --fm-gold: #ffd35a;
  --fm-gold-2: #f0b92f;
  --fm-text: #f6f8fc;
  --fm-muted: #9fb4c8;
  --fm-border: rgba(255,255,255,.1);
  --fm-border-strong: rgba(255,255,255,.2);
  --fm-field: #071526;
  --fm-control: 46px;
  --fm-radius: 16px;
  --fm-shadow: 0 18px 44px rgba(0,0,0,.34);
}
* { box-sizing: border-box; scrollbar-width: thin; scrollbar-color: #35597c transparent; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--fm-text);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
  background: var(--fm-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* tło ze „światłami studia” — stałe, nie przewija się z treścią */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 55% at 50% -12%, rgba(42,123,209,.55), transparent 62%),
    radial-gradient(ellipse 55% 45% at 6% 105%, rgba(226,58,74,.2), transparent 60%),
    radial-gradient(ellipse 45% 40% at 98% 90%, rgba(255,211,90,.08), transparent 60%),
    var(--fm-bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h2, h3, p { overflow-wrap: anywhere; }
h1 { overflow-wrap: normal; }
:focus-visible { outline: 2px solid var(--fm-gold); outline-offset: 2px; }

/* ---------- układ stron ---------- */
.fm-shell { width: min(1080px, 100% - 32px); margin: 0 auto; padding: 32px 0 88px; }
.fm-game { width: min(1180px, 100% - 28px); margin: 0 auto; padding: 22px 0 88px; }
.fm-kicker { margin: 0; color: var(--fm-gold); font-size: .74rem; font-weight: 800; letter-spacing: .22em; text-transform: uppercase; }

/* ---------- ekran główny ---------- */
.fm-hero { text-align: center; padding: 32px 16px 24px; }
.fm-hero h1, .fm-game-header h1 {
  margin: 6px 0 14px; font: 700 clamp(3rem, 9vw, 6rem)/.95 Oswald, "Arial Narrow", sans-serif; letter-spacing: .08em;
  color: var(--fm-gold);
  background: linear-gradient(180deg, #fff4c2 0%, #ffd35a 52%, #e3a51d 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 22px rgba(255,180,30,.28));
}
.fm-hero > p:last-child { max-width: 620px; margin: 0 auto; color: var(--fm-muted); font-size: 1.05rem; line-height: 1.6; }
.fm-hero.compact { padding: 8px 16px 4px; }
.fm-hero.compact h1 { font-size: clamp(2.6rem, 8vw, 4.4rem); margin-bottom: 8px; }
.fm-hero.compact .fm-kicker::before, .fm-hero.compact .fm-kicker::after { display: none; }
.fm-hero .fm-kicker { display: inline-flex; align-items: center; gap: 14px; }
.fm-hero .fm-kicker::before, .fm-hero .fm-kicker::after { content: ""; width: 38px; height: 1px; background: linear-gradient(90deg, transparent, var(--fm-gold)); }
.fm-hero .fm-kicker::after { transform: scaleX(-1); }

.fm-home-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; max-width: 820px; margin: 8px auto 28px; }
.fm-card {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 212px; padding: 28px 24px; border: 1px solid var(--fm-border-strong); border-radius: 22px; overflow: hidden;
  color: var(--fm-text); text-align: center; background: linear-gradient(150deg, #19405f, #0b1b2f 80%);
  box-shadow: var(--fm-shadow); transition: transform .18s, border-color .18s, box-shadow .18s;
}
.fm-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(ellipse 70% 60% at 50% 0%, rgba(255,211,90,.16), transparent 70%); opacity: 0; transition: opacity .2s; }
.fm-card:hover, .fm-card:focus-visible { transform: translateY(-3px); border-color: var(--fm-gold); box-shadow: 0 24px 56px rgba(0,0,0,.42), 0 0 0 1px rgba(255,211,90,.25); }
.fm-card:hover::after, .fm-card:focus-visible::after { opacity: 1; }
.fm-card > span { display: grid; place-items: center; width: 68px; height: 68px; margin-bottom: 6px; border-radius: 20px; font-size: 2rem; background: rgba(255,255,255,.07); border: 1px solid var(--fm-border); }
.fm-card strong { color: var(--fm-gold); font: 700 1.6rem Oswald, "Arial Narrow", sans-serif; text-transform: uppercase; letter-spacing: .05em; }
.fm-card small { max-width: 30ch; color: var(--fm-muted); font-size: .95rem; line-height: 1.45; text-wrap: balance; }

/* ---------- panele ---------- */
.fm-rules, .fm-panel {
  border: 1px solid var(--fm-border); border-radius: var(--fm-radius);
  background: linear-gradient(160deg, rgba(21,49,79,.92), rgba(10,24,41,.94)); box-shadow: var(--fm-shadow);
}
.fm-rules { max-width: 820px; margin: 0 auto; padding: 24px 28px; }
.fm-rules h2, .fm-panel h2 { margin: 0 0 14px; color: var(--fm-gold); font: 600 1.4rem/1.2 Oswald, "Arial Narrow", sans-serif; letter-spacing: .02em; text-transform: uppercase; }
.fm-rules ol { margin: 0; padding-left: 22px; color: #d3dfea; line-height: 1.75; }
.fm-rules li::marker { color: var(--fm-gold); font-weight: 800; }
.fm-panel { margin: 16px 0; padding: 24px; }
.fm-panel > :last-child { margin-bottom: 0; }
.fm-panel-title, .fm-round-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.fm-panel-title { flex-wrap: wrap; }
.fm-panel-title { margin-bottom: 14px; }
.fm-panel-title > div > * { margin: 0; }
.fm-panel-title .fm-kicker { margin-bottom: 4px; }
.fm-panel-title h2 { margin: 0; }
.fm-panel-title > .fm-button { flex: none; }
.fm-heading { display: flex; align-items: center; gap: 20px; margin-bottom: 22px; }
.fm-heading > .fm-button { flex: none; min-width: 118px; }
.fm-heading h1 { margin: 0; font: 600 clamp(1.7rem, 4vw, 2.5rem)/1.1 Oswald, "Arial Narrow", sans-serif; text-transform: uppercase; }
.fm-heading .fm-kicker { margin: 0 0 4px; }
.fm-help { margin: 0 0 14px; color: var(--fm-muted); font-size: .92rem; line-height: 1.6; }
.fm-help code { padding: 1px 6px; border-radius: 6px; color: var(--fm-gold); background: rgba(255,211,90,.09); overflow-wrap: anywhere; }
.fm-notice { margin: 12px 0 0; color: #b7f4cc; }
.fm-error { margin: 12px 0 0; color: #ff9a9a; }
.fm-error:empty, .fm-error[hidden] { display: none; }

/* ---------- formularze ---------- */
.fm-team-inputs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fm-panel label:not(.fm-button):not(.fm-check), .fm-modal label { display: block; color: var(--fm-muted); font-size: .84rem; font-weight: 700; letter-spacing: .02em; }
.fm-panel input:not([type=checkbox]):not([type=file]), .fm-panel textarea, .fm-panel select, .fm-modal input, .fm-modal textarea {
  display: block; width: 100%; min-height: var(--fm-control); margin-top: 8px; padding: 0 14px;
  border: 1px solid #3b5c7b; border-radius: 12px; outline: 0; color: var(--fm-text); background: var(--fm-field);
  transition: border-color .15s, box-shadow .15s;
}
.fm-panel textarea, .fm-modal textarea { padding: 12px 14px; line-height: 1.5; resize: vertical; }
.fm-panel select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background: var(--fm-field) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ffd35a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 15px center;
}
.fm-panel option { color: var(--fm-text); background: #0d2038; }
.fm-panel input::placeholder, .fm-panel textarea::placeholder, .fm-modal input::placeholder, .fm-modal textarea::placeholder { color: #67819a; }
.fm-panel input:hover, .fm-panel textarea:hover, .fm-panel select:hover, .fm-modal input:hover, .fm-modal textarea:hover { border-color: #55789a; }
.fm-panel input:focus, .fm-panel textarea:focus, .fm-panel select:focus, .fm-modal input:focus, .fm-modal textarea:focus { border-color: var(--fm-gold); box-shadow: 0 0 0 3px rgba(255,211,90,.16); }
.fm-panel input[type=number], .fm-modal input[type=number] { -moz-appearance: textfield; text-align: center; }
.fm-check { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--fm-text); font-size: .95rem; font-weight: 600; cursor: pointer; }
input[type=checkbox] { flex: none; width: 20px; height: 20px; margin: 0; accent-color: var(--fm-gold); cursor: pointer; }
.fm-wide-label { max-width: 340px; margin-top: 16px; }
.fm-join-panel, .fm-join-panel + .fm-panel { max-width: 760px; margin-inline: auto; }
.fm-join-panel label + label { margin-top: 14px; }
.fm-join-panel .fm-actions { max-width: none; grid-template-columns: 1fr 1fr; margin-top: 20px; }

/* ---------- przyciski: jeden system ---------- */
.fm-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--fm-control); padding: 8px 20px;
  border: 1px solid #ffd869; border-radius: 12px; color: #2b1d03; font-weight: 800; font-size: .95rem; line-height: 1.2; text-align: center; text-decoration: none; user-select: none;
  background: linear-gradient(180deg, #ffe587, #f1ba2e); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 6px 16px rgba(240,185,47,.16);
  transition: transform .15s, filter .15s, box-shadow .15s, background .15s, border-color .15s;
}
.fm-button:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.06); box-shadow: inset 0 1px 0 rgba(255,255,255,.55), 0 10px 22px rgba(240,185,47,.24); }
.fm-button:active:not(:disabled) { transform: translateY(0); filter: brightness(.97); }
.fm-button:disabled { opacity: .42; cursor: not-allowed; box-shadow: none; filter: saturate(.6); }
.fm-button.secondary { color: var(--fm-text); border-color: var(--fm-border-strong); background: rgba(255,255,255,.07); box-shadow: none; }
.fm-button.secondary:hover:not(:disabled) { border-color: rgba(255,211,90,.55); background: rgba(255,255,255,.12); box-shadow: none; filter: none; }
.fm-button.danger { color: #ffd9dd; border-color: rgba(255,106,118,.5); background: rgba(226,58,74,.18); box-shadow: none; }
.fm-button.danger:hover:not(:disabled) { border-color: #ff7b87; background: rgba(226,58,74,.32); box-shadow: none; filter: none; }
.fm-button.small { min-height: 38px; padding: 5px 14px; border-radius: 10px; font-size: .85rem; }
label.fm-button { cursor: pointer; }

/* grupy przycisków: kolumny o równej szerokości, rzędy o równej wysokości */
.fm-toolbar, .fm-actions {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); align-items: stretch; gap: 10px; margin-top: 16px;
}
.fm-actions { max-width: 760px; }
.fm-toolbar { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.fm-actions:has(> .fm-button:only-child) { grid-template-columns: minmax(190px, 260px); }
.fm-actions > .fm-button, .fm-toolbar > .fm-button { width: 100%; }
.fm-row-actions { display: grid; grid-template-columns: repeat(2, 92px); gap: 8px; margin: 0; }
.fm-row-actions .fm-button { width: 100%; }
.fm-final .fm-actions, .fm-final-play .fm-actions, .fm-round-result .fm-actions, .fm-code + .fm-actions { margin-inline: auto; justify-content: center; }
.fm-tv-action { display: flex; justify-content: flex-end; margin: -4px 0 12px; }
.fm-tv-action .fm-button { min-width: 168px; }
.fm-panel > .fm-button, .fm-final > .fm-button, .fm-round-result > .fm-button { min-width: 240px; margin-top: 6px; }

/* ---------- pytania w panelu ---------- */
.fm-question-list { display: grid; gap: 8px; max-height: 460px; margin-top: 16px; padding-right: 4px; overflow: auto; }
.fm-question-row, .fm-room { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border: 1px solid var(--fm-border); border-radius: 12px; background: rgba(4,14,26,.55); transition: border-color .15s; }
.fm-question-row:hover, .fm-room:hover { border-color: var(--fm-border-strong); }
.fm-question-row > div:first-child, .fm-room > div { min-width: 0; }
.fm-question-row strong, .fm-question-row small, .fm-room strong, .fm-room small { display: block; overflow-wrap: anywhere; }
.fm-question-row small, .fm-room small { margin-top: 4px; color: var(--fm-muted); font-size: .84rem; line-height: 1.45; }
.fm-room > .fm-button { flex: none; min-width: 112px; }
.fm-room-list { display: grid; gap: 8px; margin-top: 4px; }

/* ---------- lobby ---------- */
.fm-code { margin: 24px 0 4px; color: var(--fm-muted); text-align: center; }
.fm-code strong { display: inline-block; margin-left: 6px; padding: 4px 16px; border: 1px solid rgba(255,211,90,.35); border-radius: 12px; color: var(--fm-gold); background: rgba(255,211,90,.07); font: 700 2rem Oswald, sans-serif; letter-spacing: .18em; }
.fm-lobby-teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fm-team-card { min-width: 0; padding: 16px 18px; border: 1px solid var(--fm-border); border-radius: 14px; background: rgba(4,14,26,.5); }
.fm-team-card:nth-child(1) { border-top: 3px solid var(--fm-blue); }
.fm-team-card:nth-child(2) { border-top: 3px solid var(--fm-red); }
.fm-team-card h3 { margin: 0 0 8px; color: var(--fm-gold); font: 600 1.25rem Oswald, sans-serif; letter-spacing: .02em; }
.fm-player { display: grid; grid-template-columns: minmax(0, 1fr) minmax(130px, 170px) 74px; align-items: center; gap: 8px; min-height: 52px; padding: 6px 0; border-top: 1px solid var(--fm-border); font-weight: 600; }
.fm-player > span { overflow-wrap: anywhere; }
.fm-player select { min-height: 38px; margin: 0; padding: 0 34px 0 10px; border-radius: 10px; font-size: .88rem; background-position: right 11px center; }
.fm-player .fm-button { width: 100%; padding-inline: 8px; }
.fm-team-card > .fm-help { margin: 8px 0 0; }

/* ---------- zmiana nazw drużyn, liczniki ---------- */
.fm-title-actions { display: grid; grid-template-columns: repeat(2, minmax(176px, 1fr)); gap: 10px; flex: none; }
.fm-team-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.fm-team-head h3 { display: flex; align-items: center; gap: 10px; min-width: 0; margin: 0; }
.fm-count { flex: none; min-width: 28px; padding: 1px 9px; border-radius: 999px; color: var(--fm-gold); background: rgba(255,211,90,.12); border: 1px solid rgba(255,211,90,.3); font: 700 .9rem/1.5 "DM Sans", sans-serif; text-align: center; }
.fm-team-head .fm-button { flex: none; }
.fm-score-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fm-icon-btn { flex: none; width: 32px; height: 32px; padding: 0; border: 1px solid var(--fm-border-strong); border-radius: 10px; color: var(--fm-text); background: rgba(255,255,255,.08); font-size: .95rem; line-height: 1; transition: border-color .15s, background .15s; }
.fm-icon-btn:hover { border-color: var(--fm-gold); background: rgba(255,211,90,.14); }

/* ---------- gra ---------- */
.fm-game-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.fm-game-header h1 { margin: 2px 0 0; font-size: clamp(2.2rem, 6vw, 4.2rem); }
.fm-game-header > .fm-button { flex: none; min-width: 168px; }
.fm-scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0 14px; }
.fm-score-card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 68px; padding: 12px 20px;
  border: 1px solid var(--fm-border-strong); border-radius: 16px; background: linear-gradient(115deg, #17508f, #0c2745);
  box-shadow: 0 10px 26px rgba(0,0,0,.28); transition: box-shadow .2s, border-color .2s;
}
.fm-score-card:nth-child(2) { background: linear-gradient(115deg, #9a2f45, #3f2033); }
.fm-score-card.active { border-color: var(--fm-gold); box-shadow: 0 0 0 1px var(--fm-gold), 0 0 30px rgba(255,211,90,.25); }
.fm-score-card span { font: 600 1.15rem/1.2 Oswald, sans-serif; letter-spacing: .04em; text-transform: uppercase; overflow-wrap: anywhere; }
.fm-score-card.active span::before { content: "● "; color: var(--fm-gold); font-size: .8em; }
.fm-score-card strong { flex: none; min-width: 76px; padding: 4px 12px; border-radius: 10px; color: var(--fm-gold); background: rgba(3,10,20,.6); font: 700 1.9rem/1.2 Oswald, sans-serif; text-align: center; font-variant-numeric: tabular-nums; }
.fm-round { padding: clamp(18px, 3.5vw, 32px); }
.fm-badge { padding: 6px 14px; border-radius: 999px; color: #281e08; background: linear-gradient(180deg, #ffe587, #f1ba2e); font-size: .72rem; font-weight: 900; letter-spacing: .12em; }
.fm-active-team { color: var(--fm-muted); text-align: right; }
.fm-active-team b { color: var(--fm-text); }
.fm-panel h2.fm-question { margin: 22px auto 26px; max-width: 900px; color: var(--fm-text); text-align: center; text-transform: none; font: 600 clamp(1.5rem, 4vw, 2.5rem)/1.2 Oswald, "Arial Narrow", sans-serif; letter-spacing: .01em; }
.fm-board { display: grid; gap: 10px; max-width: 860px; margin: 0 auto; perspective: 900px; }
.fm-answer {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) 86px; align-items: center; gap: 14px; min-height: 60px; padding: 8px 10px;
  border: 1px solid rgba(255,255,255,.13); border-radius: 14px; background: linear-gradient(180deg, #153a62, #0e2641);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 6px 16px rgba(0,0,0,.24);
}
.fm-answer.revealed { border-color: rgba(255,211,90,.65); background: linear-gradient(180deg, #1d4f78, #12385a); box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 0 0 1px rgba(255,211,90,.18), 0 8px 24px rgba(255,190,40,.12); }
.fm-answer.just { animation: fm-flip .55s cubic-bezier(.2,.9,.3,1.1) both; }
.fm-answer-number { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid rgba(255,211,90,.35); border-radius: 12px; color: var(--fm-gold); background: rgba(3,10,20,.55); font: 700 1.1rem Oswald, sans-serif; }
.fm-answer strong { font: 600 1.15rem/1.25 Oswald, "Arial Narrow", sans-serif; letter-spacing: .06em; text-transform: uppercase; overflow-wrap: anywhere; }
.fm-answer:not(.revealed) strong { color: #5f7f9e; letter-spacing: .3em; }
.fm-answer > b { justify-self: end; display: grid; place-items: center; width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid rgba(255,211,90,.25); border-radius: 10px; color: var(--fm-gold); background: rgba(3,10,20,.62); font: 700 1.4rem Oswald, sans-serif; font-variant-numeric: tabular-nums; }
.fm-answer > b:empty::before { content: "··"; color: #4d6a86; letter-spacing: .2em; }
.fm-round-status { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; color: var(--fm-muted); }
.fm-round-status > * { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 16px; border: 1px solid var(--fm-border); border-radius: 999px; background: rgba(255,255,255,.05); font-size: .92rem; }
.fm-round-status b { color: var(--fm-gold); font-variant-numeric: tabular-nums; }
.fm-round-status > strong { border-color: rgba(255,211,90,.5); color: var(--fm-gold); background: rgba(255,211,90,.09); }
.fm-faceoff { border-color: rgba(255,211,90,.4) !important; color: var(--fm-text); }
.fm-strikes { color: #ff6671 !important; letter-spacing: .18em; }
.fm-round > .fm-help { margin: 16px 0 0; text-align: center; }

/* panel prowadzącego */
.fm-host-controls { margin: 16px 0; }
.fm-host-controls h2 { margin-bottom: 12px; }
.fm-host-controls > .fm-button.danger { display: flex; width: 100%; margin-top: 14px; }
.fm-guess-form { display: grid; grid-template-columns: minmax(0, 1fr) 160px; align-items: end; gap: 12px; margin: 20px 0 0; }
.fm-guess-form label { margin: 0; }
.fm-pending { margin: 0 0 14px; padding: 16px; border: 1px solid rgba(255,211,90,.4); border-radius: 12px; background: rgba(255,211,90,.07); }
.fm-pending p { margin: 4px 0 12px; }
.fm-pending .fm-help { margin: 4px 0 14px; }
.fm-pending .fm-button { min-width: 170px; }
.fm-answer-key { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--fm-border); }
.fm-answer-key summary { display: flex; align-items: center; gap: 8px; color: var(--fm-muted); font-weight: 700; cursor: pointer; list-style: none; }
.fm-answer-key summary::-webkit-details-marker { display: none; }
.fm-answer-key summary::before { content: "▸"; color: var(--fm-gold); transition: transform .15s; }
.fm-answer-key[open] summary::before { transform: rotate(90deg); }
.fm-answer-key > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; margin-top: 12px; }
.fm-answer-key-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 46px; padding: 8px 12px; border: 1px solid var(--fm-border); border-radius: 10px; color: var(--fm-text); background: rgba(4,14,26,.55); text-align: left; font-weight: 600; transition: border-color .15s, background .15s, transform .15s; }
.fm-answer-key-row:hover:not(:disabled) { border-color: var(--fm-gold); background: rgba(255,211,90,.08); transform: translateY(-1px); }
.fm-answer-key-row b { flex: none; min-width: 44px; padding: 3px 8px; border-radius: 8px; color: var(--fm-gold); background: rgba(3,10,20,.6); font: 700 1rem Oswald, sans-serif; text-align: center; }
.fm-answer-key-row:disabled { opacity: .42; cursor: not-allowed; text-decoration: line-through; }

/* koniec rundy / gry */
.fm-round-result, .fm-final { text-align: center; }
.fm-final > .fm-kicker { margin-bottom: 6px; }
.fm-round-result h2, .fm-final h2 { font-size: 1.8rem; }
.fm-round-result > p:not(.fm-help), .fm-final > p { margin: 0 0 8px; font-size: 1.2rem; }
.fm-round-result strong { color: var(--fm-gold); }
.fm-round .fm-round-result { margin: 24px 0 0; border-color: rgba(255,211,90,.4); background: rgba(255,211,90,.06); box-shadow: none; }
.fm-waiting { display: grid; min-height: 90vh; align-content: center; justify-items: center; text-align: center; }
.fm-waiting h1 { margin: 6px 0 10px; color: var(--fm-gold); font: 600 clamp(2rem, 6vw, 4rem) Oswald, sans-serif; }
.fm-waiting p:last-child { color: var(--fm-muted); }

/* ---------- okna dialogowe ---------- */
.fm-modal-back { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(2,8,16,.78); backdrop-filter: blur(6px); animation: fm-fade .15s ease both; }
.fm-modal { width: min(640px, 100%); max-height: 92vh; overflow: auto; padding: 26px; border: 1px solid var(--fm-border-strong); border-radius: 20px; background: linear-gradient(160deg, #15314f, #0b1c31); box-shadow: 0 30px 90px rgba(0,0,0,.6); animation: fm-rise .2s cubic-bezier(.2,.9,.3,1.1) both; }
.fm-modal h2 { margin: 0 0 12px; color: var(--fm-gold); font: 600 1.6rem/1.2 Oswald, sans-serif; text-transform: uppercase; }
.fm-modal .fm-help { margin: 0 0 14px; }
.fm-modal label + label { margin-top: 14px; }
.fm-modal textarea { min-height: 84px; }
.fm-answer-editor { display: grid; gap: 8px; margin-bottom: 12px; }
.fm-answer-editor > div { display: grid; grid-template-columns: minmax(0, 1fr) 96px var(--fm-control); align-items: center; gap: 8px; }
.fm-answer-editor input { margin: 0 !important; }
.fm-answer-editor .fm-button { width: var(--fm-control); min-height: var(--fm-control); padding: 0; font-size: 1.3rem; }
.fm-modal > .fm-button.small { min-width: 190px; }
.fm-modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.fm-modal-actions > .fm-button { flex: 1 1 0; min-width: 0; }

/* ---------- dźwięk ---------- */
#sound-toggle { position: fixed; right: 14px; bottom: 14px; z-index: 15; display: flex; flex-direction: row-reverse; align-items: center; height: 44px; padding: 0 4px; border: 1px solid var(--fm-border-strong); border-radius: 24px; background: rgba(9,24,42,.92); backdrop-filter: blur(6px); box-shadow: 0 8px 26px rgba(0,0,0,.4); }
#sound-toggle .snd-btn { width: 38px; height: 36px; border: 0; border-radius: 50%; color: var(--fm-gold); background: transparent; font-size: 1.1rem; }
#sound-toggle .snd-vol { width: 0; margin: 0; opacity: 0; accent-color: var(--fm-gold); transition: width .2s, opacity .2s, margin .2s; }
#sound-toggle:hover .snd-vol, #sound-toggle:focus-within .snd-vol { width: 100px; margin: 0 4px 0 12px; opacity: 1; }

/* ---------- Wielki finał ---------- */
.fm-final-wrap { overflow-x: auto; }
.fm-final-board { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.fm-final-board th { padding: 0 14px; color: var(--fm-muted); font-size: .72rem; letter-spacing: .14em; text-align: left; text-transform: uppercase; }
.fm-final-board td { padding: 10px 14px; vertical-align: middle; border-block: 1px solid rgba(255,255,255,.13); background: linear-gradient(180deg, #153a62, #0e2641); }
.fm-final-board td:first-child { width: 34%; border-left: 1px solid rgba(255,255,255,.13); border-radius: 12px 0 0 12px; font-weight: 700; }
.fm-final-board td:last-child { border-right: 1px solid rgba(255,255,255,.13); border-radius: 0 12px 12px 0; }
.fm-final-cell { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 30px; }
.fm-final-cell strong { overflow-wrap: anywhere; }
.fm-final-cell b { flex: none; min-width: 42px; padding: 2px 8px; border-radius: 8px; color: var(--fm-gold); background: rgba(3,10,20,.6); font: 700 1.2rem Oswald, sans-serif; text-align: center; }
.fm-final-cell.pending { justify-content: center; color: #5f7f9e; letter-spacing: .3em; }
.fm-final-cell.zero strong { opacity: .6; }
.fm-final-total { margin: 12px 0 0; text-align: center; font: 600 1.4rem Oswald, sans-serif; }
.fm-final-total b { color: var(--fm-gold); font-size: 1.9rem; }
.fm-final-play { text-align: center; }
.fm-final-timer { margin: 4px 0 14px; color: var(--fm-gold); font: 700 clamp(3.6rem, 12vw, 6.4rem)/1 Oswald, sans-serif; font-variant-numeric: tabular-nums; }
.fm-final-timer.low { color: #ff6671; animation: fm-pulse 1s ease-in-out infinite; }
.fm-final-form { display: grid; gap: 4px; max-width: 640px; margin: 0 auto; text-align: left; }
.fm-final-form label { margin-top: 10px; }
.fm-final-form .fm-button { margin-top: 16px; width: 100%; }
.fm-blind { display: grid; min-height: 55vh; align-content: center; }
.fm-judge-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.3fr); align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--fm-border); }
.fm-judge-row small { display: block; margin-top: 4px; }
.fm-judge-row select { margin-top: 0 !important; }
.fm-judge-typed { color: var(--fm-muted); overflow-wrap: anywhere; }
.fm-judge .fm-actions { margin-top: 18px; }

/* ---------- ekran TV (widok publiczności) ---------- */
.fm-tv { width: min(1560px, 100% - 56px); }
.fm-tv .fm-game-header h1 { font-size: clamp(2.6rem, 5vw, 4.6rem); }
.fm-tv .fm-score-card { min-height: 84px; padding: 14px 26px; }
.fm-tv .fm-score-card span { font-size: clamp(1.3rem, 2.2vw, 2rem); }
.fm-tv .fm-score-card strong { min-width: 110px; font-size: clamp(2.2rem, 3.4vw, 3.2rem); }
.fm-tv .fm-panel h2.fm-question { max-width: 1200px; font-size: clamp(2rem, 4vw, 3.8rem); }
.fm-tv .fm-board { max-width: 1240px; gap: 12px; }
.fm-tv .fm-answer { grid-template-columns: 64px minmax(0, 1fr) 130px; min-height: clamp(66px, 8.6vh, 100px); gap: 20px; padding: 10px 14px; border-radius: 18px; }
.fm-tv .fm-answer-number { width: 52px; height: 52px; font-size: 1.5rem; border-radius: 14px; }
.fm-tv .fm-answer strong { font-size: clamp(1.4rem, 2.6vw, 2.5rem); }
.fm-tv .fm-answer > b { min-height: 56px; font-size: clamp(1.8rem, 3vw, 3rem); }
.fm-tv .fm-round-status > * { min-height: 46px; padding: 0 22px; font-size: 1.15rem; }
.fm-tv .fm-final-board td { padding-block: 14px; font-size: clamp(1.1rem, 1.8vw, 1.6rem); }
.fm-tv .fm-final-timer { font-size: clamp(5rem, 14vw, 10rem); }

/* ---------- animacje ---------- */
@keyframes fm-flip { 0% { transform: rotateX(-88deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes fm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fm-rise { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes fm-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- tablet ---------- */
@media (max-width: 900px) {
  .fm-guess-form { grid-template-columns: minmax(0, 1fr) 140px; }
  .fm-judge-row { grid-template-columns: 1fr 1fr; }
  .fm-judge-row > select { grid-column: 1 / -1; }
}

/* ---------- telefon ---------- */
@media (max-width: 700px) {
  :root { --fm-radius: 14px; }
  .fm-kicker { letter-spacing: .14em; }
  .fm-shell { width: min(100% - 24px, 600px); padding: 18px 0 84px; }
  .fm-game { width: min(100% - 20px, 600px); padding: 14px 0 84px; }
  .fm-home-actions, .fm-team-inputs, .fm-lobby-teams { grid-template-columns: 1fr; }
  .fm-card { min-height: 168px; padding: 22px 18px; }
  .fm-rules { padding: 20px; }
  .fm-panel { padding: 18px 16px; }
  .fm-heading { gap: 14px; }
  .fm-heading > .fm-button { min-width: 96px; }
  .fm-panel-title { align-items: flex-start; }
  .fm-title-actions { grid-template-columns: 1fr; width: 100%; }
  .fm-team-head { flex-wrap: wrap; }
  .fm-toolbar, .fm-actions, .fm-join-panel .fm-actions { grid-template-columns: 1fr; }
  .fm-panel > .fm-button, .fm-final > .fm-button, .fm-round-result > .fm-button, .fm-modal > .fm-button.small { width: 100%; min-width: 0; }
  .fm-tv-action { justify-content: stretch; }
  .fm-tv-action .fm-button { width: 100%; }
  .fm-question-row { align-items: stretch; flex-direction: column; }
  .fm-row-actions { grid-template-columns: 1fr 1fr; width: 100%; }
  .fm-player { grid-template-columns: minmax(0, 1fr) minmax(110px, 150px); }
  .fm-player .fm-button { grid-column: 1 / -1; }
  .fm-game-header { align-items: flex-start; gap: 10px; }
  .fm-game-header h1 { font-size: clamp(2rem, 10.5vw, 2.7rem); letter-spacing: .05em; }
  .fm-game-header > .fm-button { min-width: 0; min-height: 40px; padding: 6px 14px; font-size: .85rem; }
  .fm-hero h1 { font-size: clamp(2.6rem, 14vw, 3.6rem); letter-spacing: .05em; }
  .fm-scoreboard { gap: 10px; }
  .fm-score-card { padding: 10px 12px; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 0; }
  .fm-score-card strong { align-self: stretch; min-width: 0; font-size: 1.6rem; }
  .fm-round-head { align-items: flex-start; flex-direction: column; gap: 8px; }
  .fm-active-team { text-align: left; }
  .fm-answer { grid-template-columns: 34px minmax(0, 1fr) 54px; gap: 8px; padding: 7px 8px; min-height: 54px; }
  .fm-answer-number { width: 32px; height: 32px; border-radius: 10px; font-size: .95rem; }
  .fm-answer strong { font-size: 1rem; letter-spacing: .04em; }
  .fm-answer > b { min-height: 36px; padding: 0 4px; font-size: 1.15rem; }
  .fm-guess-form { grid-template-columns: 1fr; }
  .fm-answer-key > div { grid-template-columns: 1fr; }
  .fm-judge-row { grid-template-columns: 1fr; }
  .fm-modal { padding: 20px 16px; }
  .fm-modal-actions { flex-direction: column-reverse; }
  .fm-answer-editor > div { grid-template-columns: minmax(0, 1fr) 80px var(--fm-control); }
  .fm-final-board td:first-child { width: auto; }
  .fm-final-board td, .fm-final-board th { padding: 8px; font-size: .88rem; }
  .fm-code strong { font-size: 1.6rem; letter-spacing: .12em; }
}

/* ==========================================================================
   Dodatki: własne checkboxy, karty wyboru graczy, efekty, historia,
   pełny ekran, responsywność (telefon, mały telefon, poziomo, dotyk)
   ========================================================================== */

/* ---------- własne checkboxy ---------- */
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; display: inline-grid; place-content: center;
  width: 24px; height: 24px; border: 2px solid var(--fm-border-strong); border-radius: 8px; background: var(--fm-field);
  transition: background .15s, border-color .15s, box-shadow .15s;
}
input[type=checkbox]::after {
  content: ""; width: 12px; height: 6px; margin-top: -2px; border-left: 3px solid #1a1403; border-bottom: 3px solid #1a1403;
  transform: rotate(-45deg) scale(0); transition: transform .15s cubic-bezier(.2,.9,.3,1.3);
}
input[type=checkbox]:checked { background: linear-gradient(180deg, var(--fm-gold), var(--fm-gold-2)); border-color: var(--fm-gold-2); }
input[type=checkbox]:checked::after { transform: rotate(-45deg) scale(1); }
input[type=checkbox]:hover:not(:disabled) { border-color: var(--fm-gold); }
input[type=checkbox]:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- karty wyboru graczy do finału ---------- */
.fm-pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
.fm-pick {
  position: relative; display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; column-gap: 12px;
  min-height: 66px; padding: 10px 14px; border: 1px solid var(--fm-border-strong); border-radius: 14px;
  background: rgba(7,21,38,.7); cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s, transform .15s;
}
.fm-pick:hover:not(.locked) { border-color: var(--fm-gold); transform: translateY(-1px); }
.fm-pick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; border: 0; }
.fm-pick input:disabled { cursor: not-allowed; }
.fm-pick-mark {
  grid-row: 1 / span 2; display: grid; place-items: center; width: 40px; height: 40px; border: 2px dashed var(--fm-border-strong); border-radius: 50%;
  color: #1a1403; font: 700 1.2rem Oswald, sans-serif; transition: background .15s, border-color .15s;
}
.fm-pick-name { align-self: end; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-pick small { align-self: start; color: var(--fm-muted); font-size: .78rem; }
.fm-pick.on { border-color: var(--fm-gold); background: linear-gradient(180deg, rgba(255,211,90,.16), rgba(255,211,90,.05)); box-shadow: 0 0 0 1px rgba(255,211,90,.35), 0 10px 26px rgba(0,0,0,.3); }
.fm-pick.on .fm-pick-mark { border: 2px solid var(--fm-gold-2); background: linear-gradient(180deg, var(--fm-gold), var(--fm-gold-2)); }
.fm-pick.on small { color: var(--fm-gold); }
.fm-pick.locked { opacity: .45; cursor: not-allowed; }
.fm-pick:has(input:focus-visible) { outline: 2px solid var(--fm-gold); outline-offset: 2px; }

/* ---------- efekty: pudło i konfetti ---------- */
.fm-x-flash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; pointer-events: none;
  font: 700 min(62vw, 62vh)/1 Oswald, "Arial Narrow", sans-serif; color: var(--fm-red);
  text-shadow: 0 0 60px rgba(226,58,74,.8), 0 10px 40px rgba(0,0,0,.6);
  background: radial-gradient(circle, rgba(226,58,74,.28), transparent 65%);
  animation: fm-x 1.15s ease-out both;
}
@keyframes fm-x { 0% { opacity: 0; transform: scale(.4); } 14% { opacity: 1; transform: scale(1.06); } 28% { transform: scale(1); } 72% { opacity: 1; } 100% { opacity: 0; transform: scale(1.02); } }
.fm-confetti { position: fixed; inset: 0; z-index: 99; overflow: hidden; pointer-events: none; }
.fm-confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 2px; animation: fm-fall linear both; }
@keyframes fm-fall { from { transform: translateY(0) rotate(0); opacity: 1; } to { transform: translateY(112vh) rotate(720deg); opacity: .9; } }

/* ---------- historia gier ---------- */
.fm-history { max-width: 820px; margin-inline: auto; }
.fm-history h3 { margin: 0 0 10px; color: var(--fm-muted); font-size: .8rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.fm-history-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 24px; }
.fm-history-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.fm-history-table th { color: var(--fm-muted); font-size: .72rem; font-weight: 700; text-align: left; padding: 0 6px 6px; }
.fm-history-table td { padding: 8px 6px; border-top: 1px solid var(--fm-border); font-weight: 600; }
.fm-history-table td:not(:first-child), .fm-history-table th:not(:first-child) { text-align: center; width: 54px; }
.fm-history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.fm-history-list li { display: grid; gap: 2px; padding: 8px 0; border-top: 1px solid var(--fm-border); font-size: .9rem; }
.fm-history-when, .fm-history-final { color: var(--fm-muted); font-size: .78rem; }

/* ---------- przyciski ekranu (pełny ekran, dźwięk) ---------- */
#fs-toggle {
  position: fixed; right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(68px + env(safe-area-inset-bottom, 0px)); z-index: 15;
  width: 44px; height: 44px; border: 1px solid var(--fm-border-strong); border-radius: 50%; color: var(--fm-gold); font-size: 1.2rem;
  background: rgba(9,24,42,.92); backdrop-filter: blur(6px); box-shadow: 0 8px 26px rgba(0,0,0,.4);
}
#fs-toggle.on { background: var(--fm-gold); color: #1a1403; }
#sound-toggle { right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
body:has(.fm-tv) #fs-toggle, body:has(.fm-tv) #sound-toggle { opacity: .25; transition: opacity .2s; }
body:has(.fm-tv) #fs-toggle:hover, body:has(.fm-tv) #sound-toggle:hover, body:has(.fm-tv) #sound-toggle:focus-within { opacity: 1; }

/* ---------- responsywność ---------- */
body { padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) 0 env(safe-area-inset-left, 0px); }
.fm-shell, .fm-game { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
.fm-waiting { min-height: 90dvh; }
.fm-blind { min-height: 55dvh; }

@media (pointer: coarse) {
  :root { --fm-control: 50px; }
  .fm-button.small { min-height: 44px; }
  .fm-icon-btn { min-width: 44px; min-height: 44px; }
  #sound-toggle .snd-btn { width: 44px; height: 40px; }
}
@media (hover: none) {
  #sound-toggle .snd-vol { width: 90px; margin: 0 4px 0 12px; opacity: 1; }
}

@media (max-width: 700px) {
  .fm-history-grid { grid-template-columns: 1fr; gap: 18px; }
  .fm-pick-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .fm-shell { width: min(100% - 16px, 600px); }
  .fm-game { width: min(100% - 14px, 600px); }
  .fm-panel { padding: 14px 12px; }
  .fm-pick-grid { grid-template-columns: 1fr; }
  .fm-answer { grid-template-columns: 28px minmax(0, 1fr) 46px; gap: 6px; padding: 6px; }
  .fm-answer-number { width: 28px; height: 28px; font-size: .85rem; }
  .fm-answer strong { font-size: .92rem; letter-spacing: .02em; }
  .fm-answer > b { font-size: 1.05rem; }
  .fm-score-card strong { font-size: 1.4rem; }
  .fm-game-header h1 { font-size: 1.8rem; }
  .fm-hero h1 { font-size: 2.3rem; }
  .fm-card { min-height: 140px; }
  .fm-round-status > * { font-size: .84rem; padding: 0 12px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .fm-shell { padding-top: 12px; }
  .fm-game { padding-top: 10px; }
  .fm-hero { padding: 10px 12px; }
  .fm-hero h1, .fm-game-header h1 { font-size: 2.2rem; margin-bottom: 6px; }
  .fm-panel { margin: 10px 0; padding: 14px 16px; }
  .fm-board { max-width: 1100px; grid-auto-flow: column; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(var(--rows, 4), auto); }
  .fm-answer { min-height: 48px; }
  .fm-waiting, .fm-blind { min-height: 70dvh; }
  .fm-final-timer { font-size: 4rem; }
}

/* ---------- kolejność odpowiadania: zgłoszenie i wybór ---------- */
.fm-flow { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--fm-border); }
.fm-buzz { min-height: 76px; font-size: 1.35rem; letter-spacing: .04em; animation: fm-pulse 1.4s ease-in-out infinite; }
.fm-active-team { line-height: 1.4; }
