:root {
  --bg: #0b0c10;
  --surface: #141821;
  --surface-2: #1b2130;
  --text: #eaeef3;
  --muted: #9aa3b2;
  --accent: #a78bfa; /* purple */
  --accent-strong: #8b5cf6;
  --success: #20c997;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji', sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 10% -20%, rgba(167,139,250,0.12), transparent 60%),
              radial-gradient(900px 600px at 120% 20%, rgba(139,92,246,0.12), transparent 70%),
              var(--bg);
  overflow-x: hidden;
}

.container {
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.header {
  padding: 24px 20px 8px;
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.logo {
  font-weight: 800;
  font-size: 26px;
  letter-spacing: 0.6px;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.subtitle {
  color: var(--muted);
  font-weight: 500;
}

.topnav { margin: 10px 0 0; display: flex; gap: 10px; }
.link { background: transparent; border: none; color: var(--muted); font-weight: 700; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.link:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.link.active { color: var(--text); background: rgba(255,255,255,0.12); }

.muted { color: var(--muted); }

.main {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 8px 0 24px;
}

.step {
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.0)), var(--surface);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 220ms ease, opacity 220ms ease;
}
.step.enter { animation: stepEnter 220ms ease; }
@keyframes stepEnter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.step[hidden] { display: none; }
.step + .step { margin-top: 16px; }
.step-title { margin: 6px 4px 14px; font-size: 18px; font-weight: 700; }

.taste-wrap { margin-top: 12px; display: grid; gap: 8px; }
.taste-title { color: var(--muted); font-size: 14px; }
.segmented { display: inline-flex; border: 1px solid rgba(255,255,255,0.12); border-radius: 999px; padding: 4px; background: rgba(255,255,255,0.06); }
.seg-item { position: relative; }
.seg-item input { position: absolute; inset: 0; opacity: 0; }
.seg-item span { display: inline-block; padding: 8px 12px; color: var(--muted); border-radius: 999px; cursor: pointer; transition: background 160ms ease, color 160ms ease; }
.seg-item input:checked + span { background: rgba(255,255,255,0.18); color: var(--text); }

.toolbar { display: flex; justify-content: flex-end; margin: 0 0 10px; }
.hint { color: var(--muted); margin: 0 2px 8px; font-size: 13px; }
.cool-wrap { display: grid; gap: 8px; margin: 6px 0 12px; }
.check-chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.06); width: fit-content; cursor: pointer; }
.check-chip input { appearance: none; width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(255,255,255,0.4); display: grid; place-items: center; }
.check-chip input:checked { background: var(--accent); border-color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
}

.option-card {
  position: relative;
  display: block;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.0)), var(--surface-2);
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  cursor: pointer;
  user-select: none;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.option-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.32); }
.option-card:active { transform: translateY(0); }
.option-card input { position: absolute; inset: 0; opacity: 0; pointer-events: none; }
.option-card .content { display: grid; gap: 4px; padding: 16px; }
.option-card .title { font-weight: 700; }
.option-card .desc { color: var(--muted); font-size: 14px; }
.option-card input:checked + .content { border-radius: 12px; outline: 2px solid transparent; box-shadow: 0 0 0 2px var(--accent); }

.summary-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: linear-gradient(180deg, rgba(167,139,250,0.12), rgba(167,139,250,0.04));
}
.summary-line { display: flex; justify-content: space-between; gap: 10px; }
.summary-line span { color: var(--muted); }
.summary-note { margin: 8px 0 0; color: var(--muted); }

.mix-list { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 6px; }
.mix-list li { 
  display: flex; 
  align-items: center;
  justify-content: space-between; 
  padding: 8px 10px; 
  border-radius: 10px; 
  background: rgba(255,255,255,0.04); 
  border: 1px solid rgba(255,255,255,0.08); 
  position: relative;
  overflow: hidden;
}
.mix-list li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--flavor-color, #888);
}
.mix-list li .flavor-name {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mix-list li .color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--flavor-color, #888);
  flex-shrink: 0;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 0 2px;
}
.controls-right { display: flex; gap: 10px; }

