/* GREAT ARTIST — a dark gallery wall. Each painting brings its own palette, so
   the board is built at runtime and its length varies from three to twelve. */

:root {
  --wall: #14121a;
  --wall-deep: #0e0c12;
  --panel: #1d1a25;
  --panel-hi: #262231;
  --line: #322d3d;
  --ivory: #efe6d6;
  --muted: #9c9384;
  --brass: #c9a227;
  --brass-hi: #e2bd44;
  --over: #d9795c;
  --under: #6f9dc7;
  --radius: 14px;
  --display: ui-serif, Georgia, 'Songti TC', 'Noto Serif CJK TC', serif;
  --ui: system-ui, -apple-system, 'Segoe UI', 'Noto Sans CJK TC', 'PingFang TC', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #221d2c 0%, transparent 60%),
    var(--wall);
  color: var(--ivory);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

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

.screen { display: none; }
.screen[data-active] { display: block; }

.screen--menu {
  min-height: 100dvh;
  display: none;
  place-items: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
}
.screen--menu[data-active] { display: grid; }

.menu-card {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(180deg, var(--panel) 0%, var(--wall-deep) 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 32px 26px;
  text-align: center;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.5);
}
.menu-card--wide { max-width: 520px; }

.crest { color: var(--brass); line-height: 0; }

.wordmark {
  margin: 12px 0 4px;
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.14em;
  line-height: 1;
}
.wordmark span { display: block; font-size: 26px; color: var(--muted); }
.wordmark em {
  display: block;
  font-size: 40px;
  font-style: normal;
  color: var(--ivory);
}

.sub { margin: 6px 0 0; color: var(--brass); font-size: 12px; letter-spacing: 0.22em; }
.pitch { margin: 18px 0 26px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; letter-spacing: 0.28em; }
.hint { margin: 6px 0 18px; color: var(--muted); font-size: 13px; }

.roomcode {
  margin: 4px 0 0;
  font-family: var(--display);
  font-size: 52px;
  letter-spacing: 0.18em;
  color: var(--brass-hi);
}

/* ----------------------------------------------------------------- inputs */

.field { text-align: left; margin-bottom: 16px; }
.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
}

input[type='text'], input:not([type]) {
  width: 100%;
}

.field input, .join-row input {
  background: var(--wall-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ivory);
  font-family: inherit;
  font-size: 16px;
  padding: 11px 13px;
  width: 100%;
}
.field input:focus, .join-row input:focus {
  outline: none;
  border-color: var(--brass);
}

.stack { display: grid; gap: 10px; }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.join-row input { text-align: center; letter-spacing: 0.3em; text-transform: uppercase; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-hi);
  color: var(--ivory);
  font: inherit;
  font-size: 15px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: #302a3c; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
/* display:inline-flex above outranks the browser's [hidden] rule: without this a
   "hidden" submit / next / again button stayed on screen. */
.btn[hidden] { display: none; }
.btn--primary {
  background: var(--brass);
  border-color: var(--brass);
  color: #201a0a;
  font-weight: 600;
}
.btn--primary:hover:not(:disabled) { background: var(--brass-hi); }
.btn--ghost { background: transparent; }
.btn--sm { padding: 9px 14px; font-size: 13px; }

.segmented { display: grid; grid-auto-flow: column; gap: 8px; }
.segmented__btn {
  border: 1px solid var(--line);
  background: var(--wall-deep);
  color: var(--muted);
  border-radius: 10px;
  padding: 10px 0;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.segmented__btn.is-on { border-color: var(--brass); color: var(--brass-hi); }
.segmented__btn:disabled { cursor: not-allowed; }

.rules {
  margin-top: 22px;
  text-align: left;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.rules summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.1em;
}
.rules ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 13px; line-height: 1.9; }

.roster { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 6px; }
.roster__item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--wall-deep);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
}
.roster__item.is-me { border-color: var(--brass); }
.roster__name { flex: 1; }
.roster__tag { font-size: 11px; color: var(--brass); letter-spacing: 0.16em; }
.roster__item.is-away { opacity: 0.6; }
.roster__tag--away { color: var(--muted); }

