/* ========================================================
   MISTERI KALENG BISKUIT NENEK - CANDY CRUSH STYLING
   High-Contrast Butter Cookies, Special Powerups & Rewards
   ======================================================== */

:root {
  --primary-red: #c62828;
  --vintage-gold: #f9a825;
  --tin-red-gradient: linear-gradient(135deg, #8e0000 0%, #c62828 50%, #5f091c 100%);
  --wood-bg: #4a2c11;
  --tablecloth-cream: #fff9ea;
  --card-bg: rgba(255, 255, 255, 0.96);
  --text-dark: #2c1810;
  --accent-gold: #ffd54f;
  --shadow-warm: 0 10px 25px rgba(60, 30, 10, 0.28);
  /* Papan menyesuaikan tinggi & lebar layar: maks 560px, min 300px */
  --board-size: max(300px, min(560px, calc(100vh - 210px), calc(100vw - 750px)));
}

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

body {
  font-family: 'Montserrat', sans-serif;
  min-height: 100vh;
  background: radial-gradient(circle at center, #703816 0%, #3a1608 100%);
  background-attachment: fixed;
  color: var(--text-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0, rgba(255, 255, 255, 0.03) 2px, transparent 2px, transparent 12px);
  pointer-events: none;
  z-index: 0;
}

/* ========================================================
   1. STORY & MODE SELECTION SCREEN (LANDING PAGE)
   ======================================================== */
#modeSelection {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Taplak meja gingham merah-putih + vignette gelap di pinggir */
  background-color: #fff5ef;
  background-image:
    radial-gradient(ellipse at center, rgba(255, 245, 235, 0) 30%, rgba(58, 22, 8, 0.75) 100%),
    linear-gradient(90deg, rgba(198, 40, 40, 0.30) 50%, transparent 50%),
    linear-gradient(rgba(198, 40, 40, 0.30) 50%, transparent 50%);
  background-size: 100% 100%, 64px 64px, 64px 64px;
  display: flex;
  padding: 16px;
  overflow-y: auto;
  z-index: 1000;
  animation: fadeIn 0.4s ease-out;
}

.menu-decor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.menu-cookie {
  position: absolute;
  top: 100%;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35));
  animation: floatCookie linear infinite;
}

.story-card {
  position: relative;
  z-index: 1;
  margin: auto;
  display: grid;
  grid-template-columns: 330px 1fr;
  width: 100%;
  max-width: 940px;
  background: #fffdf8;
  border-radius: 26px;
  overflow: hidden;
  border: 3.5px solid #8e0000;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65), 0 0 0 8px rgba(198, 40, 40, 0.35);
}

/* ---------- Kiri: tutup kaleng ---------- */
.tin-lid {
  position: relative;
  background: var(--tin-red-gradient);
  color: #fff3e0;
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.tin-lid::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  bottom: 10px;
  border: 2px dashed rgba(255, 213, 79, 0.7);
  border-radius: 18px;
  pointer-events: none;
}

.story-badge {
  display: inline-block;
  background: var(--accent-gold);
  color: #8e0000;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  padding: 6px 14px;
  border-radius: 50px;
  text-transform: uppercase;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.lid-medallion {
  --m: 220px;
  --c: 56px;
  --r: 78px;
  position: relative;
  width: var(--m);
  height: var(--m);
  border-radius: 50%;
  background: radial-gradient(circle, #a31515 0%, #6d0909 75%);
  border: 5px solid var(--vintage-gold);
  box-shadow: inset 0 0 0 6px rgba(255, 213, 79, 0.25), 0 8px 20px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.lid-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  animation: spinLid 40s linear infinite;
}

.lid-cookie {
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--c);
  height: var(--c);
  margin: calc(var(--c) / -2) 0 0 calc(var(--c) / -2);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  transform: rotate(calc(var(--i) * 60deg)) translateY(calc(var(--r) * -1));
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.45));
}

