/* ─── VARIABLES ─── */
:root {
  --bg: #0e0b1e;
  --card-bg: #16122e;
  --accent: #f72585;
  --accent2: #7209b7;
  --accent3: #4361ee;
  --accent4: #4cc9f0;
  --text: #f0ebff;
  --text-dim: #8b83a8;
  --gold: #ffd166;
  --cell-border: rgba(255,255,255,0.06);
  --radius: 12px;
  --spotify: #1DB954;
}

* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(114,9,183,0.25) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 100%, rgba(67,97,238,0.2) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 50%, rgba(247,37,133,0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ─── SCREENS ─── */
.screen { display:none; position:relative; z-index:1; }
.screen.active { display:flex; flex-direction:column; min-height:100dvh; }

/* ─── LOGO ─── */
.logo {
  font-family: 'Space Mono', monospace;
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  margin: 20px 0 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent4));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}
.logo-sub {
  font-size: .95rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 28px;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: all .2s;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 24px rgba(247,37,133,0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 32px rgba(247,37,133,0.45); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity:.5; pointer-events:none; }

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); }

.btn-embed {
  background: var(--spotify);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 13px 18px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.btn-embed:hover { filter: brightness(1.1); }
.btn-embed:active { transform: scale(.97); }

.hint {
  font-size: .82rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 400px;
  line-height: 1.6;
}

/* ─── HOME / JOIN PAGE ─── */
.home-screen {
  padding: 24px 20px 40px;
  align-items: center;
  justify-content: center;
}

.join-box {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.code-input {
  width: 100%;
  padding: 18px 20px;
  background: var(--card-bg);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Space Mono', monospace;
  font-size: 1.6rem;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  outline: none;
  transition: border-color .2s;
}
.code-input:focus { border-color: var(--accent4); }
.code-input::placeholder { color: var(--text-dim); letter-spacing: 2px; font-size: 1rem; }

.join-status {
  margin-top: 10px;
  font-size: .85rem;
  min-height: 24px;
}
.join-status.error { color: var(--accent); }

.home-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 420px;
  margin: 28px 0;
  color: var(--text-dim);
  font-size: .82rem;
}
.home-divider::before, .home-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

.admin-link {
  color: var(--accent4);
  text-decoration: none;
  font-weight: 700;
  font-size: .9rem;
  transition: color .2s;
}
.admin-link:hover { color: var(--accent); }

/* ─── ADMIN / SETUP PAGE ─── */
.setup-screen { padding: 24px 20px 40px; align-items: center; }

.setup-section {
  width: 100%;
  max-width: 560px;
  margin-bottom: 20px;
}
.setup-section h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent4);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 10px;
}

