* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

#app {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

#hud {
  display: flex;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 1.1rem;
  font-weight: 600;
  background: #1e293b;
}

#playfield {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: linear-gradient(#0f172a, #1e293b);
  border-bottom: 3px solid #f59e0b;
}

#piece {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  padding: 10px 22px;
  background: #6366f1;
  border-radius: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
  white-space: nowrap;
  will-change: top;
}

#piece.wrong { background: #dc2626; }
#piece.right { background: #16a34a; }

#piece2 {
  position: absolute;
  top: 0;
  padding: 10px 22px;
  background: #0d9488;
  border-radius: 10px;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.4);
  white-space: nowrap;
  will-change: top;
}

#piece.side-left { left: 25%; }
#piece2.side-right { left: 75%; transform: translateX(-50%); }

#piece.danger {
  animation: blink 0.25s steps(2) infinite;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.7);
}

@keyframes blink {
  50% { background: #ef4444; }
}

#hud-combo {
  color: #fbbf24;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { transform: scale(1); }
  to { transform: scale(1.2); }
}

#playfield.shake {
  animation: shake 0.35s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.score-pop {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  color: #fbbf24;
  font-size: 1.5rem;
  font-weight: 800;
  pointer-events: none;
  animation: rise 0.9s ease-out forwards;
  z-index: 5;
}

@keyframes rise {
  to { transform: translateX(-50%) translateY(-70px); opacity: 0; }
}

.particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fbbf24;
  pointer-events: none;
  animation: fly 0.7s ease-out forwards;
  z-index: 4;
}

@keyframes fly {
  to {
    transform: translate(var(--dx), var(--dy)) scale(0);
    opacity: 0;
  }
}

/* Thumb-friendly: vertical stack hugging the right edge, low on screen */
#hint-bar {
  position: absolute;
  right: 12px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  z-index: 3;
}

#hint-bar button {
  position: relative;
  width: 56px;
  height: 56px;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #4f46e5, #6366f1);
  border: 2px solid rgba(165, 180, 252, 0.5);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.45);
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-tap-highlight-color: transparent;
}
#hint-bar button:hover:not(:disabled),
#hint-bar button:active:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.65);
}
#hint-bar button:disabled {
  opacity: 0.3;
  cursor: default;
  box-shadow: none;
  filter: grayscale(1);
}

.hint-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f172a;
  background: #fbbf24;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

#hint-text {
  position: absolute;
  bottom: 24px;
  left: 12px;
  right: 84px;
  padding: 12px 16px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid #6366f1;
  border-radius: 10px;
  font-size: 1rem;
  color: #c7d2fe;
  text-align: center;
  z-index: 3;
}

.hint-line + .hint-line {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(99, 102, 241, 0.4);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.92);
  z-index: 10;
}

.screen h1 { font-size: 2.2rem; color: #a5b4fc; }
.screen p { color: #94a3b8; }

.screen button {
  padding: 12px 40px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  background: #6366f1;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.screen button:hover { background: #4f46e5; }

#options {
  display: flex;
  gap: 10px;
  padding: 14px;
  min-height: 84px;
  background: #1e293b;
}

#options button {
  flex: 1;
  padding: 14px 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: #e2e8f0;
  background: #334155;
  border: 2px solid #475569;
  border-radius: 10px;
  cursor: pointer;
}
#options button:hover { background: #475569; }
#options button:disabled { opacity: 0.5; cursor: default; }

#options button.opt-right {
  background: #16a34a;
  border-color: #22c55e;
  opacity: 1;
}

#options button.opt-wrong {
  background: #dc2626;
  border-color: #ef4444;
  opacity: 1;
}

#gameover-screen {
  justify-content: flex-start;
  overflow-y: auto;
  padding-top: 40px;
}

.review-title {
  font-size: 1.1rem;
  color: #a5b4fc;
  margin-top: 10px;
}

.learned-list {
  list-style: none;
  width: 100%;
  max-width: 360px;
  text-align: left;
}

.learned-list li {
  border-radius: 8px;
  padding: 8px 14px;
  margin-bottom: 6px;
  font-weight: 600;
}

.learned-list .mark { float: right; }

/* Green shades: 1 hit → light, 2 → medium, 3+ → super green */
.learned-list .tier-1 { background: rgba(74, 222, 128, 0.18); color: #86efac; }
.learned-list .tier-2 { background: rgba(34, 197, 94, 0.35); color: #4ade80; }
.learned-list .tier-3 {
  background: #16a34a;
  color: #f0fdf4;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.55);
}

/* Missed and never answered right */
.learned-list .tier-0 { background: rgba(250, 204, 21, 0.2); color: #fde047; }

.learned-empty { color: #64748b; font-weight: 400; }

#words-panel { overflow-y: auto; justify-content: flex-start; padding-top: 40px; z-index: 20; }

.screen button.secondary {
  background: #334155;
  font-size: 1rem;
  padding: 10px 30px;
}
.screen button.secondary:hover { background: #475569; }

#ad-gameover { width: 100%; max-width: 360px; min-height: 0; }
#ad-gameover ins { min-height: 100px; }

#site-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 8px;
  background: #0f172a;
  font-size: 0.8rem;
}
#site-footer a { color: #64748b; text-decoration: none; }
#site-footer a:hover { color: #94a3b8; }

.wave-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(15, 23, 42, 0.85);
  z-index: 8;
  animation: banner-in 0.3s ease;
}
#wave-banner-title { font-size: 2rem; font-weight: 800; color: #a5b4fc; }
#wave-banner-sub { font-size: 1rem; color: #94a3b8; }

#wave-banner-actions { display: flex; gap: 12px; margin-top: 12px; }
#wave-banner-actions button {
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 22px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #fff;
}
#wave-go-btn {
  background: #6366f1;
  position: relative;
  overflow: hidden;
}
#wave-go-btn.countdown::after {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.7);
  animation: count-shrink var(--count-ms, 4000ms) linear forwards;
  transform-origin: left;
}
@keyframes count-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}
#wave-pause-btn { background: #334155; }
#wave-pause-btn:hover { background: #475569; }

