/* ========================================================
   WORD SPIN — AUTHENTIC EUROPEAN ROULETTE STYLES
   ======================================================== */

.pointer { display: none !important; }

.answer-title { margin-top: 10px; }
.answer-title h1 { font-size: clamp(24px, 6.5vw, 38px); }
.answer-title h2 { margin-top: 3px; font-size: 13px; color: #d8cfff; font-weight: 500; }

/* --------------------------------------------------------
   Roulette Stage: Authentic SVG Casino Wheel
   -------------------------------------------------------- */
.wheel-stage {
  --wheel-size: min(86vw, 420px);
  position: relative;
  width: 100%;
  height: calc(var(--wheel-size) + 16px);
  min-height: calc(var(--wheel-size) + 16px);
  display: grid;
  place-items: center;
  margin: 0 auto 6px;
}

.roulette-wrapper {
  position: relative;
  width: var(--wheel-size);
  min-width: var(--wheel-size);
  height: var(--wheel-size);
  min-height: var(--wheel-size);
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.9), 0 0 25px rgba(227, 167, 99, 0.35);
}

.casino-roulette-svg {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}

/* Hitboxes for tapping directly on wheel sectors */
.pocket-hitboxes {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: auto;
}

.pocket-hitbox {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 25%;
  height: 25%;
  margin-left: -12.5%;
  margin-top: -12.5%;
  border-radius: 50%;
  background: transparent;
  border: 0;
  cursor: pointer;
  transform: rotate(var(--angle, calc(var(--i) * 45deg))) translateY(-120%);
  z-index: 15;
}

.pocket-hitbox:disabled {
  cursor: default;
}

/* Sector animations in SVG */
.svg-sector {
  transition: filter 0.25s ease;
}

.svg-sector.is-correct {
  animation: sector-glow 1.2s infinite alternate;
}

.svg-sector.is-wrong {
  opacity: 0.55;
}

.svg-sector.is-selected > path,
.svg-sector.is-selected > text,
.svg-sector.is-selected > circle {
  filter: drop-shadow(0 0 10px #fff08a) drop-shadow(0 0 22px #ffd65d);
}
.svg-sector.is-selected > path { stroke: #fff08a; stroke-width: 4px; }

@keyframes sector-glow {
  from { filter: drop-shadow(0 0 3px #2ee59d); }
  to { filter: drop-shadow(0 0 12px #2ee59d) drop-shadow(0 0 20px #ffd65d); }
}

/* --------------------------------------------------------
   The Roulette Ball: Ivory Ceramic Sphere
   -------------------------------------------------------- */
.roulette-ball {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f6f6f6 32%, #b5b5b5 72%, #505050 100%);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.85), inset 0 1px 2px #fff, 0 0 14px rgba(255, 255, 255, 0.95);
  z-index: 28;
  pointer-events: none;
  will-change: transform;
  display: none;
  transform: translate(-50%, -50%) rotate(var(--ball-angle, 0deg)) translateY(calc(-1 * var(--ball-radius, 47.5%))) rotate(calc(-1 * var(--ball-angle, 0deg)));
}

.roulette-ball.is-rolling {
  display: block;
}

.roulette-ball.is-landed {
  display: block;
  animation: ball-settle 0.4s ease-out;
}

@keyframes ball-settle {
  0% { transform: translate(-50%, -50%) rotate(var(--ball-angle, 0deg)) translateY(calc(-1 * var(--ball-radius, 26.8%))) rotate(calc(-1 * var(--ball-angle, 0deg))) scale(1.4); }
  50% { transform: translate(-50%, -50%) rotate(var(--ball-angle, 0deg)) translateY(calc(-1 * var(--ball-radius, 26.8%))) rotate(calc(-1 * var(--ball-angle, 0deg))) scale(0.9); }
  100% { transform: translate(-50%, -50%) rotate(var(--ball-angle, 0deg)) translateY(calc(-1 * var(--ball-radius, 26.8%))) rotate(calc(-1 * var(--ball-angle, 0deg))) scale(1); }
}

/* --------------------------------------------------------
   Choices Grid: Casino Betting Cards
   -------------------------------------------------------- */
.choices-container {
  position: absolute;
  z-index: 30;
  top: 50%;
  left: 50%;
  width: var(--wheel-size);
  height: var(--wheel-size);
  margin: 0;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.choices-label {
  font-size: 11px;
  font-weight: 700;
  color: #cbc3f5;
  margin-bottom: 7px;
  letter-spacing: 0.5px;
}

.choices-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 0;
  pointer-events: none;
}

.choice-card {
  position: relative;
  display: flex;
  align-items: center;
  width: 44%;
  min-width: 0;
  gap: 10px;
  padding: 11px 14px;
  min-height: 48px;
  border-radius: 13px;
  color: #f7f4ff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  transition: all 0.15s ease;
  cursor: pointer;
  text-align: left;
  pointer-events: auto;
}

.choice-card[data-card-choice="0"] { grid-area: 1 / 2; justify-self: center; align-self: center; }
.choice-card[data-card-choice="0"] { transform: translate(72px, 0); }
.choice-card[data-card-choice="1"] { grid-area: 1 / 1; justify-self: center; align-self: center; }
.choice-card[data-card-choice="2"] { grid-area: 2 / 2; justify-self: center; align-self: center; }
.choice-card[data-card-choice="3"] { grid-area: 2 / 1; justify-self: center; align-self: center; }
.choice-card[data-card-choice="1"],
.choice-card[data-card-choice="3"] { transform: translateX(-72px); }
.choice-card[data-card-choice="2"] { transform: translateX(72px); }

.choice-card.card-red {
  background: linear-gradient(145deg, #4a0e18, #25050a);
  border: 0;
}

.choice-card.card-black {
  background: linear-gradient(145deg, #26262e, #131316);
  border: 0;
}

.choice-card:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: none;
}

.choice-card:active:not(:disabled) {
  transform: translateY(1px);
}

.choice-card:disabled {
  cursor: default;
}

.choice-num {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: #ffd65d;
  color: #3b1702;
  font-size: 11px;
  font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.choice-word {
  min-width: 0;
  flex: 1;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: normal;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
}
  overflow: hidden;
  text-overflow: ellipsis;
}

.choice-card.is-selected {
  position: relative;
  z-index: 1;
  border: 0 !important;
  outline: 0 !important;
  background: transparent !important;
  color: #fffbe2;
  opacity: 1 !important;
  box-shadow: none !important;
}
.choice-card.is-selected .choice-word {
  color: #fff7c2;
  animation: choice-word-glow 0.8s ease-in-out infinite alternate;
}
@keyframes choice-word-glow {
  from { text-shadow: 0 0 5px #ffd65d, 0 0 10px rgba(255, 214, 93, 0.75); }
  to { text-shadow: 0 0 10px #fff08a, 0 0 24px #ffd65d, 0 0 34px rgba(255, 214, 93, 0.9); }
}

/* Large, high-contrast controls for comfortable reading and tapping. */
.choices-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.choice-card { display: grid; place-items: center; width: 88%; min-height: 76px; height: 34%; padding: 10px 4px; border-width: 0; }
.choice-num { position: absolute; top: 5px; left: 5px; width: 25px; height: 25px; font-size: 13px; }
.choice-word {
  display: block;
  width: 100%;
  flex: none;
  padding: 0 2px;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
  overflow-wrap: normal;
  word-break: normal;
  text-overflow: clip;
  line-height: 1.2;
  font-size: clamp(18px, 4.5vw, 24px);
  letter-spacing: 0;
}
.choice-correct-label { color: #baffdf; font-size: 15px; font-weight: 900; line-height: 1; text-shadow: 0 1px 4px #032f21; }
.answer-title h1 {
  width: 100%;
  white-space: nowrap;
  font-size: clamp(18px, 5.5vw, 34px);
  letter-spacing: -0.03em;
}
.answer-title h2 { font-size: 16px; }
.hint { font-size: 13px; line-height: 1.7; }

.choice-card.is-correct {
  border-color: #2ee59d !important;
  background: linear-gradient(145deg, #0f5238, #073020) !important;
  color: #8cffe2;
  box-shadow: 0 0 18px rgba(46, 229, 157, 0.6);
}

.choice-card.is-correct .choice-num {
  background: #2ee59d;
  color: #053b28;
}

.choice-card.is-wrong {
  border-color: #ff5b79 !important;
  background: linear-gradient(145deg, #571629, #360a17) !important;
  color: #ffadb7;
  opacity: 0.65;
  text-decoration: line-through;
}

.choice-card.is-wrong .choice-num {
  background: #ff5b79;
  color: white;
}

.choice-card.is-selected.is-correct,
.choice-card.is-selected.is-wrong {
  opacity: 1 !important;
  outline: 0 !important;
  box-shadow: none !important;
}

/* --------------------------------------------------------
   Feedback card & Next Button
   -------------------------------------------------------- */
.wheel-feedback {
  width: min(94%, 480px);
  margin: 10px auto 0;
  padding: 12px 16px;
  border-radius: 16px;
  text-align: center;
}

.wheel-feedback.good {
  color: #baffdf;
  background: rgba(30, 143, 108, 0.28);
  border: 1px solid #77edc2;
  box-shadow: 0 0 20px rgba(119, 237, 194, 0.25);
}

.wheel-feedback.retry {
  color: #ffd0d5;
  background: rgba(155, 56, 83, 0.28);
  border: 1px solid #ef8b9b;
  box-shadow: 0 0 20px rgba(239, 139, 155, 0.25);
}

.wheel-feedback b {
  display: block;
  font-size: 14px;
}

.wheel-feedback small {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.85;
}

.pronounce-answer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  margin: 10px auto 0;
  padding: 7px 16px;
  border-radius: 99px;
  background: #ffffffed;
  color: #4e327f;
  box-shadow: 0 3px 0 #b7a7dd;
  font-size: 11px;
  font-weight: 900;
}

.pronounce-answer svg { width: 17px; height: 17px; }
.pronounce-answer:active { translate: 0 2px; box-shadow: 0 1px 0 #b7a7dd; }
.home .pronounce-answer { min-height: 41px; margin: 0; padding: 7px 12px; font-size: 12px; white-space: nowrap; }
.home .top-actions { position: absolute; top: 96px; right: 36px; z-index: 40; display: flex; align-items: center; gap: 8px; }
.home .top-next { width: auto; min-height: 41px; margin: 0; padding: 0 12px; border-radius: 99px; font-size: 12px; white-space: nowrap; }
.home .top-next strong { margin: 0 6px 0 0; font-size: 18px; }
.home .top-next>b { font-size: 12px; letter-spacing: 0; }
.home .top-next small { display: none; }

.answer-study { margin: 18px auto 8px; max-width: 480px; padding: 20px; background: #ffffff12; border: 1px solid #a78be45c; border-radius: 18px; }
.answer-study h2 { font-size: 26px; color: #fff0aa; overflow-wrap: anywhere; }
.answer-study .study-pronunciation { margin: 7px 0 15px; color: #d0c3ec; font-size: 13px; }
.answer-study .study-example { font-size: 16px; line-height: 1.65; }
.answer-study .study-translation { margin-top: 8px; font-size: 13px; line-height: 1.8; color: #d9d0eb; }
.study-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.study-heading h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.study-heading > button { flex-shrink: 0; white-space: nowrap; }
.home .answer-study .pronounce-answer { margin: 0; }
.wordbook-entry { min-width: 0; flex: 1; }
.word-list article { align-items: flex-start; gap: 12px; }
.word-list article > button { flex: 0 0 42px; }
.wordbook-detail { margin-top: 10px; }
.wordbook-detail summary { cursor: pointer; color: #7053bf; font-size: 12px; padding: 4px 0; }
.word-list .wordbook-detail p { font-size: 13px; line-height: 1.7; margin-top: 8px; overflow-wrap: anywhere; }
.word-list .wordbook-detail .study-example { color: #31234e; }
.word-list .example-audio { display: flex; width: auto; height: auto; min-height: 38px; gap: 7px; padding: 7px 12px; margin: 0; border-radius: 12px; font-size: 12px; }
.example-audio svg { width: 18px; height: 18px; }

.next-btn {
  margin-top: 10px;
}

/* Result FX */
.outcome-fx { position: fixed; z-index: 40; inset: 0; pointer-events: none; overflow: hidden; }
.outcome-fx strong { position: absolute; z-index: 2; left: 50%; top: 40%; translate: -50% -50%; padding: 14px 26px; border-radius: 99px; font-size: clamp(24px, 7vw, 40px); white-space: nowrap; animation: outcome-pop 1.35s both; }
.outcome-fx.celebrate strong { color: #542500; background: linear-gradient(#fff8b0,#ffc632); border: 3px solid white; box-shadow: 0 0 45px #ffd85d, 0 8px 0 #a94e08; }
.outcome-fx.sad { background: rgba(8, 5, 38, 0.4); animation: sad-fade 1.7s both; }
.outcome-fx.sad strong { color: #e7e2ff; background: rgba(48, 37, 102, 0.93); border: 2px solid #8176bd; box-shadow: 0 8px 25px rgba(0,0,0,0.5); }
@keyframes outcome-pop { 0%{scale:.2;opacity:0}35%{scale:1.18;opacity:1}65%{scale:1}100%{scale:.94;opacity:0} }
@keyframes sad-fade { 0%,70%{opacity:1}100%{opacity:0} }

/* Navigation & Auth Modal */
.bottom-nav { grid-template-columns: repeat(4, 1fr); }
.auth-backdrop { position: absolute; z-index: 80; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(8, 4, 39, 0.78); backdrop-filter: blur(10px); }
.auth-modal { position: relative; width: min(100%, 430px); padding: 31px 25px 25px; border: 1px solid #806fc1; border-radius: 25px; color: #f8f5ff; text-align: center; background: linear-gradient(155deg,#2a1b70,#13094b); box-shadow: 0 24px 70px #000b, 0 0 35px rgba(141, 85, 223, 0.27); }
.auth-close { position: absolute; top: 13px; right: 13px; display: grid; place-items: center; width: 39px; height: 39px; border-radius: 50%; color: #c7bdea; background: rgba(255,255,255,0.07); }
.auth-close svg { width: 20px; }
.auth-emblem { display: grid; place-items: center; width: 58px; height: 58px; margin: 0 auto 15px; border: 2px solid #ffe27a; border-radius: 50%; color: #ffe27a; background: #6c3ac6; box-shadow: 0 0 22px rgba(255, 216, 93, 0.33); font-size: 27px; }
.auth-modal>.overline { color: #c8baff; }
.auth-modal h2 { margin: 7px 0 8px; font: 800 28px var(--serif); color: #fff0ab; }
.auth-copy { color: #c9c0e5; font-size: 11px; line-height: 1.8; }
.auth-modal form { display: grid; gap: 12px; margin-top: 20px; text-align: left; }
.auth-modal label { display: grid; gap: 6px; color: #d8d0ef; font-size: 10px; font-weight: 700; }
.auth-modal input { width: 100%; height: 48px; padding: 0 14px; border: 1px solid #7b6aaf; border-radius: 12px; outline: 0; color: #21184e; background: #fff; font: 600 14px var(--sans); }
.auth-modal input:focus { border-color: #ffda65; box-shadow: 0 0 0 3px rgba(255, 218, 101, 0.2); }
.auth-modal label small { color: #9488c0; font-size: 8px; }
#auth-error { min-height: 16px; color: #ffadb7; font-size: 10px; text-align: center; }
.auth-primary { width: 100%; min-height: 49px; margin-top: 5px; border-radius: 14px; color: #4c2400; background: linear-gradient(#fff3a2,#fdb92c); box-shadow: 0 4px 0 #9b4508; font-weight: 900; }
.auth-primary:disabled { opacity: .7; cursor: wait; }
.auth-switch { margin-top: 19px; color: #e1d8ff; background: transparent; font-size: 11px; text-decoration: underline; }
.auth-note { margin-top: 17px; color: #8f83b9; font-size: 8px; }

/* Wordbook & Stats Page Navigation */
.wordbook-header { position: relative; padding-top: 45px; }
.back-button { position: absolute; top: 0; left: 0; min-height: 36px; padding: 7px 12px; border: 1px solid #d9cfee; border-radius: 99px; color: #674b9e; background: #fff; box-shadow: 0 3px 0 #ddd4eb; font-size: 10px; font-weight: 900; }
.back-button:active { translate: 0 2px; box-shadow: 0 1px 0 #ddd4eb; }

/* Mobile Viewport Optimization */
@media (max-width: 719px) {
  .app-shell { padding-top: calc(50px + env(safe-area-inset-top)); padding-bottom: 0; }
  .home, .plain, .reveal, .quiz { min-height: calc(100dvh - 50px - env(safe-area-inset-top)); }
  .bottom-nav {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 50%;
    right: auto;
    width: min(100%, 640px);
    height: calc(50px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 8px 0;
    transform: translateX(-50%);
    border-top: 0;
    border-bottom: 1px solid #51468b;
    border-radius: 0 0 16px 16px;
  }
  .bottom-nav button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 8px; }
  .bottom-nav svg { width: 17px; height: 17px; }
  .bottom-nav button.active:after { bottom: 3px; width: 34px; }

  .wheel-stage {
    --wheel-size: min(84vw, 360px);
    height: calc(var(--wheel-size) + 12px);
    min-height: calc(var(--wheel-size) + 12px);
    margin-bottom: 4px;
  }

  /* Compact mode when feedback is visible */
  .home:has(.next-btn) .choices-container { display: block; }
  .home:has(.next-btn) .wheel-stage {
    --wheel-size: min(68vw, 280px);
    height: calc(var(--wheel-size) + 6px);
    min-height: calc(var(--wheel-size) + 6px);
  }
}

/* Keep navigation at the top and let the game background fill the available screen. */
.app-shell:has(.home) { min-height: calc(100dvh - 44px); padding-bottom: 0; }
.app-shell:has(.home) > .home { min-height: calc(100dvh - 44px); padding: 96px 36px 20px; }
.app-shell:has(.home) > .bottom-nav {
  position: absolute;
  top: 0;
  bottom: auto;
  width: 100%;
  transform: none;
  height: 72px;
  border-radius: 27px 27px 0 0;
}
@media (max-width: 719px) {
  .app-shell:has(.home) { min-height: 100dvh; padding-top: calc(50px + env(safe-area-inset-top)); }
  .app-shell:has(.home) > .home {
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 50px - env(safe-area-inset-top));
    min-height: calc(100dvh - 50px - env(safe-area-inset-top));
    padding: 18px 16px 24px;
  }
  .app-shell:has(.home) { overflow: visible; }
  .app-shell:has(.home) > .bottom-nav {
    position: fixed;
    top: 0;
    bottom: auto;
    left: 50%;
    right: auto;
    width: min(100%, 640px);
    height: calc(50px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 8px 0;
    border-radius: 0 0 16px 16px;
    transform: translateX(-50%);
  }
  .home .top-actions { position: static; justify-content: flex-end; margin: 8px 0 0; }
  .home .top-next { min-height: 41px; }
  .wheel-stage {
    --wheel-size: min(78vw, 300px);
    flex: 1 1 auto;
    height: auto;
    min-height: calc(var(--wheel-size) + 12px);
  }
  .home:has(.next-btn) .wheel-stage {
    --wheel-size: min(78vw, 300px);
    flex: 1 1 auto;
    height: auto;
    min-height: calc(var(--wheel-size) + 12px);
  }
  .choice-card[data-card-choice="0"] { transform: translate(16px, 0); }
  .choice-card[data-card-choice="1"],
  .choice-card[data-card-choice="3"] { transform: translateX(-16px); }
  .choice-card[data-card-choice="2"] { transform: translateX(16px); }
}
