/* ============================================================
   style.css — Hues & Cues Premium Dark Design
   ============================================================ */

/* FONTS & RESET */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=Inter:wght@300;400;500;600&display=swap');

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

:root {
  --bg: #080811;
  --bg2: #0f0f1a;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.18);

  --accent: #7C3AED;
  --accent2: #A78BFA;
  --accent3: #EC4899;
  --gold: #FBBF24;
  --green: #34D399;
  --red: #F87171;

  --text: #F0F0FF;
  --text-muted: rgba(240,240,255,0.5);
  --text-dim: rgba(240,240,255,0.3);

  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --shadow: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-sm: 0 4px 16px rgba(0,0,0,0.4);
  --blur: blur(16px);

  --font-main: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ============================================================
   GLASS UTILITY
   ============================================================ */
.glass {
  background: rgba(255,255,255,0.04);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ============================================================
   SCREENS
   ============================================================ */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow-y: auto;
}
.screen.active {
  display: flex;
  animation: screenFadeIn 0.35s ease;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   BUTTONS
   ============================================================ */
button {
  font-family: var(--font-main);
  font-weight: 600;
  letter-spacing: 0.015em;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.18s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  padding: 13px 28px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  box-shadow: 0 4px 20px rgba(124,58,237,0.5);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #8B5CF6, var(--accent));
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(124,58,237,0.7);
}
.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(255,255,255,0.07);
  color: var(--text);
  padding: 13px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-hover);
  font-size: 15px;
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.12);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 14px;
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.06);
}

.btn-icon-only {
  background: rgba(255,255,255,0.07);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 16px;
  cursor: pointer;
}
.btn-icon-only:hover {
  background: rgba(255,255,255,0.14);
}

.btn-full { width: 100%; }
.btn-icon { margin-right: 6px; }

/* ============================================================
   INPUTS
   ============================================================ */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

input[type="text"] {
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s, background 0.2s;
}
input[type="text"]::placeholder {
  color: var(--text-dim);
}
input[type="text"]:focus {
  border-color: var(--accent);
  background: rgba(124,58,237,0.08);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.2);
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8,8,17,0.85);
  backdrop-filter: var(--blur);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--border);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text {
  font-family: var(--font-main);
  font-weight: 500;
  color: var(--text-muted);
  font-size: 15px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, #1e1e2e, #2d1b4e);
  border: 1px solid rgba(167,139,250,0.3);
  color: var(--text);
  font-family: var(--font-main);
  font-weight: 500;
  padding: 12px 24px;
  border-radius: 99px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 2000;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  max-width: 90vw;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   HOME SCREEN
   ============================================================ */
#screen-home {
  align-items: center;
  justify-content: center;
}

