/* ==========================================================================
   STYLE.CSS - Gunshot Game (Nostalgic Lined Paper Notebook Theme)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. RESET & BASE VARIABLES
   -------------------------------------------------------------------------- */
:root {
  --paper-bg: #fdfbf7;
  --paper-line: #e3edf5;        /* Light blue notebook lines */
  --margin-line: #f8b4b4;       /* Pink notebook margin line */
  --ink-primary: #1f2937;       /* Dark graphite / ballpoint ink */
  --ink-muted: #64748b;
  --pencil-shadow: rgba(0, 0, 0, 0.08);

  --player1-color: #1e40af;     /* Classic blue pen */
  --player2-color: #065f46;     /* Classic green pen */
  --danger-red: #dc2626;        /* Red marker / cross out */
  --gold-accent: #d97706;       /* Bullet / highlight */

  --font-hand: 'Patrick Hand', 'Caveat', 'Segoe Print', 'Comic Sans MS', cursive, sans-serif;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-hand);
  background-color: #ece8df;    /* Desk / wooden table color background */
  color: var(--ink-primary);
  height: 100vh;
  height: 100dvh;               /* Exact visible mobile screen height */
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px;
  font-size: 18px;
  line-height: 1.35;
  overflow: hidden;             /* Lock body to prevent scrolling/bouncing */
}

/* --------------------------------------------------------------------------
   2. NOTEBOOK CONTAINER (Looks like an authentic paper page)
   -------------------------------------------------------------------------- */
.notebook-page {
  width: 100%;
  max-width: 480px;             /* Mobile friendly width */
  height: 100%;
  max-height: 100dvh;
  background-color: var(--paper-bg);
  /* Lined paper effect: clean horizontal blue lines every 24px */
  background-image: linear-gradient(var(--paper-line) 1px, transparent 1px);
  background-size: 100% 24px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  padding: 8px 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;             /* 100% fits within 1 screen */
}

/* Notebook binder ring holes removed to maximize clean usable space */
.notebook-page::before {
  display: none;
}

/* --------------------------------------------------------------------------
   3. TYPOGRAPHY & BUTTONS
   -------------------------------------------------------------------------- */
h1, h2, h3 {
  font-family: var(--font-hand);
  letter-spacing: 0.5px;
}

.game-title {
  text-align: center;
  font-size: clamp(1.8rem, 4vh, 2.2rem);
  font-weight: 700;
  color: #111827;
  text-shadow: 1px 1px 0px rgba(0,0,0,0.1);
  margin-bottom: 0px;
}

.game-subtitle {
  text-align: center;
  font-size: 0.92rem;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

/* Hand-drawn button style */
.btn {
  font-family: var(--font-hand);
  font-size: 1.15rem;
  font-weight: bold;
  padding: 8px 14px;
  border: 2px solid var(--ink-primary);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px; /* Doodle border */
  background: #ffffff;
  color: var(--ink-primary);
  cursor: pointer;
  box-shadow: 2px 3px 0px var(--ink-primary);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0px 1px 0px var(--ink-primary);
}

.btn-primary {
  background: #fef08a; /* Sticky note yellow */
  color: #1f2937;
  font-size: 1.25rem;
  padding: 10px 18px;
}

.btn-secondary {
  background: #f3f4f6;
  font-size: 1rem;
  padding: 5px 12px;
}

.btn-danger {
  background: #fee2e2;
  color: var(--danger-red);
  border-color: var(--danger-red);
  box-shadow: 2px 3px 0px var(--danger-red);
}

.btn-lg {
  width: 100%;
  padding: 10px 16px;
  font-size: 1.25rem;
}

/* --------------------------------------------------------------------------
   4. SCREENS: START SCREEN
   -------------------------------------------------------------------------- */
.screen {
  display: none !important;
  flex-direction: column;
  flex: 1;
}

.screen.active {
  display: flex !important;
}

#start-screen {
  justify-content: space-between;
  padding: 4px 2px;
  height: 100%;
  overflow-y: auto;
}

.doodle-hero {
  display: flex;
  justify-content: center;
  margin: 2px 0 6px 0;
}

.doodle-hero svg {
  max-width: 140px;
  height: clamp(34px, 5.5vh, 48px);
  filter: drop-shadow(2px 3px 0px rgba(0,0,0,0.06));
}

