/* Dr. Dayna — NES-style pixel look in the Cascadia Cloud Solutions palette:
   terracotta, gold, slate green and cream. */
:root {
  --bg: #17211f;
  --bg2: #1c2926;
  --raise: #2a3a36;
  --cream: #f4ede1;
  --muted: #9fb3ad;
  --line: #3d524d;
  --panel: #1f2d2a;
  --terra: #c16352;
  --gold: #d19222;
  --slate: #5b7370;
  --teal: #4fb3a9;
  --slot: var(--terra);
  --n: 6px; /* size of the stepped "pixel" corners */
  font-family: 'Press Start 2P', ui-monospace, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; color: var(--cream); background: var(--bg); }
body {
  background-color: var(--bg);
  background-image: repeating-conic-gradient(var(--bg2) 0 25%, var(--bg) 0 50%);
  background-size: 64px 64px;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
canvas, img { image-rendering: pixelated; image-rendering: crisp-edges; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
b { font-weight: normal; color: var(--gold); }

/* Stepped corners on every box, like an 8-bit menu window. */
.join, .panel, .opt, .count, .tune, .menu-row, .ov-card, .tag, .sound, #banner, .bp-toast,
.pad-start, .pad-takeover button, .speeds i, .bar {
  clip-path: polygon(
    0 var(--n), var(--n) var(--n), var(--n) 0, calc(100% - var(--n)) 0, calc(100% - var(--n)) var(--n), 100% var(--n),
    100% calc(100% - var(--n)), calc(100% - var(--n)) calc(100% - var(--n)), calc(100% - var(--n)) 100%,
    var(--n) 100%, var(--n) calc(100% - var(--n)), 0 calc(100% - var(--n))
  );
}

.tag {
  --n: 3px;
  display: inline-grid;
  place-items: center;
  padding: 0.35em 0.5em 0.25em;
  background: var(--slot);
  color: var(--bg);
}

.logo-pill { display: inline-flex; transform: rotate(-35deg); }
.logo-pill i { display: block; width: 0.6em; height: 0.55em; background: var(--terra); box-shadow: inset 0 0.12em 0 #f4a796; }
.logo-pill i + i { background: var(--gold); box-shadow: inset 0 0.12em 0 #f8d688; }

/* ---------- TV ---------- */

#tv { height: 100vh; display: flex; flex-direction: column; padding: 2.5vh 3vw; gap: 2vh; }
.tv-head { display: flex; align-items: center; gap: 2vw; }
.brand { font-size: 3vh; display: flex; align-items: center; gap: 0.6em; text-shadow: 0.3vh 0.3vh 0 #000; }
.byline { margin-left: auto; font-size: 1.4vh; letter-spacing: 0.2em; color: #c7d3cf; }
.byline span { color: var(--terra); }
.sound { font-size: 1.4vh; padding: 1em 1.2em; background: var(--raise); color: var(--gold); }

#stage { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vh; }
#foot { text-align: center; font-size: 1.7vh; color: var(--muted); min-height: 1.5em; }

.hero { text-align: center; }
.mascots { display: flex; justify-content: center; gap: 4vh; margin-bottom: 3vh; }
.mascot { width: 9vh; height: 9vh; }
.hero h1 { margin: 0; font-size: 10vh; font-weight: normal; line-height: 1.1; text-shadow: 0.9vh 0.9vh 0 var(--slate); }
.hero h1 b { color: var(--gold); text-shadow: 0.9vh 0.9vh 0 var(--terra); }
.hero p { margin: 3vh 0 0; font-size: 1.8vh; color: var(--muted); }

.joins { display: flex; gap: 2vw; }
.join, .panel {
  --n: 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5vh;
  padding: 2.5vh 1.5vw;
  background: var(--panel);
  border: 6px solid var(--line);
}
.join { width: 18vw; min-height: 32vh; justify-content: center; font-size: 1.6vh; }
.join .tag, .panel .tag { font-size: 1.8vh; }
.join.on { border-color: var(--slot); }
.qr { width: min(14vw, 21vh); height: auto; display: block; }
.join-url { font-size: 1.1vh; color: var(--muted); word-break: break-all; text-align: center; line-height: 1.6; }
.join-ok { font-size: 5vh; color: var(--slot); text-shadow: 0.5vh 0.5vh 0 #000; }
.join-name { font-size: 2vh; }

.menu-row {
  --n: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3vh;
  padding: 3vh 4vw;
  border: 6px solid transparent;
  opacity: 0.45;
}
.menu-row.sel { opacity: 1; border-color: var(--line); background: var(--panel); }
.ask { margin: 0; font-size: 3vh; font-weight: normal; }
.counts, .tunes { display: flex; gap: 2.5vw; }
.count {
  --n: 8px;
  width: 14vh;
  height: 14vh;
  display: grid;
  place-items: center;
  font-size: 6vh;
  background: var(--raise);
  color: var(--muted);
  border: 6px solid var(--line);
}
.count.sel { background: var(--terra); border-color: var(--gold); color: var(--cream); text-shadow: 0.5vh 0.5vh 0 #000; }
.tune { --n: 8px; padding: 2.2vh 2.5vw 1.8vh; font-size: 2.6vh; background: var(--raise); border: 6px solid var(--line); color: var(--muted); }
.tune.sel { background: var(--teal); border-color: var(--gold); color: var(--bg); }

.panels { display: flex; gap: 2vw; }
.panel { width: 22vw; gap: 2.5vh; padding: 3vh 1.5vw; border-color: var(--slot); }
.panel.waiting { border-color: var(--line); }
.panel.ready { background: #263a35; }
.p-head { font-size: 2vh; display: flex; align-items: center; gap: 0.6em; max-width: 100%; }
.opt { --n: 6px; width: 100%; padding: 1.8vh 1vw; border: 4px solid transparent; text-align: center; }
.opt.sel { border-color: var(--slot); background: var(--raise); }
.opt > span { display: block; color: var(--muted); font-size: 1.3vh; letter-spacing: 0.1em; }
.val { display: flex; align-items: center; justify-content: center; gap: 1.5vw; font-size: 5vh; margin-top: 1vh; }
.val b { color: var(--cream); text-shadow: 0.4vh 0.4vh 0 #000; }
.val i { font-style: normal; font-size: 2vh; color: var(--muted); }
.bar { --n: 2px; height: 1.4vh; margin-top: 1.2vh; background: #0c1412; }
.bar i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--teal) 0 6px, transparent 6px 8px); }
.speeds { display: flex; justify-content: center; gap: 0.4vw; margin-top: 1.2vh; }
.speeds i { --n: 3px; font-style: normal; font-size: 1.3vh; padding: 0.8em 0.7em 0.6em; color: var(--muted); }
.speeds i.on { background: var(--slot); color: var(--bg); }
.p-ready { font-size: 1.5vh; color: var(--muted); }
.panel.ready .p-ready { color: var(--slot); font-size: 2.6vh; text-shadow: 0.3vh 0.3vh 0 #000; animation: blink 0.8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

.boards { display: flex; gap: 2.5vw; align-items: flex-end; height: 100%; }
.bp { display: flex; flex-direction: column; align-items: center; gap: 1vh; }
.bp.dc { opacity: 0.5; }
.bp-head { display: flex; align-items: center; gap: 0.7em; font-size: 1.8vh; }
.bp-name { max-width: 14vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-wins { color: var(--gold); }
.bp-info { font-size: 1.5vh; color: var(--muted); }
.bp-well { position: relative; }
.bp-board { display: block; }
.bp-foot { font-size: 1.2vh; color: var(--muted); }
.bp-msg {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 5vh;
  pointer-events: none;
  text-shadow: 0.6vh 0.6vh 0 #000;
}
.bp-toast {
  --n: 4px;
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translateX(-50%);
  opacity: 0;
  padding: 1vh 1.2vh 0.8vh;
  font-size: 1.2vh;
  white-space: nowrap;
  pointer-events: none;
}
.bp-toast.show { opacity: 1; }
.bp-toast.bad { background: var(--terra); }
.bp-toast.good { background: var(--teal); color: var(--bg); }

#overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(12, 20, 18, 0.6); }
.ov-card {
  --n: 12px;
  min-width: 36vw;
  max-width: 62vw;
  padding: 4vh 3vw;
  background: var(--panel);
  border: 8px solid var(--gold);
  text-align: center;
  font-size: 1.7vh;
}
.ov-card h2 { margin: 0 0 2vh; font-size: 3.4vh; font-weight: normal; text-shadow: 0.4vh 0.4vh 0 #000; }
.ov-card p { margin: 3vh 0 0; color: var(--muted); line-height: 1.8; }
.trophy { font-size: 8vh; line-height: 1.2; }
.tally { list-style: none; padding: 0; margin: 2vh auto 0; display: grid; gap: 1.4vh; max-width: 30vw; text-align: left; }
.tally li { display: flex; align-items: center; gap: 0.8em; font-size: 1.9vh; }
.tally li b { margin-left: auto; }

#banner {
  position: fixed;
  top: 2vh;
  left: 50%;
  transform: translateX(-50%);
  padding: 1.4vh 2vw 1.2vh;
  background: var(--terra);
  font-size: 1.5vh;
  cursor: pointer;
}

/* ---------- phone controller ---------- */

.pad-body { position: fixed; inset: 0; touch-action: none; overscroll-behavior: none; }
#pad {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.pad-head { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.pad-head .tag { font-size: 14px; }
.pad-name { flex: 1; min-width: 0; text-align: left; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pad-status { width: 14px; height: 14px; background: #c0392b; flex: none; }
.pad-status.wait { background: var(--gold); }
.pad-status.ok { background: #5fd18b; }
.pad-hint { margin: 0; min-height: 3.4em; text-align: center; color: var(--muted); font-size: 11px; line-height: 1.7; }

.pad-controls {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  gap: 12px;
}
.dpad, .ab { --s: min(43vw, 56vh, 270px); width: var(--s); height: var(--s); }
.dpad {
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  grid-template-areas: '. up .' 'left hub right' '. down .';
  touch-action: none;
}
.dpad i { position: relative; background: var(--raise); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.4); }
.dpad [data-d='up'] { grid-area: up; }
.dpad [data-d='down'] { grid-area: down; }
.dpad [data-d='left'] { grid-area: left; }
.dpad [data-d='right'] { grid-area: right; }
.dpad .hub { grid-area: hub; }
.dpad [data-d]::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-style: normal;
  font-family: system-ui, sans-serif;
  font-size: calc(var(--s) * 0.11);
}
.dpad [data-d='up']::after { content: '▲'; }
.dpad [data-d='down']::after { content: '▼'; }
.dpad [data-d='left']::after { content: '◀'; }
.dpad [data-d='right']::after { content: '▶'; }
.dpad i.on { background: var(--slot); box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.3); }
.dpad i.on::after { color: var(--bg); }

.ab { position: relative; }
/* A and B are chunky pixel circles. */
.ab button {
  position: absolute;
  width: 47%;
  aspect-ratio: 1;
  font-size: calc(var(--s) * 0.12);
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, 0.35), inset 0 8px 0 rgba(255, 255, 255, 0.2);
  touch-action: none;
  clip-path: polygon(30% 0, 70% 0, 70% 10%, 90% 10%, 90% 30%, 100% 30%, 100% 70%, 90% 70%, 90% 90%, 70% 90%, 70% 100%, 30% 100%, 30% 90%, 10% 90%, 10% 70%, 0 70%, 0 30%, 10% 30%, 10% 10%, 30% 10%);
}
.btn-a { right: 0; top: 8%; background: var(--terra); }
.btn-b { left: 0; bottom: 8%; background: var(--gold); color: var(--bg); }
.ab button.on, .pad-start.on { transform: translateY(4px); filter: brightness(1.2); box-shadow: inset 0 4px 0 rgba(0, 0, 0, 0.35); }
.pad-start {
  --n: 6px;
  grid-column: 1 / -1;
  padding: 16px 36px 14px;
  background: var(--raise);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.4);
  font-size: 12px;
  letter-spacing: 0.2em;
  touch-action: none;
}

.pad-takeover {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  background: rgba(15, 22, 20, 0.94);
}
.pad-takeover button { padding: 16px 24px 14px; background: var(--terra); }
