:root {
  color-scheme: dark;
  --ink: #f7f8ff;
  --muted: #a8aec8;
  --surface: rgba(20, 24, 48, 0.78);
  --surface-strong: #151a34;
  --line: rgba(255, 255, 255, 0.1);
  --violet: #8c6cff;
  --cyan: #53d7ff;
  --lime: #c9ff64;
  --red: #ff5f72;
  --blue: #54a7ff;
  --yellow: #ffd85a;
  --green: #55df9a;
  --shadow: 0 28px 80px rgba(4, 7, 22, 0.45);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, rgba(140, 108, 255, 0.23), transparent 34rem),
    radial-gradient(circle at 88% 6%, rgba(83, 215, 255, 0.16), transparent 28rem),
    linear-gradient(150deg, #090c1c 0%, #0f1430 52%, #090d20 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.site-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 850; letter-spacing: -0.02em; }
.brand-mark { position: relative; width: 40px; aspect-ratio: 1; border: 8px solid var(--violet); border-radius: 50%; box-shadow: inset 0 0 0 5px #0d1127, 0 0 28px rgba(140,108,255,.35); }
.brand-mark::after { content: ""; position: absolute; inset: 6px; border: 3px solid var(--cyan); border-radius: 50%; }

.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-links a { padding: 10px 14px; border-radius: 999px; color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 700; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); background: rgba(255,255,255,.07); }

.hero { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(360px, .92fr); align-items: center; gap: clamp(42px, 7vw, 100px); min-height: calc(100vh - 82px); padding: 74px 0 90px; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 18px; color: var(--cyan); font-size: .76rem; font-weight: 850; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow::before { content: ""; width: 32px; height: 2px; background: currentColor; }
.hero h1, .page-heading h1 { max-width: 780px; margin: 0; font-size: clamp(3.4rem, 8vw, 7.6rem); line-height: .87; letter-spacing: -.07em; }
.hero h1 em { color: var(--lime); font-style: normal; }
.hero-copy { max-width: 620px; margin: 30px 0; color: var(--muted); font-size: clamp(1rem, 1.6vw, 1.2rem); line-height: 1.75; }
.hero-actions, .form-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 16px;
  color: #0c1024;
  background: var(--lime);
  text-decoration: none;
  font-weight: 850;
  cursor: pointer;
  transition: transform .18s ease, filter .18s ease, background .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-2px); filter: brightness(1.04); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.button.secondary { color: var(--ink); background: rgba(255,255,255,.07); border-color: var(--line); }
.button.ghost { color: var(--muted); background: transparent; border-color: var(--line); }
.button.danger { color: #fff; background: rgba(255,95,114,.16); border-color: rgba(255,95,114,.35); }
.button.small { min-height: 42px; padding-inline: 16px; border-radius: 13px; font-size: .9rem; }

.hero-visual { position: relative; padding: 32px; }
.hero-visual::before { content: ""; position: absolute; inset: 12% -5% -5% 12%; border-radius: 50%; background: rgba(83,215,255,.13); filter: blur(42px); }
.preview-board, .game-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 34px;
  background: linear-gradient(145deg, rgba(29,35,69,.97), rgba(14,18,42,.92));
  box-shadow: var(--shadow), inset 0 1px rgba(255,255,255,.12);
  transform: rotate(2.5deg);
}
.preview-cell, .board-cell { position: relative; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.09); border-radius: 22px; background: linear-gradient(145deg, rgba(255,255,255,.075), rgba(255,255,255,.025)); }
.preview-cell { overflow: hidden; }
.preview-ring, .ring { position: absolute; inset: 50% auto auto 50%; border: clamp(4px, .7vw, 7px) solid currentColor; border-radius: 50%; transform: translate(-50%, -50%); filter: drop-shadow(0 5px 9px rgba(0,0,0,.22)); }
.pending-ring { opacity: .72; filter: drop-shadow(0 0 9px currentColor); animation: pendingRing .55s ease-in-out infinite alternate; pointer-events: none; }
@keyframes pendingRing { to { opacity: 1; } }
.preview-ring.large, .ring.large { width: 78%; height: 78%; }
.preview-ring.medium, .ring.medium { width: 54%; height: 54%; }
.preview-ring.small, .ring.small { width: 30%; height: 30%; }
.red { color: var(--red); }
.blue { color: var(--blue); }
.yellow { color: var(--yellow); }
.green { color: var(--green); }