.player-input-card {
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px dashed #94a3b8;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.input-group {
  margin-bottom: 10px;
}

.input-group:last-child {
  margin-bottom: 0;
}

/* Mode Selector Tabs */
.mode-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}

.mode-tab {
  flex: 1;
  font-family: var(--font-hand);
  font-size: 1.05rem;
  font-weight: bold;
  padding: 6px 8px;
  border: 2px solid var(--ink-primary);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  background: #ffffff;
  color: var(--ink-primary);
  cursor: pointer;
  box-shadow: 2px 2px 0px var(--ink-primary);
  font-weight: bold;
  padding: 8px 10px;
  border: 2px solid var(--ink-primary);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  background: #ffffff;
  color: var(--ink-primary);
  cursor: pointer;
  box-shadow: 2px 2px 0px var(--ink-primary);
  transition: all 0.15s ease;
}

.mode-tab.active {
  background: #fef08a;
  border-color: #1f2937;
  transform: translateY(-2px);
  box-shadow: 2px 4px 0px var(--ink-primary);
}

/* Stepper & Count Selection */
.count-selector-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px dashed #cbd5e1;
}

.count-label {
  font-size: 1.1rem;
  font-weight: bold;
}

.stepper-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stepper-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.count-badge {
  font-size: 1.15rem;
  font-weight: bold;
  min-width: 75px;
  text-align: center;
}

.team-format-buttons {
  display: flex;
  gap: 6px;
}

.format-btn {
  padding: 4px 10px;
  font-size: 1rem;
}

.format-btn.active {
  background: #fef08a;
  font-weight: bold;
}

/* Team Inputs Grouping */
.teams-inputs-wrapper {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.team-group {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
}

.team-a-box { border-color: #93c5fd; background: #f0f7ff; }
.team-b-box { border-color: #a7f3d0; background: #f0fdf4; }

.team-title {
  font-size: 1.15rem;
  margin-bottom: 6px;
}

.team-a-color { color: var(--player1-color); }
.team-b-color { color: var(--player2-color); }

.players-inputs-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  display: block;
  font-size: 1.15rem;
  font-weight: bold;
  margin-bottom: 4px;
}

.label-p1 { color: var(--player1-color); }
.label-p2 { color: var(--player2-color); }

.pencil-input {
  width: 100%;
  font-family: var(--font-hand);
  font-size: 1.25rem;
  padding: 8px 12px;
  border: 2px solid var(--ink-primary);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-primary);
  outline: none;
  box-shadow: 1px 2px 0px rgba(0,0,0,0.1);
}

.pencil-input:focus {
  border-color: #2563eb;
  background: #eff6ff;
}

.start-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   5. SCREENS: MAIN GAME SCREEN
   -------------------------------------------------------------------------- */
#game-screen {
  gap: 4px;
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 4px;
  flex-shrink: 0;
}

.game-header h2 {
  font-size: 1.25rem;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 4px;
}

.header-actions .btn {
  padding: 4px 8px;
  font-size: 0.95rem;
}

/* Turn Banner */
.turn-banner {
  text-align: center;
  background: #ffffff;
  border: 2px solid var(--ink-primary);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  padding: 4px 10px;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.15);
  font-size: 1.15rem;
  font-weight: bold;
  transition: all 0.2s ease;
}

.turn-p1 {
  border-color: var(--player1-color);
  color: var(--player1-color);
  background: #eff6ff;
}

.turn-p2 {
  border-color: var(--player2-color);
  color: var(--player2-color);
  background: #ecfdf5;
}

.turn-aiming {
  border-color: var(--danger-red);
  color: var(--danger-red);
  background: #fef2f2;
  animation: pulse-border 1.2s infinite;
}

@keyframes pulse-border {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.4); }
  70% { transform: scale(1.02); box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Boards Layout */
.game-boards-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-height: 0;
  overflow: hidden;
}

#boards-top-container,
#boards-center-container,
#boards-bottom-container {
  flex-shrink: 1;
  min-height: 0;
}

/* --------------------------------------------------------------------------
   6. PLAYER BOARDS & SLOTS (5 COLUMNS: 1, 3, 5, 7, 9)
   -------------------------------------------------------------------------- */
.player-board {
  background: rgba(255, 255, 255, 0.85);
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  padding: 4px;
  transition: all 0.2s ease;
  position: relative;
}

