@font-face {
  font-family: "Ark Pixel 12";
  src: url("./assets/fonts/ark-pixel-12/ark-pixel-12px-monospaced-zh_cn.otf.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

:root {
  color-scheme: dark;
  --bg: #0a0d18;
  --bg-deep: #050711;
  --panel: #151a2a;
  --panel-2: #1d2639;
  --panel-3: #252d43;
  --line: #3b4862;
  --line-soft: rgba(131, 144, 165, 0.24);
  --muted: #8390a5;
  --text: #f2f0e8;
  --blue: #52a8ff;
  --blue-bright: #9adbeb;
  --blue-deep: #14213f;
  --red: #ff5f87;
  --red-bright: #f7a4ab;
  --red-deep: #35172f;
  --violet: #a96eff;
  --brass: #e4b97e;
  --brass-bright: #ffd84a;
  --wood: #694236;
  --shadow: rgba(0, 0, 0, 0.64);
  --font-pixel: "Ark Pixel 12", "PingFang SC", "Microsoft YaHei", ui-monospace, monospace;
  font-family: var(--font-pixel);
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  position: relative;
  display: grid;
  place-items: center;
  margin: 0;
  height: 100dvh;
  min-height: 100dvh;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 48%, rgba(18, 25, 31, 0.08), rgba(0, 0, 0, 0.48) 100%),
    url("./assets/shadow-arcade-wall-v1.png") center / cover no-repeat fixed,
    #05070a;
  image-rendering: pixelated;
  -webkit-font-smoothing: none;
  font-synthesis: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 45%, transparent 42%, rgba(0, 0, 0, 0.72) 100%),
    repeating-linear-gradient(0deg, rgba(242, 240, 232, 0.018) 0 1px, transparent 1px 4px);
  mix-blend-mode: normal;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.14;
  background: repeating-linear-gradient(0deg, rgba(242, 240, 232, 0.025) 0 1px, transparent 1px 4px);
}

button, select, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.48; transform: none !important; box-shadow: none !important; }

.cabinet-console {
  position: relative;
  z-index: 5;
  isolation: isolate;
  flex: 0 0 clamp(158px, 25.2vh, 190px);
  min-height: 0;
  margin-inline: calc(clamp(58px, 8vw, 128px) * -1);
  padding: clamp(12px, 1.8vh, 18px) clamp(50px, 5.2vw, 84px) clamp(10px, 1.5vh, 15px);
  display: flex;
  flex-direction: column;
  gap: clamp(2px, 0.45vh, 5px);
  overflow: hidden;
  background: transparent;
}

.cabinet-console::before {
  content: "";
  position: absolute;
  z-index: -1;
  top: clamp(10px, 1.6vh, 15px);
  right: clamp(54px, 4.7vw, 68px);
  bottom: clamp(48px, 7.2vh, 58px);
  left: clamp(54px, 4.7vw, 68px);
  pointer-events: none;
  clip-path: polygon(1.3% 0, 98.7% 0, 100% 16%, 100% 84%, 98.7% 100%, 1.3% 100%, 0 84%, 0 16%);
  background:
    radial-gradient(ellipse at 50% 34%, rgba(8, 35, 45, 0.18), transparent 58%),
    #01070c;
  box-shadow: inset 0 0 44px rgba(0, 0, 0, 0.82);
}

.cabinet-console::after {
  content: "";
  position: absolute;
  z-index: 9;
  top: clamp(10px, 1.6vh, 15px);
  right: clamp(54px, 4.7vw, 68px);
  bottom: clamp(48px, 7.2vh, 58px);
  left: clamp(54px, 4.7vw, 68px);
  pointer-events: none;
  opacity: 0.3;
  background:
    repeating-linear-gradient(0deg, rgba(166, 240, 255, 0.018) 0 1px, transparent 1px 4px),
    linear-gradient(180deg, transparent 0 42%, rgba(116, 223, 247, 0.11) 49%, transparent 57%);
  background-size: 100% 100%, 100% 220%;
  mix-blend-mode: screen;
  animation: crt-scan-wave 8.5s linear infinite;
}