/* ── Tabs ── */
.tab-bar {
  display: flex;
  gap: 4px;
  width: 100%;
  max-width: 560px;
  margin-bottom: 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 50px;
  padding: 4px;
}
.tab-btn {
  flex: 1;
  padding: 12px 10px;
  border: none;
  border-radius: 50px;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: .82rem;
  cursor: pointer;
  transition: all .25s;
  background: transparent;
  color: var(--text-dim);
  letter-spacing: .5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab-btn.active {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.tab-btn:hover:not(.active) { color: var(--text); }
.tab-btn .spotify-icon { width: 16px; height: 16px; }

.tab-panel { display: none; width: 100%; max-width: 560px; }
.tab-panel.active { display: block; }

/* ── Spotify Paste ── */
.paste-area {
  width: 100%;
  min-height: 200px;
  background: var(--card-bg);
  border: 2px dashed rgba(29,185,84,0.25);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: .92rem;
  padding: 16px;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
  line-height: 1.7;
}
.paste-area:focus { border-color: var(--spotify); }
.paste-area::placeholder { color: var(--text-dim); }

.spotify-embed-wrap {
  margin-top: 16px;
  border-radius: var(--radius);
  overflow: hidden;
}
.spotify-embed-wrap iframe {
  width: 100%;
  border: none;
  border-radius: var(--radius);
}

.import-status {
  margin-top: 10px;
  font-size: .85rem;
  color: var(--text-dim);
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.import-status.error { color: var(--accent); }
.import-status.success { color: var(--spotify); }

.imported-preview {
  margin-top: 12px;
  max-height: 260px;
  overflow-y: auto;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
  scrollbar-width: thin;
  scrollbar-color: var(--accent2) transparent;
}
.imported-preview::-webkit-scrollbar { width: 6px; }
.imported-preview::-webkit-scrollbar-thumb { background: var(--accent2); border-radius: 3px; }

.imported-track {
  padding: 10px 14px;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  animation: fadeSlideIn .3s ease backwards;
}
.imported-track:last-child { border-bottom: none; }
.track-num {
  font-family: 'Space Mono', monospace;
  font-size: .7rem;
  color: var(--text-dim);
  min-width: 22px;
  text-align: right;
}
.track-info { overflow: hidden; }
.track-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.track-artist {
  font-size: .78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-help {
  margin-top: 14px;
  padding: 14px;
  background: rgba(29,185,84,0.06);
  border: 1px solid rgba(29,185,84,0.12);
  border-radius: var(--radius);
  font-size: .82rem;
  color: var(--text-dim);
  line-height: 1.7;
}
.import-help strong { color: var(--spotify); }
.import-help .step {
  display: flex;
  gap: 10px;
  margin: 8px 0;
  align-items: flex-start;
}
.import-help .step-num {
  background: var(--spotify);
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Manual Input ── */
.playlist-input-wrap textarea {
  width: 100%;
  min-height: 220px;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: .95rem;
  padding: 16px;
  resize: vertical;
  outline: none;
  transition: border-color .2s;
  line-height: 1.7;
}
.playlist-input-wrap textarea:focus { border-color: var(--accent3); }
.playlist-input-wrap textarea::placeholder { color: var(--text-dim); }

.song-count {
  margin-top: 8px;
  font-size: .85rem;
  color: var(--text-dim);
}
.song-count strong { color: var(--accent4); }

/* ── URL Row ── */
.url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.url-row input {
  flex: 1;
  min-width: 0;
  padding: 13px 14px;
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: .92rem;
  outline: none;
  transition: border-color .2s;
}
.url-row input:focus { border-color: var(--spotify); }
.url-row input::placeholder { color: var(--text-dim); }

.generate-wrap {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 560px;
  margin: 8px 0;
  color: var(--text-dim);
  font-size: .82rem;
}
.or-divider::before, .or-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

.demo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 560px;
}

/* ─── SHARE SCREEN ─── */
.share-section {
  width: 100%;
  max-width: 560px;
  text-align: center;
}

.share-link-box {
  background: var(--card-bg);
  border: 2px solid var(--accent4);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  word-break: break-all;
  font-family: 'Space Mono', monospace;
  font-size: .95rem;
  color: var(--accent4);
  cursor: pointer;
}

.share-code {
  font-family: 'Space Mono', monospace;
  font-size: 3rem;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--gold);
  margin: 16px 0;
  text-transform: uppercase;
}

.qr-wrap {
  display: inline-block;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  margin: 20px 0;
}
.qr-wrap img {
  display: block;
  width: 200px;
  height: 200px;
}

.share-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── BINGO CARD SCREEN ─── */
.card-screen { padding: 16px 12px 100px; align-items: center; }
.card-header { text-align: center; margin-bottom: 12px; }
.card-header .logo { font-size: 1.6rem; margin: 8px 0 2px; }
.card-id {
  font-family: 'Space Mono', monospace;
  font-size: .75rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.bingo-labels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 420px;
  margin-bottom: 4px;
}
.bingo-label {
  font-family: 'Space Mono', monospace;
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
  padding: 6px 0;
}
.bingo-label:nth-child(1) { color: var(--accent); }
.bingo-label:nth-child(2) { color: var(--accent2); }
.bingo-label:nth-child(3) { color: var(--accent3); }
.bingo-label:nth-child(4) { color: var(--accent4); }
.bingo-label:nth-child(5) { color: var(--gold); }

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  width: 100%;
  max-width: 420px;
}

.bingo-cell {
  aspect-ratio: 1;
  background: var(--card-bg);
  border: 1px solid var(--cell-border);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px;
  font-size: .68rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  overflow: hidden;
  user-select: none;
  word-break: break-word;
  hyphens: auto;
  animation: popIn .35s ease backwards;
}
.bingo-cell:active { transform: scale(.93); }

.bingo-cell.checked {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 12px rgba(247,37,133,0.3);
}
.bingo-cell.checked::after {
  content: '\2713';
  position: absolute;
  top: 3px; right: 5px;
  font-size: .65rem;
  opacity: .7;
}

.bingo-cell.free-cell {
  background: linear-gradient(135deg, var(--accent2), var(--accent3));
  color: #fff;
  font-family: 'Space Mono', monospace;
  font-size: .8rem;
  font-weight: 700;
  cursor: default;
  letter-spacing: 1px;
}

/* ─── BINGO BANNERS ─── */
.bingo-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  color: #fff;
  text-align: center;
  padding: 18px;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  letter-spacing: 4px;
}
.bingo-banner.show { display: block; }

/* Small win: one line */
.bingo-banner.line-win {
  background: linear-gradient(135deg, var(--accent3), var(--accent4));
  font-size: 1.3rem;
  padding: 14px;
  animation: linePulse 0.8s ease infinite alternate;
}

/* Big win: full card */
.bingo-banner.full-win {
  background: linear-gradient(135deg, var(--accent), var(--gold));
  font-size: 2rem;
  padding: 22px;
  letter-spacing: 6px;
  animation: bingoPulse 0.5s ease infinite alternate;
  box-shadow: 0 4px 40px rgba(247,37,133,0.5);
}

@keyframes linePulse { from { transform: scale(1); } to { transform: scale(1.02); } }
@keyframes bingoPulse { from { transform: scale(1); } to { transform: scale(1.06); } }

/* ─── BOTTOM BAR ─── */
.bottom-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  background: rgba(14,11,30,0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  justify-content: center;
}
.bottom-bar .btn { flex: 1; max-width: 200px; padding: 12px 16px; font-size: .85rem; }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 99; }

