:root {
  color-scheme: dark;
  --bg: #121313;
  --panel: #202322;
  --panel-2: #2b2d29;
  --ink: #f5f1e8;
  --muted: #b9b3a4;
  --line: rgba(255, 255, 255, 0.12);
  --orange: #ff8a24;
  --orange-dark: #8f3f10;
  --purple: #7d5cff;
  --purple-dark: #2d2469;
  --yellow: #ffd35a;
  --green: #52e09b;
  --red: #ff4d4d;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(rgba(18, 19, 19, 0.84), rgba(18, 19, 19, 0.9)),
    url("./assets/venue-layout.png") center / cover fixed,
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #2b2c2a;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

button:hover,
button:focus-visible {
  border-color: rgba(255, 255, 255, 0.32);
  background: #373933;
  outline: none;
}

button:active {
  transform: translateY(1px);
}

.arena-shell {
  width: min(1280px, 100%);
  height: 100vh;
  min-height: 0;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(360px, 560px) minmax(220px, 1fr);
  gap: 12px;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid rgba(255, 138, 36, 0.42);
  box-shadow: 0 0 22px rgba(255, 138, 36, 0.3), 0 0 28px rgba(125, 92, 255, 0.18);
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 2.3rem);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
}

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1fr;
  gap: 8px;
}

.score-card,
.clock-card {
  min-height: 68px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(31, 32, 29, 0.86);
  display: grid;
  place-items: center;
  text-align: center;
}

.score-card span,
.clock-card span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.score-card strong,
.clock-card strong {
  font-size: clamp(1.8rem, 4vw, 2.7rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-card.orange {
  border-color: rgba(255, 138, 36, 0.42);
}

.score-card.purple {
  border-color: rgba(125, 92, 255, 0.44);
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#startBtn {
  color: #171712;
  background: var(--green);
  border-color: rgba(82, 224, 155, 0.9);
}

.game-frame {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #050505;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.38);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  touch-action: none;
  cursor: crosshair;
}

.match-message {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  max-width: min(680px, calc(100% - 28px));
  min-height: 42px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(18, 19, 19, 0.74);
  color: var(--ink);
  font-weight: 900;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.touch-controls {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 150px;
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 6px;
  justify-content: center;
}

.touch-controls button {
  width: 46px;
  height: 46px;
  min-height: 46px;
  padding: 0;
  background: rgba(245, 241, 232, 0.13);
  backdrop-filter: blur(6px);
}

.touch-controls [data-control="up"] {
  grid-column: 2;
}

.touch-controls [data-control="left"] {
  grid-column: 1;
  grid-row: 2;
}

.touch-controls [data-control="down"] {
  grid-column: 2;
  grid-row: 2;
}

.touch-controls [data-control="right"] {
  grid-column: 3;
  grid-row: 2;
}

.modebar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.mode-button.active {
  border-color: rgba(255, 211, 90, 0.88);
  color: #171712;
  background: var(--yellow);
}

@media (max-width: 900px) {
  .arena-shell {
    padding: 10px;
    gap: 10px;
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .brand {
    justify-content: center;
  }

  .brand h1 {
    text-align: center;
    white-space: normal;
  }

  .brand-logo {
    width: 46px;
    height: 46px;
  }

  .actions,
  .modebar {
    grid-template-columns: repeat(3, 1fr);
  }

  #gameCanvas {
    min-height: 0;
  }
}

@media (max-width: 520px) {
  .scoreboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .score-card,
  .clock-card {
    min-height: 58px;
    padding: 8px 6px;
  }

  .score-card span,
  .clock-card span {
    font-size: 0.62rem;
  }

  .touch-controls {
    width: 128px;
    right: 10px;
    bottom: 10px;
    grid-template-columns: repeat(3, 38px);
    grid-template-rows: repeat(3, 38px);
  }

  .touch-controls button {
    width: 38px;
    height: 38px;
    min-height: 38px;
  }
}
