/* ---- Fonts --------------------------------------------------------------- */
@font-face {
  font-family: "Google Sans Flex";
  src: url("assets/fonts/GoogleSansFlex-latin-wght.woff2")
    format("woff2-variations");
  font-weight: 1 1000;
  font-display: swap;
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
    U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Google Sans Flex";
  src: url("assets/fonts/GoogleSansFlex-latin-ext-wght.woff2")
    format("woff2-variations");
  font-weight: 1 1000;
  font-display: swap;
  unicode-range:
    U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Impress;
  src: url("assets/fonts/ImpressBT.ttf") format("truetype");
  font-display: block;
}

/* ---- Tokens -------------------------------------------------------------- */
:root {
  --font: "Google Sans Flex", "Google Sans", Roboto, system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #0e1222;
  --surface: #151b30; /* panel body */
  --surface-raised: #1c2440; /* panel header, inputs */
  --card: #1f2847; /* grouped content */
  --card-hover: #26305a;
  --field: #11172b;
  --line: #ffffff17;
  --line-strong: #ffffff2e;
  --frame: #d9a93a; /* panel border */

  --text: #eef1fb;
  --text-2: #b6bdd6;
  --text-3: #858dab;
  --title: #ffd866;

  --accent: #7b5cf0;
  --accent-hover: #8d72f5;
  --accent-soft: #7b5cf02e;
  --info: #3d8fe0;
  --info-hover: #4f9ced;
  --good: #3fbf8f;
  --bad: #ef5a5a;
  --bad-soft: #ef5a5a24;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --control-h: 38px;
  --control-h-sm: 30px;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;

  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
}
[hidden] {
  display: none !important;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
h2,
h3,
p {
  margin: 0;
}
a {
  color: inherit;
}

/* ---- Controls ------------------------------------------------------------ */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: var(--control-h);
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}
button:hover,
.button:hover {
  background: var(--card-hover);
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button:disabled:hover {
  background: var(--surface-raised);
}
.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.primary:hover {
  background: var(--accent-hover);
}
.primary:disabled:hover {
  background: var(--accent);
}
.accent {
  background: var(--info);
  border-color: transparent;
  color: #fff;
}
.accent:hover {
  background: var(--info-hover);
}
.danger {
  color: #ffb4b4;
  border-color: #ef5a5a55;
  background: var(--bad-soft);
}
.danger:hover {
  background: #ef5a5a3d;
}
.small {
  height: var(--control-h-sm);
  padding: 0 var(--s3);
  font-size: 13px;
}
.block {
  width: 100%;
}
.link-button {
  height: auto;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font-weight: 500;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover {
  background: none;
  color: var(--text);
}
.icon-button {
  width: var(--control-h);
  padding: 0;
}
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
input:not([type="checkbox"], [type="range"], [type="file"]),
select,
textarea {
  width: 100%;
  height: var(--control-h);
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--field);
  font-size: 14px;
}
select {
  cursor: pointer;
}
input[readonly] {
  color: var(--text-2);
}
input[type="checkbox"] {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
input[type="range"] {
  width: 100%;
  margin: 0;
  accent-color: var(--accent);
}
:is(
  button,
  .button,
  input,
  select,
  textarea,
  summary,
  [tabindex]
):focus-visible {
  outline: 2px solid var(--title);
  outline-offset: 2px;
}
canvas#game:focus-visible {
  outline: none;
}

/* Form building blocks */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.field-label output {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s3);
}
.field-row {
  display: flex;
  gap: var(--s2);
}
.field-row input {
  flex: 1;
  min-width: 0;
}
.field-row button {
  flex: none;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
  font-size: 14px;
  cursor: pointer;
}
.hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-3);
}
.notice {
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 13px;
  color: var(--text);
}
.notice.error {
  background: var(--bad-soft);
  color: #ffc9c9;
}
.notice:empty {
  display: none;
}
.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}
.button-row:not(:has(> :not([hidden]))) {
  display: none;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.stack-tight {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
}
.card {
  padding: var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.card h3,
.section-head h3 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* ---- Dialog shells ------------------------------------------------------- */
dialog {
  padding: 0;
  border: 0;
  color: inherit;
  background: none;
}
dialog::backdrop {
  background: #05081299;
  backdrop-filter: blur(3px);
}
.panel[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  display: flex;
  flex-direction: column;
  width: min(520px, calc(100vw - 32px));
  max-height: min(820px, calc(100dvh - 48px));
  overflow: hidden;
  border: 2px solid var(--frame);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow:
    0 24px 80px #0009,
    inset 0 1px 0 #ffffff0d;
}
.panel.wide[open] {
  width: min(820px, calc(100vw - 32px));
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  flex: none;
  padding: var(--s3) var(--s3) var(--s3) var(--s5);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--line);
}
.panel-header h2 {
  font-size: 20px;
  font-weight: 750;
  color: var(--title);
  letter-spacing: 0.005em;
}
.icon-button.close {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.icon-button.close:hover {
  background: var(--bad);
  color: #fff;
}
.panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: var(--s5);
}

/* Loading / result card */
#overlay[open] {
  width: min(540px, calc(100vw - 32px));
}
#overlay.is-loading[open] {
  width: min(380px, calc(100vw - 32px));
}
.loading-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s5) var(--s6);
}
.loading-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 18px;
  font-weight: 750;
  color: var(--title);
}
.loading-head output {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
#loading-progress {
  width: 100%;
  height: 8px;
  appearance: none;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--field);
}
#loading-progress::-webkit-progress-bar {
  background: var(--field);
}
#loading-progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.2s;
}
#loading-progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 4px;
}
.overlay-body {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  padding: var(--s6);
  overflow: auto;
}
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
#overlay-title {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  color: var(--title);
}
#overlay-copy {
  color: var(--text-2);
  line-height: 1.6;
}
.result:empty,
#score-status:empty {
  display: none;
}
.result {
  padding: var(--s3) var(--s4);
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---- HUD toolbar --------------------------------------------------------- */
#toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: var(--s2);
}
#toolbar .icon-button {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: #151b30d9;
  border-color: var(--line-strong);
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px #0006;
}
#toolbar .icon-button:hover,
#toolbar .icon-button[aria-expanded="true"] {
  background: var(--accent);
  border-color: transparent;
}
#toolbar .icon-button svg {
  width: 22px;
  height: 22px;
}

