/* =========================================================
   The Perfect Pour — Neon Arcade / Bar Nightlife Aesthetic
   ========================================================= */

/* ---------- Variables ---------- */
:root {
  --bg-deep:        #06070f;
  --bg-surface:     #0c0e1f;
  --bg-card:        rgba(255, 255, 255, 0.04);
  --border-subtle:  rgba(255, 255, 255, 0.08);

  /* Neon palette */
  --neon-blue:      #00d4ff;
  --neon-purple:    #9945ff;
  --neon-orange:    #ff6b2b;
  --neon-green:     #00ff9d;
  --neon-gold:      #ffd700;
  --neon-red:       #ff2d55;
  --neon-cyan:      #00ffff;
  --neon-pink:      #ff00a0;

  /* Text */
  --text-primary:   #e8eeff;
  --text-muted:     #7888aa;

  /* Glass pulse */
  --pulse-speed:    1.2s;
}

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

html, body {
  height: 100%;
  min-height: 100%;
}

body {
  background: radial-gradient(ellipse at 50% 0%, #12102a 0%, var(--bg-deep) 70%);
  color: var(--text-primary);
  font-family: Inter, system-ui, -apple-system, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Screens ---------- */
.screen {
  width: 100%;
  max-width: 480px;
  padding: 1rem 1rem 6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  min-height: calc(100vh - 60px); /* allow space for game-header partial */
}

.hidden { display: none !important; }

/* ---------- Typography helpers ---------- */
.neon-text-gold   { color: var(--neon-gold);   text-shadow: 0 0 10px rgba(255,215,0,0.6); }
.neon-text-blue   { color: var(--neon-blue);   text-shadow: 0 0 10px rgba(0,212,255,0.6); }
.neon-text-cyan   { color: var(--neon-cyan);   text-shadow: 0 0 10px rgba(0,255,255,0.6); }
.neon-text-purple { color: var(--neon-purple); text-shadow: 0 0 10px rgba(153,69,255,0.6); }
.neon-text-red    { color: var(--neon-red);    text-shadow: 0 0 10px rgba(255,45,85,0.6); }
.neon-text-green  { color: var(--neon-green);  text-shadow: 0 0 10px rgba(0,255,157,0.6); }

/* ---------- Welcome Screen ---------- */
.welcome-hero {
  text-align: center;
  padding-top: 1rem;
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 20px rgba(255,215,0,0.5));
  animation: floatIcon 3s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.game-title {
  font-size: clamp(1.8rem, 7vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--neon-blue) 0%, var(--neon-purple) 50%, var(--neon-orange) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  line-height: 1.1;
  margin-bottom: 0.6rem;
}

.game-tagline {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.game-tagline em {
  color: var(--neon-gold);
  font-style: normal;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255,215,0,0.5);
}

/* ---------- Name Input ---------- */
.welcome-name-wrap {
  width: 100%;
}

.name-input {
  width: 100%;
  padding: 0.875rem 1.25rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 1rem;
  font-family: inherit;
  text-align: center;
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.name-input::placeholder {
  color: var(--text-muted);
}

.name-input:focus {
  border-color: var(--neon-blue);
  box-shadow: 0 0 0 3px rgba(0,212,255,0.2), 0 0 16px rgba(0,212,255,0.1);
}

/* ---------- Welcome High Score ---------- */
.welcome-scores {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.6rem 1.25rem;
}

.hs-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hs-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--neon-gold);
  text-shadow: 0 0 12px rgba(255,215,0,0.6);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  text-decoration: none;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.96) !important;
}

.btn-xl {
  width: 100%;
  padding: 1.1rem 2rem;
  font-size: 1.2rem;
  border-radius: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--neon-blue) 0%, var(--neon-purple) 100%);
  color: #fff;
  box-shadow: 0 4px 24px rgba(0,212,255,0.35), 0 0 0 1px rgba(0,212,255,0.2);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,212,255,0.45), 0 0 0 1px rgba(0,212,255,0.3);
  filter: brightness(1.1);
}