.feature-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: -42px; padding-bottom: 70px; }
.feature { padding: 20px; border: 1px solid var(--line); border-radius: 20px; color: var(--muted); background: rgba(255,255,255,.035); }
.feature strong { display: block; margin-bottom: 6px; color: var(--ink); }

.page-main { padding: 58px 0 90px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 38px; }
.page-heading h1 { font-size: clamp(2.8rem, 6vw, 5.4rem); }
.page-heading p:last-child { max-width: 520px; color: var(--muted); line-height: 1.7; }

.panel { border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: 0 24px 65px rgba(3,6,20,.24); backdrop-filter: blur(18px); }
.panel-body { padding: clamp(22px, 4vw, 36px); }
.panel h2, .panel h3 { margin-top: 0; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

.game-layout { display: grid; grid-template-columns: minmax(340px, 1fr) minmax(280px, 360px); gap: 22px; align-items: start; }
.board-panel { padding: clamp(16px, 3vw, 28px); }
.game-board { width: min(100%, 650px); margin: 0 auto; transform: none; }
.board-cell { width: 100%; padding: 0; color: inherit; cursor: pointer; transition: border-color .18s, background .18s, box-shadow .18s; }
.board-cell:hover:not(:disabled) { border-color: rgba(201,255,100,.55); background: rgba(201,255,100,.075); box-shadow: inset 0 0 0 1px rgba(201,255,100,.14); }
.board-cell:disabled { cursor: default; }
.board-cell.legal { box-shadow: inset 0 0 0 1px rgba(201,255,100,.15); }
.board-cell.illegal { cursor: not-allowed; opacity: .68; }
.board-cell.illegal:hover { border-color: rgba(255,95,114,.5); background: rgba(255,95,114,.07); box-shadow: inset 0 0 0 1px rgba(255,95,114,.12); }
.board-cell.winning { animation: winPulse 1s ease-in-out infinite alternate; border-color: var(--lime); }
@keyframes winPulse { to { box-shadow: 0 0 28px rgba(201,255,100,.32), inset 0 0 0 1px var(--lime); } }

.game-sidebar { display: grid; gap: 14px; }
.status-card { padding: 20px; }
.status-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.status-row + .status-row { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.turn-indicator { display: inline-flex; align-items: center; gap: 9px; font-weight: 850; }
.color-dot { width: 13px; aspect-ratio: 1; border-radius: 50%; background: currentColor; box-shadow: 0 0 18px currentColor; }
.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; text-align: center; }
.score-player { padding: 14px 10px; border-radius: 16px; background: rgba(255,255,255,.04); }
.score-player strong { display: block; font-size: 1.8rem; }
.score-player.active { outline: 1px solid rgba(201,255,100,.5); background: rgba(201,255,100,.06); }
.team-colors { display: inline-flex; gap: 5px; margin-top: 7px; }
.team-colors i { display: block; width: 18px; aspect-ratio: 1; border: 4px solid currentColor; border-radius: 50%; }

.reserve-picker { display: grid; gap: 14px; }
.reserve-row { padding: 12px; border: 1px solid var(--line); border-radius: 20px; background: rgba(255,255,255,.025); transition: opacity .18s, border-color .18s, background .18s; }
.reserve-row.active { border-color: color-mix(in srgb, var(--reserve-color) 48%, transparent); background: color-mix(in srgb, var(--reserve-color) 7%, transparent); }
.reserve-row.inactive { opacity: .62; filter: saturate(.5); }
.reserve-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 10px; font-size: .82rem; font-weight: 850; }
.reserve-label span { display: inline-flex; align-items: center; gap: 8px; }
.reserve-label small { color: var(--muted); font-size: .68rem; font-weight: 700; }
.piece-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.piece-button { position: relative; display: grid; place-items: center; min-height: 88px; border: 1px solid var(--line); border-radius: 18px; color: var(--reserve-color, var(--violet)); background: rgba(255,255,255,.035); cursor: pointer; }
.piece-button:hover:not(:disabled), .piece-button.selected { border-color: currentColor; background: color-mix(in srgb, currentColor 10%, transparent); }
.piece-button:disabled { opacity: .35; cursor: not-allowed; }
.reserve-row.inactive .piece-button:disabled { opacity: .72; }
.piece-icon { display: block; border: 6px solid currentColor; border-radius: 50%; }
.piece-icon.small { width: 24px; height: 24px; }
.piece-icon.medium { width: 38px; height: 38px; }
.piece-icon.large { width: 52px; height: 52px; }
.piece-count { position: absolute; right: 9px; bottom: 7px; min-width: 22px; padding: 2px 6px; border-radius: 99px; color: var(--ink); background: rgba(255,255,255,.1); font-size: .72rem; font-weight: 800; }

