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

:root {
  --bg: #0f0e17;
  --surface: #1a1928;
  --card: #232136;
  --accent: #ff6e6c;
  --primary: #7f5af0;
  --secondary: #2cb67d;
  --text: #fffffe;
  --text-dim: #94a1b2;
  --left-color: #4fc3f7;
  --right-color: #ff7043;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
}

/* === START SCREEN === */
.logo {
  margin-top: 15vh;
  text-align: center;
  margin-bottom: 40px;
}
.logo h1 {
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: 6px;
  background: linear-gradient(135deg, var(--left-color), var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo .subtitle {
  color: var(--text-dim);
  margin-top: 8px;
  font-size: 1.1rem;
}
.logo-wave {
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, var(--left-color), var(--accent));
  border-radius: 2px;
  margin: 0 auto 16px;
}

/* === BUTTONS === */
.btn {
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  color: white;
}
.btn:active {
  transform: scale(0.95);
  opacity: 0.9;
}
.btn-primary { background: var(--primary); }
.btn-accent { background: var(--accent); }
.btn-secondary { background: var(--card); border: 2px solid var(--text-dim); margin-top: 12px; }
.btn-secondary-mode { background: var(--secondary); }
.btn-large { padding: 18px 48px; font-size: 1.3rem; }
.btn-shuffle {
  background: var(--card);
  border: 2px solid var(--text-dim);
  font-size: 0.95rem;
  padding: 10px 20px;
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* Rules */
.rules-toggle {
  margin-top: 24px;
  color: var(--text-dim);
  cursor: pointer;
  text-decoration: underline;
}
.rules {
  margin-top: 16px;
  background: var(--surface);
  border-radius: 12px;
  padding: 20px;
  max-width: 400px;
  text-align: left;
  line-height: 1.6;
}
.rules ol { padding-left: 20px; }
.rules li { margin-bottom: 8px; }
.hidden { display: none !important; }

/* === GAME SCREEN === */
#screen-game {
  padding: 12px 16px;
  justify-content: flex-start;
  gap: 10px;
}

.scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 500px;
}
.team {
  text-align: center;
}
.team-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.team-score {
  display: block;
  font-size: 2rem;
  font-weight: 800;
}
.team-a .team-score { color: var(--primary); }
.team-b .team-score { color: var(--accent); }
.round-info {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.turn-indicator {
  font-size: 1rem;
  font-weight: 600;
  padding: 6px 20px;
  border-radius: 20px;
  background: var(--surface);
}
.turn-a { border: 2px solid var(--primary); color: var(--primary); }
.turn-b { border: 2px solid var(--accent); color: var(--accent); }

/* Spectrum card */
.spectrum-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 500px;
  background: var(--card);
  border-radius: 16px;
  padding: 16px 20px;
}
.concept {
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 0;
  flex-shrink: 1;
  text-align: center;
}
.concept-left { color: var(--left-color); }
.concept-right { color: var(--right-color); }
.spectrum-bar {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}
.spectrum-gradient {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--left-color), var(--right-color));
}

/* === DIAL === */
.dial-container {
  position: relative;
  width: 320px;
  height: 180px;
  margin: 4px auto 0;
}

.dial {
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  overflow: hidden;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
  background: conic-gradient(
    from 180deg,
    var(--left-color) 0deg,
    #b388ff 90deg,
    var(--right-color) 180deg
  );
}

.dial::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  background: var(--bg);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.dial-ticks {
  position: absolute;
  width: 100%;
  height: 100%;
}

/* Target zone - wedge */
.target-zone {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.4s;
}
.target-zone.visible {
  opacity: 1;
}
.target-zone .tz-inner,
.target-zone .tz-mid,
.target-zone .tz-outer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  clip-path: none; /* set by JS */
}
.target-zone .tz-outer {
  background: rgba(255,255,255,0.12);
}
.target-zone .tz-mid {
  background: rgba(255,255,255,0.18);
}
.target-zone .tz-inner {
  background: rgba(255,255,255,0.35);
}

/* Needle */
.needle {
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 4px;
  height: 140px;
  background: var(--text);
  border-radius: 2px;
  transform-origin: bottom center;
  transform: translateX(-50%) rotate(0deg);
  z-index: 15;
  transition: transform 0.1s ease-out;
  box-shadow: 0 0 10px rgba(255,255,255,0.4);
}
.needle::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
}

/* Cover overlay */
.dial-cover {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--surface);
  z-index: 10;
  transition: opacity 0.5s;
  clip-path: polygon(0 0, 100% 0, 100% 50%, 0 50%);
}
.dial-cover.transparent {
  opacity: 0;
  pointer-events: none;
}

/* Touch area */
.dial-touch {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 25;
}

/* === CONTROLS === */
.controls {
  width: 100%;
  max-width: 500px;
  text-align: center;
  margin-top: 8px;
}
.phase {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.phase-text {
  color: var(--text-dim);
  font-size: 1rem;
}

/* Result */
.result-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}
.result-points {
  font-size: 3rem;
  font-weight: 800;
}
.result-label {
  color: var(--text-dim);
  font-size: 1rem;
}

/* === END SCREEN === */
#screen-end {
  justify-content: center;
  gap: 24px;
}
.end-title {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.end-scores {
  display: flex;
  gap: 48px;
}
.end-team {
  text-align: center;
}
.end-team span:first-child {
  display: block;
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 4px;
}
.end-score {
  font-size: 3rem;
  font-weight: 800;
}

/* Animations */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.pulse { animation: pulse 0.6s ease; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.phase { animation: slideUp 0.3s ease; }

/* === TABLET / SCREENS GRANDES === */
@media (min-width: 768px) {
  .logo h1 { font-size: 4rem; letter-spacing: 8px; }
  .logo .subtitle { font-size: 1.4rem; }
  .logo-wave { width: 120px; height: 5px; }
  .mode-buttons { flex-direction: row; gap: 20px; }

  #screen-game { gap: 16px; padding: 20px 24px; }

  .scoreboard, .spectrum-card, .controls { max-width: 640px; }
  .team-label { font-size: 1rem; }
  .team-score { font-size: 2.8rem; }
  .round-info { font-size: 1.1rem; }

  .turn-indicator { font-size: 1.25rem; padding: 10px 28px; }

  .spectrum-card { padding: 20px 28px; gap: 18px; }
  .concept { font-size: 1.25rem; }
  .spectrum-bar { height: 8px; }

  /* Dial mas grande */
  .dial-container { width: 520px; height: 290px; }
  .dial { width: 520px; height: 520px; }
  .dial::after { width: 28px; height: 28px; }
  .needle { height: 235px; width: 5px; }
  .needle::after { width: 16px; height: 16px; top: -5px; }

  .btn { font-size: 1.2rem; padding: 16px 36px; }
  .btn-large { padding: 20px 60px; font-size: 1.5rem; }
  .btn-shuffle { font-size: 1.05rem; padding: 12px 24px; }

  .phase-text { font-size: 1.15rem; }
  .result-points { font-size: 4rem; }
  .result-label { font-size: 1.2rem; }

  .end-title { font-size: 3rem; }
  .end-scores { gap: 80px; }
  .end-score { font-size: 4rem; }
}

/* Landscape corto: si la altura es limitada, dial un poco menor para que entre todo */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 720px) {
  #screen-game { gap: 10px; padding: 12px 20px; }
  .dial-container { width: 440px; height: 245px; }
  .dial { width: 440px; height: 440px; }
  .needle { height: 200px; }
  .team-score { font-size: 2.2rem; }
  .logo { margin-top: 6vh; margin-bottom: 24px; }
}
