/* ===== Quizybara: modern dark design system ===== */
:root {
  --bg: #08080c;
  --bg-2: #0c0c12;
  --surface: #131320;
  --surface-2: #1a1a2b;
  --surface-3: #222238;
  --border: #262638;
  --border-2: #32324a;
  --text: #f3f4fb;
  --muted: #9b9cb8;
  --faint: #6b6c87;

  --primary: #7c6cff;
  --primary-2: #9d6cff;
  --primary-grad: linear-gradient(135deg, #6d5efc 0%, #9b5cff 100%);
  --primary-glow: rgba(124, 108, 255, 0.45);

  --accent: #2dd4bf;
  --accent-2: #22d3ee;
  --accent-grad: linear-gradient(135deg, #2dd4bf 0%, #22d3ee 100%);

  --ok: #34d399;
  --danger: #f4476b;

  --radius: 16px;
  --radius-lg: 22px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 6px 20px rgba(0, 0, 0, 0.35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }

.hidden { display: none !important; }

/* ===== Buttons ===== */
.btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: 11px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-3); border-color: #3d3d5c; }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--primary-grad); color: #fff; border: none;
  box-shadow: 0 6px 18px var(--primary-glow);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 8px 24px var(--primary-glow); }
.btn.gold {
  background: transparent; color: var(--accent); border: 1px solid rgba(45, 212, 191, 0.45);
}
.btn.gold:hover { background: rgba(45, 212, 191, 0.12); border-color: var(--accent); }
.btn.danger { background: rgba(244, 71, 107, 0.14); color: #ff9bb0; border-color: rgba(244, 71, 107, 0.4); }
.btn.danger:hover { background: rgba(244, 71, 107, 0.22); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ===== Brand wordmark ===== */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  letter-spacing: -0.6px;
}
.brand .brand-text {
  background: linear-gradient(120deg, #b9adff 0%, #7c6cff 40%, #2dd4bf 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.logo-mark { width: 26px; height: 26px; display: block; flex: none; }

/* ===== Home page ===== */
.home {
  display: flex; min-height: 100vh; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(124, 108, 255, 0.18), transparent 60%),
    radial-gradient(800px 500px at 100% 110%, rgba(45, 212, 191, 0.14), transparent 55%),
    var(--bg);
}
.home-wrap { text-align: center; padding: 40px 28px; max-width: 820px; }
.home-title {
  font-size: clamp(54px, 13vw, 124px);
  font-weight: 800; letter-spacing: -3px; margin: 0;
  line-height: 1.08; padding-bottom: 0.12em;
  background: linear-gradient(115deg, #ffffff 0%, #c9c0ff 35%, #7c6cff 65%, #2dd4bf 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.home-sub { font-size: clamp(16px, 2.4vw, 21px); color: var(--muted); margin: 18px 0 44px; }
.home-cards { display: flex; gap: 22px; justify-content: center; flex-wrap: wrap; }
.home-card {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 260px; padding: 28px 24px; text-decoration: none; color: var(--text);
  text-align: center; background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
  position: relative; overflow: hidden;
}
.home-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, rgba(124,108,255,0.6), rgba(45,212,191,0.5));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity 0.16s;
}
.home-card:hover { transform: translateY(-5px); box-shadow: 0 16px 40px rgba(0,0,0,0.55); }
.home-card:hover::before { opacity: 1; }
.home-card-icon {
  font-size: 22px; width: 50px; height: 50px; display: grid; place-items: center;
  border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border-2);
  margin-top: 6px;
}
.home-card-title { font-size: 27px; font-weight: 700; letter-spacing: -0.3px; }
.home-card-desc { font-size: 13.5px; color: var(--muted); line-height: 1.5; }
.home-card.is-soon { opacity: 0.5; cursor: default; }
.home-card.is-soon:hover { transform: none; box-shadow: var(--shadow); }
.home-card.is-soon:hover::before { opacity: 0; }
.apps-title { font-size: clamp(34px, 7vw, 74px); letter-spacing: -1px; }
.home-foot { margin-top: 48px; font-size: 13px; color: var(--faint); }
.home-logo {
  width: 92px; height: 92px; display: block; margin: 0 auto 12px;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.5));
}
.home-links {
  margin-top: 14px; display: flex; gap: 12px; align-items: center;
  justify-content: center; font-size: 14px;
}
.home-links a { color: var(--muted); transition: color 0.15s; }
.home-links a:hover { color: var(--accent); }
.home-links .dot { color: var(--faint); }

