:root {
  --sky-top: #2d1b4e;
  --sky-mid: #4a2c7a;
  --sky-bottom: #6b3d9a;
  --water: #00b4d8;
  --water-light: #48cae4;
  --water-dark: #0077b6;
  --island-grass: #2d6a4f;
  --island-dirt: #5a3d2b;
  --island-light: #40916c;
  --btn-hex: #d4a574;
  --btn-hex-dark: #b8956a;
  --btn-hex-light: #e8c39e;
  --text: #ffffff;
  --text-dark: #2d1b4e;
  --warning: #e63946;
  --success: #2a9d8f;
  --wolf: #6c757d;
  --wolf-dark: #495057;
  --chicken: #f8f9fa;
  --chicken-red: #e63946;
  --corn: #ffd60a;
  --corn-green: #2d6a4f;
  --farmer-skin: #f4a261;
  --farmer-shirt: #e76f51;
  --farmer-overalls: #264653;
  --farmer-hat: #e9c46a;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Comic Neue', cursive, sans-serif;
}

/* Landscape Prompt */
.landscape-prompt {
  display: none;
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--sky-top), var(--sky-mid));
  z-index: 10000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--text);
}

.landscape-prompt .phone-icon {
  width: 80px;
  height: 140px;
  border: 4px solid var(--text);
  border-radius: 12px;
  margin-bottom: 30px;
  position: relative;
  animation: rotate-phone 2s ease-in-out infinite;
}

@keyframes rotate-phone {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

@media screen and (max-width: 768px) and (orientation: portrait) {
  .landscape-prompt { display: flex; }
  .game-container { display: none; }
}

/* Name Input Modal */
.name-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  backdrop-filter: blur(5px);
}

.name-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.name-content {
  background: linear-gradient(145deg, var(--btn-hex-light), var(--btn-hex));
  padding: 40px 60px;
  border-radius: 20px;
  text-align: center;
  color: var(--text-dark);
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 4px solid var(--btn-hex-dark);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  max-width: 400px;
  width: 90%;
}

.name-modal.visible .name-content {
  transform: scale(1);
}

.name-content input {
  width: 100%;
  padding: 15px;
  font-size: 1.2rem;
  border: 2px solid var(--btn-hex-dark);
  border-radius: 10px;
  margin: 20px 0;
  text-align: center;
  font-family: inherit;
}

.name-content input:focus {
  outline: none;
  border-color: var(--success);
}

/* Welcome & Rules Modal Styles */
.welcome-modal, .rules-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  backdrop-filter: blur(5px);
}

.welcome-modal.visible, .rules-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.welcome-content, .rules-content {
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(145deg, var(--btn-hex-light), var(--btn-hex));
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  color: var(--text-dark);
  transform: scale(0.8);
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 4px solid var(--btn-hex-dark);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.welcome-modal.visible .welcome-content,
.rules-modal.visible .rules-content {
  transform: scale(1);
}

.welcome-content h2, .rules-content h2 {
  color: var(--sky-top);
  font-size: 1.8rem;
  margin-bottom: 20px;
}

.rules-section {
  text-align: left;
  margin: 20px 0;
}

.rules-section h3 {
  color: var(--success);
  margin-bottom: 15px;
  font-size: 1.3rem;
}

.rules-section ul {
  list-style: none;
  padding: 0;
}

.rules-section li {
  margin: 12px 0;
  padding: 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1.4;
}

.rules-section .tip {
  margin-top: 15px;
  padding: 12px;
  background: rgba(42,157,143,0.2);
  border-radius: 8px;
  border-left: 4px solid var(--success);
  font-style: italic;
}

.understood-btn {
  background: var(--success) !important;
  font-size: 1.2rem !important;
  padding: 15px 50px !important;
}

/* Game Container - Full screen on PC */
.game-container {
  width: 100vw;
  height: 100dvh;
  height: var(--app-height, 100vh);
  background: linear-gradient(to bottom, var(--sky-top), var(--sky-mid), var(--sky-bottom));
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  z-index: 100;
  gap: 0;
  height: 0;
  pointer-events: none;
}

.hex-btn {
  width: 70px;
  height: 60px;
  background: linear-gradient(145deg, var(--btn-hex-light), var(--btn-hex-dark));
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-weight: bold;
  color: var(--text-dark);
  text-transform: uppercase;
  font-size: 0.7rem;
  transition: transform 0.2s;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.hex-btn:hover { transform: scale(1.05); }
.hex-btn:active { transform: scale(0.95); }
.hex-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.hex-btn .badge {
  position: absolute;
  top: -5px;
  right: 5px;
  background: var(--warning);
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.hex-btn.large {
  width: 100px;
  height: 85px;
  font-size: 0.9rem;
}

.hex-btn.large .btn-icon {
  font-size: 1.5rem;
  margin-bottom: 3px;
}

/* World - Full coverage */
.world {
  flex: 1;
  position: relative;
  width: 100%;
  overflow: hidden;
}

/* Night sky decorations */
.sky-decor {
  position: absolute;
  inset: 0 0 40% 0;
  z-index: 2;
  pointer-events: none;
}

.moon {
  position: absolute;
  top: 8%;
  right: 10%;
  width: clamp(28px, 5vw, 52px);
  height: clamp(28px, 5vw, 52px);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffce8 0%, #f7efc6 55%, #d9ce9a 100%);
  box-shadow: 0 0 20px rgba(255, 245, 190, 0.45);
}

.moon::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translate(20%, -2%);
  border-radius: 50%;
  background: rgba(45, 27, 78, 0.55);
}

.star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.7);
  animation: twinkle 2.8s ease-in-out infinite;
}

