/* ============================================================
   DECIDER — Project Decision Maker
   Theme: Dark editorial / game-show — navy + electric gold
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────────── */
:root {
  --bg-base:       #07090f;
  --bg-card:       #0d1120;
  --bg-card-hover: #131829;
  --bg-input:      #080c18;

  --border:        rgba(255,255,255,0.07);
  --border-bright: rgba(255,255,255,0.15);

  --gold:          #f5c842;
  --gold-dim:      #c49d1e;
  --gold-glow:     rgba(245,200,66,0.18);

  --cyan:          #3ef6e8;
  --red:           #ff4f5e;
  --green:         #3effa0;

  --text-primary:  #f0f2ff;
  --text-muted:    #6b7499;
  --text-dim:      #3a4162;

  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;

  --font-display: 'Bebas Neue', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'Space Mono', monospace;

  --shadow-card: 0 4px 32px rgba(0,0,0,0.5);
  --shadow-gold: 0 0 28px rgba(245,200,66,0.25);

  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.55;
}

ul { list-style: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input { font-family: inherit; }

/* ── Background Decoration ──────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
}

.bg-glow {
  position: fixed; top: -200px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 500px; pointer-events: none; z-index: 0;
  background: radial-gradient(ellipse at center, rgba(245,200,66,0.06) 0%, transparent 70%);
}

/* ── Header ─────────────────────────────────────────────────── */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(7,9,15,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(16px, 4vw, 48px);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* Logo */
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  user-select: none;
}
.logo-icon {
  font-size: 1.6rem;
  color: var(--gold);
  filter: drop-shadow(0 0 8px var(--gold));
  animation: pulse-icon 3s ease-in-out infinite;
}
@keyframes pulse-icon {
  0%, 100% { filter: drop-shadow(0 0 6px var(--gold)); }
  50%       { filter: drop-shadow(0 0 16px var(--gold)); }
}
.logo-text {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}
.logo-text em {
  font-style: normal;
  color: var(--gold);
}

/* Mode Toggle */
.mode-toggle {
  position: relative;
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
  gap: 2px;
}

.toggle-btn {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 7px;
  padding: 8px 18px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-radius: calc(var(--radius-lg) - 4px);
  transition: color var(--transition);
  white-space: nowrap;
}
.toggle-btn .toggle-icon { font-size: 0.9rem; }
.toggle-btn.active { color: var(--bg-base); }

.toggle-slider {
  position: absolute;
  top: 4px; left: 4px;
  height: calc(100% - 8px);
  background: var(--gold);
  border-radius: calc(var(--radius-lg) - 4px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), width 0.3s ease;
  box-shadow: 0 0 16px rgba(245,200,66,0.4);
  z-index: 0;
}

/* ── App Container ───────────────────────────────────────────── */
.app-container {
  position: relative; z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 48px);
}

/* ── Mode Panels ─────────────────────────────────────────────── */
.mode-panel { width: 100%; }
.mode-panel.hidden { display: none; }

/* Wheel Layout */
.wheel-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
  align-items: start;
}

/* Matrix Layout */
.matrix-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.score-card { grid-column: 1 / -1; }
.result-card { grid-column: 1 / -1; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-bright); }

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.18em;
  color: var(--gold);
  margin-bottom: 4px;
}
.card-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

/* ── Form Inputs ─────────────────────────────────────────────── */
.text-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.text-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px var(--gold-glow);
}
.text-input::placeholder { color: var(--text-dim); }

.weight-input { width: 72px; flex-shrink: 0; text-align: center; }

