:root {
  color-scheme: light;
  --ink: #18251e;
  --muted: #6d7a70;
  --panel: #fffdf7;
  --line: #d9d2bd;
  --field: #f8f4e8;
  --accent: #2e684b;
  --accent-dark: #183f2c;
  --gold: #ffb13b;
  --purple: #7c17ff;
  --purple-2: #c22cff;
  --signal: #b74b36;
  --danger: #b33a2e;
  --success: #dff4e8;
  --warn: #fff0ec;
  --night: #101a16;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--night) url("arena-bg.svg") center top / cover fixed;
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 15, .38);
  pointer-events: none;
}

body > * { position: relative; }

a { color: var(--accent-dark); }
.topbar {
  min-height: 58px;
  padding: 12px 18px;
  background: rgba(13, 24, 19, .94);
  color: #fff8e7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid rgba(228, 208, 154, .28);
}
.topbar a { color: white; text-decoration: none; }
.brand { font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: .88rem; }
.shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 22px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 18px 44px rgba(4, 8, 6, .22);
}
.login-stage {
  min-height: calc(100vh - 116px);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 460px);
  align-items: center;
  gap: 28px;
}
.login-stage.compact {
  grid-template-columns: minmax(320px, 460px);
  justify-content: center;
}
.login-copy {
  color: #fff8e7;
  max-width: 680px;
}
.login-copy h1 {
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  margin: 0 0 16px;
  text-transform: uppercase;
}
.login-copy p:not(.eyebrow) {
  max-width: 560px;
  font-size: 1.12rem;
  line-height: 1.55;
  color: #e8dcc2;
}
.login-panel { max-width: 520px; margin: 0; }
.badge-mark {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 900;
  border: 3px solid var(--gold);
  margin-bottom: 16px;
}
.mark-icon, .home-mark {
  width: 48px;
  height: 56px;
  color: #fff;
  filter: drop-shadow(0 4px 10px rgba(124, 23, 255, .46));
}
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.player-hero, .control-hero {
  color: #fff8e7;
  border: 1px solid rgba(228, 208, 154, .38);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
  background: rgba(17, 33, 25, .86);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .24);
}
.player-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.player-hero p, .control-hero p { color: #e8dcc2; }
.player-hero strong { color: #f4d06f; }
.eyebrow, .panel-kicker {
  text-transform: uppercase;
  font-size: .76rem;
  letter-spacing: .08em;
  color: var(--gold);
  font-weight: 900;
}
.panel-kicker { margin: 0 0 8px; color: #88691f; }
h1, h2 { margin: 0 0 12px; line-height: 1.15; }
.muted { color: var(--muted); }
.score {
  min-width: 120px;
  text-align: center;
  font-size: 4rem;
  font-weight: 900;
  color: #f4d06f;
  line-height: 1;
}
.score span { display: block; font-size: .9rem; font-weight: 900; color: #e8dcc2; text-transform: uppercase; letter-spacing: .08em; }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c9bea1;
  border-radius: 8px;
  padding: 12px;
  background: var(--field);
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(197, 154, 52, .32);
  border-color: var(--gold);
}
button, .button {
  border: 0;
  border-radius: 8px;
  padding: 13px 15px;
  background: var(--accent);
  color: white;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .button:hover { background: var(--accent-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; border-bottom: 1px solid var(--line); padding: 10px 8px; vertical-align: top; }
th { color: var(--muted); font-size: .85rem; }
code { background: var(--field); padding: 2px 5px; border-radius: 5px; }
.alert, .success {
  border-radius: 8px;
  padding: 12px;
  font-weight: 700;
}
.alert { background: var(--warn); color: var(--danger); }
.success { background: var(--success); color: var(--accent-dark); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.scan-row { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.control-link { margin-bottom: 0; }

.page-player-dashboard .topbar,
.page-player-login .topbar {
  display: none;
}

.page-player-dashboard .shell {
  max-width: 520px;
  padding: 0 10px 18px;
}

.game-phone {
  max-width: 480px;
  margin: 0 auto 18px;
  min-height: calc(100vh - 18px);
  padding: 18px 14px 94px;
  background:
    linear-gradient(180deg, rgba(28, 8, 70, .12), rgba(0, 10, 22, .82) 58%, rgba(0, 9, 20, .98)),
    url("arena-bg.svg") center top / cover;
  border: 1px solid rgba(194, 44, 255, .36);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .42);
  overflow: hidden;
}

.hud-row {
  display: grid;
  grid-template-columns: 54px 1fr 72px;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.home-mark {
  justify-self: center;
  width: 62px;
  height: 72px;
}

.icon-button {
  width: 46px;
  height: 46px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 10px;
  background: transparent;
}

.icon-button:hover { background: transparent; }

.icon-button span {
  display: block;
  height: 4px;
  background: #fff;
  border-radius: 2px;
}

.icon-link {
  color: #fff;
  text-align: right;
  font-weight: 800;
  text-decoration: none;
  font-size: .86rem;
}

.name-ribbon {
  position: relative;
  width: min(340px, 86%);
  margin: 18px auto 12px;
  padding: 13px 22px;
  text-align: center;
  color: #fff;
  background: linear-gradient(90deg, #5311c8, var(--purple), #9b1dff);
  box-shadow: 0 10px 22px rgba(58, 0, 120, .56);
  transform: rotate(-1deg);
}

.name-ribbon::before,
.name-ribbon::after {
  content: "";
  position: absolute;
  top: 14px;
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;
}

.name-ribbon::before {
  left: -28px;
  border-right: 34px solid #3a0b83;
}

.name-ribbon::after {
  right: -28px;
  border-left: 34px solid #3a0b83;
}

.name-ribbon span {
  display: block;
  font-size: 1.45rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-style: italic;
}

.points-orb {
  width: 196px;
  height: 196px;
  margin: 26px auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(3, 4, 16, .94) 0 54%, transparent 55%),
    conic-gradient(from -40deg, #4b0cae, #b02cff, #4b0cae, #d349ff, #4b0cae);
  border: 8px solid rgba(124, 23, 255, .78);
  box-shadow: 0 0 0 7px rgba(9, 10, 24, .76), 0 0 34px rgba(194, 44, 255, .72);
}

.points-inner {
  color: #fff;
  text-align: center;
  text-transform: uppercase;
}

.points-inner span {
  display: block;
  font-weight: 950;
  font-size: .95rem;
  line-height: 1.08;
}

.points-inner strong {
  display: block;
  font-size: 4.3rem;
  line-height: .92;
}

.identity-chip,
.district-score-chip {
  margin: 0 auto 18px;
  width: fit-content;
  max-width: 100%;
  color: #e9e7ff;
  background: rgba(1, 12, 30, .72);
  border: 1px solid rgba(194, 44, 255, .34);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: .85rem;
  overflow-wrap: anywhere;
}

.district-score-chip {
  margin-top: -8px;
  color: #fff;
  border-color: var(--district-colour, rgba(255, 177, 59, .48));
  box-shadow: 0 0 18px color-mix(in srgb, var(--district-colour, #ffb13b) 34%, transparent);
}

.district-score-chip strong {
  color: #ffcf68;
}

.district-dot {
  width: .9em;
  height: .9em;
  display: inline-block;
  border-radius: 50%;
  margin-right: .45em;
  background: var(--district-colour, #ffb13b);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .72);
  vertical-align: -.08em;
}

.player-qr-actions {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.show-qr-button {
  width: 100%;
  min-height: 72px;
  margin: 0;
  border: 2px solid rgba(194, 44, 255, .72);
  background: rgba(5, 18, 42, .82);
  color: #fff;
  font-size: 1.15rem;
  text-transform: uppercase;
}

.capture-card {
  display: grid;
  gap: 10px;
  margin: 0;
}

.capture-status {
  margin: 0;
  padding: 10px 12px;
  color: #fff;
  background: rgba(1, 12, 30, .72);
  border: 1px solid rgba(194, 44, 255, .34);
  border-radius: 8px;
  font-weight: 800;
}

.capture-card label,
.tile-form label {
  color: #fff;
  font-size: .82rem;
}

.capture-card input,
.tile-form input {
  background: rgba(4, 16, 36, .88);
  color: #fff;
  border-color: rgba(194, 44, 255, .58);
}

.capture-card button,
.scan-capture-button {
  display: block;
  min-height: 72px;
  border: 2px solid var(--purple-2);
  background: linear-gradient(135deg, #6d16ef, #8c18ff 48%, #560ec2);
  box-shadow: 0 12px 24px rgba(65, 0, 140, .46);
  font-size: 1.15rem;
  text-transform: uppercase;
}

.capture-card .secondary-action,
.secondary-action {
  min-height: auto;
  display: inline-block;
  border: 2px solid rgba(154, 166, 220, .48);
  background: rgba(5, 18, 42, .82);
  box-shadow: none;
  font-size: .95rem;
  text-transform: uppercase;
}

.action-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, .82);
  border-radius: 6px;
  font-size: .75rem;
}

.chevron {
  font-size: 2rem;
  line-height: 1;
}

.action-tiles {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.tile-form,
.tile-link {
  min-height: 108px;
  display: grid;
  align-content: center;
  gap: 8px;
  color: #fff;
  background: rgba(5, 18, 42, .82);
  border: 2px solid rgba(154, 166, 220, .44);
  border-radius: 8px;
  padding: 12px;
  text-decoration: none;
  text-transform: uppercase;
  font-weight: 950;
}

.tile-form button {
  background: transparent;
  border: 0;
  padding: 0;
  text-transform: uppercase;
  text-align: left;
}

.game-phone .scan-row {
  color: #cbd4ef;
  background: rgba(0, 10, 24, .55);
  border: 1px solid rgba(154, 166, 220, .22);
  border-radius: 8px;
  padding: 10px;
}

.game-phone .muted { color: #cbd4ef; }

.bottom-nav {
  position: sticky;
  bottom: 0;
  max-width: 480px;
  margin: -84px auto 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px 14px;
  background: rgba(0, 10, 24, .92);
  border-top: 1px solid rgba(194, 44, 255, .22);
  border-radius: 8px 8px 0 0;
}

.bottom-nav a {
  color: #bac4e2;
  text-align: center;
  text-decoration: none;
  font-size: .78rem;
  padding: 10px 4px;
  border-radius: 8px;
}

.bottom-nav a.active {
  color: #fff;
  background: linear-gradient(180deg, #6d16ef, #211174);
}

.detail-grid {
  max-width: 920px;
  margin: 0 auto;
}

.qr-dialog {
  width: min(92vw, 420px);
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.qr-dialog::backdrop {
  background: rgba(0, 4, 14, .78);
}

.dialog-card {
  position: relative;
  padding: 22px;
  text-align: center;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(20, 9, 58, .95), rgba(1, 10, 25, .98)),
    url("arena-bg.svg") center / cover;
  border: 2px solid rgba(194, 44, 255, .58);
  border-radius: 8px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .54);
}

.dialog-card h2 {
  text-transform: uppercase;
  letter-spacing: .04em;
}

.dialog-card .muted {
  color: #d6d7ee;
}

.dialog-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .12);
  font-size: 1.55rem;
  line-height: 1;
}

.dialog-mark {
  width: 70px;
  height: 70px;
  color: #fff;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 10px rgba(124, 23, 255, .46));
}

.qr-frame {
  display: grid;
  place-items: center;
  width: min(72vw, 280px);
  aspect-ratio: 1;
  margin: 16px auto 12px;
  padding: 14px;
  background: #fff;
  border: 6px solid var(--purple-2);
  border-radius: 8px;
}

.qr-frame svg {
  width: 100%;
  height: 100%;
  color: #050817;
}

.qr-code-text {
  overflow-wrap: anywhere;
  color: #ffcf68;
  font-weight: 950;
  letter-spacing: .04em;
}

.qr-video {
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 58vh;
  object-fit: cover;
  background: #020713;
  border: 2px solid rgba(194, 44, 255, .58);
  border-radius: 8px;
}

.scan-message {
  min-height: 1.4em;
  color: #ffcf68;
  font-weight: 800;
}

@media (max-width: 760px) {
  .grid.two, .hero, .player-hero, .login-stage { grid-template-columns: 1fr; display: grid; }
  .login-stage { min-height: auto; }
  .login-copy h1 { font-size: 3rem; }
  .score { text-align: left; }
  .shell { padding: 12px; }
  table { font-size: .9rem; }
}