.s1 { top: 12%; left: 12%; animation-delay: 0s; }
.s2 { top: 18%; left: 20%; animation-delay: 0.3s; }
.s3 { top: 10%; left: 30%; animation-delay: 0.6s; }
.s4 { top: 20%; left: 44%; animation-delay: 1s; }
.s5 { top: 14%; left: 58%; animation-delay: 1.3s; }
.s6 { top: 24%; left: 68%; animation-delay: 1.7s; }
.s7 { top: 16%; left: 78%; animation-delay: 2.1s; }
.s8 { top: 26%; left: 86%; animation-delay: 2.4s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.35); }
}

/* Clouds */
.cloud {
  position: absolute;
  background: rgba(255,255,255,0.15);
  border-radius: 50px;
  z-index: 1;
}

.cloud1 {
  width: 120px;
  height: 50px;
  top: 8%;
  left: 5%;
  animation: float-cloud 30s infinite linear;
}

.cloud1::before {
  content: '';
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  top: -30px;
  left: 20px;
}

.cloud1::after {
  content: '';
  position: absolute;
  width: 80px;
  height: 50px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  top: -20px;
  right: 20px;
}

@keyframes float-cloud {
  0% { transform: translateX(0); }
  100% { transform: translateX(calc(100vw + 200px)); }
}

/* Scene */
.scene {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Real Waves - SVG animated */
.water {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40%;
  background: linear-gradient(to bottom, var(--water-light), var(--water), var(--water-dark));
  overflow: hidden;
  z-index: 5;
}

.wave-svg {
  position: absolute;
  width: 200%;
  height: 100%;
  bottom: 0;
}

.wave-path {
  animation: wave-opacity 3s ease-in-out infinite;
}

.wave-path:nth-child(2) {
  animation-delay: -1s;
  opacity: 0.7;
}

.wave-path:nth-child(3) {
  animation-delay: -2s;
  opacity: 0.5;
}

@keyframes wave-opacity {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* Islands - Flat banks like reference */
.island {
  position: absolute;
  bottom: 33%;
  width: 24%;
  height: 15%;
  z-index: 10;
  overflow: visible;
}

.island.left {
  left: -1%;
  transform: rotate(-1deg);
  clip-path: polygon(0 35%, 12% 28%, 28% 32%, 45% 26%, 62% 31%, 80% 27%, 100% 34%, 100% 100%, 0 100%);
}

.island.right {
  right: -1%;
  transform: rotate(1deg);
  clip-path: polygon(0 34%, 16% 27%, 34% 31%, 52% 25%, 70% 30%, 86% 26%, 100% 35%, 100% 100%, 0 100%);
}

.island-ground {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, #66b86b 0%, #58a95f 65%, #4b8f50 100%);
}

.island-dirt {
  position: absolute;
  bottom: -18%;
  left: 0;
  right: 0;
  height: 62%;
  background: linear-gradient(to bottom, #6f5b3d, #5a472f);
  clip-path: polygon(0 18%, 100% 18%, 96% 100%, 4% 100%);
  border-bottom-left-radius: 30px;
  border-bottom-right-radius: 30px;
}

/* Grass top edge */
.island-ground::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  background: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 6px,
    rgba(255,255,255,0.16) 6px,
    rgba(255,255,255,0.16) 12px
  );
}

/* Animals */
.animal {
  position: absolute;
  width: clamp(80px, 10vw, 140px);
  height: clamp(80px, 10vw, 140px);
  cursor: pointer;
  transition: all 0.5s ease;
  z-index: 20;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
}

.animal:hover:not(.disabled):not(.dead) {
  transform: scale(1.1) translateY(-5px);
}

.animal.walking {
  animation: walk-bounce 0.4s infinite;
  z-index: 25;
}

@keyframes walk-bounce {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

.animal.on-boat {
  bottom: 38% !important;
  z-index: 15;
  clip-path: inset(0 0 28% 0);
}

.animal.selected {
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35));
  animation: none;
}