.option-input-row,
.criteria-input-row {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 16px;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-icon {
  flex-shrink: 0;
  width: 38px; height: 38px;
  background: var(--gold);
  color: var(--bg-base);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 2px 12px rgba(245,200,66,0.3);
}
.btn-icon:hover {
  background: #ffe066;
  transform: scale(1.08);
  box-shadow: 0 4px 20px rgba(245,200,66,0.5);
}
.btn-icon:active { transform: scale(0.95); }

.btn-primary {
  width: 100%;
  padding: 14px 24px;
  background: var(--gold);
  color: var(--bg-base);
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-gold);
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  margin-top: 20px;
}
.btn-primary:hover {
  background: #ffe066;
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(245,200,66,0.45);
}
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  padding: 9px 18px;
  border: 1px solid var(--border-bright);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  transition: border-color var(--transition), color var(--transition), background var(--transition);
}
.btn-ghost:hover {
  border-color: var(--gold-dim);
  color: var(--gold);
  background: var(--gold-glow);
}
.btn-sm { font-size: 0.72rem; padding: 7px 14px; }

/* ── Option List ─────────────────────────────────────────────── */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
  margin-bottom: 16px;
}

.option-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  animation: slide-in 0.22s ease forwards;
  transition: border-color var(--transition);
}
.option-item:hover { border-color: var(--border-bright); }

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

.option-color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.option-label {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.option-label-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--gold-dim);
}
.option-actions { display: flex; gap: 4px; }
.option-btn {
  width: 26px; height: 26px;
  border-radius: 4px;
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition);
}
.option-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }
.option-btn.delete:hover { color: var(--red); }
.option-btn.edit:hover { color: var(--cyan); }

/* ── Controls Footer ─────────────────────────────────────────── */
.controls-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.option-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ── History ─────────────────────────────────────────────────── */
.history-section { border-top: 1px solid var(--border); padding-top: 18px; }
.history-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.history-list {
  display: flex; flex-direction: column; gap: 5px;
  max-height: 140px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.history-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,0.03);
}
.history-item-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.history-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item-time { font-family: var(--font-mono); font-size: 0.65rem; color: var(--text-dim); flex-shrink: 0; }
.history-empty { font-size: 0.78rem; color: var(--text-dim); font-style: italic; padding: 4px 6px; }

/* ── Wheel Stage ─────────────────────────────────────────────── */
.wheel-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 16px 0;
}
.wheel-wrapper {
  position: relative;
  width: clamp(280px, 50vw, 460px);
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
}

.wheel-pointer {
  position: absolute;
  top: -8px; left: 50%;
  transform: translateX(-50%);
  font-size: 1.8rem;
  color: var(--gold);
  filter: drop-shadow(0 0 10px var(--gold));
  z-index: 10;
  line-height: 1;
}

#wheel-canvas {
  width: 100%; height: 100%;
  border-radius: 50%;
  filter: drop-shadow(0 0 30px rgba(245,200,66,0.15));
  transition: filter 0.3s;
}
#wheel-canvas.spinning {
  filter: drop-shadow(0 0 50px rgba(245,200,66,0.35));
}

/* Center hub */
.wheel-wrapper::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 28px; height: 28px;
  background: var(--bg-base);
  border: 3px solid var(--gold);
  border-radius: 50%;
  z-index: 5;
  box-shadow: 0 0 12px rgba(245,200,66,0.5);
}

/* Spin Button */
.btn-spin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: linear-gradient(135deg, #f5c842 0%, #e5a800 100%);
  color: var(--bg-base);
  border-radius: var(--radius-lg);
  padding: 18px 56px;
  box-shadow: 0 4px 32px rgba(245,200,66,0.4), 0 0 0 4px rgba(245,200,66,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.btn-spin::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 60%);
}
.btn-spin:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 48px rgba(245,200,66,0.6), 0 0 0 4px rgba(245,200,66,0.15);
}
.btn-spin:active:not(:disabled) { transform: scale(0.97); }
.btn-spin:disabled {
  opacity: 0.6; cursor: not-allowed;
  transform: none;
}
.spin-label {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 0.2em;
  line-height: 1;
}
.spin-sub {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  opacity: 0.7;
}

/* ── Criteria List ───────────────────────────────────────────── */
.criteria-list {
  display: flex; flex-direction: column; gap: 6px;
  margin-bottom: 16px;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
}
.criteria-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  animation: slide-in 0.22s ease forwards;
}
.criteria-name {
  flex: 1; font-size: 0.85rem; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.criteria-weight-badge {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--gold);
  background: var(--gold-glow);
  border: 1px solid rgba(245,200,66,0.2);
  padding: 2px 8px;
  border-radius: 20px;
  flex-shrink: 0;
}