/* ---- Side menu ----------------------------------------------------------- */
.drawer[open] {
  position: fixed;
  inset: 0 auto 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  width: min(360px, 92vw);
  height: 100dvh;
  max-height: none;
  border-right: 2px solid var(--frame);
  background: var(--surface);
  box-shadow: 12px 0 60px #0008;
}
.drawer .panel-body {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s4);
}
.menu-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}
.disclosure {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
}
.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 var(--s4);
  font-size: 14px;
  font-weight: 700;
  list-style: none;
  cursor: pointer;
  border-radius: var(--radius);
}
.disclosure > summary::-webkit-details-marker {
  display: none;
}
.disclosure > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 2px;
  border-right: 2px solid var(--text-3);
  border-bottom: 2px solid var(--text-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s;
}
.disclosure[open] > summary::after {
  transform: rotate(-135deg) translateY(-2px);
}
.disclosure > summary:hover {
  background: var(--card-hover);
}
.disclosure[open] > summary {
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
}
.disclosure-body {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  padding: var(--s3) var(--s4) var(--s4);
}
.disclosure.subtle {
  background: transparent;
}
.disclosure.subtle > summary {
  min-height: 36px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}
#settings .check {
  min-height: 26px;
}
#settings .form-grid {
  grid-template-columns: 1fr 1fr;
}
#settings h3 {
  margin-top: var(--s2);
  padding-top: var(--s3);
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
#key-bindings {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
#key-bindings > div {
  display: grid;
  grid-template-columns: 1fr 140px;
  align-items: center;
  gap: var(--s3);
  font-size: 14px;
}
#key-bindings button {
  height: var(--control-h-sm);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--mono);
}
#reset-keys {
  align-self: flex-start;
}
#throw-log {
  max-height: min(220px, 30vh);
  min-height: 52px;
  overflow: auto;
  margin: 0;
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text-2);
  font: 12px/1.6 var(--mono);
  white-space: pre;
}
#throw-log code {
  font: inherit;
}

/* ---- Account ------------------------------------------------------------- */
.identity {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.identity-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: #c9bcff;
}
.identity-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}
.identity-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.identity-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}
.identity-text span {
  font-size: 13px;
  color: var(--text-3);
}
#profile .field {
  margin-bottom: 6px;
}

