:root {
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --card: #1c2028;
  --card-border: #2a2f3a;
  --text: #eef0f4;
  --text-dim: #9aa1b0;
  --accent-music: #1db954;
  --accent-games: #66c0f4;
  --accent-food: #ff9f43;
  --accent-danger: #ff5f6d;
  --radius: 14px;
  --font-display: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 20% -10%, #1b2130 0%, var(--bg) 45%);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}

h1, h2, h3, .brand h1, .topbar-brand, .card-title, .btn {
  font-family: var(--font-display);
}

.hidden { display: none !important; }

a { color: var(--accent-games); }

/* ---------- Auth screen ---------- */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.brand { text-align: center; margin-bottom: 24px; position: relative; }
.brand-glow {
  position: absolute;
  top: -60px; left: 50%;
  transform: translateX(-50%);
  width: 220px; height: 120px;
  background: radial-gradient(ellipse, rgba(29,185,84,0.35), rgba(102,192,244,0.15) 60%, transparent 70%);
  filter: blur(10px);
  z-index: 0;
  pointer-events: none;
}
.brand h1 {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  position: relative;
  color: var(--text);
}
.brand p { color: var(--text-dim); margin: 6px 0 0; font-size: 14px; position: relative; }

.auth-tabs { display: flex; gap: 4px; background: var(--bg-elevated); border-radius: 10px; padding: 4px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 10px; border: none; border-radius: 8px; background: transparent;
  color: var(--text-dim); font-family: var(--font-display); font-weight: 600; cursor: pointer; font-size: 14px;
}
.auth-tab.active { background: var(--card); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 12px; }

input[type="text"], input[type="password"] {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}
input[type="text"]:focus, input[type="password"]:focus { border-color: var(--accent-games); }

.btn {
  border: none; border-radius: 10px; padding: 12px 18px; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform 0.08s ease, opacity 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(90deg, #1db954, #17a34a); color: #06170c; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--card-border); }
.btn-spotify { background: #1db954; color: #06170c; width: 100%; margin-top: 12px; }
.btn-danger-ghost { background: transparent; color: var(--accent-danger); border: 1px solid rgba(255,95,109,0.4); }
.btn-play { background: var(--bg-elevated); color: var(--accent-music); border: 1px solid var(--card-border); }
.btn-small { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

/* ---------- App shell ---------- */

.app { min-height: 100vh; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 16px 28px;
  background: rgba(23,26,33,0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand { font-weight: 700; font-size: 18px; }
.topbar-brand span { color: var(--accent-music); }

.tabs { display: flex; gap: 6px; flex: 1; }
.tab {
  background: transparent; border: none; color: var(--text-dim);
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  padding: 10px 16px; border-radius: 10px; cursor: pointer;
}
.tab:hover { color: var(--text); background: var(--bg-elevated); }
.tab.active { color: var(--text); background: var(--card); box-shadow: inset 0 0 0 1px var(--card-border); }

.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--text-dim); font-size: 14px; }

.content { padding: 28px; max-width: 1100px; margin: 0 auto; }

.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 820px) { .panel-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-weight: 600; font-size: 15px; margin-bottom: 14px; }

.hint { color: var(--text-dim); font-size: 13px; margin-top: 10px; line-height: 1.5; }

.search-input { width: 100%; padding: 12px 14px; }

/* ---------- Music ---------- */

.now-playing-card { display: flex; flex-direction: column; }
.now-playing { min-height: 90px; display: flex; align-items: center; gap: 12px; }
.np-empty { color: var(--text-dim); font-size: 14px; }
.np-art { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; }
.np-info .np-title { font-weight: 600; color: inherit; text-decoration: none; }
.np-info .np-title:hover { text-decoration: underline; }
.np-info .np-artist { color: var(--text-dim); font-size: 13px; }
.np-live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-music); margin-right: 6px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.result-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 360px; overflow-y: auto; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; background: var(--bg-elevated); }
.result-row img { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: #333; }
.result-row .meta { flex: 1; min-width: 0; }
.result-row .meta .t { font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: inherit; text-decoration: none; display: block; }
.result-row .meta .t:hover { text-decoration: underline; }
.result-row .meta .s { color: var(--text-dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.queue-list { display: flex; flex-direction: column; gap: 6px; }
.queue-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; }
.queue-row:nth-child(odd) { background: var(--bg-elevated); }
.queue-row img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; }
.queue-row .qr-title { color: inherit; text-decoration: none; }
.queue-row .qr-title:hover { text-decoration: underline; }
.queue-row .qr-dur { color: var(--text-dim); font-size: 12px; }
.queue-row .who { color: var(--text-dim); font-size: 12px; margin-left: auto; white-space: nowrap; }
.queue-row .qr-actions { display: flex; gap: 2px; }
.queue-row .qr-actions button {
  background: transparent; border: none; color: var(--text-dim); cursor: pointer;
  font-size: 14px; padding: 4px 6px; border-radius: 6px; line-height: 1;
}
.queue-row .qr-actions button:hover { background: var(--card); color: var(--text); }
.queue-row .qr-actions button:disabled { opacity: 0.3; cursor: default; }
.queue-row .qr-actions button:disabled:hover { background: transparent; }
.queue-row .qr-actions [data-play-now] { color: var(--accent-music); }

/* ---------- Games ---------- */

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.game-card {
  background: var(--bg-elevated); border-radius: 10px; overflow: hidden;
  border: 1px solid var(--card-border);
}
.game-card img { width: 100%; height: 90px; object-fit: cover; display: block; background: #222; }
.game-card .gc-body { padding: 10px; }
.game-card .gc-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; display: block; color: inherit; text-decoration: none; }
.game-card .gc-title:hover { text-decoration: underline; }
.game-card .gc-price { color: var(--accent-games); font-size: 12px; }
.game-card .gc-by { color: var(--text-dim); font-size: 11px; margin-top: 4px; }
.game-card .gc-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------- Food ---------- */

.food-form { display: grid; grid-template-columns: 2fr 2fr 1fr auto; gap: 8px; }
@media (max-width: 700px) { .food-form { grid-template-columns: 1fr; } }

.food-list { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.food-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg-elevated); }
.food-row .f-name { font-weight: 500; }
.food-row .f-note { color: var(--text-dim); font-size: 13px; }
.food-row .f-price { color: var(--accent-food); font-weight: 600; font-size: 13px; }
.food-row .f-by { color: var(--text-dim); font-size: 12px; margin-left: auto; }
.food-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }

/* ---------- Settings ---------- */

.settings-form { display: flex; flex-direction: column; gap: 12px; max-width: 480px; }
.settings-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card); border: 1px solid var(--card-border);
  padding: 12px 16px 12px 40px; border-radius: 10px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.35);
  animation: slideIn 0.2s ease; max-width: 320px; position: relative;
}
.toast::before {
  content: ''; position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-games);
}
.toast.error::before { background: var(--accent-danger); }
.toast.success::before { background: var(--accent-music); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
