:root {
  color-scheme: dark;
  font-family: "Geist", system-ui, sans-serif;
  color: #e8ede8;
  background: #111917;
  --line: #30403a;
  --panel: #192421;
  --accent: #d8e993;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.site-header {
  display: grid;
  grid-template-areas: "brand round profile center";
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px clamp(10px, 2vw, 24px);
  padding: 7px clamp(10px, 2vw, 28px);
  background: #192421;
  border-bottom: 1px solid var(--line);
  z-index: 1;
}
.brand { grid-area: brand; min-width: 0; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(20px, 3vw, 28px); line-height: 1.05; white-space: nowrap; }
h1 span, .stars { color: var(--accent); }
#room, #status { color: #b6c6ba; font-size: 12px; }
.round, .profile, .turn { display: flex; align-items: center; gap: 8px; min-width: 0; }
.round { grid-area: round; justify-content: space-between; }
.round-copy, .identity { min-width: 0; }
.turn { font-size: clamp(20px, 2.6vw, 32px); font-weight: 700; white-space: nowrap; letter-spacing: -.035em; }
.turn i { flex: 0 0 12px; height: 12px; border: 1px solid #869689; border-radius: 50%; }
.turn i[data-team="white"] { background: #f4f2dc; }
.turn i[data-team="black"] { background: #141a1b; }
#status { display: block; margin-top: 2px; }
#status:empty { margin-top: 0; }
#timer {
  padding: 6px 12px;
  min-width: 4.7ch;
  color: var(--accent);
  background: #111917;
  border: 1px solid #495537;
  border-radius: 10px;
  text-align: center;
  font-size: clamp(28px, 3.3vw, 42px);
  line-height: 1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#timer[data-urgent] { color: #ffc198; }
.profile {
  grid-area: profile;
  justify-self: end;
  max-width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 8px;
}
#evolution {
  grid-column: 1 / -1;
  color: #c7d8ce;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.identity { display: grid; gap: 2px; }
#name, #room { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#name, .stars { font-size: 14px; font-weight: 650; }
.stars { white-space: nowrap; font-variant-numeric: tabular-nums; }
.board { position: relative; flex: 1; min-height: 0; background: #060a09; }
#viewport { position: absolute; inset: 0; touch-action: none; cursor: grab; overflow: hidden; }
#viewport:active { cursor: grabbing; }
#viewport canvas { display: block; position: absolute; inset: 0; }
#viewport:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.board-notice {
  position: absolute;
  z-index: 1;
  top: clamp(12px, 4vh, 34px);
  left: 50%;
  translate: -50% 0;
  max-width: calc(100% - 24px);
  margin: 0;
  padding: 7px 18px;
  border-radius: 10px;
  color: var(--accent);
  background: #111917e8;
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}
.super-move-notice {
  display: block;
  text-align: center;
  color: #ffcf68;
  font-size: .62em;
  margin-top: 2px;
}
#capture-banner { color: #ffd0be; }
#turn-banner:not(:empty) ~ #capture-banner { margin-top: 2em; }
#turn-banner:has(.super-move-notice) ~ #capture-banner { margin-top: 2.75em; }
@media (max-width: 700px) {
  .site-header {
    grid-template-areas: "brand profile" "round center";
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .profile { max-width: min(100%, 48vw); }
  .round { justify-content: flex-start; }
  .camera-actions { justify-self: end; font-size: 12px; gap: 4px; }
}
button, input { font: inherit; border: 1px solid var(--line); border-radius: 9px; min-height: 40px; padding: 8px 12px; }
button { color: #182012; background: var(--accent); font-weight: 650; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
input, .secondary, .camera-actions button { color: inherit; background: #23312c; }
.camera-actions { grid-area: center; display: flex; gap: 6px; }
.camera-actions button { white-space: nowrap; min-height: 32px; padding-block: 4px; }
dialog, .promotion { border: 1px solid #405047; border-radius: 16px; background: var(--panel); color: inherit; box-shadow: 0 18px 70px #0008; }
dialog { width: min(360px, calc(100vw - 24px)); padding: 24px; }
dialog::backdrop { background: #0b13135c; }
form { display: grid; gap: 10px; }
form h2 { margin-bottom: 9px; }
form label { font-size: 14px; }
#join-error { margin: 0; color: #ffc1ad; font-size: 14px; }
#join-error:empty { display: none; }
.promotion { position: fixed; z-index: 2; width: min(460px, calc(100vw - 24px)); left: 50%; bottom: 20px; transform: translateX(-50%); padding: 16px; }
.promotion h2 { font-size: 20px; margin-bottom: 12px; }
#cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
#cards button { display: grid; justify-items: center; padding: 6px 2px; font-size: 13px; }
#cards b { font: 30px "DejaVu Sans", "Segoe UI Symbol", serif; }

#arrival-banner { color: #e8efca; }
#arrival-banner:not(:empty) + #capture-banner { margin-top: 2em; }
#join { max-height: calc(100dvh - 20px); }
#join:has(#paint-panel:not([hidden])) { width: min(640px, calc(100vw - 20px)); }
.join-layout { display: grid; gap: 18px; align-items: start; }
.join-layout:has(#paint-panel:not([hidden])) { grid-template-columns: minmax(160px, 1fr) auto; }
#paint-panel { padding-inline-start: 16px; border-inline-start: 1px solid var(--line); }
#paint-panel h2, #respawn h2 { font-size: 20px; }
#paint-panel p, #respawn p { margin: 5px 0 10px; color: #b6c6ba; font-size: 13px; }
#paint-status:empty { display: none; }
.paint-workspace { display: flex; gap: 6px; align-items: center; }
#paint-preview { width: 76px; height: 76px; }
#paint-palettes { display: grid; gap: 5px; }
.paint-row { display: flex; gap: 4px; }
.paint-row button {
  width: 24px; height: 24px; min-height: 24px; padding: 0;
  border-radius: 4px; background: var(--swatch); border-color: #728177;
}
.paint-row .paint-clear {
  background: #232c27;
  color: #ff726b;
  font-size: 20px;
  line-height: 1;
}
.paint-row button[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: -2px; }
#buy-paint { margin-top: 10px; width: 100%; }
.respawn-choices { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 580px) {
  .join-layout:has(#paint-panel:not([hidden])) { grid-template-columns: 1fr; }
  #paint-preview { width: min(64px, 24%); height: auto; }
  .paint-row { gap: 3px; }
  .paint-row button { width: clamp(18px, 6vw, 24px); }
  #paint-panel { padding: 12px 0 0; border-inline-start: 0; border-top: 1px solid var(--line); }
}

#turn-banner:not(:empty) + #arrival-banner { margin-top: 2em; }

#board-event {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 50%;
  translate: -50% 0;
  display: grid;
  justify-items: center;
  gap: 4px;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 12px 28px;
  border: 1px solid #b0654e;
  border-radius: 16px;
  background: #231c19eb;
  box-shadow: 0 12px 40px #0007;
  text-align: center;
  pointer-events: none;
}
#event-title { color: #ffd0b5; font-size: clamp(32px, 6vw, 64px); line-height: 1; letter-spacing: .04em; }
#event-detail { color: #f2e0d3; font-size: clamp(14px, 2vw, 20px); }
#board-event[data-result="end"] { top: 40%; border-color: #b7c974; background: #17221beb; }
#board-event[data-result="end"] #event-title { color: var(--accent); }
.board:has(#board-event:not([hidden])) .board-notice { top: 150px; }
@media (min-width: 701px) and (max-width: 1000px) {
  .site-header { grid-template-areas: "brand profile" "round center"; grid-template-columns: 1fr auto; }
}