/* ---- Play with friends ---------------------------------------------------- */
.section-head {
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.section-head .count {
  margin-right: auto;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #cfc4ff;
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.member-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  /* Two rows and a sliver of the third, so overflow is obviously scrollable. */
  max-height: 150px;
  min-height: 58px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: #ffffff33 transparent;
}
.member {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex: none;
  height: 58px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--card);
}
.member.self {
  border-color: #7b5cf099;
}
.member.offline {
  opacity: 0.5;
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  overflow: hidden;
  border: 2px solid #4cc3d9;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a4677, #1a2140);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.member-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.member-weight {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
}
.member-weight input {
  width: 64px !important;
  height: var(--control-h-sm) !important;
  text-align: center;
}
.eligibility {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.eligibility::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-3);
}
.eligibility[data-eligible="true"] {
  color: #9be6c9;
}
.eligibility[data-eligible="true"]::before {
  background: var(--good);
}
.waiting {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  border: 1px solid #d9a93a55;
  border-radius: var(--radius);
  background: #d9a93a1a;
  color: var(--title);
  font-weight: 650;
}
.waiting::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--title);
  animation: waiting-pulse 1.4s ease-in-out infinite;
}
@keyframes waiting-pulse {
  50% {
    opacity: 0.25;
  }
}
/* Settings the viewer cannot change are shown greyed out. */
#room-settings :is(select, input):disabled,
.member-weight input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
#room-settings .check:has(input:disabled) {
  color: var(--text-3);
  cursor: not-allowed;
}
#room-start-status:empty {
  display: none;
}
#copy-invite {
  min-width: 82px;
}
#copy-invite .copied-label,
#copy-invite[data-copied] .copy-label {
  display: none;
}
#copy-invite[data-copied] .copied-label {
  display: inline;
}
#copy-invite[data-copied] {
  color: #9be6c9;
}
#connection-log {
  max-height: 200px;
  overflow: auto;
  margin: 0;
  padding: var(--s2) var(--s3);
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--text-2);
  font: 11px/1.5 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---- Clears -------------------------------------------------------------- */
.segmented {
  display: flex;
  gap: var(--s1);
  padding: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-2);
  border-radius: var(--radius-sm);
}
.segmented button:hover {
  background: var(--card);
  color: var(--text);
}
.segmented button[aria-selected="true"],
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
.segmented.small {
  flex: none;
  height: auto;
  padding: 3px;
  border-radius: 10px;
}
.segmented.small button {
  flex: none;
  height: 28px;
  padding: 0 var(--s3);
  font-size: 13px;
  border-radius: 7px;
}
.filter-bar,
.filter-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
}
.toggle {
  height: 36px;
  border-radius: 10px;
  background: var(--field);
  border-color: var(--line);
  color: var(--text-2);
}
.toggle[aria-pressed="true"] {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.row-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
}
.row-card {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 60px;
  padding: var(--s2) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--card);
}
.row-card .rank {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--field);
  font-weight: 800;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.row-card:nth-child(1) .rank {
  background: #d9a93a;
  color: #1a1306;
}
.row-card:nth-child(2) .rank {
  background: #b9c2d6;
  color: #12161f;
}
.row-card:nth-child(3) .rank {
  background: #c27c45;
  color: #1a0f06;
}
.row-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}
.row-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.row-sub {
  font-size: 13px;
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-time {
  flex: none;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: flex;
  gap: var(--s2);
  flex: none;
}
.empty {
  padding: var(--s6) var(--s4);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-3);
}

/* ---- Replay controls ----------------------------------------------------- */
#replay-tag {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 999px;
  background: #ef5a5ad9;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  pointer-events: none;
}
#replay-bar {
  position: absolute;
  left: calc(14vh + 150px);
  right: 24px;
  bottom: max(16px, 3vh);
  display: flex;
  align-items: center;
  gap: var(--s3);
  height: 54px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #151b30e6;
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px #0008;
}
#replay-play {
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  border-color: transparent;
}
#replay-play svg {
  fill: currentColor;
  stroke-width: 2.6;
}
#replay-play .icon-pause {
  fill: none;
}
#replay-play[data-state="playing"] .icon-play,
#replay-play[data-state="paused"] .icon-pause {
  display: none;
}
#replay-time,
#replay-duration {
  flex: none;
  min-width: 64px;
  font: 600 13px var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}
#replay-time {
  text-align: right;
}
#replay-seek {
  --progress: 0%;
  flex: 1;
  min-width: 80px;
  height: 20px;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