@keyframes glow {
  0%, 100% { filter: drop-shadow(0 0 15px rgba(255,214,10,0.7)); }
  50% { filter: drop-shadow(0 0 25px rgba(255,214,10,1)); }
}

.animal.dead {
  filter: grayscale(1) brightness(0.4) sepia(0.6);
  transform: rotate(90deg) scale(0.8);
  opacity: 0.4;
}

.animal.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.animal svg {
  width: 100%;
  height: 100%;
}

/* Positions */
#animal-wolf { left: 3%; bottom: 40%; }
#animal-chicken { left: 10%; bottom: 42%; }
#animal-corn { left: 17%; bottom: 40%; }

/* Boat */
.boat-container {
  position: absolute;
  bottom: 32%;
  left: 22%;
  width: clamp(140px, 16vw, 220px);
  height: clamp(90px, 11vw, 140px);
  z-index: 15;
  transition: left 2.5s ease-in-out;
}

.boat-container.at-left { left: 22%; }
.boat-container.at-right { left: 74%; }

.boat-container.moving {
  animation: boat-rock 2.5s ease-in-out;
}

@keyframes boat-rock {
  0%, 100% { transform: rotate(0deg) translateY(0); }
  25% { transform: rotate(-4deg) translateY(-6px); }
  75% { transform: rotate(4deg) translateY(-6px); }
}

.boat {
  width: 100%;
  height: 100%;
  position: relative;
}

.boat-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.5));
}

#farmer-body {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.boat-container.moving #farmer-body {
  opacity: 1;
}

.boat-container.moving .oar-left {
  animation: row-left 0.9s ease-in-out infinite;
  transform-origin: 80% 20%;
}

.boat-container.moving .oar-right {
  animation: row-right 0.9s ease-in-out infinite;
  transform-origin: 20% 20%;
}

.boat-container.moving #farmer-body {
  animation: farmer-bob 0.9s ease-in-out infinite;
  transform-origin: center bottom;
  clip-path: inset(0 0 14% 0);
}

.oar-left {
  opacity: 0;
}

.farmer-land {
  position: absolute;
  bottom: 37%;
  left: 24%;
  width: clamp(34px, 4vw, 56px);
  height: clamp(48px, 6vw, 76px);
  z-index: 19;
  transition: left 0.35s ease, bottom 0.35s ease, transform 0.2s ease, opacity 0.2s ease;
  filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35));
}

.farmer-land svg {
  width: 100%;
  height: 100%;
}

.farmer-land.working {
  transform: translateY(-3px) scale(1.02);
}

.farmer-land.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Farmer with oars */
.farmer-container {
  position: absolute;
  bottom: 35%;
  left: 30%;
  width: 50%;
  height: 60%;
  z-index: 16;
}

.farmer {
  width: 100%;
  height: 100%;
  position: relative;
}

.farmer-rowing .oar-left {
  animation: row-left 1s ease-in-out infinite;
  transform-origin: 80% 20%;
}

.farmer-rowing .oar-right {
  animation: row-right 1s ease-in-out infinite;
  transform-origin: 20% 20%;
}

@keyframes row-left {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-35deg); }
}

@keyframes row-right {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(35deg); }
}

@keyframes farmer-bob {
  0%, 100% { transform: translate(24px, 6px) scale(0.62); }
  50% { transform: translate(24px, 8px) scale(0.62); }
}

.boat-container.farmer-working.working-left #farmer-body {
  animation: farmer-reach-left 0.9s ease-in-out;
}

.boat-container.farmer-working.working-right #farmer-body {
  animation: farmer-reach-right 0.9s ease-in-out;
}