/* Weight bar */
.weight-bar-wrapper {
  display: flex; align-items: center; gap: 12px;
}
.weight-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.weight-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
}
.weight-bar-fill.over { background: linear-gradient(90deg, var(--red), #ff8a95); }
.weight-total {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 70px;
}
.weight-total.over { color: var(--red); }
.weight-total.complete { color: var(--green); }

/* ── Score Table ─────────────────────────────────────────────── */
.score-table-wrapper {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-bright) transparent;
  border-radius: var(--radius-sm);
}
.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  min-width: 400px;
}
.score-table th {
  text-align: left;
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.score-table th.option-header {
  color: var(--gold);
  text-align: center;
}
.score-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}
.score-table tr:last-child td { border-bottom: none; }
.score-table tr:hover td { background: rgba(255,255,255,0.02); }

.score-cell-label { color: var(--text-muted); }
.score-cell-weight {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.score-input {
  width: 58px;
  display: block;
  margin: 0 auto;
  text-align: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 6px 4px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.score-input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 2px var(--gold-glow);
}

/* ── Results ─────────────────────────────────────────────────── */
.result-card {
  animation: reveal-card 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes reveal-card {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.result-content {
  display: flex; align-items: center; gap: 20px;
  background: linear-gradient(135deg, rgba(245,200,66,0.06), transparent);
  border: 1px solid rgba(245,200,66,0.2);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
}
.result-trophy { font-size: 2.5rem; flex-shrink: 0; }
.result-winner-name {
  font-family: var(--font-display);
  font-size: 2.2rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  line-height: 1;
}
.result-winner-score {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.result-breakdown {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 20px;
}
.result-row {
  display: flex; align-items: center; gap: 12px;
}
.result-row-name {
  font-size: 0.82rem;
  color: var(--text-muted);
  width: 140px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.result-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.05);
  border-radius: 4px;
  overflow: hidden;
}
.result-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0;
}
.result-bar-fill.winner {
  background: linear-gradient(90deg, #f5c842, #ffe066);
  box-shadow: 0 0 8px rgba(245,200,66,0.5);
}
.result-score-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-dim);
  width: 44px;
  text-align: right;
}
.result-crown { font-size: 0.9rem; }

/* ── Celebration Overlay ─────────────────────────────────────── */
.celebration-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(7,9,15,0.88);
  backdrop-filter: blur(6px);
  animation: fade-overlay 0.35s ease forwards;
}
.celebration-overlay.hidden { display: none; }
@keyframes fade-overlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#confetti-canvas {
  position: absolute; inset: 0; pointer-events: none;
}

.celebration-inner {
  position: relative; z-index: 1;
  text-align: center;
  animation: pop-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.5) translateY(30px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.celebration-winner {
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 6rem);
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 0 60px rgba(245,200,66,0.5);
  line-height: 1;
  margin-bottom: 12px;
  word-break: break-word;
}
.celebration-sub {
  font-size: 1rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  margin-bottom: 28px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  .wheel-layout {
    grid-template-columns: 1fr;
  }
  .wheel-stage { padding: 0; }
}

@media (max-width: 680px) {
  .matrix-layout {
    grid-template-columns: 1fr;
  }
  .score-card { grid-column: 1; }
  .result-card { grid-column: 1; }

  .mode-toggle {
    gap: 0;
    padding: 3px;
  }
  .toggle-btn {
    padding: 7px 12px;
    font-size: 0.65rem;
  }
  .toggle-btn .toggle-icon { display: none; }

  .logo-text { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .header-inner { height: 56px; }
  .btn-spin { padding: 14px 40px; }
  .spin-label { font-size: 1.7rem; }
  .result-row-name { width: 90px; }
}

/* ── Scrollbar ───────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Utility ─────────────────────────────────────────────────── */
.hidden { display: none !important; }