#replay-seek::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--accent) var(--progress),
    #ffffff2a var(--progress)
  );
}
#replay-seek::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: #ffffff2a;
}
#replay-seek::-moz-range-progress {
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
}
#replay-seek::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px #0008;
}
#replay-seek::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px #0008;
}
#replay-player-field {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-3);
}
#replay-player {
  width: 170px;
  height: var(--control-h-sm);
}
#replay-exit {
  flex: none;
}
@media (max-width: 900px) {
  #replay-bar {
    left: 16px;
    right: 16px;
    bottom: calc(14vh + 24px);
  }
  #replay-player-field > span {
    display: none;
  }
  #replay-player {
    width: 120px;
  }
}

/* ---- Game HUD (positions match the original client) ---------------------- */
canvas#game {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
}
#announcement {
  position: absolute;
  top: 33%;
  left: 50%;
  transform: translateX(-50%);
  font:
    23px Impress,
    sans-serif;
  color: #fff;
  text-align: center;
  text-shadow: 0 2px 4px #000;
  pointer-events: none;
}
#laff-meter {
  position: absolute;
  left: 6.666667vh;
  bottom: 6.5vh;
  pointer-events: none;
  color: #000;
  font:
    1.5vh/1 Impress,
    sans-serif;
}
#laff-labels {
  position: absolute;
  left: -5.625vh;
  bottom: -5.625vh;
  width: 11.25vh;
  height: 11.25vh;
  overflow: visible;
  fill: black;
  font-family: Impress, sans-serif;
  font-size: 0.4px;
  text-anchor: middle;
}
#evidence-button {
  position: absolute;
  left: calc(50% - 4.509805vh);
  top: 2.156865vh;
  width: 9.01961vh;
  height: 5.68627vh;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  touch-action: none;
}
#evidence-button:hover {
  background: transparent;
}
#evidence-count {
  position: absolute;
  right: 1.009805vh;
  bottom: 0.843135vh;
  font:
    2vh/1 Impress,
    sans-serif;
  color: white;
  pointer-events: none;
}
#charge-hud {
  position: absolute;
  left: calc(50% - 10vh);
  top: 8.5vh;
  width: 20vh;
  height: 3vh;
}
#charge-meter {
  display: block;
  appearance: none;
  width: 100%;
  height: 100%;
  border: 0.25vh inset #ddd;
  background: #d9d9d9;
  padding: 0;
}
#charge-meter::-webkit-progress-bar {
  background: #d9d9d9;
}
#charge-meter::-webkit-progress-value {
  background: #6699ff;
}
#charge-meter::-moz-progress-bar {
  background: #6699ff;
}
#fps-meter,
#boss-health {
  position: absolute;
  top: calc(17vh + 12px);
  right: 24px;
  color: white;
  font: 14px/1.5 var(--mono);
  text-shadow: 0 1px 3px black;
  pointer-events: none;
}
#boss-health {
  top: calc(17vh + 36px);
}
#settings .sub-option {
  padding-left: 26px;
}
#settings .sub-option:has(input:disabled) {
  color: var(--text-3);
  cursor: not-allowed;
}
#perf-stats {
  position: absolute;
  top: calc(17vh + 64px);
  right: 24px;
  width: min(440px, calc(100vw - 48px));
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(10, 14, 22, 0.78);
  color: white;
  pointer-events: none;
}
#perf-stats[hidden] {
  display: none;
}
#perf-graph {
  display: block;
  width: 100%;
  height: 110px;
}
.perf-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 4px 0 6px;
  font: 11px/1.4 var(--mono);
  color: rgba(255, 255, 255, 0.8);
}
.perf-key::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  vertical-align: -1px;
}
.perf-key.interval::before {
  background: rgba(255, 255, 255, 0.4);
}
.perf-key.missed::before {
  background: rgb(255, 80, 80);
}
.perf-key.work::before {
  background: rgb(90, 170, 255);
}
.perf-key.gpu::before {
  height: 2px;
  vertical-align: 3px;
  background: rgb(255, 190, 60);
}
#perf-text {
  margin: 0;
  font: 11px/1.35 var(--mono);
  white-space: pre;
  overflow: hidden;
}
.stun-timer {
  position: absolute;
  right: -13.8333333333vh;
  top: -14vh;
  width: 45vh;
  height: 45vh;
  overflow: visible;
  pointer-events: none;
  font-family: Impress, sans-serif;
}
#timer {
  position: absolute;
  left: 14vh;
  bottom: 4.5vh;
  color: white;
  font: 20px/1.5 var(--mono);
  text-shadow: 0 1px 3px black;
  pointer-events: none;
}

