/* Black and pink, dark only. Pink is the one colour: prompt cards, buttons,
   selection. Everything else is near-black and grey. */
:root {
  --page: #0B0B0B;
  --surface: #141414;
  --panel: #1C1C1C;
  --raised: #2A2A2A;
  --line: #242424;
  --text: #EDEDED;
  --muted: #8A8A8A;
  --accent: #FF3D8B;
  --accent-hi: #FF63A3;
  --on-accent: #0B0B0B;
  --accent-text: #FF5C9D;
  --good: #8BC34A;
  --warn: #FFB300;
  --bad: #FF6B6B;
  --prompt-bg: #FF3D8B;
  --prompt-text: #0B0B0B;
  --prompt-line: transparent;
  --answer-bg: #171717;
  --answer-text: #EDEDED;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
.mono { font-family: var(--mono); }
[hidden] { display: none !important; }

/* ---------- header ---------- */

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.mark {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.mark span { color: var(--accent); }
.top nav { display: flex; align-items: center; gap: 6px; }
.nav-link {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-weight: 500;
}
.nav-link:hover { color: var(--text); background: var(--panel); }
.room-tag {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  margin-right: 4px;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel); color: var(--text); }

/* ---------- general ---------- */

.wrap { max-width: 1080px; margin: 0 auto; padding: 28px 20px 60px; }
.narrow { max-width: 460px; }
h1 { font-size: 30px; line-height: 1.15; margin: 0 0 8px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 10px; font-family: var(--mono); font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 16px; margin-bottom: 24px; }
.muted { color: var(--muted); }
.small-print { color: var(--muted); font-size: 13px; }

.box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.stack > * + * { margin-top: 14px; }

label.field { display: block; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], textarea {
  width: 100%;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
}
input[type="text"]:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
.code-input { font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.2em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--raised); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.danger { color: var(--muted); }
.btn.danger:hover:not(:disabled) { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 500; }
.btn.block { width: 100%; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.split { justify-content: space-between; }

.or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0;
}
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-left: 3px solid var(--bad);
  border-radius: 6px;
  padding: 10px 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast.ok { border-left-color: var(--good); }

.banner {
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  background: var(--surface);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

/* ---------- cards ---------- */

.card {
  position: relative;
  border-radius: 8px;
  padding: 16px 16px 34px;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  min-height: 150px;
  text-align: left;
}
.card .tag {
  position: absolute;
  left: 16px;
  bottom: 11px;
  font: 500 11px var(--mono);
  letter-spacing: 0.04em;
  opacity: 0.75;
}
.card.prompt {
  background: var(--prompt-bg);
  color: var(--prompt-text);
  border: 1px solid var(--prompt-line);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  min-height: 190px;
  max-width: 340px;
}
.card.prompt .blank {
  display: inline-block;
  min-width: 70px;
  border-bottom: 3px solid currentColor;
  line-height: 1.1;
}
.card.prompt .nowrap { white-space: nowrap; }
.card.prompt .blank.filled {
  white-space: normal;
  border-bottom-color: color-mix(in srgb, currentColor 55%, transparent);
  background: color-mix(in srgb, currentColor 14%, transparent);
  border-radius: 3px 3px 0 0;
  padding: 0 4px;
}
.card.answer {
  background: var(--answer-bg);
  color: var(--answer-text);
  border: 1px solid var(--line);
}
button.card.answer {
  width: 100%;
  cursor: pointer;
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  transition: transform 0.08s ease, border-color 0.08s ease;
}
button.card.answer:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--muted); }
button.card.answer:disabled, button.card.answer[aria-disabled="true"] { cursor: default; }
button.card.answer.sel, button.card.answer.sel:hover {
  border: 2px solid var(--accent);
  padding: 15px 15px 33px;
  transform: translateY(-4px);
}
.card .order {
  position: absolute;
  right: 12px;
  top: 10px;
  font: 600 12px var(--mono);
  color: var(--accent-text);
}


.hand {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

/* ---------- home ---------- */

.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; align-items: start; }
.fan { position: relative; height: 300px; }
.fan .card { position: absolute; width: 220px; }
.fan .card.prompt { left: 0; top: 10px; transform: rotate(-4deg); z-index: 2; }
.fan .card.answer { left: 150px; top: 90px; transform: rotate(5deg); z-index: 3; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); }
.steps { list-style: none; padding: 0; margin: 24px 0 0; display: grid; gap: 10px; }
.steps li { display: grid; grid-template-columns: 28px 1fr; color: var(--muted); }
.steps li b { font-family: var(--mono); font-weight: 500; color: var(--accent-text); }


/* ---------- lobby ---------- */

.lobby { display: grid; grid-template-columns: 1.2fr 1fr; gap: 20px; align-items: start; }
.code-big {
  font: 600 44px/1 var(--mono);
  letter-spacing: 0.12em;
  margin: 4px 0 14px;
}
.players { list-style: none; margin: 0; padding: 0; }
.players li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
}
.players li:first-child { border-top: 0; }
.players .who { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; min-width: 0; }
.players .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.players .off .name { color: var(--muted); }
.label {
  font: 500 11px var(--mono);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.label.accent { color: var(--accent-text); border-color: var(--accent-text); }

.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.setting:first-of-type { border-top: 0; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 6px; }
.stepper button { width: 34px; height: 32px; border: 0; background: transparent; cursor: pointer; font-size: 18px; color: var(--muted); }
.stepper button:hover:not(:disabled) { color: var(--text); background: var(--panel); }
.stepper span { font-family: var(--mono); min-width: 32px; text-align: center; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- table ---------- */

.table { display: grid; grid-template-columns: 1fr 230px; gap: 24px; align-items: start; }
.scores h3 { margin-bottom: 6px; }
.scores li .pts { font-family: var(--mono); font-weight: 600; }
.status { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.sub-status { color: var(--muted); margin-bottom: 18px; }
.play-area { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 26px; }
.play-area .card.prompt { flex: 0 0 300px; }
.play-side { flex: 1; min-width: 220px; }
.subs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sub {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  font-family: var(--sans);
}
button.sub { cursor: pointer; }
button.sub:hover:not(:disabled) { border-color: var(--muted); }
.sub.sel, button.sub.sel:hover:not(:disabled) { border: 2px solid var(--accent); padding: 13px; }
.sub.won { border: 2px solid var(--accent); padding: 13px; }
.sub .sentence { font-size: 16px; font-weight: 500; line-height: 1.4; }
.sub .sentence b { font-weight: 700; }
.sub .by { margin-top: 10px; font: 500 12px var(--mono); color: var(--muted); display: flex; justify-content: space-between; }
.sub.won .by span:last-child { color: var(--accent-text); }

.hand-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.dim { opacity: 0.55; }
.winner-name { font-size: 40px; font-weight: 700; letter-spacing: -0.02em; margin: 6px 0 4px; }

/* ---------- card manager ---------- */

.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; padding: 3px; gap: 3px; margin-bottom: 12px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 4px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button[aria-selected="true"] { background: var(--raised); color: var(--text); }
.hint { color: var(--muted); font-size: 14px; }
.add-row { display: grid; grid-template-columns: 1fr 230px; gap: 18px; align-items: start; }
.add-input > * + * { margin-top: 10px; }
.add-tools { display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
.count { color: var(--muted); font-size: 12px; margin-left: auto; }
.form-msg { min-height: 20px; font-size: 14px; margin: 0; }
.form-msg.bad { color: var(--bad); }
.form-msg.ok { color: var(--good); }
.add-preview .card { max-width: none; width: 100%; font-size: 17px; min-height: 170px; }
.add-preview .card.answer { font-size: 16px; }
.empty-text { opacity: 0.5; font-weight: 500; }

.card-list { list-style: none; margin: 0; padding: 0; }
.card-list li { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
.card-list li:first-child { border-top: 0; }
.card-list .txt { font-weight: 500; }
.card-list .meta { font: 12px var(--mono); color: var(--muted); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* ---------- add sheet ---------- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 40;
}
.sheet-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(720px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 18px 20px 20px;
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }

/* ---------- small screens ---------- */

@media (max-width: 820px) {
  .home-grid, .lobby, .table, .cols { grid-template-columns: 1fr; }
  .fan { display: none; }
  .table .scores { order: -1; }
  .add-row { grid-template-columns: 1fr; }
  .add-preview { max-width: 260px; }
}
@media (max-width: 520px) {
  .wrap { padding: 18px 14px 50px; }
  .top { padding: 10px 14px; }
  .mark { font-size: 15px; }
  h1 { font-size: 25px; }
  .hand { grid-template-columns: repeat(2, 1fr); }
  .card { font-size: 15px; min-height: 120px; }
  .play-area .card.prompt { flex: 1 1 100%; max-width: none; }
  .code-big { font-size: 36px; }
}

.card.answer.blocked { opacity: 0.3; }

/* ---------- ? context on cards ---------- */

.card .info-btn {
  position: absolute;
  right: 10px;
  bottom: 8px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  font: 600 13px/1 var(--mono);
  opacity: 0.6;
  cursor: pointer;
  z-index: 2;
}
.card .info-btn:hover, .card .info-btn:focus-visible { opacity: 1; outline: none; }
.card .info-text { display: none; }
.card.show-info .info-text {
  display: block;
  position: absolute;
  inset: 0;
  padding: 14px 14px 40px;
  border-radius: inherit;
  background: inherit;
  font: 500 14px/1.45 var(--sans);
  letter-spacing: 0;
  text-align: left;
  overflow: auto;
  z-index: 1;
}
.card.prompt.show-info .info-text { font-size: 15px; }
.card.show-info .info-btn { opacity: 1; }