/* ===== Home animations ===== */
.home-wrap { position: relative; z-index: 1; }

/* Drifting ambient glow orbs behind the content */
.home::before, .home::after {
  content: ""; position: absolute; border-radius: 50%; filter: blur(70px);
  z-index: 0; pointer-events: none;
}
.home::before {
  width: 360px; height: 360px; top: -70px; left: -50px;
  background: rgba(124, 108, 255, 0.22); animation: drift1 15s ease-in-out infinite;
}
.home::after {
  width: 320px; height: 320px; bottom: -70px; right: -40px;
  background: rgba(45, 212, 191, 0.18); animation: drift2 18s ease-in-out infinite;
}
@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(46px, 34px) scale(1.08); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-44px, -30px) scale(1.1); }
}

/* Staggered entrance */
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.home-title { animation: fadeUp 0.7s ease-out 0.1s both, shimmer 7s ease-in-out 1s infinite; }
.home-sub { animation: fadeUp 0.7s ease-out 0.22s both; }
.home-cards .home-card { animation: fadeUp 0.7s ease-out both; }
.home-cards .home-card:nth-child(1) { animation-delay: 0.34s; }
.home-cards .home-card:nth-child(2) { animation-delay: 0.46s; }
.home-foot { animation: fadeUp 0.7s ease-out 0.58s both; }
.home-links { animation: fadeUp 0.7s ease-out 0.66s both; }

/* Gently floating capybara (fade in, then bob forever) */
.home-logo { animation: fadeIn 0.8s ease-out both, bob 2.6s ease-in-out 0.4s infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1.5deg); }
  50% { transform: translateY(-9px) rotate(1.5deg); }
}

/* Title gradient shimmer */
.home-title { background-size: 220% auto; }
@keyframes shimmer {
  0%, 100% { background-position: 0% center; }
  50% { background-position: 100% center; }
}

@media (prefers-reduced-motion: reduce) {
  .home::before, .home::after,
  .home-title, .home-sub, .home-card, .home-foot, .home-links, .home-logo {
    animation: none !important;
  }
}

/* ===== Site footer (editor + game) ===== */
.site-foot {
  display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap;
  padding: 26px 16px 34px; color: var(--faint); font-size: 13px;
}
.site-foot a { color: var(--muted); transition: color 0.15s; }
.site-foot a:hover { color: var(--accent); }
.site-foot .dot { color: var(--faint); }

/* ===== Top bar ===== */
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 24px; background: rgba(12, 12, 18, 0.82);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-size: 22px; text-decoration: none; }
.topbar .spacer { flex: 1; }
.topbar .toolgroup { display: flex; gap: 10px; flex-wrap: wrap; }
.topbar .status { font-size: 13px; color: var(--muted); }

/* ===== Editor ===== */
.editor-main { padding: 28px 24px 64px; max-width: 1320px; margin: 0 auto; }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 22px; box-shadow: var(--shadow-soft); margin-bottom: 18px;
}

.title-row { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--muted);
}
.field input, .field select {
  background: var(--surface-2); color: var(--text); border: 1.5px solid var(--border-2);
  border-radius: 12px; padding: 11px 14px; font-size: 15px; font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow);
}
.field select option { background: var(--surface-2); color: var(--text); }
.field.grow { flex: 1; min-width: 240px; }
.field.grow input { width: 100%; font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }

.dims { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }

.hint { font-size: 14px; color: var(--muted); margin: 4px 4px 22px; line-height: 1.55; }
.hint strong { color: var(--text); font-weight: 700; }

.board-scroll { overflow-x: auto; padding-bottom: 8px; }
.edit-board { display: grid; gap: 14px; min-width: 760px; }

.cat-head {
  background: var(--primary-grad);
  border: none; border-radius: 14px; padding: 13px;
  box-shadow: 0 6px 18px var(--primary-glow);
}
.cat-head input {
  width: 100%; background: transparent; border: none; color: #fff;
  font-family: inherit; font-size: 16px; font-weight: 800; text-align: center;
  letter-spacing: 0.4px; text-transform: uppercase;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.cat-head input::placeholder { color: rgba(255, 255, 255, 0.72); font-weight: 700; }
.cat-head input:focus { outline: none; }

.edit-cell {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-soft); transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
}
.edit-cell:focus-within { border-color: var(--primary); box-shadow: 0 8px 22px var(--primary-glow); }
.edit-cell.is-done { border-color: rgba(52, 211, 153, 0.5); }

/* Collapsed header (the clickable tile) */
.cell-head {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: transparent; border: none; cursor: pointer; padding: 13px 14px;
  text-align: left; color: var(--text); font-family: inherit;
  transition: background 0.15s;
}
.cell-head:hover { background: rgba(255, 255, 255, 0.03); }
.val-badge {
  flex: none; font-weight: 800; font-size: 14px; padding: 4px 12px; border-radius: 999px;
  color: #fff; background: var(--primary-grad); border: none;
  box-shadow: 0 3px 10px var(--primary-glow);
}
.cell-preview {
  flex: 1; min-width: 0; font-size: 13.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cell-preview.empty { color: var(--faint); font-style: italic; }
.cell-caret {
  flex: none; width: 8px; height: 8px; margin-left: 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.18s;
}
.row-toggle.open .cell-caret { transform: rotate(45deg); }

/* Expandable body */
.cell-body { display: none; flex-direction: column; gap: 8px; padding: 0 14px 14px; }
.edit-cell.open .cell-body { display: flex; }

/* Per-row control: just an open/close arrow */
.board-corner { background: transparent; }
.row-toggle {
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer; color: var(--muted);
  padding: 0; transition: color 0.15s;
}
.row-toggle:hover { color: var(--text); }
.row-toggle .cell-caret {
  width: 11px; height: 11px; margin: 0;
  border-right-color: currentColor; border-bottom-color: currentColor;
  border-right-width: 2.5px; border-bottom-width: 2.5px;
}
.done-check {
  flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
  background: var(--surface-3); color: var(--faint); transition: background 0.15s, color 0.15s;
}
.edit-cell.is-done .done-check { background: var(--ok); color: #053123; }

.cell-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; color: var(--muted);
}
.edit-cell textarea {
  width: 100%; resize: vertical; background: var(--surface-2); color: var(--text);
  border: 1.5px solid var(--border-2); border-radius: 10px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; line-height: 1.45; min-height: 46px;
  transition: border-color 0.15s, background 0.15s;
}
.edit-cell textarea:focus { outline: none; border-color: var(--primary); background: var(--surface-3); }
.edit-cell textarea::placeholder { color: var(--faint); }

/* ===== Game ===== */
.game-body {
  background:
    radial-gradient(900px 500px at 50% -15%, rgba(124, 108, 255, 0.16), transparent 60%),
    var(--bg);
  min-height: 100vh;
}
.game-shell { max-width: 1500px; margin: 0 auto; padding: 18px 18px 48px; }
.game-title {
  text-align: center; font-size: clamp(24px, 4vw, 42px); font-weight: 800;
  letter-spacing: -0.8px; margin: 8px 0 20px;
}
.play-board { display: grid; gap: 10px; }
.play-cat {
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 14px 10px; min-height: 78px; border-radius: 14px;
  background: var(--primary-grad); border: none;
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.6px;
  font-size: clamp(13px, 1.55vw, 20px); color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  box-shadow: 0 8px 22px var(--primary-glow);
}
.play-cell {
  position: relative; background: linear-gradient(160deg, var(--surface-2) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border-2); color: #ffffff;
  font-weight: 800; font-size: clamp(26px, 3.4vw, 48px); letter-spacing: -1px;
  min-height: 92px; border-radius: 14px;
  text-shadow: 0 0 18px rgba(124, 108, 255, 0.7), 0 2px 4px rgba(0, 0, 0, 0.5);
  transition: transform 0.12s, border-color 0.12s, box-shadow 0.12s, color 0.12s;
}
.play-cell:hover:not(.used) {
  transform: translateY(-3px); border-color: var(--primary);
  box-shadow: 0 10px 26px var(--primary-glow); color: #fff;
  text-shadow: 0 0 24px rgba(124, 108, 255, 0.9), 0 2px 4px rgba(0, 0, 0, 0.5);
}
.play-cell.used {
  color: transparent; background: var(--bg-2); border-color: var(--border);
  cursor: default; box-shadow: none; transform: none;
}

/* Clue overlay */
.overlay {
  position: fixed; inset: 0; display: none; flex-direction: column;
  align-items: center; justify-content: center; z-index: 100; padding: 5vw;
  background:
    radial-gradient(1000px 600px at 50% 0%, rgba(124, 108, 255, 0.22), transparent 60%),
    rgba(8, 8, 12, 0.97);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: zoomIn 0.18s ease-out;
}
.overlay.show { display: flex; }
@keyframes zoomIn { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.overlay .ov-cat {
  position: absolute; top: 30px; left: 0; right: 0; text-align: center;
  color: var(--muted); font-size: clamp(14px, 2.2vw, 22px); font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
}
.overlay .ov-clue {
  text-align: center; color: #fff; font-weight: 700; letter-spacing: -0.5px;
  font-size: clamp(26px, 4.6vw, 58px); line-height: 1.25; max-width: 1100px;
}
.overlay .ov-answer {
  margin-top: 36px; font-size: clamp(20px, 3.6vw, 44px); font-weight: 800; text-align: center;
  display: none; letter-spacing: -0.3px;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.overlay.revealed .ov-answer { display: block; }
.overlay .ov-controls { position: absolute; bottom: 34px; display: flex; gap: 14px; }
.overlay .ov-hint { position: absolute; bottom: 100px; font-size: 13px; color: var(--faint); }

/* Empty / load state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; min-height: 62vh; text-align: center;
}
.empty-state h2 { font-size: clamp(26px, 4vw, 34px); font-weight: 800; letter-spacing: -0.6px; margin: 0; }
.empty-state p { max-width: 460px; color: var(--muted); line-height: 1.55; }
.empty-state code {
  background: var(--surface-2); padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--border-2); font-size: 0.9em;
}

/* Scoreboard */
.scoreboard { margin: 30px auto 0; max-width: 1040px; }
.scoreboard h3 {
  text-align: center; font-size: 14px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.4px; color: var(--muted); margin: 0 0 14px;
}
.teams { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.team {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; min-width: 168px; text-align: center; box-shadow: var(--shadow-soft);
}
.team input.team-name {
  width: 100%; background: transparent; border: none; border-bottom: 1px solid var(--border-2);
  color: var(--text); text-align: center; font-size: 15px; font-weight: 700; padding: 4px;
  font-family: inherit;
}
.team input.team-name:focus { outline: none; border-bottom-color: var(--primary); }
.team .score {
  font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 10px 0;
  background: var(--primary-grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.team .score-btns { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-3); border: 1px solid var(--border-2); color: var(--text);
  padding: 11px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 200;
  font-size: 14px; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.err { border-color: var(--danger); color: #ffb3c2; }