/* ---- Toon editor --------------------------------------------------------- */
#edit-toon[open] {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  width: min(1050px, calc(100vw - 32px));
  height: min(800px, calc(100dvh - 48px));
  padding: var(--s5) var(--s6);
  overflow: hidden;
  border: 2px solid var(--frame);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 24px 80px #0009;
}
.editor-heading,
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s5);
  flex: none;
}
.editor-heading h2 {
  font-size: 24px;
  font-weight: 800;
  color: var(--title);
}
.editor-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(320px, 1.3fr);
  gap: var(--s6);
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.editor-preview-panel {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  height: 100%;
  min-height: 0;
}
#toon-preview {
  display: block;
  flex: 1;
  width: 100%;
  height: 0;
  min-height: 100px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: radial-gradient(ellipse at center, #33406e, #161c33);
  cursor: grab;
  touch-action: none;
}
#toon-preview:active {
  cursor: grabbing;
}
.editor-preview-panel > p {
  text-align: center;
}
.editor-preview-panel > label,
.editor-options label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.editor-options {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.editor-tabs {
  display: flex;
  flex-wrap: wrap;
  flex: none;
  gap: var(--s1);
  margin-bottom: var(--s4);
  padding: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--field);
}
.editor-tabs button {
  flex: 1;
  height: 32px;
  padding: 0 var(--s2);
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
}
.editor-tabs button:hover {
  background: var(--card);
  color: var(--text);
}
.editor-tabs button[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}
.editor-options [role="tabpanel"] {
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-height: 0;
  overflow: auto;
  padding: 3px;
}
.editor-options h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s2);
}
.choice-grid button {
  font-size: 14px;
  font-weight: 500;
}
.choice-grid button[aria-pressed="true"],
.catalog-grid button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.editor-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s3);
}
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: var(--s3);
  padding: var(--s2) 3px;
}
#editor-clothing-colors {
  grid-template-columns: repeat(8, minmax(0, 1fr));
}
.swatch-grid button {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid #ffffff44;
  border-radius: 50%;
  box-shadow: 0 2px 4px #0005;
}
.swatch-grid button[aria-pressed="true"] {
  outline: 3px solid var(--title);
  outline-offset: 3px;
}
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s2);
  padding: 3px;
}
.catalog-grid button {
  flex-direction: column;
  height: auto;
  min-height: 66px;
  padding: var(--s2);
  font-size: 12px;
  font-weight: 500;
  white-space: normal;
  overflow-wrap: anywhere;
}
.catalog-grid img {
  display: block;
  width: 100%;
  height: 108px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--field);
}
#toon-dna {
  height: auto;
  padding: var(--s3);
  resize: vertical;
  font: 13px/1.6 var(--mono);
}
#panel-dna > button {
  align-self: flex-start;
}
#dna-status.error,
#editor-status.error,
.error {
  color: #ffc9c9 !important;
}
.subtle {
  font-size: 13px;
  color: var(--text-3);
}
.editor-footer {
  padding-top: var(--s4);
  border-top: 1px solid var(--line);
}
.editor-footer button {
  flex: none;
}
@media (max-width: 700px) {
  #edit-toon[open] {
    padding: var(--s4);
  }
  .editor-layout {
    display: flex;
    flex-direction: column;
    gap: var(--s4);
  }
  .editor-preview-panel {
    flex: none;
    height: min(230px, 30vh);
  }
  .editor-preview-panel > label {
    display: none;
  }
  .editor-options {
    flex: 1;
  }
  .editor-tabs button {
    font-size: 12px;
  }
  #editor-clothing-colors {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* Shared mode information, available from solo and room settings. */
.mode-field-heading {
  position: relative;
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mode-help-button {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  padding: 0;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
}
.mode-help-content {
  font-size: 16px;
}
.mode-help-content h3 {
  font-size: 18px;
  color: var(--title);
  margin-bottom: 8px;
}
.mode-help-content ul {
  margin: 0;
  padding-left: 22px;
  line-height: 1.7;
}
.mode-help-content p {
  margin-top: 8px;
  color: var(--text-2);
}
.movement-table-scroll {
  overflow-x: auto;
}
.movement-values {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.movement-values caption {
  text-align: left;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 10px;
}
.movement-values th,
.movement-values td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.movement-values thead {
  background: var(--surface-raised);
}
.movement-values td {
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