.player-board.active-turn {
  border-color: var(--ink-primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.board-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  font-weight: bold;
  margin-bottom: 2px;
  padding: 0 2px;
}

.board-label .p-name {
  display: flex;
  align-items: center;
  gap: 4px;
}

.board-label .alive-count {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

/* Grid of 5 columns */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
}

/* Individual Slot Card */
.slot-card {
  background: #fff;
  border: 1.5px solid #94a3b8;
  border-radius: 6px;
  padding: 2px 1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: clamp(58px, 10.5vh, 78px);
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.slot-number {
  font-size: 0.85rem;
  font-weight: bold;
  line-height: 1;
  margin-bottom: 1px;
  color: var(--ink-primary);
  border-bottom: 1px dashed #e2e8f0;
  width: 100%;
  text-align: center;
  padding-bottom: 1px;
}

.slot-svg-container {
  width: 100%;
  height: clamp(38px, 7.5vh, 52px);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.slot-svg-container svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* When a slot is the shooter (armed & firing) */
.slot-card.is-shooter {
  border-color: var(--gold-accent);
  background: #fffbeb;
  animation: glow-shooter 1s infinite alternate;
}

@keyframes glow-shooter {
  from { box-shadow: 0 0 2px var(--gold-accent); }
  to { box-shadow: 0 0 8px var(--gold-accent); }
}

/* When a slot is targetable during aiming phase */
.slot-card.targetable {
  cursor: pointer;
  border: 2px dashed var(--danger-red);
  background: #fff1f2;
  animation: pulse-target 1s infinite alternate;
}

.slot-card.targetable:hover,
.slot-card.targetable:active {
  transform: scale(1.06);
  background: #fee2e2;
  border-style: solid;
}

@keyframes pulse-target {
  from { transform: scale(1); }
  to { transform: scale(1.04); }
}

/* Target Crosshair icon badge */
.target-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--danger-red);
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* When a slot has a saved bullet */
.slot-card.has-bullet {
  border-color: #d97706;
  background: #fffbeb;
}

.armed-bullet-badge {
  position: absolute;
  top: -6px;
  left: -6px;
  background: #d97706;
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

/* When a slot takes damage (Hit 1 - disarmed) */
.slot-card.hit-damaged {
  animation: damage-shake 0.45s ease-in-out;
}

@keyframes damage-shake {
  0% { transform: translateX(0); background: #fee2e2; border-color: #ef4444; }
  20% { transform: translateX(-6px) rotate(-3deg); }
  40% { transform: translateX(6px) rotate(3deg); }
  60% { transform: translateX(-4px) rotate(-1deg); }
  80% { transform: translateX(4px) rotate(1deg); }
  100% { transform: translateX(0); }
}

/* When a slot has been crossed out (destroyed) */
.slot-card.crossed-out {
  opacity: 0.75;
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Stickman SVG parts styling */
.sm-part {
  fill: none;
  stroke: #1e293b;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: opacity 0.25s ease, stroke-dashoffset 0.3s ease;
}

.sm-bullet {
  fill: #eab308;
  stroke: #ca8a04;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 3px rgba(234, 179, 8, 0.8));
}

.sm-cross {
  stroke: var(--danger-red);
  stroke-width: 3.5;
  stroke-linecap: round;
  animation: slam-cross 0.25s ease-out;
}

@keyframes slam-cross {
  0% { transform: scale(1.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* --------------------------------------------------------------------------
   7. ACTION CENTER (OPEN BOOK BUTTON & ROLLED NUMBER)
   -------------------------------------------------------------------------- */
.action-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 2px 0;
  flex-shrink: 0;
}

.action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.btn-open-book {
  flex: 1;
  background: #fef08a;
  border: 2px solid var(--ink-primary);
  box-shadow: 2px 2px 0px var(--ink-primary);
  font-size: 1.15rem;
  padding: 8px 12px;
}

.btn-open-book:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: 1px 1px 0px var(--ink-primary);
}

/* Bullet decision row (Shoot Now or Save Bullet) */
.decision-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.btn-shoot {
  flex: 1.2;
  background: #fee2e2;
  color: var(--danger-red);
  border: 2px solid var(--danger-red);
  box-shadow: 2px 2px 0px var(--danger-red);
  font-size: 1.15rem;
  padding: 8px 10px;
}

.btn-shoot:hover,
.btn-shoot:active {
  background: #fca5a5;
}

.btn-save {
  flex: 1;
  background: #fef08a;
  color: #854d0e;
  border: 2px solid #854d0e;
  box-shadow: 2px 2px 0px #854d0e;
  font-size: 1.15rem;
  padding: 8px 10px;
}

.btn-save:hover,
.btn-save:active {
  background: #fde047;
}

/* Book page roll badge */
.book-draw-badge {
  width: 44px;
  height: 44px;
  background: #fff;
  border: 2px solid var(--ink-primary);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.15);
  position: relative;
  flex-shrink: 0;
}

.book-draw-badge .badge-label {
  font-size: 0.65rem;
  color: var(--ink-muted);
  text-transform: uppercase;
  line-height: 1;
}

.book-draw-badge .badge-num {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  color: #b45309;
}

/* Number pop-in animation when rolled */
.number-pop {
  animation: pop-bounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-bounce {
  0% { transform: scale(0.2) rotate(-15deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

/* --------------------------------------------------------------------------
   8. POPUPS & MODALS (HOW TO PLAY, WINNER)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--paper-bg);
  background-image: linear-gradient(var(--paper-line) 1px, transparent 1px);
  background-size: 100% 26px;
  border: 2px solid var(--ink-primary);
  border-radius: 12px;
  box-shadow: 4px 6px 0px rgba(0, 0, 0, 0.3);
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modal-pop 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modal-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px dashed #94a3b8;
  padding-bottom: 8px;
  margin-bottom: 14px;
}

.modal-title {
  font-size: 1.5rem;
  margin: 0;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: var(--ink-primary);
  line-height: 1;
}

.rules-content {
  font-size: 1.05rem;
}

.rules-content ol {
  padding-left: 20px;
  margin-bottom: 12px;
}

.rules-content li {
  margin-bottom: 8px;
}

.parts-diagram {
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 10px;
  margin: 10px 0;
  display: flex;
  justify-content: space-around;
  text-align: center;
  font-size: 0.85rem;
}

.parts-diagram div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.parts-diagram svg {
  width: 32px;
  height: 48px;
}

/* Winner Card */
.winner-card {
  text-align: center;
  padding: 24px 16px;
}

.winner-trophy {
  font-size: 3.5rem;
  margin-bottom: 6px;
  animation: trophy-bounce 0.8s infinite alternate ease-in-out;
}

@keyframes trophy-bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}

.winner-card h2 {
  font-size: 2rem;
  color: #1e3a8a;
  margin-bottom: 6px;
}

.winner-card p {
  font-size: 1.2rem;
  color: var(--ink-muted);
  margin-bottom: 22px;
}

.winner-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --------------------------------------------------------------------------
   10. BULLET SHOOTING ANIMATION (FLYING ACROSS SCREEN)
   -------------------------------------------------------------------------- */
.flying-bullet {
  position: fixed;
  width: 14px;
  height: 14px;
  background: #f59e0b;
  border: 2px solid #78350f;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 0 10px #f59e0b;
  transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* --------------------------------------------------------------------------
   11. RESPONSIVE TWEAKS (MOBILE & SMALL SCREENS)
   -------------------------------------------------------------------------- */
@media (max-width: 540px) {
  body {
    padding: 0;
  }
  .notebook-page {
    border-radius: 0;
    box-shadow: none;
    padding: 6px 8px;
  }
}

@media (max-width: 380px) {
  .notebook-page {
    padding: 4px 6px;
    background-size: 100% 24px;
  }
  .slot-card {
    min-height: clamp(52px, 9.5vh, 68px);
  }
  .slot-svg-container {
    height: clamp(34px, 6.5vh, 46px);
  }
  .game-title {
    font-size: 1.7rem;
  }
}

/* --------------------------------------------------------------------------
   12. 3D BOOK FLIP ANIMATION
   -------------------------------------------------------------------------- */
.book-anim-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  display: none;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.book-anim-overlay.active {
  display: flex;
  opacity: 1;
}

.anim-player-banner {
  background: #fef08a;
  border: 2px solid var(--ink-primary);
  border-radius: 8px;
  box-shadow: 2px 3px 0px rgba(0, 0, 0, 0.3);
  padding: 6px 16px;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.35rem;
  font-weight: bold;
  color: #1e3a8a;
  text-align: center;
  max-width: 90%;
  animation: banner-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes banner-pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.book-3d-scene {
  perspective: 1100px;
  width: 300px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-3d {
  width: 145px;
  height: 195px;
  position: relative;
  transform-style: preserve-3d;
  transform: translateX(45px) rotateX(15deg);
  transition: transform 0.45s cubic-bezier(0.25, 1, 0.5, 1);
}

.book-3d.opened {
  transform: translateX(70px) rotateX(6deg);
}

/* Front Hardcover */
.book-cover-front {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 10;
  background: linear-gradient(135deg, #1e3a8a, #172554);
  border-radius: 4px 10px 10px 4px;
  box-shadow: 2px 4px 16px rgba(0, 0, 0, 0.35);
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.book-3d.opened .book-cover-front {
  transform: rotateY(-180deg);
}

.cover-design {
  width: 100%;
  height: 100%;
  border: 2px solid #fbbf24;
  border-radius: 4px 8px 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  padding: 8px 4px;
}

.cover-badge {
  font-size: 0.65rem;
  background: #fbbf24;
  color: #1e3a8a;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.cover-title {
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 1px;
  margin-bottom: 4px;
  color: #ffffff;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}

.cover-subtitle {
  font-size: 0.75rem;
  color: #93c5fd;
}

/* Flipping Leaves (Pages) */
.book-leaf {
  position: absolute;
  top: 4px;
  left: 2px;
  width: 97%;
  height: 96%;
  transform-origin: left center;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  background: #fdfbf7;
  border-radius: 2px 6px 6px 2px;
  box-shadow: inset 2px 0 4px rgba(0, 0, 0, 0.08);
}

.leaf-1 {
  z-index: 8;
  transition-delay: 0.1s;
}

.leaf-2 {
  z-index: 6;
  transition-delay: 0.2s;
}

.book-3d.opened .leaf-1 {
  transform: rotateY(-176deg);
}

.book-3d.opened .leaf-2 {
  transform: rotateY(-172deg);
}

.leaf-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fdfbf7;
  background-image: repeating-linear-gradient(#fdfbf7, #fdfbf7 14px, #e2e8f0 15px);
  border-radius: 2px 6px 6px 2px;
}

/* Inside Left Page (Fixed Base) */
.book-page-left-base {
  position: absolute;
  top: 4px;
  left: -97%;
  width: 97%;
  height: 96%;
  background-color: #fefcf9;
  background-image: repeating-linear-gradient(#fefcf9, #fefcf9 14px, #e2e8f0 15px);
  border-radius: 6px 2px 2px 6px;
  box-shadow: -2px 3px 8px rgba(0, 0, 0, 0.15);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-doodle-sketch {
  font-size: 1rem;
  color: #64748b;
  transform: rotate(-10deg);
  border: 1px dashed #cbd5e1;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.6);
}

/* Inside Right Page (Fixed Base - The Revealed Page) */
.book-page-right-base {
  position: absolute;
  top: 4px;
  left: 2px;
  width: 97%;
  height: 96%;
  background-color: #fefcf9;
  background-image: repeating-linear-gradient(#fefcf9, #fefcf9 14px, #e2e8f0 15px);
  border-radius: 2px 6px 6px 2px;
  box-shadow: 2px 3px 10px rgba(0, 0, 0, 0.18);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.book-cover-back {
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: #172554;
  border-radius: 10px 4px 4px 10px;
  box-shadow: -2px 4px 16px rgba(0, 0, 0, 0.35);
  z-index: 0;
}

.page-corner-num {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 0.95rem;
  font-weight: 800;
  color: #b45309;
}

.page-reveal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.anim-label {
  font-size: 0.95rem;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 2px;
  margin-bottom: -4px;
}

.anim-number {
  font-size: 4rem;
  font-weight: 900;
  color: #b45309;
  line-height: 1;
  text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   13. MULTI-BOARD LAYOUT & LANDSCAPE ROTATION SUPPORT
   -------------------------------------------------------------------------- */
.header-title-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-tag {
  font-size: 0.8rem;
  font-weight: bold;
  background: #fef08a;
  color: #1e293b;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #1e293b;
}

.rotation-tip {
  background: #fffbeb;
  border: 1.5px dashed #f59e0b;
  color: #b45309;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.95rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 6px;
}

.game-boards-layout {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.boards-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-badge-indicator {
  font-size: 0.85rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
}

.team-badge-a {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.team-badge-b {
  background: #dcfce7;
  color: #065f46;
  border: 1px solid #86efac;
}

/* Team Card outlines */
.player-board.team-a-board {
  border-left: 4px solid var(--player1-color);
}

.player-board.team-b-board {
  border-left: 4px solid var(--player2-color);
}

/* Landscape Mode Optimization for Mobile Phones (Held Horizontally) */
@media (orientation: landscape) and (max-height: 520px) {
  body {
    padding: 4px 8px;
  }

  .notebook-page {
    max-width: 960px;
    height: 100%;
    max-height: 100dvh;
    padding: 6px 12px 8px 12px;
  }

  /* Start Screen Landscape */
  .doodle-hero {
    margin: 2px 0 6px 0;
  }

  .doodle-hero svg {
    max-height: 40px;
  }

  .teams-inputs-wrapper {
    flex-direction: row;
    gap: 10px;
  }

  .team-group {
    flex: 1;
  }

  .players-inputs-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 4px;
  }

  /* Game Screen Landscape */
  .game-boards-layout {
    display: grid;
    grid-template-columns: 1fr 220px 1fr;
    align-items: start;
    gap: 8px;
  }

  .game-boards-layout.layout-3p {
    grid-template-columns: 1fr 225px 1fr;
    align-items: center;
  }

  .game-boards-layout.layout-3p #boards-top-container,
  .game-boards-layout.layout-3p #boards-bottom-container {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  #boards-top-container {
    order: 1;
    max-height: 84vh;
    overflow-y: auto;
    padding-right: 2px;
  }

  .action-center {
    order: 2;
    position: sticky;
    top: 4px;
    padding: 2px 0;
  }

  #boards-bottom-container {
    order: 3;
    max-height: 84vh;
    overflow-y: auto;
    padding-right: 2px;
  }

  /* Compact slots in landscape */
  .slot-card {
    min-height: 68px;
    padding: 2px;
  }

  .slot-svg-container {
    height: 44px;
  }

  .btn-open-book {
    font-size: 1.1rem;
    padding: 8px 10px;
  }

  .book-draw-badge {
    width: 42px;
    height: 42px;
  }

  .book-draw-badge .badge-num {
    font-size: 1.4rem;
  }
}

/* ====================================================================
   DESKTOP & LAPTOP SCREENS (Comfortable, Beautiful Centered Notebook)
   ==================================================================== */
@media (min-width: 768px) and (min-height: 521px) {
  body {
    padding: 20px;
    background-color: #ece8df;
  }

  .notebook-page {
    max-width: 520px;
    height: 94vh;
    max-height: 880px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08);
    padding: 14px 18px;
  }

  #start-screen {
    padding: 8px 4px;
  }

  .doodle-hero svg {
    height: 50px;
    max-width: 160px;
  }

  .player-input-card {
    padding: 12px;
    margin-bottom: 12px;
  }

  .slot-card {
    min-height: 94px;
    padding: 4px 2px;
  }

  .slot-svg-container {
    height: 62px;
  }

  .action-center {
    gap: 8px;
    padding: 6px 0;
  }

  .btn-open-book {
    font-size: 1.25rem;
    padding: 10px 16px;
  }

  .book-draw-badge {
    width: 48px;
    height: 48px;
  }

  .book-draw-badge .badge-num {
    font-size: 1.6rem;
  }
}

/* ====================================================================
   ONLINE MULTIPLAYER STYLES (Firebase Room Codes & Waiting Lobby)
   ==================================================================== */
.online-toggle-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.online-toggle-btn {
  flex: 1;
  padding: 8px 10px;
  background: #f1f5f9;
  border: 2px solid var(--ink-primary);
  border-radius: 8px;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.15rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--ink-secondary);
}

.online-toggle-btn.active {
  background: var(--paper-highlight);
  color: var(--ink-primary);
  box-shadow: 2px 3px 0px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.online-panel {
  display: flex;
  flex-direction: column;
}

.room-code-card {
  background: #fef9c3;
  border: 2px dashed #ca8a04;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: center;
  margin-bottom: 8px;
}

.room-code-label {
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 2px;
  color: #854d0e;
  display: block;
}

.room-code-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0;
}

#display-room-code {
  font-family: 'Caveat', cursive;
  font-size: clamp(1.8rem, 3.5vh, 2.2rem);
  font-weight: 700;
  letter-spacing: 6px;
  color: #1e3a8a;
  background: #ffffff;
  padding: 2px 14px;
  border: 2px solid #1e3a8a;
  border-radius: 8px;
  box-shadow: 2px 3px 0px rgba(30, 58, 138, 0.3);
}

.btn-copy {
  padding: 6px 12px;
  background: #ffffff;
  border: 2px solid var(--ink-primary);
  border-radius: 6px;
  font-family: 'Patrick Hand', cursive;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 2px 2px 0px rgba(0, 0, 0, 0.2);
  transition: all 0.15s ease;
}

.btn-copy:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.2);
}

.btn-share {
  background: #dcfce7;
  color: #166534;
  border-color: #166534;
}

.lobby-name-edit-box {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lobby-name-input {
  width: 120px;
  padding: 2px 6px;
  border: 1.5px solid var(--ink-primary);
  border-radius: 6px;
  font-family: 'Patrick Hand', cursive;
  font-size: 1.05rem;
  font-weight: bold;
  background: #fff;
  outline: none;
}

.btn-inline-edit {
  background: #f1f5f9;
  border: 1.5px solid var(--ink-primary);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
  font-weight: bold;
  font-family: 'Patrick Hand', cursive;
  transition: all 0.1s ease;
}

.btn-inline-edit:active {
  transform: scale(0.95);
}

.room-code-hint {
  font-size: 0.95rem;
  color: #713f12;
  margin: 4px 0 0 0;
}

.lobby-players-section {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 8px;
  max-height: 25vh;
  overflow-y: auto;
}

.lobby-players-title {
  font-size: 1.15rem;
  margin: 0 0 6px 0;
  color: var(--ink-primary);
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 3px;
}

.lobby-players-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.lobby-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
}

.lobby-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: bold;
  font-size: 1.1rem;
}

.lobby-player-badge {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: bold;
}

.badge-host {
  background: #fef08a;
  color: #854d0e;
  border: 1px solid #eab308;
}

.badge-guest {
  background: #e2e8f0;
  color: #475569;
}

.guest-waiting-notice {
  text-align: center;
  padding: 10px;
  background: #eff6ff;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  color: #1e40af;
  font-size: 1.1rem;
  font-weight: bold;
  animation: pulse-notice 1.6s infinite ease-in-out;
}

@keyframes pulse-notice {
  0%, 100% { opacity: 0.85; transform: scale(0.99); }
  50% { opacity: 1; transform: scale(1.01); }
}

.online-room-tag {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1.5px solid #93c5fd;
  font-weight: bold;
}

.online-turn-notice {
  background: #fef9c3;
  border: 2px dashed #eab308;
  color: #854d0e;
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  font-size: 1.15rem;
  font-weight: bold;
  margin-bottom: 8px;
  animation: pulse-notice 1.5s infinite ease-in-out;
}

/* ====================================================================
   PWA INSTALL BANNER STYLING
   ==================================================================== */
.pwa-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fffbeb;
  border: 2px dashed #f59e0b;
  border-radius: 8px;
  padding: 6px 10px;
  margin: 4px 0 10px 0;
  gap: 8px;
  box-shadow: 2px 2px 0px rgba(245, 158, 11, 0.25);
  animation: banner-subtle 2.5s infinite ease-in-out;
}

@keyframes banner-subtle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.pwa-install-text {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.pwa-badge {
  background: #fef08a;
  border: 1px solid #d97706;
  color: #92400e;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.5px;
}

.pwa-msg {
  font-size: 0.95rem;
  font-weight: bold;
  color: #78350f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-install-pill {
  padding: 4px 12px;
  font-size: 0.95rem;
  white-space: nowrap;
  border-radius: 20px;
  background: #f59e0b;
  border: 2px solid #1f2937;
  color: #1f2937;
  font-weight: bold;
  box-shadow: 2px 2px 0px #1f2937;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-install-pill:hover,
.btn-install-pill:active {
  background: #d97706;
  color: #ffffff;
  transform: translateY(1px);
  box-shadow: 1px 1px 0px #1f2937;
}

