* { box-sizing: border-box; }
:root {
  --bg: #1d1f2b;
  --panel: #2a2d3d;
  --panel2: #343849;
  --text: #eceef5;
  --muted: #9aa0b5;
  --accent: #ffb703;
  --ok: #3ccf6e;
  --bad: #ff5d5d;
  --hint: #6ab8ff;
}
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.hidden { display: none !important; }
button {
  font: inherit; cursor: pointer; border: 0; border-radius: 8px;
  background: var(--accent); color: #222; padding: 8px 14px; font-weight: 600;
}
button:disabled { opacity: .4; cursor: default; }
input, textarea {
  font: inherit; border-radius: 8px; border: 1px solid #555a70;
  background: #1a1c26; color: var(--text); padding: 8px 10px;
}
.muted { color: var(--muted); }
.error { color: var(--bad); min-height: 1.2em; }

/* --- ekrany startowe --- */
.screen { min-height: 100%; }
#join, #lobby { display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; }
.card { background: var(--panel); border-radius: 16px; padding: 24px; width: 100%; max-width: 380px; }
.card.wide { max-width: 860px; }
.card h1 { margin-top: 0; }
#joinForm { display: flex; flex-direction: column; gap: 10px; }
.share { background: var(--panel2); padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; }
.share code { color: var(--accent); font-size: 1.1em; user-select: all; }
.lobby-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 24px; }
@media (max-width: 700px) { .lobby-grid { grid-template-columns: 1fr; } }
#settingsBox label { display: block; margin-bottom: 8px; }
#settingsBox input[type=number] { width: 90px; }
.packs-head { margin: 10px 0 6px; }
.packs { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.packs label { display: flex; gap: 8px; align-items: center; margin: 0 !important; }
.packs .cnt { color: var(--muted); font-size: .85em; }
.packs .adult { color: var(--bad); }
textarea { width: 100%; margin-top: 6px; }
.big { font-size: 1.2em; padding: 12px 28px; margin-top: 16px; }
.lobby-chat .messages { max-height: 160px; margin-top: 16px; }

.plist button.kick { background: none; color: var(--muted); padding: 0 4px; font-size: .85em; font-weight: 400; }
.plist button.kick:hover, .plist button.kick.armed { color: var(--bad); }
button.link { background: none; color: var(--muted); padding: 4px 0; font-weight: 400; font-size: .85em; text-decoration: underline; }
.plist { list-style: none; margin: 0; padding: 0; }
.plist li {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--panel2); border-radius: 8px; margin-bottom: 4px;
}
.plist li.off { opacity: .4; }
.plist li.me { outline: 2px solid var(--accent); }
.plist .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plist .pts { font-weight: 700; font-variant-numeric: tabular-nums; }
.plist .prog { height: 3px; background: var(--accent); border-radius: 2px; margin-top: 3px; }

/* --- gra --- */
#game { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; padding: 12px; height: 100vh; }
@media (max-width: 900px) {
  #game { grid-template-columns: 1fr; height: auto; }
  .side { height: 60vh; }
}
.board { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.topbar {
  display: grid; grid-template-columns: 180px 1fr 110px; gap: 12px; align-items: center;
  background: var(--panel); border-radius: 12px; padding: 10px 16px;
}
.turn { color: var(--muted); }
.word { font-size: 1.5em; font-weight: 700; letter-spacing: .05em; text-align: center; }
.word .secret { color: var(--accent); }
.word .hintw { color: var(--hint); }
.word .hintw.small { font-size: .55em; margin-left: 10px; white-space: nowrap; }
.mask { display: inline-flex; flex-wrap: wrap; justify-content: center; column-gap: 26px; row-gap: 4px; vertical-align: middle; }
.mask .w { display: inline-flex; gap: 5px; }
.mask .ch { display: inline-block; min-width: .7em; text-align: center; }
.mask .ch.rev { color: var(--accent); }
.timer { justify-self: end; font-size: 1.6em; font-weight: 800; font-variant-numeric: tabular-nums; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .5; } }

.canvas-wrap { position: relative; flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; }
.stage { position: relative; }
canvas {
  display: block; width: 100%; height: 100%;
  background: #fff; border-radius: 12px; touch-action: none;
}
canvas.drawing { cursor: crosshair; }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; text-align: center;
  background: rgba(20, 22, 32, .85); border-radius: 12px; padding: 20px; font-size: 1.2em;
}
.overlay .big-word { font-size: 2em; font-weight: 800; color: var(--accent); }
.overlay .choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.overlay .choices button { font-size: 1.1em; padding: 14px 20px; }
.podium { list-style: none; padding: 0; margin: 0; font-size: 1.1em; }
.podium li { margin: 4px 0; }

