/* style.css */
:root {
  --bg-top: #f7f9fc;
  --bg-bottom: #eaf0f7;
  --text-dark: #1a233b;
  --text-muted: #64748b;
  --primary-navy: #151e33;
  --primary-navy-dark: #0b1120;
  --accent-blue: #1c73e8;
  --accent-blue-soft: #e3effd;
  --danger-red: #ff3355;
  --tile-depth: #0c1220;
  --btn-shadow: 0 4px 14px rgba(20, 28, 48, 0.08);
  --app-height: 100dvh;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100vh);
  overflow: hidden;
  position: fixed;
  background-color: var(--primary-navy-dark);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-dark);
}

#app {
  width: 100%;
  height: 100%;
  height: var(--app-height, 100vh);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  position: relative;
  overflow: hidden;
  z-index: 10;
}

/* TOP HEADER */
.game-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--primary-navy);
  border-radius: 50%;
  cursor: pointer;
  outline: none;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background-color: rgba(20, 30, 55, 0.06);
}

.level-title-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.level-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary-navy);
  letter-spacing: -0.3px;
}

/* SECONDARY STATS BAR */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 8px 16px;
  flex-shrink: 0;
  gap: 8px;
}

.hearts-container {
  display: flex;
  align-items: center;
  gap: 3px;
}

.heart-icon {
  filter: drop-shadow(0 2px 3px rgba(255, 51, 85, 0.25));
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.heart-icon.lost {
  opacity: 0.25;
  transform: scale(0.85);
  filter: grayscale(100%);
}

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: -0.1px;
}

.badge-moves, .badge-arrows {
  background: #eef2f7;
  color: #334155;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.badge-difficulty {
  background: var(--accent-blue-soft);
  color: var(--accent-blue);
}

/* PUZZLE BOARD CONTAINER */
.puzzle-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 10px;
}

.board-container {
  position: relative;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 24px;
  box-shadow: 0 12px 36px rgba(18, 28, 54, 0.06), inset 0 0 0 1px rgba(255, 255, 255, 0.7);
  transition: width 0.2s ease, height 0.2s ease;
  touch-action: none;
}

/* 3D ARROW TILES */
.arrow-tile {
  position: absolute;
  cursor: pointer;
  touch-action: manipulation;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform, opacity;
  transform-origin: center center;
  transition: transform 0.08s ease;
}

.tile-inner {
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background: linear-gradient(145deg, #1b263e, #131c30);
  box-shadow: 0 5px 0 var(--tile-depth), 0 8px 16px rgba(13, 19, 32, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: box-shadow 0.15s ease, background 0.15s ease;
}

.tile-inner::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 35%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 100%);
  border-top-left-radius: 13px;
  border-top-right-radius: 13px;
  pointer-events: none;
}

.arrow-tile:active .tile-inner {
  transform: translateY(3px);
  box-shadow: 0 2px 0 var(--tile-depth), 0 4px 8px rgba(13, 19, 32, 0.2);
}

.arrow-svg {
  width: 65%;
  height: 65%;
  fill: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
  transition: transform 0.2s ease;
  pointer-events: none;
}

