:root {
  --bg: #07100f;
  --surface: rgba(13, 26, 24, 0.94);
  --surface-raised: #132b28;
  --surface-soft: rgba(255, 255, 255, 0.045);
  --line: rgba(215, 246, 235, 0.15);
  --line-strong: rgba(109, 240, 205, 0.38);
  --text: #f4faf7;
  --muted: #a9bbb5;
  --accent: #6df0cd;
  --accent-ink: #03231c;
  --coral: #ff7b68;
  --yellow: #f4cf66;
  --danger: #ff8a9b;
  --success: #77e69a;
  --shadow: 0 22px 64px rgba(0, 0, 0, 0.28);
  --radius-lg: 24px;
  --radius-md: 14px;
  color-scheme: dark;
  font-family: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
input[type="range"] {
  touch-action: manipulation;
}

.backdrop {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: fixed;
}

.map-grid {
  inset: 0;
  position: absolute;
  background-image:
    linear-gradient(rgba(109, 240, 205, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109, 240, 205, 0.035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 85%);
}

.signal {
  border: 1px solid rgba(109, 240, 205, 0.12);
  border-radius: 50%;
  position: absolute;
}

.signal::before,
.signal::after {
  border: inherit;
  border-radius: inherit;
  content: "";
  inset: 18%;
  position: absolute;
}

.signal::after {
  inset: 36%;
}

.signal-a {
  height: 42rem;
  left: -17rem;
  top: -15rem;
  width: 42rem;
}

.signal-b {
  border-color: rgba(255, 123, 104, 0.1);
  bottom: -18rem;
  height: 38rem;
  right: -15rem;
  width: 38rem;
}

.shell {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  margin: 0 auto;
  max-width: 1320px;
  min-height: 100vh;
  padding: 1.25rem 1.5rem 2rem;
  position: relative;
  z-index: 1;
}

.app-header {
  align-items: center;
  display: flex;
  grid-column: 1 / -1;
  justify-content: space-between;
  min-width: 0;
  padding: 0.5rem 0.25rem 0.75rem;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 0.9rem;
  min-width: 0;
}

.brand-mark {
  fill: none;
  flex: 0 0 44px;
  height: 44px;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-width: 2;
  width: 44px;
}

.eyebrow,
.mode-label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  margin: 0 0 0.2rem;
  text-transform: uppercase;
}

.app-header h1 {
  font-size: 2rem;
  line-height: 1.15;
  margin: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
  padding: 1.25rem;
  position: relative;
}

.panel-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
  min-width: 0;
}

.panel-head > div {
  align-items: baseline;
  display: flex;
  gap: 0.55rem;
  min-width: 0;
}