.lid-center {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #fff3e0;
  border: 4px solid var(--vintage-gold);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  font-size: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.story-title {
  font-family: 'Fredoka One', cursive, sans-serif;
  color: #ffe082;
  font-size: 30px;
  line-height: 1.1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

.story-subtitle {
  color: #ffccbc;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}

.lid-est {
  color: var(--accent-gold);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 2px;
}

/* ---------- Kanan: cerita & pilihan mode ---------- */
.story-body {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.story-content {
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
  color: #4a3429;
}

.warning-box {
  background: #fff3e0;
  border-left: 5px solid #ff9800;
  padding: 12px 16px;
  border-radius: 8px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #bf360c;
}

.warning-icon {
  font-size: 26px;
}

.mode-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-mode {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border: 2px solid transparent;
  border-radius: 16px;
  cursor: pointer;
  text-align: left;
  font-family: 'Montserrat', sans-serif;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-mode .btn-icon {
  /* Lebar tetap (cukup untuk 2 emoji di font apa pun) supaya teks kedua tombol sejajar */
  flex: 0 0 88px;
  width: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  font-size: 30px;
  line-height: 1;
}

.btn-mode strong {
  display: block;
  font-size: 17px;
  margin-bottom: 3px;
}

.btn-mode small {
  font-size: 12.5px;
  opacity: 0.88;
}

.btn-relax {
  background: linear-gradient(135deg, #2e7d32, #43a047);
  color: white;
  box-shadow: 0 6px 15px rgba(46, 125, 50, 0.3);
}

.btn-relax:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 20px rgba(46, 125, 50, 0.45);
}

.btn-rush {
  background: linear-gradient(135deg, #c2185b, #e91e63);
  color: white;
  box-shadow: 0 6px 15px rgba(233, 30, 99, 0.3);
}

.btn-rush:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 20px rgba(233, 30, 99, 0.45);
}

.story-tips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}

.tip-chip {
  background: #f1f8e9;
  border: 1px dashed #8bc34a;
  border-radius: 50px;
  padding: 5px 11px;
  font-size: 11.5px;
  font-weight: 600;
  color: #33691e;
}

.menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.menu-footer-note {
  font-size: 11px;
  font-weight: 700;
  color: #a1887f;
}

/* ========================================================
   2. MAIN GAME ARENA LAYOUT
   ======================================================== */
.game-arena {
  width: 100%;
  max-width: 1400px;
  padding: 15px 20px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 15px;
  animation: fadeIn 0.3s ease-out;
}

.top-nav {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 12px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-warm);
  border: 2px solid #e0c8b0;
}

.game-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 32px;
}

.logo-text h2 {
  font-family: 'Fredoka One', cursive, sans-serif;
  font-size: 20px;
  color: #8e0000;
  margin: 0;
}

.logo-text span {
  font-size: 12px;
  font-weight: 700;
  color: #795548;
}

.top-actions {
  display: flex;
  gap: 10px;
}

.btn-tool {
  background: #f5f0e6;
  border: 1.5px solid #d7ccc8;
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 13px;
  color: #4e342e;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-tool:hover {
  background: #d7ccc8;
  transform: translateY(-2px);
}

.btn-back {
  background: #ffebee;
  border-color: #ffcdd2;
  color: #c62828;
}

.btn-back:hover {
  background: #ef9a9a;
}

.arena-body {
  display: flex;
  gap: 25px;
  align-items: flex-start;
  justify-content: center;
}

/* ========================================================
   3. SIDE NARRATIVE & SCOREBOARD PANEL
   ======================================================== */
.story-panel,
.guide-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  /* Kalau layar sangat pendek, panel bisa di-scroll sendiri */
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 2px 4px 8px;
}

.story-panel {
  flex: 0 0 290px;
  order: 1;
}

.guide-panel {
  flex: 0 0 320px;
  order: 3;
}

.character-card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 14px 16px;
  box-shadow: var(--shadow-warm);
  border: 2px solid #d7ccc8;
  position: relative;
}

.character-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.avatar-container {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #ffe0b2;
  border: 3px solid #ffb74d;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.avatar-emoji {
  font-size: 30px;
  line-height: 1;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.avatar-container:hover .avatar-emoji {
  transform: scale(1.15) rotate(5deg);
}

.avatar-status-pulse {
  position: absolute;
  bottom: 0px;
  right: 0px;
  width: 13px;
  height: 13px;
  background: #4caf50;
  border: 2px solid white;
  border-radius: 50%;
}

.character-info h4 {
  font-size: 15px;
  color: #3e2723;
  margin-bottom: 2px;
}

.character-role {
  font-size: 11.5px;
  color: #8d6e63;
  font-weight: 600;
}

.speech-bubble {
  background: #fff8e1;
  border: 2px solid #ffe082;
  border-radius: 14px;
  padding: 10px 12px;
  position: relative;
  min-height: 52px;
  display: flex;
  align-items: center;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.03);
}