.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--panel); border-radius: 12px; padding: 8px; }
.colors, .sizes { display: flex; flex-wrap: wrap; gap: 4px; }
.colors button { width: 30px; height: 30px; padding: 0; border: 2px solid #0003; border-radius: 50%; }
.colors button.sel, .sizes button.sel, #eraserBtn.sel { outline: 3px solid var(--accent); outline-offset: 1px; }
.sizes button { background: var(--panel2); width: 36px; height: 36px; padding: 0; display: flex; align-items: center; justify-content: center; }
.sizes span { display: block; background: var(--text); border-radius: 50%; }
.tools > button { background: var(--panel2); color: var(--text); font-size: 1.2em; padding: 4px 12px; }
.host-tools { display: flex; gap: 8px; }
.host-tools button { background: var(--panel2); color: var(--muted); font-size: .85em; }

.side { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.scores { max-height: 35%; overflow-y: auto; }
.messages {
  flex: 1; overflow-y: auto; background: var(--panel); border-radius: 12px; padding: 8px;
  display: flex; flex-direction: column; gap: 3px; font-size: .95em;
}
.msg { display: flex; align-items: center; gap: 8px; padding: 3px 4px; border-radius: 6px; word-break: break-word; }
.msg .meter { flex: 0 0 64px; height: 10px; background: #0005; border-radius: 5px; overflow: hidden; }
.msg .meter div { height: 100%; border-radius: 5px; transition: width .4s; }
.msg .pct { flex: 0 0 34px; font-size: .8em; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.msg .who { font-weight: 700; }
.msg.system { color: var(--muted); font-style: italic; }
.msg.correct { color: var(--ok); font-weight: 700; font-style: normal; }
.msg.fail { color: var(--bad); font-style: normal; }
.msg.hint { color: var(--hint); font-style: normal; white-space: pre-wrap; }
.small { font-size: .85em; }
.msg.close { background: #ffb70322; }
.msg .tag { color: var(--accent); font-weight: 700; font-size: .85em; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; }

/* --- strona główna --- */
#home { display: flex; justify-content: center; padding: 5vh 16px; }
.home { width: 100%; max-width: 980px; }
.home-head { text-align: center; margin-bottom: 20px; }
.home-head h1 { font-size: 2.6em; margin: 0 0 6px; }
.home-name { display: inline-flex; flex-direction: column; gap: 6px; margin-top: 14px; font-weight: 600; }
.home-name input { font-size: 1.2em; text-align: center; width: 280px; }
.home-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 20px; align-items: start; }
.home-grid .card { max-width: none; }
.home-grid h2 { margin: 0 0 12px; font-size: 1.2em; }
.home-grid h2.sep { margin-top: 26px; padding-top: 18px; border-top: 1px solid #ffffff14; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; }
.form input[type=number] { width: 90px; }
.radio { display: flex; flex-direction: column; gap: 6px; }
.radio label { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.form .big { margin-top: 4px; align-self: flex-start; }
.code-form { display: flex; gap: 8px; }
.code-form input { width: 140px; text-transform: uppercase; letter-spacing: .15em; font-weight: 700; }
.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.room-list li { display: flex; align-items: center; gap: 12px; background: var(--panel2); border-radius: 10px; padding: 10px 12px; }
.room-main { flex: 1; min-width: 0; }
.room-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seats { font-variant-numeric: tabular-nums; color: var(--muted); }
.badge { font-size: .75em; padding: 1px 6px; border-radius: 6px; vertical-align: middle; }
.badge.adult { background: #ff5d5d33; color: var(--bad); }
a.back { display: inline-block; margin-top: 10px; color: var(--muted); font-size: .9em; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.lobby-head h1 { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.ghost { background: var(--panel2); color: var(--muted); font-weight: 400; font-size: .9em; }
#settingsBox label.check { display: flex; align-items: center; gap: 8px; }
.custom { margin-top: 6px; }
.custom textarea { width: 100%; resize: vertical; font-size: .95em; }
.custom-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.badge { background: #ffffff14; color: var(--muted); }
.badge.adult { background: #ff5d5d33; color: var(--bad); }

/* --- baner planowanej aktualizacji --- */
.maint {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: 34px;
  display: flex; align-items: center; justify-content: center; padding: 0 12px;
  background: #3a3220; color: var(--accent); font-size: .9em; font-weight: 600; text-align: center;
}
.maint.soon { background: #4a1f1f; color: #ffb3b3; }
body.has-maint { padding-top: 34px; }
body.has-maint #game { height: calc(100vh - 34px); }
.custom-btns { display: flex; gap: 6px; }