.section-index {
  color: var(--accent);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.panel-head h2 {
  font-size: 0.92rem;
  margin: 0;
  text-transform: uppercase;
}

.pill,
.timer,
.live-dot {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.78rem;
  min-height: 2rem;
  padding: 0.3rem 0.72rem;
}

.pill.accent {
  border-color: rgba(255, 123, 104, 0.45);
  color: #ffc5bb;
}

.timer {
  border-color: var(--line-strong);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.arena-panel {
  display: flex;
  flex-direction: column;
  grid-column: span 8;
  min-height: 37rem;
}

.setup-panel {
  grid-column: span 4;
}

.status-panel {
  grid-column: 1 / -1;
}

.voice-panel {
  grid-column: span 5;
}

.log-panel {
  grid-column: span 7;
}

.app-footer {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 0.75rem;
  grid-column: 1 / -1;
  justify-content: space-between;
  padding: 0.5rem 0.25rem 0;
}

.app-footer nav {
  display: flex;
  gap: 1rem;
}

.arena-stage {
  align-items: center;
  background: #091815;
  border: 1px solid var(--line);
  border-radius: 20px;
  display: grid;
  flex: 1;
  grid-template-columns: minmax(250px, 0.9fr) minmax(260px, 1.1fr);
  min-height: 18rem;
  overflow: hidden;
  padding: 1.25rem;
  position: relative;
}

.radar {
  aspect-ratio: 1;
  border: 1px solid rgba(109, 240, 205, 0.28);
  border-radius: 50%;
  justify-self: center;
  max-width: 16rem;
  position: relative;
  width: 100%;
}

.radar::before {
  background: conic-gradient(from 0deg, transparent 0 72%, rgba(109, 240, 205, 0.16));
  border-radius: 50%;
  content: "";
  inset: 0;
  position: absolute;
  animation: radar-sweep 5s linear infinite paused;
  opacity: 0.45;
}

body[data-phase="searching"] .radar::before,
body[data-phase="countdown"] .radar::before,
body[data-phase="live"] .radar::before {
  animation-play-state: running;
  opacity: 1;
}

body[data-phase="live"] .radar::before {
  animation-duration: 1.4s;
}

.radar-ring {
  border: 1px solid rgba(109, 240, 205, 0.18);
  border-radius: 50%;
  position: absolute;
}

.radar-ring-a {
  inset: 20%;
}

.radar-ring-b {
  inset: 40%;
}

.radar-axis {
  background: rgba(109, 240, 205, 0.12);
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
}

.radar-axis-x {
  height: 1px;
  width: 100%;
}

.radar-axis-y {
  height: 100%;
  width: 1px;
}

.radar-player {
  align-items: center;
  border-radius: 999px;
  display: flex;
  font-size: 0.58rem;
  font-weight: 900;
  height: 2.2rem;
  justify-content: center;
  position: absolute;
  width: 2.2rem;
  z-index: 2;
}

.radar-you {
  background: var(--accent);
  color: var(--accent-ink);
  left: calc(50% - 1.1rem);
  top: calc(50% - 1.1rem);
}

.radar-opponent {
  background: var(--coral);
  color: #32100b;
  right: 15%;
  top: 23%;
}

.arena-copy {
  min-width: 0;
  padding: 1rem;
  position: relative;
  z-index: 2;
}

.arena-copy h3 {
  font-size: 1.8rem;
  line-height: 1.25;
  margin: 0 0 0.75rem;
  max-width: 18ch;
}

.arena-subline,
.voice-copy,
.privacy-note {
  color: var(--muted);
  line-height: 1.65;
}

.arena-subline,
.voice-copy {
  margin: 0;
}

.scoreboard {
  align-items: center;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr auto 1fr;
  margin: 1rem 0;
}

.score-box {
  align-items: center;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  min-height: 5.5rem;
  padding: 0.8rem 1rem;
}

.score-box span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.score-box strong {
  font-size: 3rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.score-you strong {
  color: var(--accent);
}

.score-opponent strong {
  color: var(--coral);
}

.score-divider {
  color: var(--muted);
  font-size: 1.4rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.8rem;
  min-width: 0;
}

.compact-field {
  margin-bottom: 0.65rem;
}

.auth-block {
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
  padding-bottom: 0.35rem;
}

.account-management {
  border-bottom: 1px solid var(--line);
  display: none;
  margin: -0.2rem 0 1rem;
  padding-bottom: 1rem;
}

body[data-authenticated="true"] .account-management {
  display: block;
}

.account-management summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.55rem 0;
}

.account-management summary:focus-visible {
  border-radius: 6px;
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.account-management-body {
  background: rgba(255, 138, 155, 0.06);
  border: 1px solid rgba(255, 138, 155, 0.2);
  border-radius: 12px;
  margin-top: 0.4rem;
  padding: 0.8rem;
}

.account-management-body p {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.55;
  margin: 0 0 0.75rem;
}

.account-management-body button {
  width: 100%;
}

.field > span,
.field-row {
  color: var(--muted);
  font-size: 0.82rem;
}

.field-row {
  align-items: baseline;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-width: 0;
}

.field-row strong {
  color: var(--text);
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.field input[type="text"],
.field input[type="password"],
.field select {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  min-height: 2.8rem;
  min-width: 0;
  outline: none;
  padding: 0.72rem 0.8rem;
  width: 100%;
}

.field input[readonly] {
  color: var(--muted);
}

input[type="range"] {
  accent-color: var(--accent);
  min-height: 2rem;
  width: 100%;
}

.button-row,
.arena-actions {
  display: flex;
  gap: 0.6rem;
  min-width: 0;
}

button {
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 750;
  min-height: 2.85rem;
  padding: 0.72rem 0.95rem;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.secondary {
  background: var(--surface-raised);
  border-color: var(--line);
  color: var(--text);
}

.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.danger {
  background: var(--danger);
  color: #300912;
}

.danger-outline {
  border-color: rgba(255, 138, 155, 0.45);
  color: #ffc2cc;
}

.auth-actions button,
.queue-actions button {
  flex: 1 1 auto;
}

.auth-actions .ghost {
  flex: 0 1 auto;
}

.location-field button {
  width: 100%;
}

.privacy-note {
  border-left: 2px solid var(--line-strong);
  font-size: 0.75rem;
  margin: 1rem 0 0;
  padding-left: 0.75rem;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--text);
}

.arena-actions {
  align-items: stretch;
}

.ready-button {
  flex: 0 0 8rem;
}

.pulse-button {
  align-items: center;
  background: var(--coral);
  color: #32100b;
  display: flex;
  flex: 1;
  justify-content: space-between;
  min-height: 4rem;
  overflow: hidden;
  padding-inline: 1.25rem;
  position: relative;
}

.pulse-button span {
  font-size: 1.25rem;
  text-transform: uppercase;
}

.pulse-button small {
  font-size: 0.7rem;
}

.pulse-button:not(:disabled)::after {
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: inherit;
  content: "";
  inset: 0;
  position: absolute;
  animation: pulse-border 1.2s ease-out infinite;
}

.pulse-button.pulse-hit {
  filter: brightness(1.15);
  transform: scale(0.985);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.status-item {
  border-left: 1px solid var(--line);
  min-width: 0;
  padding: 0.25rem 0.85rem;
}

.status-item:first-child {
  border-left: 0;
  padding-left: 0;
}

.status-label {
  color: var(--muted);
  display: block;
  font-size: 0.7rem;
  margin-bottom: 0.35rem;
}

.status-item strong {
  display: block;
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.voice-copy {
  margin-bottom: 1rem;
}

.voice-panel audio {
  margin-top: 0.75rem;
  width: 100%;
}

.safety-card {
  background: rgba(255, 138, 155, 0.045);
  border: 1px solid rgba(255, 138, 155, 0.2);
  border-radius: var(--radius-md);
  margin-top: 1rem;
  padding: 0.9rem;
}

.safety-card > div:first-child {
  margin-bottom: 0.8rem;
}

.safety-card p {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.55;
  margin: 0;
}

.safety-card .mode-label {
  color: var(--danger);
  margin-bottom: 0.2rem;
}

.safety-category {
  margin-bottom: 0.7rem;
}

.safety-actions button {
  flex: 1 1 0;
}

.safety-card .safety-status {
  color: var(--text);
  min-height: 1.2em;
  padding-top: 0.65rem;
}

.live-dot {
  gap: 0.4rem;
}

.live-dot > span {
  background: var(--success);
  border-radius: 50%;
  height: 0.45rem;
  width: 0.45rem;
}

.log-list {
  display: grid;
  gap: 0.45rem;
  list-style: none;
  margin: 0;
  max-height: 13rem;
  overflow: auto;
  padding: 0;
}

.log-list li {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0.2rem;
}

.log-time {
  color: var(--accent);
  flex: 0 0 3.2rem;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.log-text {
  line-height: 1.45;
}

.legal-shell {
  margin: 0 auto;
  max-width: 820px;
  min-height: 100vh;
  padding: 2rem 1rem 3rem;
}

.back-link {
  display: inline-block;
  margin: 0 0 1rem 0.25rem;
}

.legal-panel {
  overflow: visible;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

.legal-panel h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.15;
  margin: 0 0 1rem;
}

.legal-lead {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.8;
  margin: 0 0 2rem;
}

.legal-panel section {
  border-top: 1px solid var(--line);
  padding: 1.35rem 0 0.2rem;
}

.legal-panel h2 {
  font-size: 1.05rem;
  margin: 0 0 0.65rem;
}

.legal-panel section p,
.legal-panel li {
  color: var(--muted);
  line-height: 1.8;
}

.legal-panel ul {
  padding-left: 1.25rem;
}

.legal-updated {
  color: var(--muted);
  font-size: 0.75rem;
  margin: 1.5rem 0 0;
}

@keyframes radar-sweep {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-border {
  from {
    opacity: 0.8;
    transform: scale(0.98);
  }
  to {
    opacity: 0;
    transform: scale(1.08);
  }
}

@media (max-width: 1100px) {
  .arena-panel,
  .setup-panel,
  .status-panel,
  .voice-panel,
  .log-panel {
    grid-column: 1 / -1;
  }

  .arena-panel {
    min-height: auto;
  }

  .status-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    row-gap: 1rem;
  }

  .status-item:nth-child(5) {
    border-left: 0;
    padding-left: 0;
  }
}

@media (max-width: 720px) {
  .shell {
    padding: 0.8rem 0.8rem max(1.5rem, env(safe-area-inset-bottom));
  }

  .app-header h1 {
    font-size: 1.45rem;
  }

  .eyebrow {
    font-size: 0.62rem;
  }

  .brand-mark {
    flex-basis: 36px;
    height: 36px;
    width: 36px;
  }

  .panel {
    border-radius: 18px;
    padding: 1rem;
  }

  .arena-stage {
    grid-template-columns: 1fr;
  }

  .radar {
    max-width: 13rem;
  }

  .arena-copy {
    padding: 1rem 0 0;
  }

  .arena-copy h3 {
    font-size: 1.4rem;
    max-width: none;
  }

  .score-box {
    align-items: flex-start;
    flex-direction: column;
    min-height: 5rem;
  }

  .score-box strong {
    font-size: 2.4rem;
  }

  .arena-actions,
  .button-row {
    flex-wrap: wrap;
  }

  .ready-button {
    flex: 1 1 100%;
  }

  .pulse-button {
    flex-basis: 100%;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.45rem;
  }

  .status-item:nth-child(odd) {
    border-left: 0;
    padding-left: 0;
  }

  .status-item:nth-child(5) {
    border-left: 0;
  }
}

@media (max-width: 430px) {
  .app-header {
    align-items: flex-start;
    gap: 0.75rem;
  }

  .app-header > .pill {
    max-width: 5.5rem;
    overflow: hidden;
    padding-inline: 0.5rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-header h1 {
    font-size: 1.28rem;
  }

  .scoreboard {
    gap: 0.4rem;
  }

  .score-box {
    padding: 0.7rem;
  }

  .auth-actions button,
  .queue-actions button,
  .safety-actions button {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}
