:root {
  --ink: #23201b;
  --ink-2: #5c564c;
  --ink-3: #8f877a;
  --desk: #e9e3d6;
  --desk-2: #ddd5c4;
  --paper: #fffdf7;
  --line: #cfc6b3;
  --red: #c8412c;
  --red-soft: #f6dcd5;
  --blue: #2c5fb8;
  --blue-soft: #d9e4f6;
  --ok: #2f8048;
  --warn: #b7791f;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--desk);
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
[hidden] { display: none !important; }

/* ---- üst çubuk ---- */
.top {
  display: grid;
  grid-template-columns: 1fr auto auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--desk-2);
}
.score { display: flex; align-items: baseline; gap: 10px; font-weight: 600; }
.score b { font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.score.red { color: var(--red); }
.score.blue { color: var(--blue); justify-content: flex-end; }
.score.turn .team-name { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; }
.status { text-align: center; min-width: 0; }
.status-main { font-weight: 600; font-size: 15px; }
.status-sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 20px;
  min-width: 64px;
  text-align: center;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.timer.low { color: var(--red); border-color: var(--red); }

/* ---- düzen ---- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  min-height: 0;
}
.stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px 14px 14px;
  min-width: 0;
  min-height: 0;
}

.wordbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 15px;
  color: var(--ink-2);
}
.wordbar .word {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--ink);
}
.mask { display: flex; gap: 6px; }
.mask span {
  width: 26px;
  border-bottom: 3px solid var(--ink);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  line-height: 30px;
  text-transform: uppercase;
}
.mask .gap { border: 0; width: 14px; }
.wordbar .count { font-size: 13px; color: var(--ink-3); }

.board-wrap {
  position: relative;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line);
  touch-action: none;
  display: block;
}
#board.can-draw { cursor: crosshair; }

.tools {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.palette, .sizes { display: flex; gap: 6px; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--paper);
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
}
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.size, .tool {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  display: grid;
  place-items: center;
  padding: 0;
}
.size i { display: block; border-radius: 50%; background: var(--ink); }
.size.on, .tool.on { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---- yan panel ---- */
.side {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--paper);
  min-height: 0;
}
.gallows { padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
#hangman { width: 100%; height: 120px; display: block; }
#hangman path, #hangman circle { fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
#hangman .frame path { stroke: var(--ink-3); }
#hangman .part { opacity: 0; transition: opacity .25s; }
#hangman .part.on { opacity: 1; stroke: var(--red); }
.gallows-info { text-align: center; font-size: 13px; color: var(--ink-2); margin-top: 4px; }

.chat {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}
.chat li { line-height: 1.35; overflow-wrap: anywhere; padding: 3px 6px; border-radius: 6px; }
.chat .who { font-weight: 600; margin-right: 6px; }
.chat .who.red { color: var(--red); }
.chat .who.blue { color: var(--blue); }
.chat .sys { color: var(--ink-2); font-style: italic; font-size: 13px; }
.chat .team-only { background: var(--desk); }
.chat .tag { font-size: 11px; color: var(--ink-3); margin-right: 6px; text-transform: uppercase; letter-spacing: .04em; }
.chat .verdict { float: right; font-size: 12px; font-weight: 600; margin-left: 8px; }
.chat .wrong .verdict { color: var(--red); }
.chat .wrong .text { text-decoration: line-through; text-decoration-color: var(--red); }
.chat .near .verdict { color: var(--warn); }
.chat .dup .verdict { color: var(--ink-3); }
.chat .correct { background: #dcefe2; }
.chat .correct .verdict { color: var(--ok); }

.chat-form { display: flex; gap: 6px; padding: 10px 12px 12px; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1;
  min-width: 0;
  font: inherit;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.chat-form input:focus { outline: 2px solid var(--ink); outline-offset: -1px; }
.chat-form input:disabled { background: var(--desk); }
.chat-form button, .btn {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 600;
}
.btn.ghost { background: transparent; color: var(--ink); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.red { background: var(--red); border-color: var(--red); }
.btn.blue { background: var(--blue); border-color: var(--blue); }

/* ---- kaplama ekranlar ---- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(233, 227, 214, .78);
  overflow: auto;
}
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px 24px;
  width: min(560px, 100%);
  box-shadow: 0 10px 30px rgba(35, 32, 27, .12);
}
.card.wide { width: min(760px, 100%); }
.card h1, .card h2 { margin: 0 0 6px; font-size: 22px; }
.card p { margin: 6px 0; color: var(--ink-2); }
.card .big-word { font-size: 30px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); margin: 10px 0; }
.card .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.card .hint { font-size: 13px; color: var(--ink-3); }

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.team-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.team-card.red { border-top: 4px solid var(--red); }
.team-card.blue { border-top: 4px solid var(--blue); }
.team-card h3 { margin: 0 0 8px; font-size: 16px; display: flex; justify-content: space-between; }
.team-card.red h3 { color: var(--red); }
.team-card.blue h3 { color: var(--blue); }
.team-card ul { list-style: none; margin: 0 0 10px; padding: 0; min-height: 54px; font-size: 14px; }
.team-card li { padding: 2px 0; }
.team-card .btn { width: 100%; }
.off { color: var(--ink-3); }
.me { font-weight: 700; }
.badge { font-size: 11px; color: var(--ink-3); margin-left: 6px; }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 16px; }
.settings label { font-size: 13px; color: var(--ink-2); display: grid; gap: 4px; }
.settings select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }

.rules { margin: 10px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; }
.rules li { margin: 2px 0; }

.pick-form { display: flex; gap: 8px; margin-top: 12px; }
.pick-form input { flex: 1; min-width: 0; font: inherit; font-size: 18px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip { border: 1px dashed var(--ink-3); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 14px; }

.result-won { color: var(--ok); }
.result-lost { color: var(--red); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10;
  max-width: 90vw;
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 240px; }
  .side { border-left: 0; border-top: 1px solid var(--line); grid-template-rows: minmax(0, 1fr) auto; }
  .gallows { display: none; }
  .teams { grid-template-columns: 1fr; }
}