.notice { padding: 13px 15px; border: 1px solid rgba(83,215,255,.22); border-radius: 14px; color: #d9f7ff; background: rgba(83,215,255,.08); line-height: 1.45; }
.notice.error { border-color: rgba(255,95,114,.3); color: #ffd7dc; background: rgba(255,95,114,.1); }
.notice.success { border-color: rgba(85,223,154,.3); color: #d7ffea; background: rgba(85,223,154,.09); }

.forms-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field { display: grid; gap: 8px; }
.field + .field { margin-top: 16px; }
.field label { color: var(--muted); font-size: .84rem; font-weight: 750; }
.field input, .field select {
  width: 100%; min-height: 50px; padding: 0 15px; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: rgba(6,9,25,.55); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(83,215,255,.11); }
.field input.code-input { text-transform: uppercase; letter-spacing: .2em; font-weight: 850; }

.room-code { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 18px; border: 1px dashed rgba(201,255,100,.42); border-radius: 18px; background: rgba(201,255,100,.055); }
.room-code strong { font-size: clamp(1.6rem, 4vw, 2.6rem); letter-spacing: .16em; }
.copy-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.players-list { display: grid; gap: 10px; margin: 18px 0; }
.player-line { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 15px; background: rgba(255,255,255,.045); }
.status-pill { padding: 5px 9px; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.07); font-size: .72rem; font-weight: 800; }
.status-pill.ready { color: #bfffdc; background: rgba(85,223,154,.12); }
.connection-dot { display: inline-block; width: 8px; aspect-ratio: 1; margin-right: 7px; border-radius: 50%; background: #6b718c; }
.connection-dot.online { background: var(--green); box-shadow: 0 0 10px var(--green); }

.rules-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.rule-card { padding: 22px; }
.rule-card h2 { font-size: 1.15rem; }
.rule-card p, .rule-card li { color: var(--muted); line-height: 1.65; }
.rule-card.wide { grid-column: 1 / -1; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(3,5,16,.75); backdrop-filter: blur(12px); }
.modal { width: min(520px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: 26px; background: #151a34; box-shadow: var(--shadow); text-align: center; }
.modal h2 { margin: 8px 0 12px; font-size: clamp(2rem, 5vw, 3.2rem); letter-spacing: -.04em; }

.footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px 0 42px; border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; min-height: auto; padding-top: 58px; }
  .hero-visual { width: min(580px, 100%); margin: 0 auto; }
  .feature-strip { margin-top: 0; }
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar { grid-template-columns: repeat(2, 1fr); }
  .game-sidebar > :first-child { grid-column: 1 / -1; }
}

@media (max-width: 620px) {
  .site-shell { width: min(100% - 20px, 1180px); }
  .site-header { min-height: 68px; }
  .nav-links a { padding: 8px 9px; font-size: .8rem; }
  .nav-links a:nth-child(2) { display: none; }
  .hero { padding: 44px 0 60px; }
  .hero h1 { font-size: clamp(3rem, 17vw, 5.3rem); }
  .hero-visual { padding: 6px; }
  .preview-board, .game-board { gap: 7px; padding: 10px; border-radius: 24px; }
  .preview-cell, .board-cell { border-radius: 15px; }
  .feature-strip, .forms-grid, .rules-grid, .game-sidebar { grid-template-columns: 1fr; }
  .game-sidebar > :first-child, .rule-card.wide { grid-column: auto; }
  .page-heading { display: block; }
  .page-heading h1 { font-size: clamp(2.8rem, 14vw, 4.4rem); }
  .scoreboard { gap: 6px; }
  .score-player { padding-inline: 6px; }
  .piece-button { min-height: 76px; }
  .footer { display: block; }
}

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