:root {
  --bg: #070b14;
  --surface: #111827;
  --surface-2: #1a2336;
  --border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc;
  --muted: #94a3b8;
  --cyan: #00e5ff;
  --pink: #ff3b5c;
  --gold: #ffb800;
  --green: #22c55e;
  --radius: 16px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: radial-gradient(circle at top center, #131d36 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--cyan);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.container-narrow {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 16px 48px;
}

.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-badge {
  background: linear-gradient(135deg, var(--cyan), #6366f1);
  color: #050811;
  padding: 4px 10px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 900;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease, background 0.15s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--cyan), #38bdf8);
  color: #050811;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #232f47;
  text-decoration: none;
}

.btn-danger {
  background: rgba(255, 59, 92, 0.16);
  color: #ff6b84;
  border-color: rgba(255, 59, 92, 0.35);
}

.btn-sm {
  padding: 8px 13px;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
}

.card {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.card + .card {
  margin-top: 20px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  background: #0b1120;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus {
  border-color: var(--cyan);
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 1.4rem !important;
  font-weight: 800;
  text-align: center;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.avatar-option {
  background: #0b1120;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 10px 4px;
  font-size: 1.5rem;
  text-align: center;
  cursor: pointer;
}

.avatar-option.selected {
  border-color: var(--cyan);
  background: rgba(0, 229, 255, 0.12);
}

.error-msg {
  background: rgba(255, 59, 92, 0.15);
  border: 1px solid rgba(255, 59, 92, 0.4);
  color: #ff8fa1;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: none;
}

.error-msg.visible {
  display: block;
}

.grid-games {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.game-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-ready {
  background: rgba(34, 197, 94, 0.18);
  color: #4ade80;
}

.badge-preview {
  background: rgba(255, 59, 92, 0.18);
  color: #ff7a90;
}

.badge-soon {
  background: rgba(255, 184, 0, 0.15);
  color: #ffd15c;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  background: #0b1120;
  border: 1px solid var(--border);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  background: rgba(0, 229, 255, 0.14);
  border-color: var(--cyan);
  color: var(--text);
}

/* TV Display Layout */
.tv-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.tv-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(17, 24, 39, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 24px;
  flex-wrap: wrap;
}

.tv-room-pill {
  display: flex;
  align-items: center;
  gap: 18px;
}

.tv-code {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--cyan);
  line-height: 1;
}

.tv-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  flex: 1;
}

@media (max-width: 900px) {
  .tv-grid {
    grid-template-columns: 1fr;
  }
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 16px;
}

.player-tile {
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.player-tile.buzzed-1 {
  border-color: var(--gold);
  box-shadow: 0 0 24px rgba(255, 184, 0, 0.28);
  transform: scale(1.03);
}

.player-tile.buzzed-other {
  border-color: var(--cyan);
}

.player-tile.offline {
  opacity: 0.45;
}

.player-avatar {
  font-size: 2.2rem;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed-item {
  background: #0b1120;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Mobile Controller */
.buzzer-btn {
  width: 100%;
  min-height: 170px;
  border-radius: 24px;
  border: none;
  background: radial-gradient(circle at 35% 30%, #ff6b84, #e11d48);
  color: white;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  box-shadow: 0 12px 0 #9f1239, 0 20px 35px rgba(225, 29, 72, 0.4);
  cursor: pointer;
  margin: 12px 0 22px;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.buzzer-btn:active {
  transform: translateY(6px);
  box-shadow: 0 6px 0 #9f1239, 0 10px 20px rgba(225, 29, 72, 0.3);
}

.buzzer-btn.buzzed {
  background: radial-gradient(circle at 35% 30%, #fde047, #eab308);
  color: #090d16;
  box-shadow: 0 10px 0 #a16207;
}

.reaction-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.reaction-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 4px;
  font-size: 1.5rem;
  cursor: pointer;
}

.reaction-btn:active {
  transform: scale(0.92);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 54px);
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}

.dpad-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  cursor: pointer;
}

.dpad-btn:active {
  background: var(--cyan);
  color: #050811;
}

.floating-reactions {
  position: fixed;
  bottom: 30px;
  right: 40px;
  pointer-events: none;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 99;
}

.reaction-toast {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--cyan);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  font-size: 1.1rem;
  animation: fadeSlide 2.6s ease forwards;
}

@keyframes fadeSlide {
  0% { opacity: 0; transform: translateY(14px) scale(0.9); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; transform: translateY(-10px); }
  100% { opacity: 0; transform: translateY(-28px); }
}

.footer-links {
  margin-top: 26px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 18px;
  flex-wrap: wrap;
}