.btn {
  appearance: none;
  border: none;
  padding: 12px 16px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, background 160ms ease;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

.btn.primary { color: #0e0e12; background: linear-gradient(135deg, #ffffff, #cec3ff); }
.btn.primary:hover { background: linear-gradient(135deg, #ffffff, #b9a8ff); }
.btn.secondary { color: var(--text); background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); }
.btn.secondary:hover { background: rgba(255,255,255,0.12); }
.btn.ghost { color: var(--muted); background: transparent; border: 1px dashed rgba(255,255,255,0.22); }
.btn.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.36); }
.btn.success { color: #06281c; background: linear-gradient(135deg, #34d399, #22c55e); }
.btn.success:hover { background: linear-gradient(135deg, #22c55e, #16a34a); }

.footer {
  padding: 18px 20px 28px;
  color: var(--muted);
  text-align: center;
}

/* Dice overlay */
.overlay[hidden] { display: none !important; }
.overlay { position: fixed; inset: 0; background: rgba(10,12,16,0.75); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 1000; }
.dice-scene { 
  width: 260px; 
  height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.dice-scene canvas { 
  width: 260px !important; 
  height: 260px !important; 
  display: block;
  touch-action: none;
}
.dice-scene .hint { 
  color: var(--muted); 
  margin: 0;
  text-align: center;
}
.hint { color: var(--muted); }
/* CSS cube removed in favor of WebGL */
@keyframes spin { from { transform: rotateX(0) rotateY(0); } to { transform: rotateX(360deg) rotateY(360deg); } }

/* Presentation overlay */
.overlay.present { background: rgba(10,12,16,0.9); padding: 16px; }
.present-card { width: min(860px, 96vw); background: var(--surface); border: 1px solid rgba(255,255,255,0.12); border-radius: 16px; box-shadow: var(--shadow); display: grid; gap: 12px; padding: 16px; }
.present-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.present-brand { font-weight: 800; letter-spacing: 0.5px; }
.present-actions { display: flex; gap: 8px; }
.present-body { display: grid; gap: 10px; font-size: 18px; }
.present-line strong { font-size: 20px; }
.mix-list.large li { padding: 12px 14px; font-size: 18px; }
/* removed table input styles */

@media (max-width: 480px) {
  .present-card { padding: 12px; }
  .present-body { font-size: 16px; }
  .present-line strong { font-size: 18px; }
  .dice-scene { width: 200px; height: 220px; }
  .dice-scene canvas { width: 200px !important; height: 200px !important; }
}

.saved-list { display: grid; gap: 10px; }
.saved-card { display: grid; gap: 8px; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px solid rgba(255,255,255,0.08); }
.saved-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.saved-title { font-weight: 700; }
.saved-meta { 
  color: var(--muted); 
  font-size: 13px; 
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.saved-actions { display: flex; gap: 8px; }
.saved-stars { display: inline-flex; gap: 6px; align-items: center; }
.star { 
  cursor: pointer; 
  font-size: 32px; 
  color: rgba(255,255,255,0.2); 
  transition: color 150ms ease, transform 150ms cubic-bezier(0.34, 1.56, 0.64, 1), filter 150ms ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding: 4px;
  margin: -4px;
}
.star:hover { 
  color: rgba(248, 208, 71, 0.6); 
  transform: scale(1.15);
  filter: drop-shadow(0 0 8px rgba(248, 208, 71, 0.4));
}
.star.active { 
  color: #f8d047;
  filter: drop-shadow(0 2px 4px rgba(248, 208, 71, 0.5));
}
.star:active { 
  transform: scale(1.3) rotate(-8deg); 
  filter: drop-shadow(0 0 12px rgba(248, 208, 71, 0.8));
}
.star.bump { animation: starBump 280ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes starBump { 
  0% { transform: scale(1) rotate(0deg); } 
  30% { transform: scale(1.4) rotate(-12deg); filter: drop-shadow(0 0 16px rgba(248, 208, 71, 0.9)); } 
  60% { transform: scale(0.95) rotate(3deg); } 
  100% { transform: scale(1) rotate(0deg); } 
}
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 20px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: var(--muted); transition: transform 120ms ease, box-shadow 200ms ease; }
.tag:active { transform: scale(0.95); }
.tag.pulse-like { animation: pulseGreen 220ms ease; }
.tag.pulse-dislike { animation: pulseRed 220ms ease; }
@keyframes pulseGreen { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.6); } 100% { box-shadow: 0 0 0 12px rgba(52,211,153,0); } }
@keyframes pulseRed { 0% { box-shadow: 0 0 0 0 rgba(239,68,68,0.6); } 100% { box-shadow: 0 0 0 12px rgba(239,68,68,0); } }
.tag.like { color: #34d399; }
.tag.dislike { color: #ef4444; }
.empty-note { color: var(--muted); margin: 12px 2px 0; }

.profile-card { display: grid; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid rgba(255,255,255,0.08); margin-bottom: 12px; }
.profile-head { display: grid; gap: 8px; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.badge { padding: 6px 10px; border-radius: 999px; font-size: 12px; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: var(--text); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12); box-shadow: var(--shadow); z-index: 999; }

/* Mobile optimizations */
@media (max-width: 480px) {
  .header { padding: 16px 12px 6px; }
  .topnav { gap: 6px; overflow-x: auto; }
  .link { padding: 6px 10px; font-size: 14px; }

  .profile-summary { gap: 4px; }
  .level-row { font-size: 14px; }
  .xp-progress { height: 6px; }
  .meta-row { font-size: 12px; }

  .main { width: calc(100% - 16px); padding: 6px 0 16px; }
  .step { padding: 16px; }
  .step-title { font-size: 16px; margin: 4px 2px 12px; }

  .grid { gap: 10px; }
  .option-card .content { padding: 14px; }

  .toolbar { margin-bottom: 8px; }
  #rollBtn { width: 100%; }
  .hint { font-size: 12px; }

  .controls { flex-direction: column; align-items: stretch; gap: 10px; }
  .controls .btn { width: 100%; }
  .controls-right { width: 100%; order: -1; display: grid; grid-template-columns: 1fr; gap: 8px; }

  .saved-card { padding: 12px; }
  .saved-head { flex-direction: column; align-items: stretch; gap: 8px; }
  .saved-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .saved-stars { gap: 4px; }
  .star { font-size: 28px; padding: 6px; margin: -6px; }

  .dice-scene { width: 180px; height: 200px; }
  .dice-scene canvas { width: 180px !important; height: 180px !important; }

  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); font-size: 14px; }

  /* Make segmented controls wrap nicely on mobile */
  .segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0; border: 0; background: transparent; }
  .seg-item span { width: 100%; text-align: center; border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; background: rgba(255,255,255,0.06); }
  .seg-item input:checked + span { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.24); }
}


