:root {
  color-scheme: dark;
  --bg: #050812;
  --panel: rgba(9, 15, 29, 0.9);
  --line: rgba(108, 235, 255, 0.28);
  --cyan: #47eaff;
  --coral: #ff6a5d;
  --text: #f5f8ff;
  --muted: #9eb0ce;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 14% 8%, rgba(71, 234, 255, 0.22), transparent 28rem),
    radial-gradient(circle at 88% 14%, rgba(255, 106, 93, 0.2), transparent 26rem),
    linear-gradient(180deg, #08111f 0%, var(--bg) 52%, #02040a 100%);
}

button, input { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.topbar, .fight-call, .scorebar, footer {
  border: 1px solid var(--line);
  background: rgba(5, 10, 20, 0.74);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.38);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}

.brand img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  filter: drop-shadow(0 0 14px rgba(71, 234, 255, 0.48));
}

.brand span { display: grid; line-height: 1; }
.brand small, .eyebrow {
  color: #64fff2;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}
.brand strong { font-size: 1.42rem; letter-spacing: 0; }

.top-actions, .fight-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mode, .secondary-button, .primary-button, .icon-button {
  border: 1px solid rgba(104, 232, 255, 0.34);
  color: var(--text);
  background: rgba(12, 19, 34, 0.9);
  border-radius: 999px;
  text-decoration: none;
  font-weight: 900;
}

.mode {
  padding: 9px 12px;
  color: #77fff4;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
}

.secondary-button, .primary-button, .icon-button {
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.secondary-button:hover, .primary-button:hover, .icon-button:hover {
  transform: translateY(-1px);
  border-color: rgba(104, 232, 255, 0.72);
}

.secondary-button:disabled, .primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.secondary-button {
  padding: 10px 13px;
  font-size: 0.76rem;
  letter-spacing: 0.06em;
}

.primary-button {
  padding: 13px 18px;
  background: linear-gradient(135deg, rgba(71, 234, 255, 0.28), rgba(255, 106, 93, 0.22));
}

.icon-button {
  width: 42px;
  height: 42px;
}

.fight-call {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  margin: 14px 0;
  padding: 14px;
  border-radius: 18px;
}

.fight-call span {
  display: block;
  color: #64fff2;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.fight-call strong { font-size: 1rem; }

#roomLink {
  grid-column: 1 / -1;
  width: 100%;
  min-width: 0;
  display: none;
  padding: 11px 14px;
  border: 1px solid rgba(104, 232, 255, 0.3);
  border-radius: 12px;
  color: #dce8ff;
  background: rgba(0, 0, 0, 0.28);
}

#roomLink.visible { display: block; }

.scorebar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 18px 18px 0 0;
}

.team, .clock {
  display: flex;
  align-items: center;
  gap: 12px;
}

.team span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team strong {
  font-size: clamp(2rem, 6vw, 3.35rem);
  line-height: 1;
}

.team.cyan strong { color: var(--cyan); text-shadow: 0 0 18px rgba(71, 234, 255, 0.65); }
.team.coral { justify-content: flex-end; }
.team.coral strong { color: var(--coral); text-shadow: 0 0 18px rgba(255, 106, 93, 0.65); }

.clock {
  display: grid;
  justify-items: center;
  min-width: 154px;
  padding: 8px 15px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
}

.clock strong { font-size: 1rem; }
.clock span {
  color: #64fff2;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.arena-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(104, 232, 255, 0.25);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  background: #030711;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 260px;
  background: #030711;
}

.event-banner {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -8px);
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, 0.58);
  opacity: 0;
  pointer-events: none;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: opacity 160ms ease, transform 160ms ease;
}

.event-banner.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.overlay {
  position: absolute;
  inset: auto 24px 24px 24px;
  max-width: 560px;
  padding: 22px;
  border: 1px solid rgba(104, 232, 255, 0.34);
  border-radius: 18px;
  background: rgba(4, 8, 18, 0.86);
  backdrop-filter: blur(12px);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.48);
}

.overlay.hidden { display: none; }

.overlay h1 {
  margin: 6px 0 8px;
  font-size: clamp(2.2rem, 7vw, 4.5rem);
  line-height: 0.92;
}

.overlay p {
  margin: 0 0 16px;
  color: #c9d7ee;
}

.control-guide {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.control-guide div {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.control-guide strong {
  color: #64fff2;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.control-guide span {
  color: #dbe7ff;
  font-size: 0.88rem;
}

.touch-controls {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.touch-controls button {
  min-height: 50px;
  border: 1px solid rgba(104, 232, 255, 0.26);
  border-radius: 14px;
  color: #eaf4ff;
  background: rgba(10, 18, 34, 0.9);
  font-weight: 1000;
  letter-spacing: 0.06em;
  touch-action: manipulation;
}

.touch-controls button.is-down, .touch-controls .go.is-down {
  border-color: rgba(71, 234, 255, 0.9);
  background: rgba(71, 234, 255, 0.2);
}

.touch-controls .boost {
  border-color: rgba(255, 106, 93, 0.44);
  background: rgba(255, 106, 93, 0.18);
}

footer {
  margin-top: 16px;
  padding: 12px;
  border-radius: 16px;
  color: var(--muted);
  text-align: center;
  font-size: 0.84rem;
}

@media (max-width: 760px) {
  .shell { width: min(100% - 18px, 1180px); padding-top: 10px; }
  .topbar, .fight-call { align-items: stretch; }
  .topbar, .fight-call, .scorebar { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .top-actions, .fight-actions { justify-content: stretch; }
  .fight-actions > * { flex: 1 1 auto; text-align: center; }
  .scorebar { grid-template-columns: 1fr; }
  .team, .team.coral { justify-content: space-between; }
  .clock { order: -1; }
  .overlay {
    position: relative;
    inset: auto;
    max-width: none;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
  .touch-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
