:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-hover: #212634;
  --border: #2a3040;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #ec4899;
  --accent-hover: #db2777;
  --success: #10b981;
  --yt: #ff0000;
  --sp: #1db954;
  --am: #fa243c;
  --radius: 14px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.app-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

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

.logo-icon {
  font-size: 1.6rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: linear-gradient(135deg, #818cf8, #f472b6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.room-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.room-badge strong {
  color: #818cf8;
  letter-spacing: 0.1em;
  font-size: 1.05rem;
}

/* Views */
.view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.view.active {
  display: block;
}

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

/* Cards & Layout */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.hero-card {
  text-align: center;
  max-width: 780px;
  margin: 20px auto;
}

.hero-card h2 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

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

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 20px;
  align-items: stretch;
  text-align: left;
}

.lobby-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.lobby-box h3 {
  font-size: 1.05rem;
}

.lobby-box p {
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-grow: 1;
}

.lobby-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.grid-layout {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-header h2 {
  font-size: 1.15rem;
}

.hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 18px;
}

/* Forms & Inputs */
.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

.req {
  color: var(--accent);
}

input[type="text"], select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-align: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
}

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

.btn-primary {
  background: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #334155;
}
.btn-secondary:hover:not(:disabled) {
  background: #475569;
}

.btn-accent {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  width: 100%;
}
.btn-accent:hover:not(:disabled) {
  opacity: 0.92;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

/* Badges & Lists */
.badge {
  background: #312e81;
  color: #a5b4fc;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge.owner {
  background: #831843;
  color: #fbcfe8;
}

.submitted-banner {
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 10px;
  color: #6ee7b7;
  font-size: 0.85rem;
}

.participant-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.participant-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}

.status-pill {
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  font-weight: 600;
}

.owner-box {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.small-note {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 8px;
  text-align: center;
}

.waiting-box {
  text-align: center;
  padding: 16px;
  background: var(--bg);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Playlist View */
.playlist-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.playlist-toolbar .hint {
  margin-bottom: 0;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

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

.track-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.2s, border-color 0.2s;
}

.track-card.revealed {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(236, 72, 153, 0.08), var(--surface));
}

.track-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.track-num {
  font-weight: 800;
  color: var(--primary);
  font-size: 0.9rem;
}

.track-info h3 {
  font-size: 1.15rem;
  margin-bottom: 2px;
}

.track-info p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Streaming Links */
.stream-links {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.stream-btn {
  text-decoration: none;
  text-align: center;
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  transition: opacity 0.2s;
}

.stream-btn:hover {
  opacity: 0.85;
}

.stream-yt { background: #dc2626; }
.stream-sp { background: #16a34a; }
.stream-am { background: #e11d48; }

/* Guess & Reveal Area */
.guess-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.guess-select {
  padding: 8px 10px;
  font-size: 0.85rem;
}

.reveal-box {
  margin-top: auto;
  padding: 12px;
  background: rgba(236, 72, 153, 0.14);
  border-radius: 10px;
  border: 1px solid rgba(236, 72, 153, 0.4);
}

.reveal-owner {
  font-weight: 800;
  color: #f472b6;
  font-size: 1rem;
}

.reveal-comment {
  font-size: 0.83rem;
  color: var(--text);
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #334155;
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

@media (max-width: 720px) {
  .lobby-grid, .grid-layout {
    grid-template-columns: 1fr;
  }
  .lobby-divider {
    padding: 4px 0;
  }
}