/* 園區共用分享面板（shared/client/share.js）：配這面深色牆的色票。 */
.share-panel { margin: 0 0 18px; }
.share-panel.pshare {
  --pshare-bg: var(--wall-deep);
  --pshare-fg: var(--ivory);
  --pshare-accent: var(--brass-hi);
  --pshare-btn: var(--panel-hi);
  border: 1px solid var(--line);
  align-items: center;
}
.share-panel .pshare-row { justify-content: center; }

/* ------------------------------------------------------------- play frame */

.screen--play {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 14px calc(20px + env(safe-area-inset-bottom));
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.bar__left, .bar__right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--muted);
  white-space: nowrap;
}
.pill em { font-style: normal; color: var(--ivory); font-variant-numeric: tabular-nums; }
.pill--clock em { min-width: 2ch; text-align: right; }
.pill--clock.is-urgent { border-color: var(--over); }
.pill--clock.is-urgent em { color: var(--over); }

.piece-name {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.piece-movement { font-size: 12px; color: var(--brass); letter-spacing: 0.16em; }

/* ----------------------------------------------------------------- plates */

.plates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.plate {
  margin: 0;
  position: relative;
  background: var(--wall-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 10px 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}
.plate img, .plate canvas {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  background: var(--panel);
}
.plate figcaption {
  padding: 8px 2px 10px;
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--muted);
  text-align: center;
}
.plate.is-blank canvas { opacity: 0; }
.plate.is-blank::after {
  content: '拉動滑桿開始重畫';
  position: absolute;
  inset: 10px 10px 38px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.12em;
}

/* ----------------------------------------------------------------- mixbar */

.mixbar {
  display: flex;
  height: 20px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--wall-deep);
  margin-bottom: 14px;
}
.mixbar__seg { flex-basis: 0; min-width: 0; }
.mixbar.is-empty { background: repeating-linear-gradient(45deg, #1a1722 0 6px, #16131d 6px 12px); }

/* ------------------------------------------------------------------ board */

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 4px 22px;
  margin-bottom: 16px;
}
.board.is-locked { opacity: 0.55; }

/* A short board should not be stretched across a desktop into three lonely
   columns; it stays one column and centred. */
.board--narrow {
  grid-template-columns: minmax(0, 460px);
  justify-content: center;
}

.swatch {
  display: grid;
  grid-template-columns: 34px 1fr 40px;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
}
/* With no names to read, the swatch IS the label — it has to be big enough to
   hold against a whole painting, and ringed so a near-black one still reads
   as a swatch rather than a hole in the page. */
.swatch__chip {
  width: 34px;
  height: 26px;
  border-radius: 6px;
  background: var(--pigment);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.22), 0 1px 3px rgba(0, 0, 0, 0.4);
}
.swatch.is-used .swatch__chip { box-shadow: 0 0 0 2px var(--brass), 0 1px 3px rgba(0, 0, 0, 0.4); }
.swatch__pct {
  font-size: 13px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Not the pigment colour: ink and slate are unreadable against this wall. */
.swatch.is-used .swatch__pct { color: var(--ivory); }

.swatch__slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
/* --fill is written by board.js: WebKit has no ::-moz-range-progress, so the
   filled portion has to be painted into the track itself. */
.swatch__slider::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(
    90deg,
    var(--pigment) 0,
    var(--pigment) var(--fill, 0%),
    #3c3648 var(--fill, 0%),
    #3c3648 100%
  );
}
.swatch__slider::-moz-range-track {
  height: 5px;
  border-radius: 3px;
  background: #3c3648;
}
.swatch__slider::-moz-range-progress {
  height: 5px;
  border-radius: 3px;
  background: var(--pigment);
}
.swatch__slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--pigment);
  border: 2px solid var(--wall);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.swatch__slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pigment);
  border: 2px solid var(--wall);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.swatch__slider:disabled { cursor: not-allowed; }