@keyframes farmer-reach-left {
  0%, 100% { transform: translate(24px, 6px) scale(0.62); }
  50% { transform: translate(21px, 5px) scale(0.63); }
}

@keyframes farmer-reach-right {
  0%, 100% { transform: translate(24px, 6px) scale(0.62); }
  50% { transform: translate(27px, 5px) scale(0.63); }
}

/* Splash effects */
.splash-container {
  position: absolute;
  bottom: -10px;
  left: -30%;
  right: -30%;
  height: 40px;
  pointer-events: none;
}

.splash-drop {
  position: absolute;
  width: 10px;
  height: 10px;
  background: rgba(255,255,255,0.8);
  border-radius: 50%;
  animation: splash-fall 0.4s ease-out forwards;
}

@keyframes splash-fall {
  0% { transform: translateY(0) scale(1); opacity: 0.9; }
  100% { transform: translateY(30px) scale(0.3); opacity: 0; }
}

.boat-container.moving .splash-container {
  opacity: 1;
}

/* Passenger - scaled down to fit with farmer */
.boat-passenger {
  position: absolute;
  bottom: 40%;
  left: 15%;
  width: 35%;
  height: 35%;
  z-index: 14;
  display: none !important;
}

.boat-passenger svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Attempts Display */
.attempts-display {
  position: absolute;
  top: 3%;
  left: 50%;
  transform: translateX(-50%);
  color: white;
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  z-index: 130;
  background: rgba(0,0,0,0.3);
  padding: 5px 15px;
  border-radius: 20px;
  transition: all 0.3s ease;
}

.attempts-display.high-attempts {
  background: rgba(230,57,70,0.6);
  animation: pulse-warning 1s ease-in-out infinite;
}

@keyframes pulse-warning {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.05); }
}

/* Score */
.score-display {
  position: absolute;
  top: calc(3% + 40px);
  left: 3%;
  bottom: auto;
  color: white;
  font-size: clamp(1rem, 2vw, 1.3rem);
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
  z-index: 130;
}

/* Auto-restart countdown (on fail) */
.restart-countdown {
  position: absolute;
  top: calc(3% + 70px);
  left: 3%;
  bottom: auto;
  color: #fff;
  font-size: clamp(0.95rem, 1.8vw, 1.15rem);
  font-weight: 800;
  text-shadow: 0 2px 4px rgba(0,0,0,0.55);
  z-index: 55;
  pointer-events: none;
}

/* Bottom Bar */
.bottom-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 12px 14px 16px;
  background: linear-gradient(to top, rgba(0,119,182,0.38), rgba(0,180,216,0.1) 55%, transparent);
  backdrop-filter: blur(3px);
  z-index: 100;
}

.mobile-only {
  display: none;
}

.glass-btn {
  background: linear-gradient(160deg, rgba(255,255,255,0.3), rgba(255,255,255,0.14));
  border: 1px solid rgba(255,255,255,0.42);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.45);
  box-shadow: 0 8px 20px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.35);
}

.glass-btn .btn-icon {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}

.go-fab {
  position: absolute;
  right: clamp(10px, 2vw, 24px);
  bottom: clamp(18px, 2.6vh, 28px);
  z-index: 120;
}

/* Status */
.status-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 200;
  pointer-events: none;
}

.status-msg {
  background: rgba(0,0,0,0.8);
  color: white;
  padding: 15px 30px;
  border-radius: 30px;
  font-size: clamp(1rem, 2.5vw, 1.4rem);
  white-space: nowrap;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s ease;
  border: 2px solid rgba(255,255,255,0.3);
}

.status-msg.visible {
  opacity: 1;
  transform: scale(1);
}

.status-msg.danger {
  background: rgba(230,57,70,0.9);
  animation: shake 0.5s ease;
}

.status-msg.success {
  background: rgba(42,157,143,0.9);
}

.status-msg.hint {
  background: rgba(233,196,106,0.9);
  color: var(--text-dark);
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) translateX(0); }
  25% { transform: translate(-50%, -50%) translateX(-10px); }
  75% { transform: translate(-50%, -50%) translateX(10px); }
}

.fullscreen-fab {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 160;
}

.blood-drop {
  position: fixed;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ff8c8c, #b20018 70%);
  pointer-events: none;
  z-index: 194;
}

.devoured-cabbage {
  opacity: 0 !important;
  transform: scale(0.14) !important;
  filter: none !important;
}