@keyframes crt-scan-wave {
  from { background-position: 0 0, 0 105%; }
  to { background-position: 0 0, 0 -115%; }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(100vw, 177.683dvh);
  height: min(100dvh, 56.28vw);
  min-height: 0;
  margin: 0 auto;
  padding: clamp(18px, 2.7vh, 28px) clamp(82px, 12vw, 205px) clamp(28px, 5.2vh, 52px);
  display: flex;
  flex-direction: column;
  gap: clamp(5px, 0.8vh, 9px);
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(180deg, rgba(2, 5, 13, 0.04), rgba(2, 5, 13, 0.08)),
    url("./assets/mustard-retro-arcade-cabinet-v9.png") center / 100% 100% no-repeat;
  background-blend-mode: normal;
  border: 0;
  box-shadow:
    -20px 0 45px rgba(0, 142, 255, 0.08),
    20px 0 45px rgba(255, 20, 101, 0.07),
    0 28px 80px rgba(0, 0, 0, 0.62);
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.app-shell::before {
  z-index: -1;
  inset: 0;
  border: 0;
  background:
    linear-gradient(90deg, rgba(50, 181, 255, 0.08), transparent 17%, transparent 83%, rgba(255, 38, 111, 0.08)),
    radial-gradient(ellipse at 50% 72%, rgba(25, 64, 109, 0.12), transparent 58%);
  box-shadow: inset 0 0 90px rgba(0, 0, 0, 0.44);
}

.app-shell::after {
  z-index: 8;
  inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 4px);
  opacity: 0.42;
}

.topbar {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  min-height: 0;
  padding: clamp(12px, 1.8vh, 16px) calc(clamp(8px, 1.4vw, 19px) + 18px) 5px;
  border: 0;
  clip-path: none;
  background: transparent;
  box-shadow: none;
}

.topbar::before, .topbar::after { display: none; }

.brand-block { position: relative; min-width: 0; padding-left: 6px; }
.brand-kicker, .overlay-eyebrow, .card-tag, .stage-hud, .footer-note {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 10px;
}

.brand-kicker {
  color: var(--brass);
  display: flex;
  gap: 7px;
  align-items: center;
  font-family: var(--font-pixel);
  font-weight: 800;
}

.cyan-dot, .live-dot {
  width: 7px;
  height: 7px;
  border-radius: 0;
  background: var(--brass-bright);
  box-shadow: 0 0 10px rgba(255, 216, 74, 0.8);
  display: inline-block;
}

.cyan-dot { background: var(--blue-bright); box-shadow: 0 0 10px rgba(82, 168, 255, 0.82); }

.brand-block h1 {
  margin: 5px 0 0;
  color: #fff0b0;
  font-family: var(--font-pixel);
  font-size: clamp(25px, 2.8vw, 40px);
  line-height: 0.98;
  letter-spacing: 0.06em;
  text-shadow: 2px 0 0 #285286, -2px 0 0 #873052, 0 4px 0 #02050b, 0 0 12px #02050b, 0 0 20px rgba(255, 216, 74, 0.24);
}

.controls-block { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding: 0; border: 0; background: transparent; box-shadow: none; }
.online-controls { display: flex; align-items: center; gap: 8px; }
.online-only { display: flex; }
html[data-game-mode="local"] .online-only { display: none !important; }
html[data-game-mode="online"] .local-only { display: none !important; }
.control-group { display: grid; gap: 6px; }
.control-group label { color: var(--muted); font-size: 11px; }