@keyframes banner-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.wave-banner.review #wave-banner-title { color: #60a5fa; }
.wave-banner.golden #wave-banner-title { color: #fbbf24; }
.wave-banner.sudden #wave-banner-title { color: #ef4444; }
.wave-banner.expressions #wave-banner-title { color: #c084fc; }
.wave-banner.dual #wave-banner-title { color: #4ade80; }


#playfield.golden {
  background: linear-gradient(#1c1917, #3b2f0b);
  border-bottom-color: #fbbf24;
  box-shadow: inset 0 0 40px rgba(251, 191, 36, 0.25);
}

/* Journey bar (start screen) */
#journey-bar { width: 100%; max-width: 340px; }
.journey-track { display: flex; gap: 3px; }
.journey-seg {
  position: relative;
  flex: 1;
  height: 18px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 5px;
  overflow: hidden;
}
.journey-seg span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #94a3b8;
}
.journey-seg.done .journey-fill, .journey-seg .journey-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #6366f1);
}
.journey-seg.done span, .journey-seg.current span { color: #e2e8f0; }
.journey-seg.soon { opacity: 0.55; }
.journey-caption { margin-top: 6px; font-size: 0.8rem; color: #94a3b8; text-align: center; }

/* Journey panel */
#journey-panel { overflow-y: auto; justify-content: flex-start; padding-top: 40px; z-index: 20; }
.journey-total { font-size: 0.9rem; }
#journey-list { list-style: none; width: 100%; max-width: 380px; text-align: left; }
.journey-band {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.journey-band.current { border-color: #6366f1; box-shadow: 0 0 10px rgba(99, 102, 241, 0.35); }
.journey-band.done { border-color: #16a34a; }
.journey-band.soon { opacity: 0.6; }
.band-head { display: flex; align-items: center; gap: 8px; }
.band-icon { width: 18px; text-align: center; }
.journey-band.done .band-icon { color: #4ade80; }
.band-range { margin-left: auto; font-size: 0.75rem; color: #64748b; }
.band-desc { font-size: 0.85rem; color: #94a3b8; margin-top: 4px; }
.band-preview { font-size: 0.8rem; color: #818cf8; margin-top: 4px; font-style: italic; }

/* Milestone screen */
#milestone-screen { z-index: 25; }
#milestone-screen h1 { color: #fbbf24; }
#milestone-next { color: #a5b4fc; font-weight: 600; }

.hidden { display: none !important; }

/* Combo escalation — one new layer per tier */
#hud-combo.combo-tier-1 { animation-duration: 0.45s; }
#hud-combo.combo-tier-2 { color: #fb923c; text-shadow: 0 0 8px rgba(251, 146, 60, 0.7); }
#hud-combo.combo-tier-3 { color: #f97316; text-shadow: 0 0 10px rgba(249, 115, 22, 0.8); }
#hud-combo.combo-tier-4 { color: #ef4444; text-shadow: 0 0 12px rgba(239, 68, 68, 0.8); }
#hud-combo.combo-tier-5 { color: #ef4444; text-shadow: 0 0 14px rgba(239, 68, 68, 1); }
#hud-combo.combo-tier-6 { color: #f43f5e; text-shadow: 0 0 16px rgba(244, 63, 94, 1); }
#hud-combo.combo-tier-7 { color: #fbbf24; text-shadow: 0 0 18px rgba(251, 191, 36, 1); }

#playfield.combo-glow {
  box-shadow: inset 0 0 30px rgba(239, 68, 68, 0.25);
  animation: glow-pulse 1.2s ease-in-out infinite alternate;
}
#playfield.combo-gold {
  box-shadow: inset 0 0 40px rgba(251, 191, 36, 0.35);
}
@keyframes glow-pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.12); }
}

#playfield.gold-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(251, 191, 36, 0.35);
  pointer-events: none;
  z-index: 9;
  animation: flash-out 0.5s ease-out forwards;
}
@keyframes flash-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.hype-pop {
  position: absolute;
  left: 50%;
  top: 35%;
  transform: translateX(-50%);
  font-size: 2rem;
  font-weight: 900;
  color: #f97316;
  text-shadow: 0 0 16px rgba(249, 115, 22, 0.8);
  pointer-events: none;
  z-index: 7;
  animation: hype 1.2s ease-out forwards;
}
.hype-pop.gold {
  color: #fbbf24;
  text-shadow: 0 0 20px rgba(251, 191, 36, 1);
}
@keyframes hype {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  20% { transform: translateX(-50%) scale(1.2); opacity: 1; }
  40% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { transform: translateX(-50%) translateY(-30px) scale(1); opacity: 0; }
}

.particle.hot { background: #f97316; }
.particle.gold { background: #fbbf24; box-shadow: 0 0 6px rgba(251, 191, 36, 0.9); }

/* Start-screen wave selector */
#wave-select {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
}
#wave-select.hidden { display: none; }
#wave-select span { color: #94a3b8; font-size: 0.95rem; min-width: 130px; }
#wave-select button {
  width: 36px;
  height: 36px;
  font-size: 1.2rem;
  font-weight: 800;
  border: none;
  border-radius: 8px;
  background: #334155;
  color: #fff;
  cursor: pointer;
  padding: 0;
}
#wave-select button:disabled { opacity: 0.35; cursor: default; }
