:root {
  --bg1: #4a0018;
  --bg2: #7b0d2b;
  --gold: #ffda7b;
  --gold2: #f5b94d;
  --panel: rgba(0,0,0,0.35);
  --panel2: rgba(0,0,0,0.55);
  --white: #ffffff;
  --green: #3cc46b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(ellipse at top, var(--bg2), var(--bg1));
  color: var(--white);
  min-height: 100vh;
}

.header {
  text-align: center;
  padding: 30px 14px 10px 14px;
}

.header h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(255,214,107,0.75);
}

.subtitle {
  margin-top: 8px;
  font-style: italic;
  opacity: 0.9;
}

.container {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 10px 12px 30px 12px;
}

.machine {
  position: relative;
  width: min(920px, 100%);
  background: var(--panel);
  border-radius: 16px;
  padding: 18px 18px 30px 18px;
  box-shadow: 0 16px 40px rgba(0,0,0,0.55);
}

.reels {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  background: var(--panel2);
  padding: 12px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.08);
}

.reel {
  height: 250px;
  overflow: hidden;
  background: #0c0c0c;
  border-radius: 10px;
  border: 3px solid #222;
  position: relative;
}

.reel-strip {
  will-change: transform;
}

.symbol {
  height: 84px;
  display: grid;
  place-items: center;
  text-align: center;
  background: linear-gradient(#fff9e0, #f3e1a7);
  border-bottom: 1px solid #e9d7a0;
  color: #2d0313;
  font-weight: 800;
  padding: 6px 8px;
}

.symbol .num {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 2px;
}

.symbol .preview {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
}

.symbol.completed {
  opacity: 0.55;
  filter: grayscale(0.2);
}

.symbol.winner {
  outline: 3px solid var(--gold2);
  box-shadow: 0 0 14px rgba(245,185,77,0.9);
  z-index: 2;
}

.payline {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  background: linear-gradient(to right, transparent, var(--gold), transparent);
  box-shadow: 0 0 10px rgba(255,214,107,0.8);
  pointer-events: none;
}

.controls {
  margin-top: 16px;
  display: grid;
  place-items: center;
}

.spin-btn {
  width: min(320px, 90%);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  background: #c78c52;
  color: #3b0015;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(0,0,0,0.5);
}

.spin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.result {
  margin-top: 10px;
  min-height: 24px;
  text-align: center;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 6px rgba(255,214,107,0.7);
}

/* Lesson popup positioned lower */
.lesson-popup {
  position: fixed;
  left: 50%;
  top: 58%;
  transform: translateX(-50%);
  width: min(680px, 92vw);
  background: #fff;
  color: #2d0313;
  border-radius: 12px;
  padding: 14px 16px 16px 16px;
  box-shadow: 0 14px 30px rgba(0,0,0,0.6);
  opacity: 0;
  pointer-events: none;
  z-index: 9999;
}

.lesson-popup.open {
  opacity: 1;
  pointer-events: auto;
}

.lesson-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.lesson-popup-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  color: var(--bg2);
}

.lesson-close {
  background: transparent;
  border: none;
  font-weight: 900;
  cursor: pointer;
  color: var(--bg2);
  font-size: 18px;
}

.lines {
  max-height: 36vh;
  overflow-y: auto;
  padding-right: 6px;
  border-top: 1px solid #eee;
  border-bottom: 1px solid #eee;
}

.lines .line {
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}

.lines .speaker {
  font-weight: 900;
  margin-bottom: 4px;
}

.lines .en {
  font-size: 17px;
  font-weight: 800;
}

.lines .pron {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 2px;
  font-style: italic;
}

.lines .sp {
  font-size: 15px;
  margin-top: 4px;
}

.lesson-footer-msg {
  margin-top: 10px;
  background: #fff3cf;
  padding: 10px;
  border-radius: 8px;
  font-weight: 800;
  text-align: center;
  color: #b04b00;
}

.mark-btn {
  margin-top: 10px;
  width: 100%;
  background: var(--green);
  border: none;
  color: #fff;
  padding: 12px;
  font-size: 15px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 900;
}

.footer {
  font-size: 12px;
  opacity: 0.9;
  padding: 18px 14px 28px 14px;
  max-width: 700px;
  margin: 0 auto;
  text-align: center;
}

@media (max-width: 420px) {
  .reel { height: 210px; }
  .symbol { height: 64px; }
  .symbol .num { font-size: 18px; }
  .payline { height: 6px; }
  .lesson-popup { top: 60%; }
}
