:root {
  color-scheme: dark;
  font-family: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;
  --bg-top: #111525;
  --bg-bottom: #03040a;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f7ff;
  --accent: #6c63ff;
  --accent-2: #21d4fd;
  --danger: #ff8a7a;
  --success: #61e8a2;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 25% 15%, rgba(108, 99, 255, 0.15), transparent 45%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: clamp(12px, 2vw, 32px);
}

.site-frame {
  width: min(1200px, 100%);
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 2vw, 32px);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(14px, 2vw, 24px);
  border-radius: 22px;
  border: 1px solid var(--surface-strong);
  background: rgba(7, 8, 16, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  margin: 0;
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  letter-spacing: 0.2em;
}

.controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.controls label {
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.7;
}

.controls button {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--surface-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.controls button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.35);
}

.menu-shell {
  width: min(880px, 100%);
  background: rgba(4, 6, 18, 0.75);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: clamp(22px, 4vw, 40px);
  box-shadow: 0 35px 120px rgba(0, 0, 0, 0.65);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(18px, 3vw, 32px);
}

.controls input[type="range"] {
  width: 150px;
  accent-color: var(--accent-2);
}

.site-main {
  border-radius: 32px;
  border: 1px solid var(--surface-strong);
  background: rgba(7, 8, 16, 0.92);
  padding: clamp(18px, 2vw, 36px);
}

.spectator-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: 16px;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.spectator-banner.visible {
  opacity: 1;
  transform: translateY(0);
}

.spectator-chip {
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.spectator-banner .subtle {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 0.7rem;
  opacity: 0.6;
}

.battlefield-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: clamp(16px, 3vw, 28px);
}

.battlefield-header h2 {
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
}

.battlefield-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  letter-spacing: 0.2em;
  font-size: 0.7rem;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.03);
}

.chip.status.offline {
  border-color: rgba(255, 138, 122, 0.4);
  color: var(--danger);
}

.chip.status.online {
  border-color: rgba(97, 232, 162, 0.4);
  color: var(--success);
}

.chip.status.error {
  border-color: rgba(255, 219, 159, 0.4);
  color: #ffdba1;
}

.match-layout {
  display: grid;
  grid-template-columns: minmax(160px, 0.7fr) minmax(360px, 1fr) minmax(160px, 0.7fr);
  gap: clamp(14px, 2vw, 28px);
  align-items: stretch;
}

.match-core {
  display: flex;
  justify-content: center;
}

.board-card {
  width: 100%;
  padding: clamp(16px, 2vw, 24px);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(165deg, rgba(9, 11, 24, 0.96), rgba(3, 4, 10, 0.95));
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
}

.board-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.board-label {
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.board-score {
  font-size: 1.1rem;
  font-weight: 600;
}

.opponent-card .board-score {
  font-size: 0.95rem;
  opacity: 0.85;
}

.board-meta {
  display: none;
}

.board-card canvas {
  width: min(380px, 70vw);
  height: auto;
  border-radius: 16px;
  background: #02030a;
}

.board-card.is-ko canvas {
  filter: blur(3px) saturate(0.2) brightness(0.8);
  opacity: 0.35;
}

.board-card.is-ko .board-title,
.board-card.is-ko .board-meta {
  opacity: 0.4;
}

.board-ko-flag {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(3, 4, 12, 0.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.board-card.is-ko .board-ko-flag {
  opacity: 1;
}

.opponent-rail {
  min-height: 100%;
  border-radius: 28px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  padding: 14px;
}

body.multi-active .opponent-rail:empty::after {
  content: "EN ATTENTE";
  letter-spacing: 0.3em;
  font-size: 0.7rem;
  opacity: 0.45;
}

.opponent-card {
  width: 100%;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 8, 15, 0.94);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.opponent-card.is-ko {
  opacity: 0.6;
}

.opponent-card canvas {
  width: 100%;
  min-width: 220px;
  max-width: 320px;
  margin: 0 auto;
  height: auto;
  border-radius: 12px;
}

.opponent-card-full canvas {
  width: clamp(300px, 32vw, 360px);
}

.opponent-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  text-transform: uppercase;
  opacity: 0.7;
}

body.duo-layout .match-layout {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
}

body.duo-layout .opponent-rail:first-child {
  display: none;
}

body.duo-layout .opponent-rail:last-child {
  border-style: solid;
}

.menu-console {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(260px, 0.8fr);
  gap: clamp(20px, 3vw, 36px);
}

.menu-column {
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: clamp(22px, 3vw, 36px);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 20px;
}


button.primary,
button.secondary,
button.ghost {
  font-size: 0.95rem;
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #030307;
  box-shadow: 0 12px 30px rgba(33, 212, 253, 0.35);
}

button.secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
}

button.ghost {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  color: var(--text);
}

button.primary:hover,
button.secondary:hover,
button.ghost:hover {
  transform: translateY(-2px);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 4, 12, 0.92);
  backdrop-filter: blur(28px);
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: clamp(18px, 4vw, 48px);
  z-index: 10;
}

.overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.overlay#menu {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.6)),
    url("https://i.redd.it/s0ck9tx1wcm21.jpg") center/cover;
}

.overlay-content {
  width: min(720px, 100%);
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(150deg, rgba(7, 9, 18, 0.97), rgba(4, 5, 12, 0.95));
  padding: clamp(22px, 4vw, 40px);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
}

.overlay-content.menu-shell {
  width: min(920px, 100%);
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}

.menu-pane {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.menu-pane h2 {
  margin: 0;
}

.menu-shell {
  width: min(880px, 100%);
  background: rgba(4, 6, 18, 0.75);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: clamp(22px, 4vw, 40px);
  box-shadow: 0 35px 120px rgba(0, 0, 0, 0.65);
.menu-shell {
  width: min(880px, 100%);
  background: rgba(4, 6, 18, 0.75);
  border-radius: 32px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: clamp(22px, 4vw, 40px);
  box-shadow: 0 35px 120px rgba(0, 0, 0, 0.65);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(18px, 3vw, 32px);
}
.panel {
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: clamp(18px, 3vw, 30px);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero-panel {
  background: rgba(0, 0, 0, 0.55);
}

.control-panel {
  background: rgba(3, 5, 18, 0.75);
}

.hero-header h2 {
  margin: 6px 0 0;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hero-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.block {
  width: 100%;
}

.surface-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.surface-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.tetromino-strip {
  display: flex;
  gap: 6px;
}

.tetromino {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  background: #fff;
  opacity: 0.8;
}

.tetromino.t {
  background: #ff6bd6;
}

.tetromino.o {
  background: #ffd447;
}

.tetromino.l {
  background: #ff8a34;
}

.tetromino.i {
  background: #48d7ff;
}

.tetromino.s {
  background: #61e8a2;
}

.card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-card .field + .field {
  margin-top: 6px;
}

.status-card {
  gap: 8px;
}

.status-label {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  opacity: 0.65;
}
.field-row {
  display: flex;
  gap: 8px;
}

.field-row input {
  flex: 1;
}

.field input {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  padding: 10px 14px;
}

.field input:focus {
  outline: none;
  border-color: var(--accent-2);
}

.multi-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lobby-hints {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.hint-title {
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.6;
  margin: 0 0 4px;
}

.hint-copy {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.8;
}

.menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.menu-quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
}

.status-line {
  min-height: 18px;
  font-size: 0.85rem;
  color: var(--accent-2);
}

.status-line.error {
  color: var(--danger);
}

.gameover-panel {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gameover-header h2 {
  margin: 6px 0 0;
}

.scoreboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}


.scoreboard-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

.scoreboard-note {
  text-align: center;
  opacity: 0.75;
  font-size: 0.9rem;
}

.scoreboard-rankset {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 90px;
  font-weight: 600;
}

.scoreboard-emoji {
  font-size: 1.4rem;
}

.scoreboard-rank {
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}

.scoreboard-name {
  flex: 1;
  font-weight: 600;
  text-align: left;
}

.scoreboard-points-wrap {
  min-width: 130px;
  text-align: right;
}

.scoreboard-points {
  font-size: 1rem;
  font-weight: 600;
}

.gameover-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.lobby-modal {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lobby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.02);
}

.lobby-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

@media (max-width: 960px) {
  .match-layout {
    grid-template-columns: 1fr;
  }

  .opponent-rail {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    gap: 14px;
    align-items: flex-start;
  }

  .controls {
    flex-wrap: wrap;
  }

  .board-card canvas,
  body.duo-layout .opponent-card canvas {
    width: min(320px, 90vw);
  }
}