.mode-switch,
.difficulty-options {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 2px solid #596780;
  border-top-color: #b8c0cd;
  border-bottom-color: #252d43;
  background: linear-gradient(180deg, #151a2a, #0a0d18);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.86), 0 4px 0 rgba(0, 0, 0, 0.44);
}

.mode-btn, .difficulty-btn {
  border: 1px solid transparent;
  border-radius: 1px;
  padding: 8px 12px 9px;
  color: var(--muted);
  background: transparent;
  font-family: var(--font-pixel);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  text-shadow: 0 1px 0 #050711;
  transition: background 160ms steps(2, end), color 160ms ease, box-shadow 160ms steps(2, end), transform 120ms steps(2, end);
}

.mode-btn:hover, .difficulty-btn:hover:not(:disabled) { color: var(--text); background: rgba(228, 185, 126, 0.12); }
.mode-btn.active { color: #08111f; border-color: var(--blue-bright); background: var(--blue); box-shadow: inset 0 -4px #285286, inset 0 2px #9adbe8, 0 0 16px rgba(82, 168, 255, 0.36); text-shadow: none; }
html[data-game-mode="local"] .mode-btn.active { color: #2c1725; border-color: var(--red-bright); background: var(--red); box-shadow: inset 0 -4px #873052, inset 0 2px #f7a4ab, 0 0 16px rgba(255, 95, 135, 0.34); }
.difficulty-control { display: flex; align-items: center; gap: 7px; min-width: 0; }
.difficulty-label { display: inline-flex; align-items: center; gap: 6px; color: var(--brass); font-family: var(--font-pixel); font-size: 11px; font-weight: 800; white-space: nowrap; }
.difficulty-crown {
  position: relative;
  display: inline-flex;
  width: 19px;
  height: 15px;
  flex: 0 0 19px;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(2px 2px 0 #694236) drop-shadow(0 0 4px rgba(255, 216, 74, 0.72));
  transform: translateY(-1px);
  animation: crown-glow 1.8s steps(2, end) infinite;
}
.difficulty-crown svg { display: block; width: 100%; height: 100%; overflow: visible; fill: #ffd84a; }

@keyframes crown-glow {
  0%, 100% { filter: drop-shadow(2px 2px 0 #694236) drop-shadow(0 0 3px rgba(255, 216, 74, 0.62)); }
  50% { filter: drop-shadow(2px 2px 0 #694236) drop-shadow(0 0 7px rgba(255, 216, 74, 0.95)); }
}
.difficulty-btn.active { color: #2c2225; border-color: #fff0b0; background: var(--brass-bright); box-shadow: inset 0 -4px #bd6041, inset 0 2px #fff0b0, 0 0 13px rgba(255, 216, 74, 0.3); text-shadow: none; }
.difficulty-btn:disabled { cursor: not-allowed; opacity: 1; }
.difficulty-btn.locked:disabled { color: #596780; box-shadow: inset 0 0 0 1px rgba(89, 103, 128, 0.28), 0 0 10px rgba(0, 0, 0, 0.36) !important; }

select, input {
  appearance: none;
  color: var(--text);
  background-color: var(--panel-2);
  border: 2px solid var(--line);
  border-radius: 1px;
  padding: 9px 30px 9px 11px;
  outline: none;
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--brass) 50%), linear-gradient(135deg, var(--brass) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(82, 168, 255, 0.16); }
.mode-badge { color: var(--text); background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 1px; padding: 9px 11px; font-size: 12px; white-space: nowrap; }
.mode-badge.connected { color: var(--blue-bright); border-color: rgba(82, 168, 255, 0.6); background: var(--blue-deep); }

.secondary-btn, .primary-btn {
  position: relative;
  border-radius: 0;
  font-family: var(--font-pixel);
  font-weight: 900;
  letter-spacing: 0.04em;
  clip-path: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px, 100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%, 4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
  transition: transform 120ms steps(2, end), box-shadow 120ms steps(2, end), background 120ms steps(2, end);
}

.secondary-btn {
  border: 2px solid #b9a5db;
  color: #f4eaff;
  background: linear-gradient(180deg, #4d3973, #2b2045);
  padding: 8px 12px;
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.13), inset 0 -4px #1c1530, 0 4px 0 #0a0710, 0 0 12px rgba(169, 110, 255, 0.13);
}

.secondary-btn:hover { transform: translateY(-1px); background: linear-gradient(180deg, #66508d, #382951); }
.secondary-btn:active { transform: translateY(2px); box-shadow: inset 0 2px rgba(255, 255, 255, 0.08), inset 0 -2px #1c1530, 0 1px 0 #0a0710; }
.ghost-btn { border: 0; color: var(--muted); background: transparent; border-radius: 1px; padding: 9px 11px; font-size: 12px; }
.ghost-btn:hover { color: var(--text); }

.primary-btn {
  border: 3px solid #fff0b0;
  color: #251a1a;
  background: linear-gradient(180deg, #ffe4a8 0 24%, #e49b5e 25% 100%);
  padding: 10px 16px;
  text-shadow: 0 1px rgba(255, 240, 176, 0.42);
  box-shadow:
    inset 0 2px rgba(255, 255, 255, 0.4),
    inset 0 -5px #8b4639,
    0 5px 0 #2b171b,
    0 0 20px rgba(255, 216, 74, 0.18);
}

.primary-btn:hover {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #fff1be 0 24%, #f0ab69 25% 100%);
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.5), inset 0 -5px #9e5040, 0 6px 0 #2b171b, 0 0 28px rgba(255, 216, 74, 0.32);
}
.primary-btn:active { transform: translateY(3px); box-shadow: inset 0 2px rgba(255, 255, 255, 0.28), inset 0 -3px #8b4639, 0 2px 0 #2b171b, 0 0 18px rgba(255, 216, 74, 0.2); }
.primary-btn.large { padding: 12px 22px; min-width: 170px; }

.room-card {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 50px;
  padding: 2px 4px;
  border: 0;
  clip-path: none;
  background: transparent;
  box-shadow: none;
}

html[data-game-mode="online"] .room-card {
  position: absolute;
  z-index: 6;
  top: clamp(19px, 2.8vh, 27px);
  left: 33%;
  right: 36%;
  justify-content: center;
  gap: 0;
}

.room-card::before { display: none; }
.room-card .card-title-row { margin-bottom: 3px; }
.room-card p { color: var(--muted); font-size: 10px; margin: 0; }
.room-list {
  display: grid;
  gap: 2px;
  width: min(100%, 310px);
  margin-inline: auto;
  font-family: var(--font-pixel);
  font-synthesis: none;
  text-rendering: geometricPrecision;
}
.room-row {
  display: grid;
  grid-template-columns: minmax(80px, 1fr) 48px 64px;
  align-items: center;
  gap: 8px;
  min-height: 25px;
  padding: 1px 5px;
  border-left: 2px solid #596780;
  background: rgba(5, 7, 17, 0.48);
  box-shadow: inset 0 0 0 1px rgba(131, 144, 165, 0.1);
  font-family: var(--font-pixel);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0;
}
.room-name,
.room-status,
.room-join-btn {
  font-family: var(--font-pixel);
  font-synthesis: none;
}
.room-name { color: var(--text); font-size: 12px; font-weight: 400; }
.room-status { color: var(--blue-bright); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; text-align: center; }
.room-join-btn { padding: 6px 9px; font-size: 11px; font-weight: 400; }
.room-actions { display: flex; align-items: end; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.room-code-input { width: 120px; text-transform: uppercase; }
.room-code-label { min-width: 58px; color: var(--blue-bright); font-size: 18px; letter-spacing: 0.12em; text-align: center; }
html[data-game-mode="local"] .connection-badge { color: var(--red); }

main {
  position: absolute;
  z-index: 2;
  left: 17.6%;
  right: 17.6%;
  top: 32.4%;
  bottom: 8.1%;
  min-height: 0;
  display: flex;
  padding: 0;
}

.stage-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: clamp(7px, 0.72vw, 11px) clamp(8px, 0.82vw, 13px) clamp(9px, 0.9vw, 14px);
  border: 0;
  clip-path: polygon(10px 0, calc(100% - 10px) 0, 100% 10px, 100% calc(100% - 10px), calc(100% - 10px) 100%, 10px 100%, 0 calc(100% - 10px), 0 10px);
  background:
    linear-gradient(180deg, #17130f 0, #07090d 13%, #03050a 82%, #21160e 100%);
  box-shadow:
    inset 0 0 0 1px rgba(238, 181, 96, 0.42),
    inset 0 0 0 5px rgba(1, 3, 7, 0.94),
    inset 0 13px 18px -12px rgba(0, 0, 0, 0.98),
    inset 0 -10px 16px -11px rgba(196, 119, 51, 0.42),
    0 9px 18px rgba(0, 0, 0, 0.66);
}

.stage-card::before,
.stage-card::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.stage-card::before {
  z-index: 4;
  inset: 0;
  border: 1px solid rgba(215, 153, 77, 0.45);
  clip-path: inherit;
  box-shadow:
    inset 0 0 0 5px rgba(2, 4, 8, 0.94),
    inset 0 0 18px 6px rgba(0, 0, 0, 0.72);
}

.stage-card::after {
  z-index: 5;
  inset: clamp(6px, 0.62vw, 10px);
  background:
    linear-gradient(90deg, rgba(229, 163, 81, 0.64), rgba(229, 163, 81, 0.64)) left top / 22px 2px no-repeat,
    linear-gradient(180deg, rgba(229, 163, 81, 0.64), rgba(229, 163, 81, 0.64)) left top / 2px 16px no-repeat,
    linear-gradient(90deg, rgba(229, 163, 81, 0.64), rgba(229, 163, 81, 0.64)) right top / 22px 2px no-repeat,
    linear-gradient(180deg, rgba(229, 163, 81, 0.64), rgba(229, 163, 81, 0.64)) right top / 2px 16px no-repeat,
    linear-gradient(90deg, rgba(105, 64, 35, 0.76), rgba(105, 64, 35, 0.76)) left bottom / 22px 2px no-repeat,
    linear-gradient(180deg, rgba(105, 64, 35, 0.76), rgba(105, 64, 35, 0.76)) left bottom / 2px 16px no-repeat,
    linear-gradient(90deg, rgba(105, 64, 35, 0.76), rgba(105, 64, 35, 0.76)) right bottom / 22px 2px no-repeat,
    linear-gradient(180deg, rgba(105, 64, 35, 0.76), rgba(105, 64, 35, 0.76)) right bottom / 2px 16px no-repeat;
}

.stage-hud {
  position: absolute;
  z-index: 7;
  left: calc(clamp(50px, 5.2vw, 84px) + clamp(8px, 1.4vw, 19px) + 24px - clamp(8px, 1vw, 14px));
  right: clamp(68px, 6.4vw, 104px);
  bottom: clamp(65px, 9.4vh, 74px);
  min-height: 0;
  height: clamp(29px, 4.4vh, 34px);
  padding: 0 clamp(8px, 1vw, 14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  border: 0;
  clip-path: none;
  background: transparent;
  text-transform: none;
  letter-spacing: 0;
  box-shadow: none;
  transform: translateY(8px);
}

.stage-help, .stage-status { display: flex; align-items: center; min-width: 0; white-space: nowrap; }
.stage-help { gap: 12px; overflow: hidden; font-size: 15px; text-shadow: 0 2px 2px #02050b, 0 0 7px #02050b; }
.stage-help-label { color: var(--brass); font-family: var(--font-pixel); font-size: 15px; font-weight: 900; letter-spacing: 0.08em; text-shadow: 0 2px 0 #02050b, 0 0 8px rgba(228, 185, 126, 0.28); }
.stage-help > span:not(.stage-help-label) { display: inline-flex; align-items: center; gap: 7px; }
.stage-help kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  min-height: 28px;
  padding: 3px 8px;
  border: 2px solid #596780;
  border-top-color: #b8c0cd;
  border-bottom-color: #151a2a;
  border-radius: 0;
  background: linear-gradient(180deg, #30394f, #1a2132);
  box-shadow: inset 0 0 0 1px rgba(10, 13, 24, 0.82), 0 3px 0 #080a11;
  color: #fff0b0;
  font-family: var(--font-pixel);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.stage-status { justify-content: flex-end; gap: 10px; font-size: 11px; overflow: hidden; }
.stage-status-primary { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-family: var(--font-pixel); font-weight: 800; text-shadow: 0 2px 2px #02050b, 0 0 7px #02050b; }
.stage-score strong { color: var(--text); font-weight: 800; }
.stage-event { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.stage-status-message { display: none; }

.canvas-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0;
  border: 2px solid #10151e;
  border-top-color: #03050a;
  border-bottom-color: #29303a;
  outline: 0;
  clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 5px, 100% calc(100% - 5px), calc(100% - 5px) 100%, 5px 100%, 0 calc(100% - 5px), 0 5px);
  background: #0a0d18;
  box-shadow:
    0 0 0 1px rgba(170, 113, 57, 0.24),
    inset 0 0 0 2px #02050b,
    inset 22px 0 34px -31px rgba(82, 168, 255, 0.88),
    inset -22px 0 34px -31px rgba(255, 95, 135, 0.84),
    inset 0 0 42px rgba(0, 0, 0, 0.9),
    0 4px 11px rgba(0, 0, 0, 0.78);
}

.canvas-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(242, 240, 232, 0.035) 0 1px, transparent 1px 4px);
  opacity: 0.75;
  mix-blend-mode: screen;
}

.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 54%, rgba(0, 0, 0, 0.42) 100%);
}

canvas {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  /* resizeCanvas() already fits the content box in 2:1. Keeping a second
     max-height constraint here can introduce fractional-pixel squeezing. */
  max-height: none;
  aspect-ratio: 2 / 1;
  touch-action: none;
  image-rendering: pixelated;
}

canvas:focus { outline: none; }

.overlay-card {
  position: absolute;
  z-index: 3;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 36px));
  padding: 23px;
  text-align: center;
  border: 4px solid #bd855a;
  border-top-color: #ffe0a1;
  border-bottom-color: #4a302b;
  border-radius: 0;
  clip-path: polygon(0 8px, 8px 8px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px));
  background:
    linear-gradient(180deg, rgba(21, 26, 42, 0.97), rgba(10, 13, 24, 0.98)),
    url("./assets/arcade-cabinet-fascia.png") center / cover,
    repeating-linear-gradient(0deg, rgba(242, 240, 232, 0.03) 0 1px, transparent 1px 4px);
  box-shadow:
    inset 0 0 0 2px #252d43,
    inset 0 0 0 4px #3a2330,
    inset 0 0 26px rgba(0, 0, 0, 0.76),
    0 8px 0 rgba(0, 0, 0, 0.62),
    -9px 0 28px rgba(82, 168, 255, 0.14),
    9px 0 28px rgba(255, 95, 135, 0.13),
    0 0 38px rgba(228, 185, 126, 0.16);
}

.overlay-card::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 7px;
  height: 3px;
  background: linear-gradient(90deg, var(--blue), var(--brass-bright) 48%, var(--red));
  box-shadow: -2px 0 8px rgba(82, 168, 255, 0.5), 2px 0 8px rgba(255, 95, 135, 0.46);
  opacity: 0.78;
}
.overlay-card h2 {
  margin: 10px 0 9px;
  color: #fff0b0;
  font-family: var(--font-pixel);
  font-size: clamp(20px, 3vw, 29px);
  letter-spacing: 0.04em;
  text-shadow: 2px 0 #285286, -2px 0 #873052, 0 3px 0 #2c2225;
}
.overlay-card p { color: #b8c0cd; line-height: 1.7; font-size: 14px; margin: 0 auto 20px; }
.overlay-eyebrow { color: var(--brass-bright); }
.round-ready-count { margin: -2px 0 16px; color: var(--blue-bright); font-family: var(--font-pixel); font-size: 13px; font-weight: 800; letter-spacing: 0.08em; }
html[data-game-mode="local"] .round-ready-count { display: none; }
html[data-game-mode="online"] #overlayStartText, html[data-game-mode="local"] #overlayStartText { display: none; }
.hidden { display: none !important; }

.card-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title-row h2 { margin: 0; color: var(--text); font-family: var(--font-pixel); font-size: 14px; letter-spacing: 0.02em; }
.card-tag { padding: 4px 7px; color: var(--violet); border: 1px solid rgba(169,110,255,0.5); border-radius: 1px; font-size: 9px; }
.control-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.control-columns.single-control { grid-template-columns: minmax(0, 360px); }
.player-label { font-size: 12px; font-weight: 800; margin-bottom: 8px; }
.cyan-text { color: var(--blue); }
.pink-text { color: var(--red); }
kbd { padding: 3px 5px; border: 1px solid rgba(242, 240, 232, 0.22); border-bottom-color: rgba(242, 240, 232, 0.4); border-radius: 1px; background: rgba(242, 240, 232, 0.06); color: var(--text); font-size: 10px; }
.footer-note { color: #596780; text-align: center; padding-top: 22px; font-size: 10px; }

/* Monochrome blue CRT language for the cabinet's upper information screen. */
.cabinet-console {
  --crt-blue-white: #d9fbff;
  --crt-blue: #8eeeff;
  --crt-blue-mid: #45bddc;
  --crt-blue-dim: #477e91;
  --crt-blue-deep: #0a3444;
  --crt-screen: rgba(2, 15, 23, 0.9);
  font-family: var(--font-pixel);
  text-rendering: geometricPrecision;
}

.cabinet-console .brand-kicker,
.cabinet-console .difficulty-label,
.cabinet-console .stage-help-label,
.cabinet-console .card-title-row h2 {
  color: var(--crt-blue);
  text-shadow: 0 0 2px var(--crt-blue-white), 0 0 7px rgba(69, 189, 220, 0.72);
}

.cabinet-console .brand-block h1 {
  color: var(--crt-blue-white);
  font-family: var(--font-pixel);
  font-weight: 900;
  text-shadow:
    1px 0 0 rgba(217, 251, 255, 0.5),
    0 0 2px var(--crt-blue-white),
    0 0 7px rgba(69, 189, 220, 0.9),
    0 0 14px rgba(32, 127, 158, 0.5);
}

.cabinet-console .cyan-dot,
.cabinet-console .live-dot {
  background: var(--crt-blue-white);
  box-shadow: 0 0 4px var(--crt-blue), 0 0 10px rgba(69, 189, 220, 0.78);
}

.cabinet-console .mode-switch,
.cabinet-console .difficulty-options {
  border-color: var(--crt-blue-deep);
  border-top-color: var(--crt-blue-mid);
  border-bottom-color: #06151e;
  background: linear-gradient(180deg, rgba(8, 36, 48, 0.78), var(--crt-screen));
  box-shadow: inset 0 0 0 1px #020b10, inset 0 0 12px rgba(31, 117, 145, 0.13), 0 0 7px rgba(69, 189, 220, 0.14);
}

.cabinet-console .mode-btn,
.cabinet-console .difficulty-btn {
  color: var(--crt-blue-dim);
  font-family: inherit;
  text-shadow: 0 0 4px rgba(69, 189, 220, 0.24);
}

.cabinet-console .mode-btn:hover,
.cabinet-console .difficulty-btn:hover:not(:disabled) {
  color: var(--crt-blue-white);
  background: rgba(46, 145, 174, 0.13);
  text-shadow: 0 0 6px rgba(142, 238, 255, 0.72);
}

.cabinet-console .mode-btn.active,
html[data-game-mode="local"] .cabinet-console .mode-btn.active,
.cabinet-console .difficulty-btn.active {
  color: var(--crt-blue-white);
  border-color: var(--crt-blue);
  background: linear-gradient(180deg, rgba(24, 88, 108, 0.76), rgba(5, 38, 51, 0.9));
  box-shadow: inset 0 1px rgba(217, 251, 255, 0.25), inset 0 -3px #062733, 0 0 8px rgba(69, 189, 220, 0.52);
  text-shadow: 0 0 2px var(--crt-blue-white), 0 0 6px rgba(69, 189, 220, 0.72);
}

.cabinet-console .difficulty-btn.locked:disabled {
  color: #315463;
  box-shadow: inset 0 0 0 1px rgba(49, 84, 99, 0.34) !important;
  text-shadow: none;
}

.cabinet-console .difficulty-crown {
  animation: crt-crown-glow 1.8s steps(2, end) infinite;
}

.cabinet-console .difficulty-crown svg { fill: var(--crt-blue); }

@keyframes crt-crown-glow {
  0%, 100% { filter: drop-shadow(2px 2px 0 #092b38) drop-shadow(0 0 3px rgba(69, 189, 220, 0.58)); }
  50% { filter: drop-shadow(2px 2px 0 #092b38) drop-shadow(0 0 7px rgba(142, 238, 255, 0.9)); }
}

.cabinet-console .stage-hud,
.cabinet-console .stage-help,
.cabinet-console .stage-status-primary,
.cabinet-console .room-card p,
.cabinet-console .room-name,
.cabinet-console .room-status {
  color: var(--crt-blue);
  font-family: inherit;
  text-shadow: 0 0 2px rgba(217, 251, 255, 0.65), 0 0 6px rgba(69, 189, 220, 0.5);
}

.cabinet-console .stage-help kbd {
  color: var(--crt-blue-white);
  border-color: var(--crt-blue-deep);
  border-top-color: var(--crt-blue-mid);
  border-bottom-color: #06151e;
  background: linear-gradient(180deg, rgba(15, 57, 73, 0.9), rgba(3, 23, 32, 0.96));
  box-shadow: inset 0 0 0 1px #020b10, inset 0 0 8px rgba(69, 189, 220, 0.13), 0 2px 0 #020a0e, 0 0 5px rgba(69, 189, 220, 0.24);
  text-shadow: 0 0 2px var(--crt-blue-white), 0 0 5px rgba(69, 189, 220, 0.68);
}

.cabinet-console .room-row {
  border-left-color: var(--crt-blue-mid);
  background: rgba(2, 18, 27, 0.72);
  box-shadow: inset 0 0 0 1px rgba(69, 189, 220, 0.18);
}

.cabinet-console .room-join-btn {
  color: var(--crt-blue-white);
  border-color: var(--crt-blue-mid);
  background: linear-gradient(180deg, rgba(18, 74, 94, 0.86), rgba(5, 35, 48, 0.94));
  box-shadow: inset 0 1px rgba(217, 251, 255, 0.2), inset 0 -2px #041c26, 0 0 6px rgba(69, 189, 220, 0.28);
  text-shadow: 0 0 5px rgba(142, 238, 255, 0.68);
}

.cabinet-console .room-join-btn:hover {
  background: linear-gradient(180deg, rgba(27, 98, 121, 0.9), rgba(7, 45, 58, 0.96));
}

@media (max-height: 700px) and (min-width: 901px) {
  .brand-block h1 {
    margin-top: 2px;
    font-size: clamp(30px, 2.5vw, 38px);
  }

  .stage-hud {
    bottom: clamp(48px, 7.2vh, 52px);
  }
}

@media (max-width: 900px) {
  .app-shell { width: 100%; padding: 12px clamp(34px, 9vw, 82px) 24px; }
  .topbar { align-items: center; gap: 8px; }
  .brand-block h1 { font-size: clamp(25px, 4.4vw, 35px); }
  .controls-block { justify-content: flex-end; flex-wrap: nowrap; }
  .difficulty-control { justify-content: center; }
  .difficulty-label { display: none; }
  .mode-switch { width: auto; }
  .mode-btn { flex: 1; }
  .online-controls { flex: 1 1 auto; justify-content: center; }
  .room-card { align-items: flex-start; flex-direction: column; }
  html[data-game-mode="online"] .room-card { position: static; min-height: 0; }
  .room-list { width: 100%; }
  .room-actions { width: 100%; justify-content: flex-start; }
  .stage-help { overflow-x: auto; }
  .stage-status { flex: 0 0 auto; }
}

@media (max-width: 560px) {
  .app-shell { width: 100%; padding: 7px 20px 15px; gap: 4px; }
  .topbar { min-height: 88px; flex-basis: auto; padding: 7px 8px; flex-wrap: wrap; align-content: center; }
  .brand-block { flex: 0 0 auto; }
  .brand-kicker { font-size: 8px; }
  .brand-block h1 { font-size: 24px; }
  .controls-block { gap: 5px; }
  .difficulty-control { flex-wrap: nowrap; }
  .difficulty-options { flex: 1 1 auto; }
  .difficulty-btn { flex: 1 1 0; padding: 6px 5px 7px; font-size: 10px; }
  .mode-switch { width: auto; }
  .online-controls { width: 100%; gap: 6px; }
  .online-controls .primary-btn { padding-inline: 10px; }
  .room-card { padding: 10px; }
  .room-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .room-code-input, .room-code-label { width: 100%; }
  .room-code-label { grid-column: 1 / -1; }
  .room-actions .ghost-btn { grid-column: 1 / -1; }
  .mode-switch { flex: 0 1 auto; }
  .mode-btn { padding: 6px 5px 7px; font-size: 10px; }
  .stage-card { padding: 0; border: 0; }
  .stage-hud { padding: 5px 7px; gap: 6px; }
  .stage-help { gap: 7px; font-size: 12px; overflow-x: auto; }
  .stage-help-label { font-size: 12px; }
  .stage-help > span:not(.stage-help-label) { gap: 6px; }
  .stage-help kbd { min-width: 29px; min-height: 24px; padding: 2px 5px; font-size: 11px; }
  .stage-status { display: none; }
  main { padding-top: 5px; }
  .canvas-wrap { border-width: 4px; }
  .overlay-card { padding: 18px; }
}
