:root {
  --bg-color: #06090e;
  --surface: rgba(14, 20, 32, 0.8);
  --border: rgba(255, 255, 255, 0.12);
  --primary: #00e5ff;
  --secondary: #76ff03;
  --accent: #ffd600;
  --danger: #ff1744;
  --font-hud: 'Chakra Petch', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-text: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  font-family: var(--font-hud);
  color: #fff;
  overflow-x: hidden;
}

.lobby-layout {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
  gap: 16px;
}

/* Header */
.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  backdrop-filter: blur(12px);
}

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

.live-dot {
  width: 10px;
  height: 10px;
  background: var(--danger);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--danger);
  animation: pulse-dot 1.5s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1.5px;
}

.queue-status-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.3);
  padding: 6px 14px;
  border-radius: 8px;
}

.queue-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
}

.queue-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pos-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.pos-desc {
  font-size: 11px;
  color: #94a3b8;
}

/* Content Split */
.lobby-content {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  flex: 1;
}

@media (max-width: 800px) {
  .lobby-content {
    grid-template-columns: 1fr;
  }
}

/* Minigame Panel */
.minigame-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(12px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  display: flex;
  flex-direction: column;
}

.panel-title span {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
}

.panel-title .sub {
  font-size: 10px;
  color: #94a3b8;
  font-family: var(--font-text);
}

.minigame-score-box {
  display: flex;
  gap: 14px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 10px;
  border-radius: 6px;
}

.minigame-score-box strong {
  color: var(--accent);
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 640 / 300;
  background: #020408;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.8);
}

#runner-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.runner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 6, 10, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  transition: opacity 0.2s ease;
}

.runner-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.runner-overlay h2 {
  font-size: 22px;
  color: var(--secondary);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.runner-overlay p {
  font-family: var(--font-text);
  font-size: 12px;
  color: #94a3b8;
  max-width: 320px;
  margin-bottom: 16px;
}

.btn-play {
  padding: 10px 24px;
  background: linear-gradient(135deg, #00e676, #76ff03);
  color: #000;
  font-family: var(--font-hud);
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(118, 255, 3, 0.4);
}

.btn-play:active {
  transform: scale(0.96);
}

/* Side Panel (Leaderboard & Chat) */
.side-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(12px);
}

.tab-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: #94a3b8;
  font-family: var(--font-hud);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  background: rgba(0, 229, 255, 0.05);
}

.tab-view {
  display: none;
  flex: 1;
  padding: 14px;
}

.tab-view.active {
  display: flex;
  flex-direction: column;
}

/* Leaderboard Table */
.table-container {
  overflow-y: auto;
  max-height: 280px;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.leaderboard-table th {
  text-align: left;
  padding: 8px;
  color: #64748b;
  font-size: 10px;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.leaderboard-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.rank-1 { color: #ffd700; font-weight: 700; }
.rank-2 { color: #c0c0c0; font-weight: 700; }
.rank-3 { color: #cd7f32; font-weight: 700; }
.loading-row { text-align: center; color: #64748b; }

/* Chat Box */
.chat-box {
  flex: 1;
  min-height: 220px;
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  margin-bottom: 12px;
}

.chat-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

.chat-bubble .meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--primary);
  margin-bottom: 2px;
}

.chat-bubble .text {
  font-family: var(--font-text);
  color: #e2e8f0;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
}

#chat-input {
  flex: 1;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-text);
  font-size: 12px;
  outline: none;
}

#chat-input:focus {
  border-color: var(--primary);
}

.btn-send {
  padding: 8px 16px;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  color: #000;
  font-family: var(--font-hud);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

/* Footer */
.lobby-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #64748b;
  padding: 6px 0;
}

.link-controller {
  color: #000;
  background: var(--primary);
  padding: 8px 14px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 10px rgba(0, 229, 255, 0.3);
}
