:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: #141b2f;
  --panel-strong: #1d2742;
  --line: rgba(148, 163, 184, .22);
  --text: #edf2ff;
  --muted: #a8b3c7;
  --accent: #22d3ee;
  --accent-2: #f59e0b;
  --danger: #fb7185;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(34, 211, 238, .15), transparent 28rem),
    linear-gradient(135deg, #0b1020 0%, #141827 48%, #15101c 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  color: var(--text);
  background: var(--panel-strong);
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, opacity .15s ease;
}

button:hover {
  transform: translateY(-1px);
  background: #263557;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}

button.loading {
  position: relative;
  padding-left: 38px;
}

button.loading::before {
  position: absolute;
  left: 14px;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: var(--accent);
  border-radius: 50%;
  content: "";
  animation: spin .75s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

.topBar,
.loginPage,
.controls,
.playerColumn,
.centerPanel {
  border: 1px solid var(--line);
  background: rgba(20, 27, 47, .88);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .22);
  backdrop-filter: blur(14px);
}

.loginPage {
  display: grid;
  width: min(520px, 100%);
  min-height: calc(100vh - 44px);
  margin: 0 auto;
  padding: 28px;
  align-content: center;
  gap: 22px;
  border-radius: 8px;
}

.loginHero {
  display: flex;
  align-items: center;
  gap: 14px;
}

.loginHero p,
.loginHero h1 {
  margin: 0;
}

.loginHero p {
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.loginHero h1 {
  font-size: 36px;
  line-height: 1;
}

.loginBox {
  display: grid;
  gap: 14px;
}

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

.authTabs button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 900;
  background: rgba(8, 17, 31, .66);
}

.authTabs button.active {
  color: #04111f;
  background: var(--accent);
}

.loginActions {
  display: grid;
}

.loginActions button {
  min-height: 44px;
  border-radius: 8px;
  font-weight: 900;
}

.loginBox p {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.hidden,
.locked {
  display: none;
}

.topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 8px;
}

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

.brandMark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #04111f;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.brand p,
.brand h1 {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.brand h1 {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
}

.statusStrip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.statusStrip span,
.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(8, 17, 31, .66);
}

.controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(130px, 170px) auto auto;
  gap: 12px;
  align-items: end;
  margin-top: 12px;
  padding: 12px;
  border-radius: 8px;
}

.nameField {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.nameField input,
.nameField select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #08111f;
  padding: 0 12px;
  outline: none;
}

.nameField select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--accent) 50%),
    linear-gradient(135deg, var(--accent) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 18px,
    calc(100% - 12px) 18px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

input[readonly] {
  color: var(--accent);
  font-weight: 800;
}

.modeButtons,
.gameButtons {
  display: flex;
  gap: 8px;
}

.modeButtons button,
.gameButtons button,
.mobilePad button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
}

.primary {
  color: #04111f;
  background: var(--accent);
}

.primary:hover {
  background: #67e8f9;
}

.ghost {
  background: rgba(148, 163, 184, .14);
}

.danger {
  background: rgba(251, 113, 133, .18);
  color: #fecdd3;
}

.iconBtn {
  width: 44px;
  padding: 0;
  font-size: 20px;
}

.arena {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(210px, 260px) minmax(300px, 1fr);
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.playerColumn,
.centerPanel {
  border-radius: 8px;
  padding: 12px;
}

.playerColumn.active {
  border-color: rgba(34, 211, 238, .58);
}

.playerHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.playerHeader span,
.stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.playerHeader strong {
  font-size: 18px;
}

.playerHeader b {
  font-size: 28px;
  color: var(--accent);
}

.boardFrame {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #08111f;
}

.boardFrame.muted {
  opacity: .86;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr 112px;
  gap: 8px;
  margin-top: 10px;
}

.stats strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.matchState {
  display: grid;
  gap: 8px;
}

.matchState span {
  color: var(--accent-2);
  font-weight: 900;
  text-transform: uppercase;
  font-size: 12px;
}

.matchState strong {
  font-size: 22px;
  line-height: 1.15;
}

.matchState p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.mobilePad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
}

.mobilePad [data-action="down"],
.mobilePad [data-action="drop"] {
  grid-column: span 3;
}

@media (max-width: 980px) {
  .controls,
  .arena {
    grid-template-columns: 1fr;
  }

  .modeButtons,
  .gameButtons {
    flex-wrap: wrap;
  }

  .modeButtons button {
    flex: 1 1 120px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 12px, 420px);
    padding-top: 6px;
  }

  .topBar {
    align-items: flex-start;
    flex-direction: column;
  }

  .statusStrip {
    justify-content: flex-start;
  }

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

  .stats div:last-child {
    grid-column: span 2;
  }
}