.btn-secondary {
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.875rem 1.5rem;
  font-size: 0.95rem;
}

.btn-secondary:hover {
  transform: translateY(-2px);
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.07);
}

/* --- Action Button (big central START POUR / STOP!) --- */
.action-area {
  width: 100%;
  padding: 0 0 1rem;
  display: flex;
  justify-content: center;
}

.btn-action {
  width: 100%;
  max-width: 340px;
  padding: 1.25rem 2rem;
  font-size: 1.35rem;
  letter-spacing: 0.1em;
  border-radius: 18px;
  background: linear-gradient(135deg, #ff6b2b 0%, #ff2d55 100%);
  color: #fff;
  box-shadow: 0 6px 28px rgba(255,107,43,0.45), 0 0 0 2px rgba(255,107,43,0.2);
}

.btn-action:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 36px rgba(255,107,43,0.55), 0 0 0 2px rgba(255,107,43,0.3);
  filter: brightness(1.08);
}

.btn-action.pouring {
  background: linear-gradient(135deg, #ff2d55 0%, #ff0088 100%);
  box-shadow: 0 6px 28px rgba(255,45,85,0.55), 0 0 0 2px rgba(255,45,85,0.3);
  animation: stopBtnPulse 0.7s ease-in-out infinite alternate;
}

@keyframes stopBtnPulse {
  from { box-shadow: 0 6px 28px rgba(255,45,85,0.55), 0 0 0 2px rgba(255,45,85,0.3); }
  to   { box-shadow: 0 8px 40px rgba(255,45,85,0.75), 0 0 0 3px rgba(255,45,85,0.5); }
}

/* ---------- HUD ---------- */
.hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  margin-top: 0.25rem;
}

.hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  flex: 1;
}

.hud-label {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.hud-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.hud-score .hud-value {
  font-size: 1.2rem;
}

/* ---------- Glass Area ---------- */
.glass-area {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  padding: 0.5rem 0;
  flex: 1;
}

.glass-type-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--neon-blue);
  text-shadow: 0 0 8px rgba(0,212,255,0.4);
  opacity: 0.8;
}

.glass-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ---------- SVG Glass Styles (applied via JS-injected SVG) ---------- */
.glass-svg {
  filter: drop-shadow(0 0 6px rgba(0,212,255,0.2));
  transition: filter 0.3s ease;
  overflow: visible;
}

/* Pulsing glass glow (speed controlled by JS CSS variable) */
.glass-svg.pulse-active {
  animation: glassPulse var(--pulse-speed, 1.2s) ease-in-out infinite alternate;
}

@keyframes glassPulse {
  from { filter: drop-shadow(0 0 6px rgba(0,212,255,0.25)); }
  to   { filter: drop-shadow(0 0 18px rgba(0,212,255,0.7)) drop-shadow(0 0 36px rgba(153,69,255,0.4)); }
}

/* ---------- Score Popup ---------- */
.score-popup {
  position: absolute;
  top: 10%;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
  animation: popupAnim 0.9s ease-out forwards;
}

@keyframes popupAnim {
  0%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
  70%  { opacity: 1; transform: translateX(-50%) translateY(-30px) scale(1.15); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-52px) scale(0.9); }
}

/* ---------- Round Result ---------- */
.round-result {
  width: 100%;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.6rem 1rem;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  min-height: 2.5rem;
}

/* ---------- Distraction Overlay ---------- */
.distraction-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.distraction-overlay.flash {
  animation: flashAnim 0.18s ease-out forwards;
}

@keyframes flashAnim {
  0%   { opacity: 0; background: rgba(153,69,255,0.35); }
  40%  { opacity: 1; }
  100% { opacity: 0; background: rgba(0,212,255,0.2); }
}

/* Glass jitter distraction */
@keyframes jitterAnim {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-5px) rotate(-0.5deg); }
  40%  { transform: translateX(5px) rotate(0.5deg); }
  60%  { transform: translateX(-3px); }
  80%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}

.glass-wrapper.jitter {
  animation: jitterAnim 0.35s ease-in-out;
}

