:root {
  --bg: #101014;
  --panel: #1b1b22;
  --line: #2c2c38;
  --text: #e8e8f0;
  --muted: #9a9aaa;
  --accent: #ffd700;
  --cyan: #00d7d7;
  --magenta: #d700d7;
  --red: #ff4b4b;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
button {
  font: inherit; cursor: pointer; border: 1px solid var(--accent); background: transparent;
  color: var(--accent); padding: .45rem 1rem; border-radius: 4px;
}
button:hover { background: var(--accent); color: #000; }
button.small { padding: .1rem .5rem; font-size: .8rem; }
a.button {
  border: 1px solid var(--accent); color: var(--accent); padding: .45rem 1rem; border-radius: 4px;
  text-align: center; text-decoration: none;
}
a.button:hover { background: var(--accent); color: #000; }
input {
  font: inherit; width: 100%; padding: .45rem .6rem; background: #0b0b0f; color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
}
input.code { text-transform: uppercase; letter-spacing: .2em; font-family: var(--mono); }
kbd {
  font-family: var(--mono); font-size: .8rem; padding: 0 .3rem; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 3px; background: #0b0b0f; margin: 0 1px;
}
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: .85rem; }
.error { color: var(--red); }

/* lobby */
.lobby { max-width: 760px; margin: 0 auto; padding: 4rem 1rem; text-align: center; }
.title { margin: 0; line-height: 0; }
.title img { width: 360px; max-width: 100%; height: auto; }
.subtitle { color: var(--muted); margin-top: .25rem; }
.intro { max-width: 600px; margin: 0 auto; color: var(--text); }
.cards { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; margin-top: 2rem; }
.card {
  flex: 1 1 280px; max-width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 1.25rem; text-align: left; display: flex; flex-direction: column; gap: .75rem;
}
.card h2 { margin: 0; font-size: 1.1rem; color: var(--cyan); }
.card label { display: flex; flex-direction: column; gap: .3rem; color: var(--muted); font-size: .9rem; }

/* game page */
.play {
  display: flex; flex-wrap: wrap; gap: 1rem; padding: 1rem; justify-content: center; align-items: flex-start;
  min-height: 100vh;
}
.screen-col { flex: 1 1 640px; max-width: 960px; min-width: 0; }
.screen-wrap { position: relative; }
#screen {
  width: 100%; height: auto; aspect-ratio: 320 / 240; image-rendering: pixelated;
  image-rendering: crisp-edges; display: block; background: #000; outline: none;
  border-radius: 4px; box-shadow: 0 0 0 1px var(--line);
}
#screen:focus { box-shadow: 0 0 0 2px var(--accent); }
.overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: .75rem; align-items: center;
  justify-content: center; text-align: center; padding: 2rem; color: var(--text); background: rgba(0, 0, 0, .7);
  font-size: 1.1rem; border-radius: 4px;
}
.overlay:empty { display: none; }
.overlay p { margin: 0; font-size: 1.4rem; color: var(--accent); }
.side { flex: 0 1 300px; display: flex; flex-direction: column; gap: .75rem; min-width: 260px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .75rem .9rem; }
.box h3 { margin: 0 0 .5rem; font-size: .85rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.row { display: flex; gap: .5rem; align-items: center; }
.label { color: var(--muted); }
#code { font-family: var(--mono); letter-spacing: .15em; color: var(--accent); }
.status { margin-top: .5rem; color: var(--cyan); min-height: 1.4em; }
.status.you { color: var(--accent); font-weight: 600; }
.seats { list-style: none; margin: 0 0 .5rem; padding: 0; }
.seats li {
  display: flex; align-items: center; gap: .5rem; padding: .25rem 0; border-bottom: 1px solid var(--line);
}
.seats li:last-child { border-bottom: 0; }
.seats .num { font-family: var(--mono); color: var(--muted); width: 1.2rem; }
.seats .dot { width: .55rem; height: .55rem; border-radius: 50%; background: #444; }
.seats .dot.on { background: #3ad13a; }
.seats .dot.none { background: transparent; box-shadow: inset 0 0 0 1px var(--muted); }
.seats li.dead .name { text-decoration: line-through; color: var(--muted); }
.seats .me { color: var(--accent); }
.seats .tag { margin-left: auto; font-size: .75rem; color: var(--muted); }
.seats .turn { color: var(--accent); }
.keys p { margin: 0 0 .5rem; color: var(--muted); font-size: .85rem; line-height: 1.9; }
.pad-check { margin-bottom: .5rem; }
/* on-screen keys: they press the same Spectrum keys as the keyboard */
.pad {
  display: flex; flex-wrap: wrap; gap: .6rem; margin-top: .6rem; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; -webkit-touch-callout: none;
}
.pad button {
  min-height: 2.9rem; padding: .2rem; border-color: var(--line); background: var(--panel); color: var(--text);
  font-size: .95rem; line-height: 1.1; touch-action: manipulation;
}
.pad button:hover { background: var(--panel); color: var(--text); }
.pad button.pressed, .pad button.on { background: var(--accent); border-color: var(--accent); color: #000; }
.pad button small { display: block; font-size: .65rem; color: var(--muted); }
.pad button.pressed small, .pad button.on small { color: #000; }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; flex: 1 1 10rem; }
.pad .dpad button { font-size: 1.3rem; }
.pad .dpad .select { font-size: .85rem; border-color: var(--accent); color: var(--accent); }
.pad-row { display: grid; gap: .35rem; flex: 1 1 100%; }
.pad .digits { grid-template-columns: repeat(10, 1fr); }
.pad .letters { grid-template-columns: repeat(7, 1fr); }
.pad .letters .wide { grid-column: span 2; }
.check { display: flex; gap: .4rem; align-items: center; color: var(--muted); font-size: .9rem; }
.check input { width: auto; }
.chatlog { height: 140px; overflow-y: auto; font-size: .85rem; margin-bottom: .5rem; }
.chatlog .who { color: var(--cyan); }
.chatlog .watcher { color: var(--muted); }
#chatform { display: flex; flex-direction: column; gap: .4rem; }
.rules { margin-top: .5rem; font-size: .85rem; }
.rules ul { margin: .2rem 0 0; padding-left: 1.1rem; color: var(--text); }
/* custom game page */
.card.custom { max-width: 460px; }
.card.custom h3 { margin: .5rem 0 0; font-size: .95rem; color: var(--cyan); }
.card.custom select {
  font: inherit; padding: .4rem .5rem; background: #0b0b0f; color: var(--text);
  border: 1px solid var(--line); border-radius: 4px;
}
#chatform .hint { margin: 0; }

/* accounts */
a { color: var(--cyan); }
.title a { color: inherit; text-decoration: none; }
.userbar {
  display: flex; gap: 1rem; justify-content: flex-end; align-items: center; padding: .75rem 1rem;
  color: var(--muted); font-size: .9rem;
}
.userbar form { margin: 0; }
.userbar + .lobby { padding-top: 1rem; }
.footer { padding: 1.5rem 1rem; text-align: center; font-size: .85rem; }
.footer a, .footer .version { color: var(--muted); }
.playing-as { margin: 0; }
.playing-as strong { color: var(--accent); }
/* after a registered player's name */
.reg { color: var(--cyan); font-size: .8em; margin-left: .2em; cursor: help; }
.policy { max-width: 696px; margin: 2rem auto 0; display: block; }
.policy h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.policy ul { padding-left: 1.2rem; margin: 0; }
.policy li { margin-bottom: .5rem; }
.help .toc { font-size: .9rem; line-height: 1.8; }
.help h3 { color: var(--cyan); scroll-margin-top: 1rem; }
/* the game mechanics page: wider, with tables that scroll sideways on small screens */
.lobby.wide { max-width: 1040px; }
.mechanics { max-width: 1000px; }
.mechanics h4 { font-size: .95rem; margin: 1rem 0 .4rem; color: var(--accent); scroll-margin-top: 1rem; }
.mechanics ol { padding-left: 1.4rem; margin: 0; }
.mechanics ol li, .mechanics ul ul li { margin-bottom: .3rem; }
.mechanics ul ul, .mechanics ol ul { margin-top: .4rem; }
.mechanics .table { overflow-x: auto; margin: .5rem 0 1rem; }
.mechanics table { border-collapse: collapse; font-size: .85rem; }
.mechanics th, .mechanics td { padding: .3rem .45rem; border-bottom: 1px solid var(--line); text-align: left; }
.mechanics th { color: var(--muted); font-weight: 600; white-space: nowrap; }
.mechanics td:first-child, .mechanics .stats td:last-child { white-space: nowrap; }
.mechanics .formula { font-family: var(--mono); font-size: .85rem; background: var(--bg);
  border-left: 3px solid var(--cyan); padding: .5rem .75rem; }
.mechanics code { font-family: var(--mono); font-size: .85em; }
.card .error, .card .hint { font-size: .8rem; }
.card .hint ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.mygames { max-width: 696px; margin: 1.5rem auto 0; }
.mygames ul { list-style: none; margin: 0; padding: 0; }
.mygames li {
  display: flex; gap: 1rem; align-items: baseline; padding: .35rem 0; border-bottom: 1px solid var(--line);
}
.mygames li:last-child { border-bottom: 0; }
.mygames .code { font-family: var(--mono); letter-spacing: .15em; color: var(--accent); }
.mygames .hint { margin-left: auto; }
.mygames li form { margin: 0; }
#cancel-game { margin-top: .6rem; }
.policy form.confirm { display: flex; gap: 1rem; align-items: center; }
.policy .code { font-family: var(--mono); letter-spacing: .15em; color: var(--accent); }

/* replay progress */
.catchup {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: .5rem; background: rgba(0, 0, 0, .6); border-radius: 4px;
}
.catchup p { margin: 0; }
.catchup-track { width: min(60%, 320px); height: 8px; border: 1px solid var(--line); border-radius: 4px; }
.catchup-bar { width: 0; height: 100%; background: var(--accent); border-radius: 4px; }

/* covers another wizard's spell menu when spells are hidden */
.curtain {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #000; border-radius: 4px; color: var(--cyan); font-size: 1.1rem; text-align: center;
}
.card label.check { flex-direction: row; align-items: center; }

/* your games */
.mygames h2 .yourturn { color: var(--accent); font-size: .9rem; }
.mygames .filters { display: flex; gap: 1rem; font-size: .9rem; }
.mygames .state { color: var(--muted); }
.mygames li.turn .state { color: var(--accent); font-weight: 600; }

/* sound on/off and volume */
.sound { display: flex; gap: .75rem; align-items: center; }
.sound input[type=range] {
  flex: 1; min-width: 0; padding: 0; border: 0; background: none; accent-color: var(--accent);
}

/* replay */
.small-link { margin-left: auto; font-size: .85rem; }
.controls .row { flex-wrap: wrap; margin: .6rem 0; }
.controls select {
  font: inherit; font-size: .8rem; background: #0b0b0f; color: var(--text);
  border: 1px solid var(--line); border-radius: 4px; padding: .1rem .3rem;
}
.catchup-track.seek { width: 100%; height: 10px; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button:disabled:hover { background: transparent; color: var(--accent); }

/* public watching */
.public { margin-top: .5rem; display: flex; flex-direction: column; gap: .4rem; }
.public .hint { margin: 0; }
#copy-watch { align-self: flex-start; }
.mygames.live h2 { color: var(--magenta); }

/* all games (admins) */
.allgames .search { display: flex; gap: .5rem; align-items: center; }
.allgames .search input { flex: 1; min-width: 0; }
.allgames .pages { justify-content: center; margin-top: .5rem; }

/* a card's heading with a link on the right */
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.card-head a { font-size: .9rem; }
.pad .actions .wide3 { grid-column: span 3; }
