@font-face {
  font-family: "Anton";
  src: url("fonts/anton-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --bg: #000;
  --fg: #f2f2f2;
  --dim: #a9a9b3;
  --accent: #ff3d2e;
  --accent2: #ffd23e;
  --panel: rgba(8, 8, 12, .86);
  --head: "Anton", "Arial Narrow", Impact, sans-serif;
  --sal: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}
#stage { position: fixed; inset: 0; touch-action: none; outline: none; }
#game { display: block; width: 100%; height: 100%; background: #000; touch-action: none; }

/* overlay + hud: on a portrait screen the canvas draws the arena a quarter turn clockwise
 * (stage left = screen top), so these turn the same way and the app stays landscape */
#overlay, #hudbar { position: absolute; inset: 0; }
#overlay { display: grid; place-items: center; padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); overflow: auto; }
#overlay[hidden], #hudbar[hidden] { display: none; }
#hudbar { pointer-events: none; }
@media (orientation: portrait) {
  #overlay, #hudbar {
    inset: auto; top: 0; left: 0;
    width: 100vh; height: 100vw;
    width: 100dvh; height: 100dvw;
    transform-origin: 0 0;
    transform: rotate(90deg) translateY(-100%);
  }
  #overlay { padding: 14px; }
  .pwa-install {
    left: auto; right: max(16px, env(safe-area-inset-right)); bottom: auto; top: 50%;
    transform: rotate(90deg) translate(50%, -50%); transform-origin: 100% 50%;
  }
}

.panel {
  position: relative;
  width: min(440px, 100%);
  max-height: 100%;
  overflow: auto;
  text-align: center;
  padding: 18px 20px 18px;
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .14), 0 12px 40px rgba(0, 0, 0, .6);
}
.panel.wide { width: min(640px, 100%); }
.panel[hidden] { display: none; }
h1, h2 { font-family: var(--head); font-weight: 400; text-transform: uppercase; letter-spacing: .03em; margin: 0 0 12px; line-height: 1; }
h1 { font-size: clamp(44px, 11vmin, 76px); color: #fff; text-shadow: 0 0 18px rgba(255, 61, 46, .5); }
h1 span { display: block; color: var(--accent); font-size: .78em; letter-spacing: .14em; margin-top: 4px; }
h2 { font-size: 34px; }
.menu-list { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.btn {
  appearance: none; cursor: pointer;
  min-height: 3rem;
  padding: 8px 22px;
  border: 2px solid rgba(255, 255, 255, .85);
  border-radius: 12px;
  background: #18181f;
  color: #fff;
  font: 400 24px/1.1 var(--head);
  letter-spacing: .06em;
  text-transform: uppercase;
}
.btn:hover, .btn:focus-visible { background: var(--accent); border-color: #fff; outline: none; }
.btn:active { transform: translateY(2px); }
.btn.ghost { border-color: rgba(255, 255, 255, .35); color: var(--dim); }
.btn.small { font-size: 20px; min-height: 2.75rem; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.row { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row.split { align-items: flex-start; }
.col { flex: 1 1 200px; display: flex; flex-direction: column; gap: 8px; }
.note { color: var(--dim); margin: 10px 0 0; min-height: 1.2em; font-size: 15px; }
.sub { margin: 0; color: var(--dim); font-size: 15px; }
.big { font: 400 30px/1.15 var(--head); margin: 0 0 6px; letter-spacing: .03em; }
.icon-btn {
  appearance: none; cursor: pointer; pointer-events: auto;
  width: 3rem; height: 3rem; padding: 10px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .8);
  background: rgba(20, 20, 26, .7);
  color: #fff;
}
.icon-btn svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.corner { position: absolute; top: 10px; right: 10px; }
#btn-pause { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
@media (orientation: portrait) { #btn-pause { top: 12px; right: 12px; } }

.opt-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; text-align: left; }
@media (max-width: 600px) and (orientation: landscape), (max-height: 600px) and (orientation: portrait) { .opt-list { grid-template-columns: 1fr; } }
/* a short stage (a phone held sideways, or a portrait phone whose stage is turned): compact cards */
@media (orientation: landscape) and (max-height: 520px), (orientation: portrait) and (max-width: 520px) {
  .panel { padding: 10px 14px; }
  h1 { font-size: 40px; margin-bottom: 8px; }
  h2 { font-size: 24px; margin-bottom: 6px; }
  .menu-list { gap: 7px; }
  .btn { min-height: 2.6rem; font-size: 20px; padding: 4px 18px; }
  .btn.small { min-height: 2.5rem; font-size: 18px; }
  .row { margin-top: 6px; }
  .note { margin-top: 4px; font-size: 13px; }
  .opt-list { gap: 3px 14px; }
  .opt .lbl { font-size: 16px; }
  .help { font-size: 14px; margin-bottom: 4px; }
  .help li { margin: 2px 0; }
  .keys { margin: 4px 0; font-size: 13px; }
  input { min-height: 2.5rem; padding: 6px 10px; font-size: 18px; }
  .players { margin-top: 6px; }
}
.opt { display: flex; align-items: center; gap: 6px; }
.opt .lbl { flex: 1; font: 400 18px/1.1 var(--head); letter-spacing: .05em; text-transform: uppercase; }
.opt .val { min-width: 2.6em; text-align: center; font: 400 20px var(--head); }
.opt button { appearance: none; width: 2.6rem; height: 2.6rem; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .6); background: #18181f; color: #fff; font: 400 20px var(--head); cursor: pointer; }
.opt button:active { background: var(--accent); }
.help { text-align: left; margin: 0 0 10px; padding-left: 1.2em; line-height: 1.35; }
.help li { margin: 4px 0; }
.keys { color: var(--dim); font-size: 15px; }
kbd { display: inline-block; min-width: 1.6em; padding: 0 5px; margin: 0 1px; border-radius: 5px; border: 1px solid #666; font: inherit; color: #fff; }
@media (hover: none) and (pointer: coarse) { .kbd-only { display: none; } }
@media (hover: hover), (pointer: fine) { .touch-only { display: none; } }
.field { display: flex; flex-direction: column; gap: 4px; text-align: left; font-size: 15px; color: var(--dim); }
input { font: 400 20px/1.2 system-ui, sans-serif; padding: 10px 12px; min-height: 2.75rem; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .4); background: #101016; color: #fff; -webkit-user-select: text; user-select: text; }
input:focus { outline: none; border-color: var(--accent2); }
.code-in { text-transform: uppercase; text-align: center; letter-spacing: .3em; font-family: var(--head); font-size: 26px; }
.code { color: var(--accent2); letter-spacing: .12em; }
.seg { display: flex; gap: 4px; }
.seg button { flex: 1; appearance: none; min-height: 2.75rem; border-radius: 10px; border: 2px solid rgba(255, 255, 255, .35); background: #101016; color: var(--dim); font: 400 16px var(--head); letter-spacing: .04em; text-transform: uppercase; cursor: pointer; }
.seg button.on { border-color: #fff; color: #fff; background: #2a2a34; }
.link-row input { flex: 1 1 220px; font-size: 15px; }
.players { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: #15151c; font: 400 20px var(--head); letter-spacing: .04em; }
.players li .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .5); }
.players li .tag { margin-left: auto; font-size: 15px; color: var(--dim); }
.players li.off { opacity: .5; }
body.playing .pwa-install { display: none; }
