/* Sketch-only styles. The theme and the shared controls are in ../shared/base.css;
   the canvas and its toolbar bring their own small styles (canvas.js). */

code { font-size: 13px; color: var(--text); }
textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  font-size: 16px;
  padding: 12px;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.pill {
  background: var(--red);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

/* Join */
.code-input { text-transform: uppercase; letter-spacing: 6px; font-weight: 800; font-size: 20px; text-align: center; }
.wait { align-items: center; padding: 32px 16px; }
.spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 4px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Lobby */
.room { align-items: center; text-align: center; }
.room-code { font-size: 44px; font-weight: 900; letter-spacing: 8px; color: var(--accent); }
.link-text { word-break: break-all; }
/* White behind the QR code so every phone camera reads it, in both themes. */
.qr { width: 168px; max-width: 100%; margin: 6px auto; padding: 6px; background: #fff; border-radius: 10px; }
.qr svg { display: block; width: 100%; height: auto; }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
}
.players .pname { flex: 1; font-weight: 600; }
.players .pscore { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.tag { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 8px; background: var(--accent); color: #1b1b1b; }
.tag.you { background: var(--line); color: var(--text); }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.set-row > span { font-weight: 600; }
.set-row .stepper span { min-width: 56px; font-size: 20px; }
.stepper button:disabled { opacity: 0.35; cursor: default; }
.settings.readonly .seg button:disabled,
.settings.readonly .chip:disabled { cursor: default; }
.seg button:disabled { cursor: default; }
.chip:disabled { cursor: default; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { flex: none; width: 22px; height: 22px; accent-color: var(--accent); }
/* Keeps its line when empty, so the checkbox below does not jump when the count shows up. */
#custom-count:empty::before { content: "\a0"; }

/* Podium */
.top3 { display: flex; justify-content: center; align-items: flex-end; gap: 10px; }
.place {
  flex: 1;
  max-width: 140px;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  word-break: break-word;
}
.place .medal { font-size: 34px; }
.place .pname { font-weight: 800; }
.place .pscore { color: var(--accent); font-weight: 800; font-size: 20px; }
.place.p1 { order: 2; padding-top: 28px; }
.place.p2 { order: 1; }
.place.p3 { order: 3; }
.ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ranking li { display: flex; gap: 8px; font-size: 16px; }
.ranking .rank { width: 24px; color: var(--muted); }
.ranking .who { flex: 1; font-weight: 600; }
.ranking .total { font-variant-numeric: tabular-nums; font-weight: 700; }

/* Turns table (podium and the lobby's "Last game"): scrolls inside its box on a phone */
.turns-box { overflow: auto; max-height: 60vh; margin: 0 -4px; }
.turns { border-collapse: collapse; width: 100%; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.turns th, .turns td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); }
.turns th:nth-child(-n + 3), .turns td:nth-child(-n + 3) { text-align: left; }
.turns thead th { position: sticky; top: 0; background: var(--panel); font-weight: 700; }
.turns .zero { color: var(--muted); }
.turns .drew { font-style: italic; }
.turns tfoot td { font-weight: 800; color: var(--accent); border-bottom: 0; }
.turns tfoot td:not(:first-child) { text-align: right; } /* "Total" spans the first 3 columns */
.results summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; }
.results summary::-webkit-details-marker { display: none; }
.results summary::after { content: "Hide"; color: var(--muted); font-size: 13px; }
.results:not([open]) summary::after { content: "Show"; }

/* ---------- Game screen ----------
   It fills the visual viewport (see fitViewport in app.js), so the keyboard pushes the
   guess box up instead of covering it. Portrait: top bar, canvas, then players, tools or
   chat, guess box. Landscape (body.land): canvas left, the rest right. */
body.in-game { overflow: hidden; }
.screen.game {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vvtop, 0px);
  height: var(--vvh, 100dvh);
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: calc(6px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  max-width: 1400px;
  margin: 0 auto;
}

.topbar { display: flex; align-items: center; gap: 8px; min-height: 44px; flex: none; }
.clock {
  flex: none;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--panel);
  border: 2px solid var(--line);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.clock.low { border-color: var(--red); color: var(--red); }
.word { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.word .label { color: var(--muted); font-size: 14px; }
.word .answer { font-size: 20px; font-weight: 800; color: var(--accent); }
.word .answer.good { color: var(--green); }
.word .mask {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 1.1em;
  max-width: 100%;
}
.word .mword { white-space: pre; }
.sk-leave .stack { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sk-leave .btn { width: 100%; }
/* The drawer's word: hidden until tapped (see renderSecret in app.js) */
.word .peek {
  min-height: 44px;
  max-width: 100%;
  padding: 2px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  line-height: 1.15;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 4px;
  cursor: pointer;
}
.word .peek.hidden-word .label { color: var(--text); font-weight: 700; font-size: 15px; }
.word .lengths { font-size: 12px; color: var(--muted); }
.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.round { font-size: 12px; color: var(--muted); white-space: nowrap; }
.icon-btn {
  flex: none;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 16px;
}

.stage { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; }

/* The canvas box: 4:3 in portrait, but it may shrink when the keyboard is open.
   canvas.js keeps the picture 4:3 and centred inside it. */
.board {
  position: relative;
  flex: 0 1 auto;
  width: 100%;
  aspect-ratio: 4 / 3;
  min-height: 90px;
}
.board .sk-pad { position: absolute; inset: 0; width: auto; height: auto; aspect-ratio: auto; max-height: none; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(20, 22, 43, 0.92);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  text-align: center;
  overflow-y: auto;
}
.overlay h2 { font-size: 20px; }
.overlay .answer { color: var(--accent); }
.overlay p { margin: 0; }
.choices { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.choice {
  background: var(--accent);
  color: #1b1b1b;
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  min-width: 110px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.choice .cw { font-size: 18px; font-weight: 800; }
.choice .lv { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 1px 8px; background: rgba(0, 0, 0, 0.12); }
.choice:active { transform: scale(0.97); }
.deltas { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 180px; }
.deltas li { display: flex; justify-content: space-between; gap: 16px; font-size: 16px; }
.deltas .plus { color: var(--green); font-weight: 800; }
.deltas .zero { color: var(--muted); }

.side { flex: 1 1 0; min-height: 120px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }

.strip { display: flex; gap: 6px; overflow-x: auto; flex: none; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.pchip {
  flex: none;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
}
.pchip .pts { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.pchip.me { border-color: var(--muted); }
.pchip.guessed { background: var(--green); border-color: var(--green); color: #10261c; }
.pchip.guessed .pts { color: #10261c; }
.pchip.away { opacity: 0.45; }

.tools { flex: none; }
.tools .sk-tools { padding: 0; gap: 6px; }
.tools .sk-tools button { min-width: 40px; height: 40px; }
.tools .sk-tools .sk-size { width: 40px; }
/* 9 colors fit in one row on a 360 px wide phone */
.tools .sk-tools .sk-color { width: 34px; min-width: 34px; }
.tools .sk-group { gap: 5px; }

/* The chat scrolls on its own; touch-action and overscroll keep the swipe inside it. */
.feed {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  list-style: none;
  margin: 0;
  padding: 8px 10px;
  background: var(--panel);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 15px;
  line-height: 1.3;
  word-break: break-word;
}
.feed li:first-child { margin-top: auto; }
.feed .who { font-weight: 700; }
.feed .info { color: var(--muted); font-style: italic; }
.feed .good { color: var(--green); font-weight: 700; }
.feed .close { color: var(--accent); font-weight: 700; }
.feed .like { color: var(--green); }
.feed .dislike { color: var(--red); }

.guess { display: flex; gap: 6px; align-items: center; flex: none; }
.guess input { padding: 10px 12px; }
.guess input:disabled { opacity: 0.5; }
.guess .btn { padding: 11px 14px; }
.votes { display: flex; gap: 4px; }
.votes button {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 20px;
  padding: 0;
}

/* Landscape: canvas on the left at full height, players, chat and guess box on the right. */
body.land .stage { flex-direction: row; }
body.land .board { width: auto; height: 100%; flex: 0 1 auto; min-width: 0; min-height: 0; }
body.land .side { min-width: 230px; max-width: 420px; min-height: 0; }
body.land .topbar { min-height: 38px; }
body.land .clock { width: 38px; height: 38px; font-size: 15px; }