/* SHAKE ANIMATION FOR BLOCKED ARROW */
@keyframes shakeBlocked {
  0% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-6px, 0) rotate(-4deg); }
  40% { transform: translate(6px, 0) rotate(4deg); }
  60% { transform: translate(-4px, 0) rotate(-2deg); }
  80% { transform: translate(4px, 0) rotate(2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.arrow-tile.blocked {
  animation: shakeBlocked 0.34s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.arrow-tile.blocked .tile-inner {
  border-color: rgba(255, 51, 85, 0.6);
  box-shadow: 0 5px 0 #4a0c18, 0 8px 16px rgba(255, 51, 85, 0.2);
}

/* HINT PULSE ANIMATION */
@keyframes hintPulse {
  0%, 100% {
    box-shadow: 0 5px 0 var(--tile-depth), 0 0 0 0 rgba(255, 183, 3, 0.8);
  }
  50% {
    box-shadow: 0 5px 0 var(--tile-depth), 0 0 16px 5px rgba(255, 183, 3, 0.9);
  }
}

.arrow-tile.hint-active .tile-inner {
  animation: hintPulse 0.9s infinite ease-in-out;
  border-color: #ffb703;
}

/* ESCAPE FLY ANIMATIONS */
.arrow-tile.escaping-up {
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease !important;
  transform: translateY(-130vh) scale(1.15) !important;
  opacity: 0 !important;
  pointer-events: none;
}

.arrow-tile.escaping-down {
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease !important;
  transform: translateY(130vh) scale(1.15) !important;
  opacity: 0 !important;
  pointer-events: none;
}

.arrow-tile.escaping-left {
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease !important;
  transform: translateX(-130vw) scale(1.15) !important;
  opacity: 0 !important;
  pointer-events: none;
}

.arrow-tile.escaping-right {
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease !important;
  transform: translateX(130vw) scale(1.15) !important;
  opacity: 0 !important;
  pointer-events: none;
}

/* BOTTOM FOOTER */
.game-footer {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding: 0 16px 16px 16px;
  flex-shrink: 0;
}

.action-circle-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid rgba(220, 226, 238, 0.8);
  box-shadow: 0 6px 18px rgba(18, 28, 54, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1e293b;
  cursor: pointer;
  outline: none;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease;
}

.action-circle-btn:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(18, 28, 54, 0.06);
}

.hint-badge {
  position: absolute;
  top: -4px;
  right: -2px;
  background: var(--accent-blue);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(28, 115, 232, 0.4);
}

/* MODAL OVERLAYS */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 20, 36, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
  transition: opacity 0.25s ease;
}

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

.menu-card {
  width: 100%;
  max-width: 340px;
  background: #ffffff;
  border-radius: 28px;
  padding: 32px 24px;
  box-shadow: 0 24px 48px rgba(9, 14, 28, 0.25);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  animation: popCard 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popCard {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.menu-logo-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: linear-gradient(135deg, #f0f4f9, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.8), 0 4px 12px rgba(0, 0, 0, 0.05);
}

.game-brand-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--primary-navy);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.game-brand-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-weight: 500;
}

.menu-stats-preview {
  display: flex;
  width: 100%;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-box {
  flex: 1;
  background: #f8fafc;
  border: 1px solid #edf2f7;
  padding: 12px 8px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

.stat-val {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-navy);
}

.btn-primary {
  width: 100%;
  height: 52px;
  border-radius: 26px;
  background: linear-gradient(135deg, #1e73e8, #1557bf);
  color: #ffffff;
  border: none;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(30, 115, 232, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(30, 115, 232, 0.25);
}

.btn-secondary {
  width: 100%;
  height: 48px;
  border-radius: 24px;
  background: #f1f5f9;
  color: var(--primary-navy);
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
}

.btn-ghost {
  width: 100%;
  height: 44px;
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
}

.menu-options-row {
  margin-top: 16px;
}

.secondary-pill-btn {
  background: #f1f5f9;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 13px;
  color: #475569;
  cursor: pointer;
}

.modal-header-title {
  font-size: 24px;
  font-weight: 900;
  color: var(--primary-navy);
  margin-bottom: 6px;
}

.modal-header-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions-list {
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* CELEBRATION MODAL */
.celebration-card .trophy-badge {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #fff8e6;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.cleared-text {
  font-size: 15px;
  font-weight: 700;
  color: #10b981;
  margin-bottom: 20px;
}

.level-stats-summary {
  width: 100%;
  background: #f8fafc;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sum-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #64748b;
}

.sum-row strong {
  color: var(--primary-navy);
  font-weight: 800;
}

/* CONFETTI CANVAS */
.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
}

/* SEAMLESS BLACKOUT TRANSITION */
.blackout-screen {
  position: fixed;
  inset: 0;
  background-color: #000000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-in-out;
  z-index: 999998;
}

.blackout-screen.active {
  opacity: 1;
  pointer-events: all;
}

/* FULLSCREEN PRANK VIDEO OVERLAY */
.prank-fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: var(--app-height, 100dvh);
  background-color: #000000;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.prank-video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.prank-unmute-prompt {
  position: absolute;
  bottom: 40px;
  background: rgba(0, 0, 0, 0.75);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 700;
  backdrop-filter: blur(4px);
  pointer-events: none;
  animation: pulsePrompt 1.2s infinite ease-in-out;
}

@keyframes pulsePrompt {
  0%, 100% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
}

.hidden {
  display: none !important;
}

/* ACCESSIBILITY: REDUCED MOTION */
@media (prefers-reduced-motion: reduce) {
  .arrow-tile.escaping-up,
  .arrow-tile.escaping-down,
  .arrow-tile.escaping-left,
  .arrow-tile.escaping-right {
    transition: opacity 0.15s linear !important;
    transform: none !important;
  }
  .arrow-tile.blocked {
    animation: none !important;
  }
}