/* -------------------------------------------------------------- submitbar */

.submitbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.submitted-note { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.1em; }

/* ----------------------------------------------------------------- reveal */

.plates-note {
  margin: -4px 0 16px;
  text-align: center;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}
.plates-note strong { color: var(--brass); font-weight: 600; }

.verdict { margin-bottom: 16px; }
.verdict__card {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
}
.verdict__card p { margin: 0; }
.verdict__grade { font-family: var(--display); font-size: 24px; color: var(--brass-hi); letter-spacing: 0.1em; }
.verdict__accuracy { font-size: 15px; }
.verdict__points { font-size: 26px; font-variant-numeric: tabular-nums; }
.verdict__bonus { font-size: 13px; color: var(--brass); }
.verdict__tv { font-size: 12px; color: var(--muted); flex-basis: 100%; text-align: center; }
.verdict__miss { text-align: center; color: var(--muted); }

.compare {
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 16px;
}
.compare__head {
  display: grid;
  grid-template-columns: 26px 1fr 46px;
  gap: 10px;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--muted);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.compare__head span:nth-child(2) { text-align: center; }
.compare__head span:last-child { text-align: right; }

.compare__row {
  display: grid;
  grid-template-columns: 26px 1fr 46px;
  gap: 10px;
  align-items: center;
}
.compare__label { display: flex; align-items: center; gap: 7px; font-size: 12px; }
.compare__chip {
  width: 22px;
  height: 16px;
  border-radius: 4px;
  background: var(--pigment);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14);
  flex: none;
}
.compare__bars { display: grid; gap: 3px; }
.compare__bar {
  position: relative;
  height: 11px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.05);
}
.compare__bar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--fill);
  background: var(--pigment);
  border-radius: 3px;
}
.compare__bar--yours::before { opacity: 0.45; }
.compare__bar em {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-style: normal;
  font-size: 9px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.compare__row.is-idle { opacity: 0.35; }
.compare__delta { font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.compare__delta.is-over { color: var(--over); }
.compare__delta.is-under { color: var(--under); }
.compare__delta.is-exact { color: var(--brass); }

/* -------------------------------------------------------------- standings */

.standings { display: grid; gap: 5px; margin-bottom: 16px; }
.standing {
  display: grid;
  grid-template-columns: 26px 1fr auto auto;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.standing.is-me { border-color: var(--brass); }
.standing__rank { color: var(--muted); font-family: var(--display); font-size: 16px; }
/* The final screen sits inside a centred menu card; names still read left. */
.standing__name { text-align: left; }
.standing__last { color: var(--brass); font-size: 12px; font-variant-numeric: tabular-nums; }
.standing__total { font-size: 17px; font-variant-numeric: tabular-nums; min-width: 4ch; text-align: right; }
.standings--final .standing { padding: 14px; }
.standings--final .is-rank1 { border-color: var(--brass-hi); background: linear-gradient(90deg, #2a2318, var(--panel)); }

.final-title { font-family: var(--display); font-weight: 400; font-size: 24px; margin: 14px 0 20px; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  margin: 0;
  background: var(--panel-hi);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 20;
}

/* ----------------------------------------------------------- narrow phone */

@media (max-width: 560px) {
  .wordmark em { font-size: 34px; }
  .roomcode { font-size: 42px; }
  .piece-name { font-size: 17px; }
  .bar { gap: 8px; }
  .plate { padding: 7px 7px 0; }
  .swatch { grid-template-columns: 30px 1fr 36px; gap: 10px; }
  .swatch__chip { width: 30px; height: 24px; }
  .compare__head, .compare__row { grid-template-columns: 24px 1fr 40px; }
  .menu-card { padding: 26px 20px; }
}

/* 共用連線提示列（shared/client/conn-status.js）：窄螢幕時「重新整理」不要被擠成直排。 */
.pcs-bar button { flex: none; white-space: nowrap; }