/* ---------- Game Over Screen ---------- */
.gameover-hero {
  text-align: center;
  padding-top: 1rem;
}

.gameover-emoji {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  filter: drop-shadow(0 0 16px rgba(255,215,0,0.5));
}

.gameover-title {
  font-size: clamp(1.8rem, 7vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--neon-gold);
  text-shadow: 0 0 24px rgba(255,215,0,0.5), 0 0 48px rgba(255,215,0,0.2);
  margin-bottom: 0.4rem;
}

.gameover-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.gameover-scores {
  display: flex;
  gap: 1rem;
  width: 100%;
}

.score-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.score-block-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.score-block-value {
  font-size: 2rem;
  font-weight: 900;
}

.new-hs-badge {
  background: linear-gradient(135deg, var(--neon-gold) 0%, #ff8c00 100%);
  color: #000;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.7rem 1.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(255,215,0,0.5);
  animation: badgeBounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badgeBounce {
  0%   { transform: scale(0.5); opacity: 0; }
  60%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.gameover-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

/* ---------- Leaderboard ---------- */
.leaderboard-panel {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1rem 1.25rem;
}

.leaderboard-title {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--neon-gold);
  text-shadow: 0 0 8px rgba(255,215,0,0.4);
  text-align: center;
  margin-bottom: 0.75rem;
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
}

.leaderboard-rank {
  font-size: 0.8rem;
  font-weight: 800;
  width: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.leaderboard-item:nth-child(1) .leaderboard-rank { color: #ffd700; }
.leaderboard-item:nth-child(2) .leaderboard-rank { color: #c0c0c0; }
.leaderboard-item:nth-child(3) .leaderboard-rank { color: #cd7f32; }

.leaderboard-name {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--neon-gold);
  text-shadow: 0 0 6px rgba(255,215,0,0.4);
  flex-shrink: 0;
}

.leaderboard-date {
  font-size: 0.65rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.leaderboard-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 0.5rem 0;
}

/* ---------- Instructions ---------- */
.instructions {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1rem 1.25rem;
}

.instructions-title {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--neon-purple);
  text-shadow: 0 0 8px rgba(153,69,255,0.4);
  margin-bottom: 0.75rem;
  text-align: center;
}

.instructions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  counter-reset: step-counter;
}

.instructions-list li {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  padding-left: 1.75rem;
  position: relative;
  counter-increment: step-counter;
}

.instructions-list li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(153,69,255,0.2);
  border: 1px solid rgba(153,69,255,0.3);
  border-radius: 50%;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--neon-purple);
}

.instructions-list li strong {
  color: var(--text-primary);
}

/* ---------- SVG elements (styled inline via JS, but base helpers) ---------- */

/* Liquid fill ripple on perfect pour */
@keyframes liquidRipple {
  0%   { opacity: 0.6; transform: scaleX(1); }
  50%  { opacity: 0.3; transform: scaleX(1.04); }
  100% { opacity: 0; transform: scaleX(1); }
}

/* HUD score bounce */
@keyframes scoreBounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1); }
}

.hud-score .hud-value.bounce {
  animation: scoreBounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-block;
}

/* ---------- Focus outlines ---------- */
*:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--neon-blue), 0 0 0 6px rgba(0,212,255,0.2);
  border-radius: 4px;
}
button:focus-visible { box-shadow: 0 0 0 3px var(--neon-blue), 0 0 0 8px rgba(0,212,255,0.25); }

/* ---------- Responsive ---------- */
@media (max-width: 400px) {
  .screen { padding: 0.75rem 0.75rem 5rem; }
  .game-title { font-size: 1.6rem; }
  .btn-action { font-size: 1.2rem; padding: 1rem 1.5rem; }
}

@media (min-height: 800px) {
  .screen { gap: 1.5rem; }
}

/* landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .screen { min-height: unset; padding-bottom: 2rem; }
  .welcome-icon { font-size: 2.5rem; }
  .game-title { font-size: 1.6rem; }
  .glass-area { min-height: 200px; }
}