.speech-bubble::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 24px;
  border-width: 0 10px 10px 10px;
  border-style: solid;
  border-color: transparent transparent #ffe082 transparent;
}

.speech-bubble p {
  font-size: 12.5px;
  line-height: 1.4;
  color: #4e342e;
  font-weight: 600;
  font-style: italic;
  transition: opacity 0.2s ease;
}

.score-card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow-warm);
  border: 2px solid #d7ccc8;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.score-meta {
  text-align: center;
  background: #fbf6ec;
  border-radius: 12px;
  padding: 8px;
  border: 1px dashed #d7ccc8;
}

.meta-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #8d6e63;
}

.score-number {
  font-family: 'Fredoka One', cursive, sans-serif;
  font-size: 38px;
  color: #8e0000;
  line-height: 1.1;
  margin-top: 2px;
}

.rank-container {
  text-align: center;
}

.rank-label {
  font-size: 11px;
  font-weight: 700;
  color: #795548;
  display: block;
  margin-bottom: 2px;
}

.rank-badge {
  background: linear-gradient(135deg, #ff8f00, #ffb300);
  color: white;
  font-weight: 800;
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 50px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  box-shadow: 0 4px 10px rgba(255, 143, 0, 0.35);
  animation: pulseRank 2s infinite ease-in-out;
}

.timer-box {
  background: #ffebee;
  border: 1.5px solid #ffcdd2;
  border-radius: 12px;
  padding: 10px 12px;
}

.timer-header {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 800;
  color: #b71c1c;
  margin-bottom: 5px;
}

#timerText {
  font-size: 16px;
  font-family: 'Fredoka One', cursive, sans-serif;
}

.timer-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(183, 28, 28, 0.15);
  border-radius: 10px;
  overflow: hidden;
}

.timer-bar-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #8bc34a);
  border-radius: 10px;
  transition: width 0.5s linear, background 0.5s ease;
}

.snack-counter {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #fbf6ec;
  padding: 8px 12px;
  border-radius: 12px;
}

.counter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #4e342e;
}

.counter-icon {
  font-size: 20px;
}

/* ========================================================
   REWARD & SCORING GUIDE (PANDUAN SKOR & PERBEDAAN CAMILAN)
   ======================================================== */
.reward-guide {
  background: #fff8eb;
  border: 1.5px solid #e0c8b0;
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.guide-header {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #795548;
  display: block;
  text-align: center;
  margin-bottom: 2px;
}

.guide-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border-radius: 8px;
  padding: 6px 9px;
  border: 1px solid #e8dac9;
}

.guide-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-left .guide-icon {
  font-size: 18px;
}

.guide-left strong {
  display: block;
  font-size: 12px;
  color: #2c1810;
  line-height: 1.1;
}

.guide-left small {
  font-size: 10px;
  color: #8d6e63;
}

.guide-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.badge-pts {
  font-family: 'Fredoka One', cursive, sans-serif;
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 6px;
  color: #ffffff;
}