/* Effects */
.eating-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(230,57,70,0.2) 0%, transparent 60%);
  z-index: 180;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.eating-overlay.visible { opacity: 1; }

.feather {
  position: fixed;
  width: 22px;
  height: 22px;
  background: white;
  border-radius: 50% 0 50% 50%;
  pointer-events: none;
  z-index: 190;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.feather:nth-child(3n) { background: var(--chicken-red); }
.feather:nth-child(5n) { background: #f4a261; }

@keyframes feather-fly {
  0% { transform: translate(0,0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) rotate(var(--rot)) scale(0.2); opacity: 0; }
}

.corn-piece {
  position: fixed;
  width: 12px;
  height: 12px;
  background: var(--corn);
  border-radius: 3px;
  pointer-events: none;
  z-index: 190;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

@keyframes corn-fly {
  0% { transform: translate(0,0) scale(1); opacity: 1; }
  50% { transform: translate(calc(var(--tx)*0.5), calc(var(--ty)*0.5-80px)) scale(1.3); }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.2); opacity: 0; }
}

.crunch-text {
  position: fixed;
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  font-weight: bold;
  pointer-events: none;
  z-index: 195;
  text-shadow: 0 4px 8px rgba(0,0,0,0.5);
  animation: crunch-pop 1s ease-out forwards;
}

@keyframes crunch-pop {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  30% { transform: scale(1.4) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) translateY(-60px); opacity: 0; }
}

/* Victory Modal */
.victory-modal, .hint-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

.victory-modal.visible, .hint-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background: linear-gradient(145deg, var(--btn-hex-light), var(--btn-hex));
  padding: 40px 60px;
  border-radius: 20px;
  text-align: center;
  color: var(--text-dark);
  transform: scale(0);
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 4px solid var(--btn-hex-dark);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.victory-modal.visible .modal-content,
.hint-modal.visible .modal-content {
  transform: scale(1);
}

.modal-content h2 {
  font-size: 2.5rem;
  margin-bottom: 15px;
  color: var(--success);
}

.modal-content h3 {
  font-size: 1.8rem;
  margin-bottom: 20px;
  color: var(--sky-top);
}

.hint-step {
  background: rgba(255,255,255,0.3);
  padding: 12px 18px;
  margin: 10px 0;
  border-radius: 10px;
  text-align: left;
  font-size: 1.1rem;
}

.close-btn {
  margin-top: 25px;
  padding: 12px 40px;
  background: var(--sky-mid);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  font-family: inherit;
}

.close-btn:hover { transform: scale(1.05); }

.confetti {
  position: fixed;
  width: 14px;
  height: 14px;
  z-index: 290;
  pointer-events: none;
}

@keyframes confetti-fall {
  0% { transform: translateY(-100px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Responsive */
@media (max-width: 1024px) {
  .island { width: 20%; }
  .animal { width: 70px; height: 70px; }
}

@media (max-width: 600px) {
  .hex-btn { width: 60px; height: 52px; font-size: 0.6rem; }
  .hex-btn.large { width: 85px; height: 72px; }
  .animal { width: 60px; height: 60px; }
  .boat-container { width: 120px; height: 80px; bottom: 27%; }
  .animal.on-boat { bottom: 33% !important; }
  .mobile-only { display: flex; }
  .bottom-bar { justify-content: flex-start; padding-right: 105px; }
  
  .welcome-content h2, .rules-content h2 {
    font-size: 1.4rem;
  }
  
  .rules-section li {
    font-size: 0.9rem;
    padding: 8px;
  }
}

/* Leaderboard */
.leaderboard-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 550;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  backdrop-filter: blur(5px);
}

.leaderboard-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.leaderboard-content {
  max-width: 400px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(145deg, var(--btn-hex-light), var(--btn-hex));
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  color: var(--text-dark);
  border: 4px solid var(--btn-hex-dark);
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.leaderboard-table {
  width: 100%;
  margin: 20px 0;
  border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.leaderboard-table th {
  background: rgba(0,0,0,0.1);
  font-weight: bold;
}

.leaderboard-table tr:nth-child(1) td { color: gold; font-weight: bold; }
.leaderboard-table tr:nth-child(2) td { color: silver; font-weight: bold; }
.leaderboard-table tr:nth-child(3) td { color: #cd7f32; font-weight: bold; }

.time-display {
  font-size: 1.2rem;
  margin: 10px 0;
  color: var(--success);
}
