/* ============================================================
   NEON RIFT — LOBBY
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;500;600;700&display=swap');

:root {
  --bg-base: #07071a;
  --bg-surface: #0c0c22;
  --bg-panel: #0f0f2e;
  --bg-raised: #141438;
  --neon-cyan: #00e5ff;
  --neon-magenta: #e040fb;
  --neon-purple: #7c4dff;
  --neon-green: #00e676;
  --neon-amber: #ffc400;
  --text-primary: #d8d8f0;
  --text-muted: #7a7aaa;
  --border-cyan: rgba(0, 229, 255, 0.4);
  --border-soft: rgba(0, 229, 255, 0.14);
  --font-display: 'Orbitron', 'Courier New', monospace;
  --font-body: 'Rajdhani', 'Segoe UI', sans-serif;
  --nav-height: 64px;
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

body.sheet-locked {
  overflow: hidden;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

/* ── Background ──────────────────────────────────────────── */
.lobby-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 60% 50% at 15% 50%, rgba(0, 90, 200, 0.07) 0%, transparent 100%),
    radial-gradient(ellipse 50% 40% at 85% 20%, rgba(124, 77, 255, 0.06) 0%, transparent 100%),
    var(--bg-base);
  pointer-events: none;
}

.lobby-bg__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 229, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 229, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
}

/* ── Layout ──────────────────────────────────────────────── */
.lobby {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px 48px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand__mark {
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-surface);
}

.tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 9px;
  font-weight: 700;
  color: var(--text-muted);
}

.tab.is-active {
  background: var(--bg-raised);
  color: var(--neon-cyan);
  box-shadow: inset 0 0 0 1px var(--border-cyan);
}

.badge {
  background: var(--neon-magenta);
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.view--play {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.catalog {
  min-width: 0;
}

.empty {
  grid-column: 1 / -1;
  color: var(--text-muted);
  padding: 24px 0;
  text-align: center;
}

/* ── Chips ───────────────────────────────────────────────── */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.chip.is-active {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
  color: #001018;
}

/* ── Game tiles ──────────────────────────────────────────── */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.tile {
  --c: var(--neon-cyan);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 150px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: linear-gradient(160deg, var(--bg-raised), var(--bg-surface));
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.tile::before {
  content: "";
  position: absolute;
  right: -30%;
  bottom: -60%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.08;
}

.tile:hover {
  transform: translateY(-3px);
  border-color: var(--c);
  box-shadow: 0 0 22px color-mix(in srgb, var(--c) 30%, transparent);
}

.tile.is-selected {
  border-color: var(--c);
  box-shadow: 0 0 0 2px var(--c), 0 0 22px color-mix(in srgb, var(--c) 35%, transparent);
}

.tile__icon {
  font-size: 38px;
  line-height: 1;
  margin-bottom: auto;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--c) 60%, transparent));
}

.tile__name {
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 10px;
}

.tile__meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.tile__live {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  color: var(--neon-green);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--neon-green);
  box-shadow: 0 0 8px var(--neon-green);
}

/* ── Create sheet ────────────────────────────────────────── */
.sheet {
  --c: var(--neon-cyan);
  position: sticky;
  top: 16px;
  border: 1px solid var(--border-cyan);
  border-radius: 18px;
  background: var(--bg-panel);
  overflow: hidden;
}

.sheet__grab,
.sheet__close,
.scrim {
  display: none;
}

.sheet__hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 30%, transparent), transparent);
}

.sheet__icon {
  font-size: 46px;
  line-height: 1;
}

.sheet__title {
  font-family: var(--font-display);
  font-size: 18px;
}

.sheet__meta {
  font-size: 14px;
  color: var(--text-muted);
}

.sheet__body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.field__label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
}

.field__hint {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.seg {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
}

.seg button {
  flex: 1 0 40px;
  padding: 9px 0;
  font-weight: 700;
}

.seg button.is-active {
  background: var(--neon-cyan);
  color: #001018;
}

.toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  cursor: pointer;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle__track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-soft);
  transition: background 0.15s;
}

.toggle__track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s, background 0.15s;
}

.toggle input:checked + .toggle__track {
  background: var(--neon-cyan);
}

.toggle input:checked + .toggle__track::after {
  transform: translateX(18px);
  background: #001018;
}

.toggle input:focus-visible + .toggle__track {
  outline: 2px solid var(--neon-cyan);
  outline-offset: 2px;
}

.advanced {
  border-top: 1px dashed var(--border-soft);
  padding-top: 12px;
}

.advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
}

.advanced[open] summary {
  margin-bottom: 12px;
}

.advanced .field + .field {
  margin-top: 12px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--neon-cyan);
}

input[type="password"],
.codebox input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
}

.form-error {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 82, 82, 0.12);
  color: #ff8a80;
  font-size: 14px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--neon-cyan);
  color: var(--neon-cyan);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}

.btn--solid {
  background: var(--neon-cyan);
  color: #001018;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn--create {
  padding: 12px;
  font-size: 15px;
}

/* ── Rooms ───────────────────────────────────────────────── */
.rooms-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.codebox {
  display: flex;
  gap: 8px;
  flex: 0 1 300px;
}

.codebox input {
  border-style: dashed;
  border-color: var(--border-cyan);
  letter-spacing: 0.1em;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.room {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--bg-surface);
}

.room__icon {
  font-size: 24px;
}

.room__info {
  min-width: 0;
}

.room__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
}

.room__meta {
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room__lock {
  font-size: 13px;
}

.status {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 6px;
}

.status--lobby {
  background: rgba(0, 230, 118, 0.15);
  color: var(--neon-green);
}

.status--playing {
  background: rgba(255, 196, 0, 0.15);
  color: var(--neon-amber);
}

.pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

.pip {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  border: 1px solid var(--border-cyan);
}

.pip.is-human {
  background: var(--neon-cyan);
  border-color: var(--neon-cyan);
}

.pip.is-cpu {
  background: var(--neon-purple);
  border-color: var(--neon-purple);
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .lobby {
    padding-bottom: calc(var(--nav-height) + 24px);
  }

  .view--play {
    grid-template-columns: 1fr;
  }

  .tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 55;
    border-radius: 0;
    border-width: 1px 0 0;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(12, 12, 34, 0.97);
  }

  .tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 6px 0;
    font-size: 13px;
  }

  .chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: none;
  }

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

  .tile {
    min-height: 104px;
    padding: 10px;
  }

  .tile__icon {
    font-size: 28px;
  }

  .tile__name {
    font-size: 11px;
  }

  .tile__cat {
    display: none;
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(0, 0, 0, 0.55);
  }

  .sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 70;
    max-height: 86vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    transform: translateY(105%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  }

  .sheet.is-open {
    transform: none;
  }

  .sheet__grab {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--border-cyan);
    margin: 8px auto 0;
  }

  .sheet__close {
    display: block;
    margin-left: auto;
    padding: 4px 8px;
    font-size: 22px;
    color: var(--text-muted);
  }

  .sheet__body {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .btn--create {
    position: sticky;
    bottom: 0;
    box-shadow: 0 -12px 20px var(--bg-panel);
  }

  .codebox,
  .rooms-tools .chips {
    flex-basis: 100%;
    min-width: 0;
  }
}

@media (max-width: 380px) {
  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .sheet {
    transition: none;
  }
}