/* ─── ANIMATIONS ─── */
@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  70% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes screenShake {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-4px, 2px); }
  20% { transform: translate(4px, -2px); }
  30% { transform: translate(-3px, 3px); }
  40% { transform: translate(3px, -1px); }
  50% { transform: translate(-2px, 2px); }
  60% { transform: translate(2px, -2px); }
  70% { transform: translate(-1px, 1px); }
  80% { transform: translate(1px, -1px); }
  90% { transform: translate(0, 1px); }
}
.screen-shake { animation: screenShake 0.5s ease; }

/* ─── RESPONSIVE: PHONE (default) ─── */
.bingo-grid { max-width: 100%; }

/* ─── RESPONSIVE: LARGE PHONE (480px+) ─── */
@media (min-width: 480px) {
  .bingo-grid { max-width: 420px; gap: 5px; }
  .bingo-cell { font-size: .78rem; border-radius: 12px; }
  .bingo-labels { max-width: 420px; gap: 5px; }
}

/* ─── RESPONSIVE: TABLET (768px+) ─── */
@media (min-width: 768px) {
  .bingo-grid { max-width: 540px; gap: 6px; }
  .bingo-cell { font-size: .92rem; border-radius: 14px; padding: 8px; }
  .bingo-labels { max-width: 540px; gap: 6px; }
  .bingo-label { font-size: 1.8rem; }
  .card-screen { padding: 28px 24px 110px; }
  .card-header .logo { font-size: 2rem; }
  .card-id { font-size: .85rem; }
  .bottom-bar .btn { font-size: .95rem; padding: 14px 20px; }
  .logo { font-size: 2.8rem; }
  .code-input { font-size: 2rem; padding: 22px 24px; }
  .share-code { font-size: 3.5rem; }
  .qr-wrap img { width: 256px; height: 256px; }
}

/* ─── RESPONSIVE: LAPTOP (1024px+) ─── */
@media (min-width: 1024px) {
  .bingo-grid { max-width: 620px; gap: 8px; }
  .bingo-cell { font-size: 1rem; border-radius: 14px; padding: 10px; }
  .bingo-labels { max-width: 620px; gap: 8px; }
  .bingo-label { font-size: 2rem; }
  .card-screen { padding: 32px 32px 120px; }
  .card-header .logo { font-size: 2.2rem; }
  .bottom-bar {
    max-width: 620px;
    margin: 0 auto;
    border-radius: 16px 16px 0 0;
  }
  .logo { font-size: 3rem; }
}

/* ─── RESPONSIVE: WIDE (1280px+) ─── */
@media (min-width: 1280px) {
  .bingo-grid { max-width: 700px; }
  .bingo-labels { max-width: 700px; }
  .bottom-bar { max-width: 700px; }
}