.pts-gold {
  background: linear-gradient(135deg, #f57f17, #fbc02d);
  color: #2c1810;
  font-weight: 800;
}

.pts-orange {
  background: linear-gradient(135deg, #e64a19, #ff7043);
}

.pts-normal {
  background: #8d6e63;
}

.badge-bonus {
  font-size: 9.5px;
  font-weight: 700;
  border-radius: 4px;
  padding: 1px 5px;
}

.bonus-gold {
  background: #fff9c4;
  color: #b78103;
  border: 1px solid #fdd835;
}

.bonus-orange {
  background: #fbe9e7;
  color: #bf360c;
  border: 1px solid #ffab91;
}

.bonus-normal {
  color: #8d6e63;
}

.special-combos-box {
  background: #f1f8e9;
  border: 1px dashed #8bc34a;
  border-radius: 8px;
  padding: 7px 10px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.combo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 6px;
}

.combo-pill {
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
}

.pill-striped {
  background: #ffeb3b;
  color: #b78103;
}

.pill-bomb {
  background: #ff7043;
  color: #ffffff;
}

.combo-row small {
  font-size: 10px;
  color: #33691e;
  font-weight: 600;
}

/* ========================================================
   TIN CONTENTS LEGEND
   ======================================================== */
.tin-legend {
  background: #fbf5ea;
  border: 1.5px solid #e0cbb8;
  border-radius: 14px;
  padding: 8px 10px;
}

.legend-header {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #795548;
  display: block;
  margin-bottom: 6px;
  text-align: center;
}

.legend-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.legend-badge {
  background: #fff;
  border: 1.5px solid #d7ccc8;
  border-radius: 8px;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 700;
  color: #4e342e;
}

.badge-icon {
  width: 20px;
  height: 20px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

.badge-blue { background: #e3f2fd; border-color: #90caf9; color: #0d47a1; }
.badge-red { background: #ffebee; border-color: #ef9a9a; color: #b71c1c; }
.badge-green { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
.badge-brown { background: #efebe9; border-color: #bcaaa4; color: #3e2723; }
.badge-yellow { background: #fffde7; border-color: #fff59d; color: #f57f17; }
.badge-orange { background: #fbe9e7; border-color: #ffccbc; color: #bf360c; }

/* ========================================================
   4. BOARD WRAPPER & CSS GRID
   ======================================================== */
.board-wrapper {
  flex: 0 0 auto;
  order: 2;
}

.tablecloth-frame {
  background: #fffdf8;
  background-image: 
    radial-gradient(#ebd6b0 15%, transparent 16%),
    radial-gradient(#ebd6b0 15%, transparent 16%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
  padding: 16px 18px;
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 4px #d7ccc8;
  border: 7px solid #7c2d12;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.board-header-note {
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 18px;
  border-radius: 50px;
  font-size: 12px;
  font-weight: 700;
  color: #5d4037;
  border: 1.5px dashed #bcaaa4;
}

.grid-container {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
}

.grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 5px;
  width: 100%;
  height: 100%;
  padding: 8px;
  background: radial-gradient(circle at center, #261104 0%, #120601 100%);
  border-radius: 22px;
  box-shadow: inset 0 4px 18px rgba(0, 0, 0, 0.8), 0 0 0 5px #b71c1c, 0 8px 24px rgba(0,0,0,0.5);
  border: 3.5px solid #ffb300;
  user-select: none;
  touch-action: none;
  overflow: hidden;
}

.grid div {
  width: 100%;
  height: 100%;
  background-size: 92%;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.15s ease;
  position: relative;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.45);
}

.grid div:hover {
  transform: scale(1.09);
  filter: drop-shadow(0 4px 8px rgba(255, 215, 64, 0.6));
  z-index: 5;
}

.grid div.selected-candy {
  outline: 3.5px solid #ffffff;
  outline-offset: -2px;
  filter: drop-shadow(0 0 14px #ffee58) brightness(1.15);
  transform: scale(1.14);
  z-index: 10;
  animation: pulseSelect 0.65s infinite alternate ease-in-out;
}

.grid div.invalid-swap {
  animation: invalidWiggle 0.35s ease-in-out;
}

/* ========================================================
   SPECIAL COOKIE POWERUPS (STRIPED & BOMB)
   ======================================================== */
/* Striped Horizontal (Biskuit Kilat Baris) */
.grid div[data-special="striped-h"]::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: 12px;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.85) 0, rgba(255,255,255,0.85) 5px, transparent 5px, transparent 11px);
  box-shadow: 0 0 12px #ffee58, inset 0 0 8px #ffffff;
  border: 2px solid #ffffff;
  animation: beamPulse 0.7s infinite alternate;
  pointer-events: none;
}

/* Striped Vertical (Biskuit Kilat Kolom) */
.grid div[data-special="striped-v"]::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: 12px;
  background: repeating-linear-gradient(90deg, rgba(255,255,255,0.85) 0, rgba(255,255,255,0.85) 5px, transparent 5px, transparent 11px);
  box-shadow: 0 0 12px #ffee58, inset 0 0 8px #ffffff;
  border: 2px solid #ffffff;
  animation: beamPulse 0.7s infinite alternate;
  pointer-events: none;
}

/* Toples Bom (Area Bomb 3x3) */
.grid div[data-special="bomb"]::after {
  content: "💣";
  position: absolute;
  top: -6px; right: -6px;
  font-size: 16px;
  background: #ffeb3b;
  border-radius: 50%;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 12px #ff5722, 0 0 6px #fff;
  border: 2px solid #ffffff;
  animation: bombPulse 0.6s infinite alternate;
  pointer-events: none;
  z-index: 6;
}

@keyframes beamPulse {
  0% { opacity: 0.65; filter: drop-shadow(0 0 4px #ffee58); }
  100% { opacity: 1; filter: drop-shadow(0 0 14px #ffffff); }
}

@keyframes bombPulse {
  0% { transform: scale(0.95); box-shadow: 0 0 8px #ff5722; }
  100% { transform: scale(1.2); box-shadow: 0 0 18px #ff1744, 0 0 8px #ffee58; }
}

@keyframes invalidWiggle {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-4px) rotate(-4deg); }
  40%, 80% { transform: translateX(4px) rotate(4deg); }
}

/* Floating onomatopoeia layer */
.floating-layer {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 20;
}

.floating-text {
  position: absolute;
  font-family: 'Fredoka One', cursive, sans-serif;
  font-size: 20px;
  font-weight: 900;
  text-shadow: 2px 2px 0px #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  pointer-events: none;
  animation: floatComic 1.2s forwards cubic-bezier(0.215, 0.61, 0.355, 1);
  white-space: nowrap;
}

/* ========================================================
   5. GAME OVER & SILATURAHMI MODAL (WARTA KELUARGA)
   ======================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(20, 5, 0, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.35s ease-out;
}

.modal-card {
  background: #fbf5e8;
  max-width: 530px;
  width: 100%;
  border-radius: 22px;
  padding: 30px 35px;
  border: 4px solid #8e0000;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.65);
  text-align: center;
  position: relative;
  background-image: repeating-linear-gradient(0deg, rgba(0,0,0,0.02) 0px, rgba(0,0,0,0.02) 1px, transparent 1px, transparent 16px);
}

.newspaper-header { margin-bottom: 15px; }

.newspaper-tag {
  background: #c62828;
  color: white;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 4px;
  letter-spacing: 1px;
}

.newspaper-header h2 {
  font-family: 'Fredoka One', cursive, sans-serif;
  color: #212121;
  font-size: 28px;
  margin-top: 8px;
  letter-spacing: 2px;
}

.news-line {
  border: 0;
  height: 2px;
  background: #3e2723;
  margin-top: 8px;
}

.modal-avatar {
  font-size: 64px;
  margin: 10px 0;
  animation: bounceAvatar 1.5s infinite;
}

.modal-headline {
  font-family: 'Fredoka One', cursive, sans-serif;
  color: #8e0000;
  font-size: 19px;
  line-height: 1.35;
  margin-bottom: 18px;
}

.result-details {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 18px;
}

.result-pill {
  background: #fff;
  border: 1.5px solid #d7ccc8;
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.result-pill span {
  font-size: 11.5px;
  color: #795548;
  font-weight: 700;
}

.result-pill strong {
  font-size: 18px;
  color: #8e0000;
  margin-top: 2px;
}

.modal-review {
  font-size: 14px;
  line-height: 1.55;
  color: #4e342e;
  background: #fff9c4;
  border-left: 4px solid #fbc02d;
  padding: 12px 14px;
  border-radius: 8px;
  text-align: left;
  margin-bottom: 24px;
  font-style: italic;
}

.modal-buttons { display: flex; gap: 12px; }

.btn-modal {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-modal.btn-primary {
  background: linear-gradient(135deg, #c62828, #8e0000);
  color: white;
  box-shadow: 0 4px 12px rgba(198, 40, 40, 0.4);
}

.btn-modal.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(198, 40, 40, 0.5);
}

.btn-modal.btn-secondary {
  background: #e0d5c1;
  color: #3e2723;
}

.btn-modal.btn-secondary:hover { background: #d7ccc8; }

/* ========================================================
   6. ANIMATIONS
   ======================================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulseRank {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); filter: brightness(1.08); }
}

@keyframes pulseSelect {
  0% { transform: scale(1.08); filter: drop-shadow(0 0 10px #ffee58); }
  100% { transform: scale(1.18); filter: drop-shadow(0 0 18px #fff59d); }
}

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

@keyframes floatComic {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.7) rotate(-5deg);
  }
  20% {
    opacity: 1;
    transform: translateY(-15px) scale(1.2) rotate(4deg);
  }
  70% {
    opacity: 1;
    transform: translateY(-45px) scale(1) rotate(-2deg);
  }
  100% {
    opacity: 0;
    transform: translateY(-75px) scale(0.85);
  }
}

@keyframes floatCookie {
  from { transform: translateY(0) rotate(0deg); }
  to { transform: translateY(-125vh) rotate(360deg); }
}

@keyframes spinLid {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.shake-board {
  animation: boardShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes boardShake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

/* ========================================================
   7. RESPONSIVENESS
   ======================================================== */

/* Laptop dengan layar pendek: rapatkan jarak supaya muat tanpa scroll */
@media (min-width: 1181px) and (max-height: 760px) {
  :root {
    --board-size: max(300px, min(560px, calc(100vh - 172px), calc(100vw - 750px)));
  }
  .game-arena {
    padding: 10px 16px;
    gap: 10px;
  }
  .top-nav {
    padding: 8px 20px;
  }
  .logo-icon {
    font-size: 26px;
  }
  .tablecloth-frame {
    padding: 12px 14px;
  }
  .board-header-note {
    margin-bottom: 8px;
    padding: 4px 14px;
  }
  .story-panel,
  .guide-panel {
    max-height: calc(100vh - 84px);
    gap: 8px;
  }
  .score-number {
    font-size: 30px;
  }
  .guide-left small {
    display: none;
  }
}

/* Tablet & layar sempit: semua kolom ditumpuk ke bawah */
@media (max-width: 1180px) {
  :root {
    --board-size: min(560px, calc(100vw - 80px));
  }
  .arena-body {
    flex-direction: column;
    align-items: center;
  }
  .story-panel,
  .guide-panel {
    flex: 0 0 auto;
    width: 100%;
    max-width: 560px;
    max-height: none;
    overflow-y: visible;
  }
}

/* Landing page: satu kolom di layar sempit */
@media (max-width: 800px) {
  .story-card {
    grid-template-columns: 1fr;
    max-width: 520px;
  }
  .tin-lid {
    padding: 22px 16px;
    gap: 8px;
  }
  .lid-medallion {
    --m: 150px;
    --c: 38px;
    --r: 52px;
  }
  .lid-center {
    width: 56px;
    height: 56px;
    font-size: 30px;
  }
  .story-title {
    font-size: 22px;
  }
  .story-subtitle,
  .lid-est {
    display: none;
  }
  .story-body {
    padding: 20px 18px;
  }
}

/* Landing page: laptop dengan layar pendek */
@media (min-width: 801px) and (max-height: 720px) {
  .tin-lid {
    padding: 18px 16px;
    gap: 8px;
  }
  .lid-medallion {
    --m: 180px;
    --c: 46px;
    --r: 64px;
  }
  .lid-center {
    width: 68px;
    height: 68px;
    font-size: 38px;
  }
  .story-title {
    font-size: 24px;
  }
  .story-body {
    padding: 18px 24px;
    gap: 10px;
  }
  .story-content {
    font-size: 13px;
    line-height: 1.5;
  }
  .warning-box {
    padding: 8px 12px;
    margin: 8px 0;
  }
  .btn-mode {
    padding: 10px 16px;
  }
}

@media (max-width: 620px) {
  .game-arena {
    padding: 10px;
  }
  .top-nav {
    flex-direction: column;
    gap: 8px;
    padding: 10px 14px;
  }
  .grid {
    padding: 5px;
    gap: 3px;
    border-radius: 14px;
  }
  .grid div {
    border-radius: 6px;
  }
  .modal-card {
    padding: 22px 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-cookie,
  .lid-ring {
    animation: none;
  }
}

/* ========================================================
   8. CREDITS PAGE
   ======================================================== */
.btn-credits {
  background: #f5f0e6;
  border: 1.5px solid #d7ccc8;
  padding: 10px 20px;
  border-radius: 12px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 13px;
  color: #4e342e;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-credits:hover {
  background: #d7ccc8;
  transform: translateY(-2px);
}

.credits-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  text-align: left;
}

.credits-row {
  background: #fff;
  border: 1.5px solid #d7ccc8;
  border-radius: 12px;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
}

.credits-label {
  font-size: 11.5px;
  color: #795548;
  font-weight: 700;
}

.credits-row strong {
  font-size: 15px;
  color: #8e0000;
  margin-top: 2px;
}

.credits-card .modal-review {
  font-size: 13px;
}

@media (max-height: 700px) {
  .credits-card {
    max-height: 100%;
    overflow-y: auto;
  }
}
