@font-face {
  font-family: "Rodin";
  src: url("/rodin-pro.otf") format("opentype");
  font-display: swap;
  /* Rodin's quotation glyphs are too wide for this English UI. */
  unicode-range: U+0000-0021, U+0023-0026, U+0028-2017, U+2020-10FFFF;
}

:root {
  color-scheme: dark;
  --app-viewport-height: 100vh;
  --red: #ff3131;
  --white: #fff;
  --muted: #a7a7a7;
  --black: #000;
  --player: #fff;
  font-family: "Rodin", Arial, sans-serif;
  background: var(--black);
  color: var(--white);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: #000; }
body { overscroll-behavior: none; }
body.phone-mode { user-select: none; -webkit-user-select: none; }
body.trigger-mode { height: var(--app-viewport-height, 100vh); overflow: hidden; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.brand-logo { display: block; width: min(100%, 580px); height: auto; margin: 0 auto; }
.page-shell {
  width: min(100%, 740px);
  min-height: 100vh;
  min-height: var(--app-viewport-height, 100dvh);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
.home-page { justify-content: center; text-align: center; }
.home-page .brand-logo { margin-bottom: 46px; }
.home-kicker, .eyebrow { color: var(--muted); font-size: 12px; letter-spacing: .19em; text-transform: uppercase; }
.home-title { margin: 12px 0; font-size: clamp(30px, 8vw, 60px); line-height: .98; letter-spacing: -.045em; text-transform: uppercase; }
.home-copy { max-width: 410px; margin: 14px auto 28px; color: var(--muted); font-size: 16px; line-height: 1.5; }
.home-links { display: flex; justify-content: center; gap: 12px; margin-top: 22px; }
.text-link { color: #fff; text-decoration: none; font-size: 13px; padding: 12px; }
.red-button, .dark-button {
  border: 0;
  border-radius: 13px;
  min-height: 58px;
  padding: 0 24px;
  color: #fff;
  background: var(--red);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
.red-button { width: 100%; }
.red-button:hover, .dark-button:hover { filter: brightness(1.12); }
.red-button:active, .dark-button:active { transform: scale(.985); }
.red-button:disabled { cursor: not-allowed; opacity: .45; }
.dark-button { background: #171717; border: 1px solid #393939; }
.field {
  width: 100%;
  height: 58px;
  padding: 0 17px;
  border: 1px solid #3b3b3b;
  border-radius: 12px;
  outline: none;
  color: #fff;
  background: #101010;
  font-size: 17px;
}
.field:focus { border-color: var(--red); }
.form-stack { display: grid; gap: 12px; width: 100%; }
.error-line { min-height: 22px; color: #ff7b7c; font-size: 13px; text-align: left; }

.phone-shell { min-height: 100vh; min-height: var(--app-viewport-height, 100dvh); position: relative; padding: max(17px, env(safe-area-inset-top)) 20px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; overflow-x: hidden; }
.trigger-mode .phone-shell { height: 100%; min-height: 0; max-height: none; overflow: hidden; }
.phone-shell::before { content: ""; position: fixed; inset: 5px; border: 1px solid var(--player); opacity: .48; pointer-events: none; z-index: 20; }
.phone-top { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; }
.phone-top .brand-logo { width: min(76vw, 300px); margin: 0 auto; }
.step-label { color: #c6c6c6; font-size: 11px; letter-spacing: .1em; white-space: nowrap; }
.phone-content { flex: 1; min-height: min-content; display: flex; flex-direction: column; justify-content: center; padding: 19px 0; text-align: center; animation: enter .35s ease both; }
.phone-heading { margin: 14px 0 8px; font-size: clamp(26px, 7vw, 40px); line-height: 1.05; letter-spacing: -.035em; }
.phone-copy { max-width: 380px; margin: 0 auto 23px; color: #b2b2b2; font-size: 15px; line-height: 1.55; }
.player-chip { align-self: center; display: flex; align-items: center; gap: 9px; margin: 0 0 13px; color: var(--player); font-size: 13px; letter-spacing: .04em; }
.color-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--player); box-shadow: 0 0 12px color-mix(in srgb, var(--player), transparent 30%); }
.pairing { align-items: center; }
.spinner { width: 37px; height: 37px; margin: 0 auto 20px; border: 3px solid #4e1415; border-top-color: var(--red); border-radius: 50%; animation: spin .8s linear infinite; }
.paired-mark { color: #69db9b; font-size: 17px; letter-spacing: .08em; }
.setup-list { display: grid; gap: 10px; margin: 10px 0 18px; padding: 0; text-align: left; list-style: none; }
.setup-list li { display: flex; gap: 10px; align-items: flex-start; color: #ddd; font-size: 13px; line-height: 1.4; }
.setup-list .check { color: #fff; font-size: 15px; font-weight: bold; }
.note { margin: 0 0 20px; color: #dedede; font-size: 13px; }
.device-art { width: min(80vw, 460px); height: auto; max-height: min(46vh, 46dvh); object-fit: contain; align-self: center; margin: 11px auto 20px; }

.rotate-warning { z-index: 40; position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 26px; background: #000; text-align: center; }
.rotate-warning.visible { display: flex; }
.rotate-warning p { max-width: 280px; margin: 0; color: #fff; font-size: 24px; line-height: 1.2; }
.trigger-layout { position: relative; inset: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 0 0; pointer-events: none; }
.trigger-info { flex: 1 1 0%; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 0; text-align: center; pointer-events: auto; }
.trigger-status { min-height: 22px; max-width: 340px; margin-top: 9px; color: #eee; font-size: 14px; line-height: 1.5; letter-spacing: .02em; }
.trigger-title { margin: 8px 0 3px; color: var(--player); font-size: clamp(21px, 6vw, 34px); }
.trigger-score { color: var(--player); font-size: clamp(37px, 12vw, 62px); line-height: 1; font-variant-numeric: tabular-nums; }
.aim-ring { width: min(35vw, 155px); flex-shrink: 0; aspect-ratio: 1; border-radius: 50%; margin: 8px 0; background: conic-gradient(var(--red) var(--progress, 0%), #333 var(--progress, 0%)); display: grid; place-items: center; transition: filter .15s ease; }
.aim-ring-inner { width: calc(100% - 16px); height: calc(100% - 16px); border-radius: inherit; display: grid; place-items: center; background: #000; color: #fff; font-size: 15px; font-weight: bold; }
.aim-ring.is-ready { --progress: 100%; box-shadow: 0 0 25px #ff313133; }
.aim-ring.is-ready .aim-ring-inner { color: var(--red); font-size: 20px; }
.trigger-zone { flex: 0 0 clamp(180px, 45%, 360px); min-height: 160px; display: flex; justify-content: center; align-items: flex-end; background: #242424; border: 1px solid #444; border-bottom: 0; border-radius: 14px 14px 0 0; padding-bottom: 12px; color: #d5d5d5; font-size: 11px; letter-spacing: .25em; pointer-events: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.trigger-zone.pressed { background: #303030; }
.solo-actions { width: min(100%, 270px); margin: 12px auto 8px; pointer-events: auto; }
.solo-actions .red-button { min-height: 48px; font-size: 14px; }
.ready-banner { margin: 3px 0 5px; color: var(--red); font-size: 14px; font-weight: bold; letter-spacing: .13em; }
@media (max-height: 740px) {
  .trigger-info .aim-ring { width: 95px; margin: 4px 0; }
  .trigger-status { font-size: 12px; }
  .solo-actions { margin: 6px auto; }
  .solo-actions .red-button { min-height: 48px; }
  .trigger-layout { padding-top: 4px; }
}
@media (max-height: 740px) and (max-width: 760px) {
  .phone-shell { padding-top: max(12px, env(safe-area-inset-top)); }
  .phone-top { gap: 6px; }
  .phone-top .brand-logo { width: min(68vw, 245px); }
  .phone-content { padding: 12px 0; }
  .phone-heading { margin: 8px 0 6px; }
  .phone-copy { margin-bottom: 14px; font-size: 14px; line-height: 1.4; }
  .setup-list { gap: 7px; margin: 6px 0 12px; }
  .note { margin-bottom: 12px; }
  .device-art { max-height: min(30vh, 30dvh, 200px); margin: 6px auto 12px; }
}
.waiting-state { color: #d5d5d5; font-size: 13px; }
.screen-flash { position: fixed; inset: 0; z-index: 15; background: rgba(255,49,49,.23); pointer-events: none; animation: flash .28s ease-out both; }
.game-over { text-align: center; }
.game-over .result-word { color: var(--red); font-size: clamp(40px, 12vw, 62px); line-height: 1; letter-spacing: -.04em; }
.game-over .final-score { margin: 12px 0 20px; font-size: 45px; font-variant-numeric: tabular-nums; }
.mini-table { width: 100%; margin: 14px auto; border-collapse: collapse; text-align: left; font-size: 12px; }
.mini-table td { border-bottom: 1px solid #242424; padding: 9px 4px; }
.mini-table td:last-child { text-align: right; }
.phone-footer { padding-top: 9px; color: #8b8b8b; text-align: center; font-size: 10px; letter-spacing: .12em; }

.board-page { min-height: 100svh; padding: 30px clamp(20px, 5vw, 80px); }
.board-header { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; border-bottom: 1px solid #292929; padding-bottom: 23px; }
.board-header .brand-logo { width: min(80vw, 350px); margin: 0 auto; }
.board-title { margin: 30px 0 8px; font-size: clamp(38px, 7vw, 82px); line-height: .95; text-transform: uppercase; letter-spacing: -.05em; }
.board-subtitle { margin: 0 0 25px; color: var(--muted); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; }
.board-controls { display: flex; align-items: center; gap: 8px; }
.period-button { min-height: 38px; padding: 0 13px; border: 1px solid #363636; border-radius: 8px; background: #101010; color: #aaa; cursor: pointer; }
.period-button.active { border-color: var(--red); color: #fff; }
.board-list { display: grid; }
.board-row { min-height: 81px; display: grid; grid-template-columns: 72px minmax(0,1fr) auto; align-items: center; gap: 13px; border-bottom: 1px solid #232323; animation: enter .3s ease both; }
.board-rank { color: #777; font-size: clamp(18px, 3vw, 25px); font-variant-numeric: tabular-nums; }
.board-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(19px, 4vw, 34px); }
.board-meta { margin-top: 4px; color: #777; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; }
.board-score { color: var(--red); font-size: clamp(24px, 5vw, 43px); font-variant-numeric: tabular-nums; }
.empty-board { padding: 42px 0; color: #888; text-align: center; }
.debug-page { width: min(1200px, 100%); margin: 0 auto; }
.debug-login { width: min(100%, 430px); margin: 15vh auto 0; text-align: center; }
.debug-login .brand-logo { margin-bottom: 30px; }
.debug-error { min-height: 24px; color: #ff7b7c; font-size: 13px; }
.debug-page .board-header { margin-bottom: 24px; }
.debug-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.debug-panel { min-width: 0; padding: 19px; border: 1px solid #292929; border-radius: 13px; background: #090909; }
.panel-title { margin: 0 0 16px; color: #bbb; font-size: 12px; letter-spacing: .15em; text-transform: uppercase; }
.session-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.session-code { color: var(--red); font-size: 32px; letter-spacing: .18em; }
.qr-image { width: min(200px, 31vw); aspect-ratio: 1; padding: 8px; background: #fff; }
.player-list { display: grid; gap: 9px; }
.debug-player { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px; border: 1px solid #252525; border-radius: 9px; }
.debug-player-name { font-size: 15px; }
.debug-player-info { margin-top: 3px; color: #888; font-size: 10px; }
.debug-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.small-button { min-height: 35px; padding: 0 10px; border: 1px solid #3a3a3a; border-radius: 7px; color: #ddd; background: #161616; font-size: 11px; cursor: pointer; }
.small-button.red { border-color: #792324; background: #351011; color: #ffb9b9; }
.score-input { width: 74px; height: 36px; padding: 0 8px; border: 1px solid #333; border-radius: 7px; color: #fff; background: #111; }
.aim-canvas { display: block; width: 100%; aspect-ratio: 1.8; border: 1px solid #282828; border-radius: 10px; background: radial-gradient(ellipse at center, #111 0%, #080808 73%); }
.aim-label { display: flex; justify-content: space-between; gap: 10px; margin-top: 9px; color: #888; font-size: 10px; }
.debug-actions .red-button { flex: 1; width: auto; min-height: 42px; font-size: 12px; }
.debug-status { min-height: 19px; margin-top: 9px; color: #aaa; font-size: 11px; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

@media (orientation: landscape) and (max-width: 980px) {
  body.phone-mode .rotate-warning { display: flex; }
}
@media (max-width: 760px) {
  .debug-grid { grid-template-columns: 1fr; }
  .board-header { align-items: flex-start; }
  .board-title { margin-top: 24px; }
  .board-row { grid-template-columns: 42px minmax(0,1fr) auto; }
}