.home-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.color-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbFloat 8s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: #7C3AED; top: -150px; left: -100px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: #EC4899; top: 20%; right: -80px; animation-delay: 2s; }
.orb-3 { width: 350px; height: 350px; background: #0EA5E9; bottom: -80px; left: 20%; animation-delay: 4s; }
.orb-4 { width: 300px; height: 300px; background: #10B981; bottom: 10%; right: 15%; animation-delay: 1s; }

@keyframes orbFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

.home-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  padding: 32px 24px;
  width: 100%;
  max-width: 480px;
}

.home-hero {
  text-align: center;
}

.home-logo {
  font-family: var(--font-main);
  font-size: clamp(52px, 10vw, 80px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.logo-hues {
  background: linear-gradient(135deg, #A78BFA, #7C3AED);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-and {
  color: var(--text-muted);
  font-weight: 300;
  padding: 0 10px;
}
.logo-cues {
  background: linear-gradient(135deg, #F472B6, #EC4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.home-tagline {
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 17px;
  font-weight: 400;
}

.home-card {
  width: 100%;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.join-group {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}
.join-group .input-group {
  flex: 1;
}
.join-group input {
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-size: 18px;
  text-align: center;
}

.home-credit {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

/* ============================================================
   LOBBY SCREEN
   ============================================================ */
#screen-lobby {
  align-items: flex-start;
  justify-content: center;
}

.lobby-container {
  width: 100%;
  max-width: 900px;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.lobby-title {
  font-family: var(--font-main);
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.code-display {
  text-align: right;
}
.code-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.code-value-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.code-value {
  font-family: var(--font-main);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.2em;
  background: linear-gradient(135deg, var(--gold), #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.lobby-body {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}

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

.lobby-players-panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.panel-header h2 {
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 700;
}
.player-count {
  font-size: 13px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.06);
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.player-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lobby-player {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  animation: playerIn 0.3s ease;
}

@keyframes playerIn {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 8px currentColor;
}

.player-name {
  flex: 1;
  font-family: var(--font-main);
  font-weight: 500;
}

.badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 99px;
  background: rgba(124,58,237,0.2);
  color: var(--accent2);
  border: 1px solid rgba(124,58,237,0.3);
}
.badge.you {
  background: rgba(236,72,153,0.2);
  color: #F9A8D4;
  border-color: rgba(236,72,153,0.3);
}

.lobby-info-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rules-card {
  padding: 22px;
}
.rules-card h3 {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 14px;
  color: var(--accent2);
}
.rules-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.rules-list li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.rules-list strong {
  color: var(--text);
}

.pts {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 12px;
}
.pts.exact  { background: rgba(52,211,153,0.2); color: var(--green); }
.pts.inner  { background: rgba(251,191,36,0.2); color: var(--gold); }
.pts.outer  { background: rgba(248,113,113,0.2); color: var(--red); }

.lobby-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
#screen-game {
  flex-direction: column;
}

.game-layout {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: 200px 1fr 260px;
  gap: 0;
  overflow: hidden;
}

@media (max-width: 900px) {
  .game-layout {
    grid-template-columns: 160px 1fr 200px;
  }
}

@media (max-width: 650px) {
  .game-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  #sidebar-scores { display: none; }
}

.sidebar {
  background: rgba(8,8,17,0.8);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#sidebar-hud {
  border-right: none;
  border-left: 1px solid var(--border);
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h3 {
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Scoreboard */
.scoreboard {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.score-row:hover { background: var(--surface); }
.score-row.me { background: rgba(124,58,237,0.1); border: 1px solid rgba(124,58,237,0.2); }

.score-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.score-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-pts {
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 800;
  color: var(--accent2);
}

/* Canvas */
.canvas-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  min-width: 0;
}

#canvas-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#color-grid {
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--border), 0 16px 48px rgba(0,0,0,0.6);
  cursor: crosshair;
  display: block;
}

/* HUD Panel */
.hud-panel {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
  overflow-y: auto;
}

.hud-round-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hud-round-badge {
  font-family: var(--font-main);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.hud-cue-giver {
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 7px;
}
.hud-cue-giver .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hud-clues {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.clue-chip {
  padding: 10px 16px;
  background: rgba(167,139,250,0.1);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 700;
  color: var(--accent2);
  text-align: center;
  letter-spacing: 0.04em;
  word-break: break-word;
}

.hud-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.color-preview {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.hud-instruction {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}
.hud-instruction strong { color: var(--text); }

.clue-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.clue-input-group input {
  font-size: 15px;
  text-align: center;
}
.clue-input-group button {
  padding: 12px;
  background: linear-gradient(135deg, var(--accent), #5b21b6);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(124,58,237,0.4);
}
.clue-input-group button:hover {
  background: linear-gradient(135deg, #8B5CF6, var(--accent));
  transform: translateY(-1px);
}

.hud-waiting {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0;
  font-style: italic;
}

.hud-scoring {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.hud-scoring h3 {
  font-family: var(--font-main);
  font-size: 22px;
  font-weight: 800;
}

.color-swatch {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  vertical-align: middle;
  border: 2px solid rgba(255,255,255,0.2);
  margin: 0 4px;
}

/* ============================================================
   END SCREEN
   ============================================================ */
#screen-end {
  align-items: center;
  justify-content: center;
}

.end-container {
  width: 100%;
  max-width: 560px;
  padding: 48px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  text-align: center;
}

.end-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#end-title {
  font-family: var(--font-main);
  font-size: 56px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--gold), #f59e0b, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: titlePop 0.5s ease;
}

@keyframes titlePop {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.end-winner-text {
  font-family: var(--font-main);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-muted);
}

.end-scoreboard {
  width: 100%;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.end-score-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  animation: slideUp 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 80ms);
  border: 1px solid transparent;
  transition: background 0.15s;
}
.end-score-row.me {
  background: rgba(124,58,237,0.12);
  border-color: rgba(124,58,237,0.25);
}
.end-score-row:first-child {
  background: rgba(251,191,36,0.08);
  border-color: rgba(251,191,36,0.2);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.end-rank {
  font-size: 22px;
  width: 32px;
  text-align: center;
}
.end-name {
  flex: 1;
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 600;
  text-align: left;
}
.end-pts {
  font-family: var(--font-main);
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
}

.end-actions {
  display: flex;
  gap: 14px;
}
.end-actions .btn-primary {
  padding: 14px 36px;
  font-size: 16px;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }
