/* ============================================
   PERAHU BIDAR MATEMATIKA – Sungai Lematang
   style.css  |  PID-optimized: solid colors
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;800;900&family=Fredoka+One&display=swap');

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

/* ======== WARNA SOLID (PID) ======== */
:root {
  /* Warna angka – fully solid, vivid */
  --c1: #00BCD4;
  /* Cyan    = 1  → teks gelap */
  --c2: #FF6D00;
  /* Orange  = 2  → teks gelap */
  --c3: #CDDC39;
  /* Lime    = 3  → teks gelap */
  --c4: #E53935;
  /* Merah   = 4  → teks putih */
  --c5: #FF4081;
  /* Pink    = 5  → teks putih */
  --c6: #7B1FA2;
  /* Ungu    = 6  → teks putih */
  --c7: #6D4C41;
  /* Coklat  = 7  → teks putih */
  --c8: #2E7D32;
  /* Hijau   = 8  → teks putih */
  --c9: #1565C0;
  /* Biru    = 9  → teks putih */
  --c10: #37474F;
  /* Abu     = 10 → teks putih */

  /* UI Solid */
  --bg: #0B2545;
  --bg2: #0D3461;
  --card: #163A6A;
  --card2: #1E4D86;
  --border: #2D6A9F;
  --river-top: #0A4A6E;
  --river-mid: #0D6B9E;
  --river-bot: #0A4A6E;
  --foam: #7DD3FC;

  --gold: #F59E0B;
  --green: #16A34A;
  --red: #DC2626;
  --p1: #2563EB;
  --p2: #DC2626;

  --ff: 'Nunito', sans-serif;
  --ft: 'Fredoka One', cursive;
  --r: 14px;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: var(--ff);
  background: var(--bg);
  color: #fff;
  overflow: hidden;
}

/* ======== SCREENS ======== */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* we let inner content scroll if needed */
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* ======== RIVER BG (menu/setup/result) ======== */
.river-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #0B2545 0%, #0D5080 40%, #1272A8 70%, #0B2545 100%);
  overflow: hidden;
  z-index: 0;
}

.river-wave {
  position: absolute;
  left: -50%;
  bottom: 0;
  width: 200%;
  height: 100px;
  background: rgba(125, 211, 252, 0.1);
  border-radius: 50% 50% 0 0;
  animation: waveAnim 6s ease-in-out infinite;
}

.river-wave.wave1 {
  bottom: -15px;
  opacity: .8;
}

.river-wave.wave2 {
  bottom: -35px;
  animation-delay: 2s;
  opacity: .5;
  height: 80px;
}

.river-wave.wave3 {
  bottom: -55px;
  animation-delay: 4s;
  opacity: .3;
  height: 60px;
}

@keyframes waveAnim {

  0%,
  100% {
    transform: translateX(0) scaleY(1);
  }

  50% {
    transform: translateX(3%) scaleY(1.1);
  }
}

/* ========================================
   MENU
   ======================================== */
.menu-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 680px;
  padding: 10px 20px;
  overflow: hidden;
  max-height: 100vh;
}

.menu-content::-webkit-scrollbar {
  width: 0px;
}

.menu-logo {
  text-align: center;
}

.boat-icon {
  font-size: 45px;
  display: block;
  animation: boatBob 2s ease-in-out infinite;
}

@keyframes boatBob {

  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }

  50% {
    transform: translateY(-10px) rotate(3deg);
  }
}

.game-title {
  font-family: var(--ft);
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  line-height: 1.1;
  color: #fff;
  text-shadow: 0 3px 12px rgba(0, 0, 0, .6);
}

.game-title span {
  color: var(--gold);
}

.game-subtitle {
  font-size: 1rem;
  font-weight: 700;
  color: var(--foam);
  margin-top: 6px;
  letter-spacing: 1px;
}

/* Legend */
.legend-preview {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 14px 18px;
  text-align: center;
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
}

.legend-title {
  font-weight: 800;
  font-size: .95rem;
  color: var(--foam);
  margin-bottom: 12px;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.legend-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.legend-circle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  box-shadow: 0 5px 16px rgba(0, 0, 0, .55);
  font-size: 20px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
}

.legend-circle:hover {
  transform: scale(1.1);
}

.legend-circle.dark-text {
  color: #111;
  text-shadow: none;
}

.legend-circle.light-text {
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}

.legend-num {
  display: none;
}

/* Compact legend – IN-GAME (besar & jelas) */
.legend-row.compact .legend-circle {
  width: 54px;
  height: 54px;
  font-size: 18px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .5);
}

.legend-row.compact .legend-num {
  font-size: .78rem;
  font-weight: 900;
  background: rgba(0, 0, 0, .45);
  border-radius: 5px;
  padding: 1px 5px;
}

.legend-bar {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 8px 10px;
  flex-shrink: 0;
}

/* Mode buttons */
.menu-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--r);
  font-family: var(--ff);
  font-size: 0.95rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  min-width: 150px;
}

.btn-mode .btn-icon {
  font-size: 2rem;
}

.btn-single {
  background: #2563EB;
  color: #fff;
  box-shadow: 0 5px 16px rgba(37, 99, 235, .5);
}

.btn-battle {
  background: #D97706;
  color: #fff;
  box-shadow: 0 5px 16px rgba(217, 119, 6, .5);
}

.btn-mode:hover {
  transform: translateY(-3px) scale(1.04);
}

.btn-mode:active {
  transform: scale(.96);
}

/* ========================================
   SETUP
   ======================================== */
.setup-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 700px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100vh;
  overflow: hidden;
  justify-content: center;
}

.setup-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setup-title {
  font-family: var(--ft);
  font-size: 1.4rem;
  color: var(--gold);
}

.btn-back {
  background: var(--card2);
  border: 2px solid var(--border);
  color: #fff;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: var(--ff);
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  transition: background .2s;
}

.btn-back:hover {
  background: var(--card);
}

.setup-section {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
}

.setup-section h3 {
  font-size: .85rem;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--foam);
}

.setup-row-2col {
  display: flex;
  gap: 10px;
}

.setup-row-2col .setup-section {
  flex: 1;
}

/* Level cards */
.level-cards {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.level-card {
  background: var(--bg2);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: center;
  transition: all .2s;
  flex: 1;
}

.level-card.active {
  border-color: var(--gold);
  background: #1A3A00;
}

.level-num {
  font-family: var(--ft);
  font-size: 1.8rem;
  color: var(--gold);
  line-height: 1;
}

.level-desc {
  font-size: .72rem;
  color: rgba(255, 255, 255, .8);
  margin: 3px 0;
}

.level-tag {
  font-size: .65rem;
  font-weight: 800;
  background: var(--card2);
  border-radius: 20px;
  padding: 2px 7px;
  display: inline-block;
}

/* Operation buttons */
.op-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.op-btn {
  padding: 7px 12px;
  border: 2px solid var(--border);
  background: var(--bg2);
  color: #fff;
  border-radius: 8px;
  font-family: var(--ff);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}

.op-btn.active {
  border-color: var(--green);
  background: #14532D;
}

.op-btn:hover {
  transform: scale(1.06);
}

/* Timer picker */
.timer-picker {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.timer-adj {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--card2);
  border: 2px solid var(--border);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 900;
  cursor: pointer;
  transition: background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-adj:hover {
  background: var(--border);
}

.timer-val {
  font-family: var(--ft);
  font-size: 2rem;
  color: var(--gold);
  min-width: 60px;
  text-align: center;
}

/* Name inputs */
.name-inputs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.name-input-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.name-input-group label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--foam);
}

.name-input-group input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--bg2);
  color: #fff;
  font-family: var(--ff);
  font-size: .95rem;
  outline: none;
}

.name-input-group input:focus {
  border-color: var(--gold);
}

.name-input-group input::placeholder {
  color: rgba(255, 255, 255, .35);
}

.btn-start {
  width: 100%;
  padding: 14px;
  background: #16A34A;
  color: #fff;
  border: none;
  border-radius: var(--r);
  font-family: var(--ff);
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  transition: all .2s;
  letter-spacing: .5px;
  box-shadow: 0 5px 16px rgba(22, 163, 74, .5);
}

.btn-start:hover {
  background: #15803D;
  transform: translateY(-2px);
}

/* ========================================
   COUNTDOWN
   ======================================== */
.countdown-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.countdown-label {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--foam);
  margin-bottom: 12px;
}

.countdown-number {
  font-family: var(--ft);
  font-size: clamp(5rem, 18vw, 11rem);
  color: var(--gold);
  text-shadow: 0 0 40px rgba(245, 158, 11, .7);
  animation: countPop .6s ease-out;
  line-height: 1;
}

@keyframes countPop {
  0% {
    transform: scale(2.2);
    opacity: 0;
  }

  60% {
    transform: scale(.9);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.countdown-sub {
  font-size: 1.1rem;
  font-weight: 700;
  color: rgba(255, 255, 255, .65);
  margin-top: 14px;
}

/* ========================================
   GAME 1 PLAYER – NO SCROLL
   ======================================== */
#screen-game1p {
  background: var(--bg);
  justify-content: flex-start;
  align-items: center;
}

.game1p-layout {
  width: 100%;
  max-width: 560px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 12px;
  gap: 8px;
  overflow: hidden;
}

/* Header */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 7px 12px;
  flex-shrink: 0;
}

.player-tag {
  font-weight: 800;
  font-size: .9rem;
  padding: 5px 12px;
  border-radius: 20px;
}

.p1-tag {
  background: #1E3A8A;
  border: 2px solid var(--p1);
}

.p2-tag {
  background: #7F1D1D;
  border: 2px solid var(--p2);
}

.timer-box {
  font-family: var(--ft);
  font-size: 1.2rem;
  color: var(--gold);
  background: #78350F;
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 5px 14px;
}

.score-box {
  text-align: center;
}

.score-label {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  color: var(--foam);
}

.score-box span:last-child {
  font-family: var(--ft);
  font-size: 1.7rem;
  color: var(--gold);
}


/* Question area */
.question-area {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 12px;
  text-align: center;
  flex-shrink: 0;
}

.question-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.question-row.compact {
  gap: 8px;
}

.color-circle {
  border-radius: 50%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .65);
  flex-shrink: 0;
}

.color-circle.big {
  width: 96px;
  height: 96px;
}

.color-circle.med {
  width: 62px;
  height: 62px;
}

.operator-symbol {
  font-size: 2.8rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  line-height: 1;
}

.operator-symbol.small {
  font-size: 1.8rem;
}

.equals-symbol {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--foam);
  text-shadow: 0 2px 6px rgba(0, 0, 0, .5);
  line-height: 1;
}

.equals-symbol.small {
  font-size: 1.8rem;
}

.answer-box {
  min-width: 80px;
  height: 70px;
  background: var(--bg2);
  border: 3px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ft);
  font-size: 2.2rem;
  color: var(--gold);
  transition: all .18s;
}

.answer-box.small {
  min-width: 54px;
  height: 48px;
  font-size: 1.6rem;
}

.answer-box.correct {
  border-color: #22C55E;
  background: #14532D;
}

.answer-box.wrong {
  border-color: #EF4444;
  background: #7F1D1D;
  animation: shake .3s;
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-7px);
  }

  75% {
    transform: translateX(7px);
  }
}

/* ---- Numpad 0-9 ---- */
.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  flex-shrink: 0;
}

.numpad.small-numpad {
  gap: 4px;
  flex: 1;
  min-height: 0;
}

.num-btn {
  aspect-ratio: 1;
  background: var(--card2);
  border: 2px solid var(--border);
  color: #fff;
  border-radius: 10px;
  font-family: var(--ft);
  font-size: 1.5rem;
  font-weight: 900;
  cursor: pointer;
  transition: all .1s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, .4);
}

/* Panel numpad: fixed height, tidak pakai aspect-ratio */
.small-numpad .num-btn {
  aspect-ratio: unset;
  height: 100%;
  font-size: 1.1rem;
  border-radius: 7px;
  border-width: 1px;
}

.num-btn:hover {
  background: #2D6A9F;
  transform: scale(1.08);
}

.num-btn:active {
  transform: scale(.9);
  background: var(--border);
}

/* Actions */
.numpad-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  justify-content: center;
}

.btn-clear {
  padding: 10px 22px;
  background: #DC2626;
  border: 2px solid #EF4444;
  border-radius: 10px;
  color: #fff;
  font-family: var(--ff);
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s;
}

.btn-clear.sm {
  padding: 7px 16px;
  font-size: .8rem;
  border-radius: 8px;
}

.btn-submit {
  padding: 10px 30px;
  background: #16A34A;
  border: 2px solid #22C55E;
  border-radius: 10px;
  color: #fff;
  font-family: var(--ff);
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  transition: all .15s;
}

.btn-submit.sm {
  padding: 7px 20px;
  font-size: .8rem;
  border-radius: 8px;
}

.btn-clear:hover {
  background: #B91C1C;
}

.btn-submit:hover {
  background: #15803D;
}

/* Streak */
.streak-bar {
  display: none;
}

/* ========================================
   GAME 2 PLAYER – NO SCROLL
   ======================================== */
#screen-game2p {
  background: var(--bg);
  justify-content: flex-start;
  align-items: center;
}

.game2p-layout {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  gap: 6px;
  overflow: hidden;
}

/* Race header */
.race-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 6px 14px;
  flex-shrink: 0;
  position: relative;
}

.race-scores-group {
  display: flex;
  align-items: center;
  gap: 18px;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.race-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.race-score-p1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  color: var(--foam);
  font-weight: 800;
  font-size: .85rem;
}

.race-score-p2 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  color: #FCA5A5;
  font-weight: 800;
  font-size: .85rem;
}

.race-score-val {
  font-family: var(--ft);
  font-size: 1.6rem;
  color: var(--gold);
}

.race-header .timer-box {
  font-size: 1rem;
}

.vs-badge {
  font-family: var(--ft);
  font-size: 1.1rem;
  font-style: italic;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid var(--gold);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

/* ---- SUNGAI LEMATANG RIVER TRACK ---- */
.river-track {
  position: relative;
  border-radius: 12px;
  overflow: visible;
  height: 130px;
  background: linear-gradient(180deg, var(--river-top) 0%, var(--river-mid) 50%, var(--river-top) 100%);
  border: 3px solid #2D8CBB;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
  flex-shrink: 0;
  clip-path: inset(0 0 0 0 round 12px);
}

/* Flowing water */
.river-water {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg,
      transparent 0px,
      transparent 16px,
      rgba(125, 211, 252, 0.12) 16px,
      rgba(125, 211, 252, 0.12) 19px);
  background-size: 38px 100%;
  animation: riverFlow 1.6s linear infinite;
}

@keyframes riverFlow {
  0% {
    background-position: 0 0;
  }

  100% {
    background-position: 38px 0;
  }
}

/* Sungai Lematang text */
.river-text,
.river-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--ft);
  font-size: 1.3rem;
  color: rgba(255, 255, 255, .25);
  letter-spacing: 6px;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
  user-select: none;
}

/* Lanes */
.race-lane {
  position: absolute;
  width: calc(100% - 16px);
  left: 8px;
  display: flex;
  align-items: center;
  height: 34px;
}

.lane-p1 {
  top: 15px;
}

.lane-p2 {
  bottom: 15px;
}

/* Boat */
.boat {
  position: absolute;
  left: 0%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: left 0.55s cubic-bezier(.34, 1.56, .64, 1);
  z-index: 4;
}

.boat-p1 .boat-svg {
  font-size: 26px;
}

.boat-p2 .boat-svg {
  font-size: 26px;
}

.boat-label {
  font-size: .55rem;
  font-weight: 900;
  background: rgba(0, 0, 0, .7);
  border-radius: 3px;
  padding: 1px 3px;
  color: #fff;
  line-height: 1.2;
}

/* Finish flag & vertical line */
.finish-line {
  position: absolute;
  right: 8px;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 5;
  border-left: 2px dashed rgba(255, 255, 255, 0.6);
  padding-left: 4px;
}

.finish-flag {
  font-size: 1.1rem;
}

.finish-text {
  font-family: var(--ft);
  font-size: 0.7rem;
  color: var(--gold);
  writing-mode: vertical-rl;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* Progress bars */
.progress-track {
  position: absolute;
  left: 8px;
  right: 36px;
  height: 3px;
  background: rgba(255, 255, 255, .15);
  border-radius: 2px;
  z-index: 3;
}

.pt-p1 {
  top: calc(15px + 20px);
}

.pt-p2 {
  bottom: calc(15px + 20px);
}

.progress-fill-p1 {
  height: 100%;
  width: 0%;
  background: #3B82F6;
  border-radius: 2px;
  transition: width .55s ease;
}

.progress-fill-p2 {
  height: 100%;
  width: 0%;
  background: #EF4444;
  border-radius: 2px;
  transition: width .55s ease;
}

/* Player panels */
.player-panels {
  display: flex;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.player-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--r);
  padding: 8px;
  overflow: hidden;
  min-height: 0;
}

.panel-header {
  font-weight: 900;
  font-size: .85rem;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border);
  flex-shrink: 0;
}

.p1-header {
  color: var(--foam);
}

.p2-header {
  color: #FCA5A5;
}

.panel-actions {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  justify-content: center;
}

.panel-stats {
  display: none;
}

/* ========================================
   RESULT
   ======================================== */
.result-content {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.result-trophy {
  font-size: 5rem;
  animation: trophyBounce 1s ease-out;
}

@keyframes trophyBounce {
  0% {
    transform: scale(0) rotate(-15deg);
    opacity: 0;
  }

  70% {
    transform: scale(1.15) rotate(5deg);
  }

  100% {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.result-title {
  font-family: var(--ft);
  font-size: 2.5rem;
  color: var(--gold);
}

.result-winner {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.result-stats {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  min-width: 110px;
  text-align: center;
}

.stat-card .stat-val {
  font-family: var(--ft);
  font-size: 1.8rem;
  color: var(--gold);
  display: block;
}

.stat-card .stat-label {
  font-size: .75rem;
  font-weight: 700;
  color: rgba(255, 255, 255, .7);
}

.result-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 380px;
}

.btn-back-main {
  flex: 1;
  padding: 12px;
  background: var(--card2);
  border: 2px solid var(--border);
  color: #fff;
  border-radius: var(--r);
  font-family: var(--ff);
  font-size: .95rem;
  font-weight: 800;
  cursor: pointer;
  transition: background .2s;
}

.btn-back-main:hover {
  background: var(--card);
}

#btn-play-again {
  flex: 1;
}

/* Confetti */
.confetti-container {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 1;
  }

  100% {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

/* Feedback flash */
.feedback-flash {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  animation: flashAnim .35s ease-out forwards;
}

.correct-flash {
  background: rgba(34, 197, 94, .18);
}

.wrong-flash {
  background: rgba(239, 68, 68, .18);
}

@keyframes flashAnim {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* Boat animations */
.boat.moving .boat-svg {
  animation: boatRock .55s ease-in-out infinite alternate;
}

@keyframes boatRock {
  0% {
    transform: rotate(-2deg) translateY(0);
  }

  100% {
    transform: rotate(2deg) translateY(-3px);
  }
}

.boat.correct-pulse {
  animation: boatPulse .45s ease-out;
}

@keyframes boatPulse {
  0% {
    filter: brightness(1);
  }

  40% {
    filter: brightness(2) drop-shadow(0 0 10px #22C55E);
  }

  100% {
    filter: brightness(1);
  }
}

/* Score pop */
@keyframes scorePop {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.4);
    color: var(--gold);
  }
}

.score-pop {
  animation: scorePop .28s ease-out;
}

/* Audio button */
.audio-btn {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 200;
  width: 44px;
  height: 44px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform .2s;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}

.audio-btn:hover {
  transform: scale(1.12);
}

/* ========================================
   MENU FOOTER & MODAL INFO
   ======================================== */
.menu-footer {
  margin-top: 10px;
  padding: 12px 20px;
  background: rgba(0, 0, 0, 0.15);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.btn-info {
  background: linear-gradient(135deg, #3B82F6, #2563EB);
  color: #fff;
  border: none;
  padding: 10px 24px;
  font-size: 1.1rem;
  font-weight: 800;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

.btn-info:active {
  transform: translateY(2px);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.4);
}

.copyright {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, .7);
  font-weight: 600;
}

.copyright a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 800;
}

.copyright a:hover {
  text-decoration: underline;
  color: #FFD700;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity .3s;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  display: flex;
}

.modal-content.info-content {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  border-radius: 20px;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8);
  transform: translateY(0) scale(1);
  transition: transform .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  padding: 0;
  overflow: hidden;
}

.modal-overlay.hidden .modal-content {
  transform: translateY(50px) scale(0.95);
}

.info-header {
  background: linear-gradient(135deg, #1E3A8A, #3B82F6);
  padding: 25px 20px;
  text-align: center;
  position: relative;
  border-bottom: 3px solid var(--gold);
}

.info-header h2 {
  color: white;
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.5px;
}

.btn-close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}

.btn-close-modal:hover {
  background: var(--red);
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.4);
}

.info-scroll-area {
  padding: 25px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.info-scroll-area::-webkit-scrollbar {
  width: 8px;
}

.info-scroll-area::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.info-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.info-scroll-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.4);
}

.info-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  transition: transform 0.2s, background 0.2s;
}

.info-card:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.2);
}

.info-icon {
  font-size: 2.5rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.2));
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  flex-shrink: 0;
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.1), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.info-text h3 {
  color: var(--gold);
  margin: 0 0 8px 0;
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.info-text p {
  margin: 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 500;
}

/* ======== RESPONSIVE ======== */
@media (max-width: 600px) {
  .game-title {
    font-size: 2rem;
  }

  .game-subtitle {
    font-size: 0.9rem;
  }

  .menu-buttons {
    flex-direction: row;
    width: 100%;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
  }

  .btn-mode {
    width: auto;
    flex: 1;
    padding: 12px 6px;
    font-size: 0.95rem;
    min-width: 0;
  }

  #btn-2player {
    display: none !important;
  }

  .btn-icon {
    font-size: 1.8rem;
  }

  .legend-row {
    gap: 6px;
  }

  .legend-circle {
    width: 38px;
    height: 38px;
    font-size: 15px;
  }

  .legend-num {
    font-size: 0.7rem;
    padding: 1px 4px;
  }

  .legend-row.compact .legend-circle {
    width: 34px;
    height: 34px;
    font-size: 13px;
  }

  .color-circle.big {
    width: 60px;
    height: 60px;
  }

  .color-circle.med {
    width: 42px;
    height: 42px;
  }

  .menu-footer {
    margin-top: 15px;
    padding: 15px;
    width: 90%;
  }

  .btn-info {
    padding: 8px 16px;
    font-size: 1rem;
  }

  .copyright {
    font-size: 0.8rem;
  }

  .game-header {
    font-size: 0.85rem;
    padding: 4px;
  }

  #btn-exit-1p,
  #btn-exit-2p {
    font-size: 0.75rem !important;
    padding: 4px 8px !important;
  }

  .race-header {
    font-size: 0.85rem;
    padding: 4px 8px;
  }

  .river-track {
    height: 60px;
    margin-bottom: 5px;
  }

  .race-lane {
    height: 26px;
  }

  .boat-svg {
    font-size: 1.4rem;
  }

  .boat-label {
    font-size: 0.6rem;
    padding: 1px 3px;
  }

  .player-panels {
    flex-direction: row;
    gap: 4px;
    padding: 0 4px 4px;
  }

  .player-panel {
    padding: 4px;
    gap: 4px;
  }

  .panel-header {
    font-size: 0.85rem;
  }

  .operator-symbol {
    font-size: 1.2rem;
  }

  .answer-box {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  .num-btn {
    font-size: 1.1rem;
  }

  .numpad {
    gap: 4px;
  }

  .numpad-actions {
    flex-direction: row;
    gap: 4px;
  }

  .numpad-actions button {
    padding: 8px;
    font-size: 0.9rem;
    flex: 1;
  }

  .streak-bar {
    font-size: 0.75rem;
  }

  .modal-content.info-content {
    width: 95%;
    max-height: 90vh;
  }

  .info-header {
    padding: 15px;
  }

  .info-header h2 {
    font-size: 1.3rem;
  }

  .info-card {
    flex-direction: column;
    gap: 10px;
    align-items: center;
    text-align: center;
    padding: 15px;
  }

  .info-icon {
    width: 45px;
    height: 45px;
    font-size: 1.6rem;
  }

  .info-scroll-area {
    padding: 15px;
  }
}