@font-face {
  font-family: 'Bangers';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/bangers.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/nunito-400.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/nunito-700.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../assets/fonts/nunito-800.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('../assets/fonts/nunito-900.woff2') format('woff2');
}

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

:root {
  --wood-dark: #8B4513;
  --wood-medium: #CD853F;
  --wood-light: #DEB887;
  --wood-grain: #D2691E;
  --wood-deep: #4E342E;
  --gold: #FFD700;
  --gold-dark: #FFA500;
  --gold-glow: rgba(255, 215, 0, 0.45);
  --red: #FF4757;
  --green: #2ED573;
  --cream: #FFF8E1;
  --peach: #FFCC80;
  --shadow: rgba(139, 69, 19, 0.25);
  --panel-bg: linear-gradient(160deg, rgba(255, 248, 225, 0.18) 0%, rgba(62, 39, 35, 0.72) 100%);
  --panel-border: rgba(255, 215, 0, 0.28);
  --panel-shadow: 0 16px 48px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --ui-pad: clamp(0.65rem, 2.2vw, 1.25rem);
  --panel-max-w: min(92vw, 440px);
  --radius-lg: clamp(16px, 3vw, 22px);
  --radius-md: 12px;
  --radius-sm: 8px;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  font-family: 'Nunito', sans-serif;
  cursor: crosshair;
  overscroll-behavior: none;
  touch-action: none;
}

#wood-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-color: #3E2723;
  background-image:
    radial-gradient(ellipse at 50% 35%, rgba(255, 224, 178, 0.35) 0%, transparent 55%),
    linear-gradient(180deg, #C89B68 0%, #B8895A 35%, #A67B4E 70%, #6D4C41 100%);
  background-size: cover;
}

#vignette-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(30, 18, 8, 0.35) 100%);
}

#game-canvas,
#slash-canvas {
  position: fixed;
  inset: 0;
  z-index: 2;
  touch-action: none;
}

#game-canvas {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(255, 224, 178, 0.2) 0%, transparent 55%),
    linear-gradient(180deg, #C89B68 0%, #B8895A 35%, #A67B4E 70%, #6D4C41 100%);
}

#slash-canvas {
  z-index: 3;
  pointer-events: auto;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(62, 39, 35, 0.42);
  backdrop-filter: blur(4px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    calc(var(--safe-top) + var(--ui-pad))
    calc(var(--safe-right) + var(--ui-pad))
    calc(var(--safe-bottom) + var(--ui-pad))
    calc(var(--safe-left) + var(--ui-pad));
}

.screen.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* Shared UI panel */
.ui-panel {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.panel-badge {
  display: inline-block;
  margin-bottom: 0.65rem;
  padding: 0.28rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.14);
  border: 1px solid rgba(255, 215, 0, 0.35);
  color: var(--gold);
  font-size: clamp(0.65rem, 2vw, 0.75rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 1.35rem;
}

.panel-header.compact {
  margin-bottom: 1rem;
}

.panel-header-icon {
  font-size: 1.35rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.panel-header h2,
.panel-content h2 {
  color: var(--cream);
  text-align: center;
  font-size: clamp(1.4rem, 4.5vw, 1.85rem);
  font-family: 'Bangers', cursive;
  letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  margin: 0;
}

.full-width {
  width: 100%;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.25rem;
}

/* Main Menu */
.menu-content {
  text-align: center;
  animation: fadeInUp 0.6s ease;
  width: min(100%, 540px);
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2rem) clamp(1rem, 3.5vw, 1.75rem);
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.game-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(3rem, 10vw, 6rem);
  color: var(--gold);
  text-shadow: 
    3px 3px 0 var(--wood-dark),
    6px 6px 0 rgba(0,0,0,0.3),
    0 0 30px rgba(255, 215, 0, 0.4);
  letter-spacing: 4px;
  margin-bottom: 0.2em;
}

.title-fruit {
  display: inline-block;
  animation: bounce 2s ease infinite;
}

.title-fruit:last-child {
  animation-delay: 0.5s;
}

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

.subtitle {
  color: #FFE0B2;
  font-size: clamp(0.85rem, 2.8vw, 1.2rem);
  margin-bottom: clamp(1.25rem, 4vw, 2.5rem);
  letter-spacing: clamp(2px, 1.5vw, 8px);
  text-transform: uppercase;
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.mode-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(0.65rem, 2vw, 1rem);
  width: var(--panel-max-w);
  max-width: 100%;
  margin: 0 auto clamp(1rem, 3vw, 2rem);
}

.mode-btn {
  width: 100%;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  border-radius: var(--radius-md);
  transition: transform 0.2s ease, filter 0.2s ease;
}

.mode-btn-inner {
  display: flex;
  align-items: center;
  gap: clamp(0.65rem, 2.5vw, 1rem);
  width: 100%;
  padding: clamp(0.75rem, 2.2vw, 1rem) clamp(0.85rem, 2.5vw, 1.15rem);
  background: linear-gradient(145deg, rgba(215, 168, 110, 0.95), rgba(166, 123, 78, 0.95));
  border: 2px solid rgba(78, 52, 46, 0.85);
  border-radius: var(--radius-md);
  color: var(--cream);
  box-shadow: 0 5px 0 #4E342E, 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: all 0.2s ease;
}

.mode-btn:hover .mode-btn-inner {
  transform: translateY(-2px);
  background: linear-gradient(145deg, #E8BF8A, #C89B68);
  box-shadow: 0 7px 0 #4E342E, 0 12px 24px rgba(0, 0, 0, 0.32);
}

.mode-btn:active .mode-btn-inner {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #4E342E;
}

.mode-icon-wrap {
  flex-shrink: 0;
  width: clamp(2.5rem, 8vw, 3rem);
  height: clamp(2.5rem, 8vw, 3rem);
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.mode-icon-wrap.classic { background: rgba(255, 87, 34, 0.18); }
.mode-icon-wrap.zen { background: rgba(76, 175, 80, 0.18); }
.mode-icon-wrap.arcade { background: rgba(255, 193, 7, 0.2); }

.mode-text {
  flex: 1;
  min-width: 0;
  text-align: left;
}

.mode-arrow {
  flex-shrink: 0;
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0.55;
  font-weight: 900;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.mode-btn:hover .mode-arrow {
  opacity: 1;
  transform: translateX(3px);
}

.mode-icon {
  font-size: clamp(1.5rem, 5vw, 2rem);
  margin-bottom: 0.3rem;
}

.mode-name {
  display: block;
  font-size: clamp(1rem, 3.2vw, 1.25rem);
  font-weight: 900;
  line-height: 1.2;
}

.mode-desc {
  display: block;
  font-size: clamp(0.72rem, 2.2vw, 0.82rem);
  opacity: 0.82;
  margin-top: 0.15rem;
  line-height: 1.35;
}

.settings-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.menu-credits {
  margin-top: 1rem;
  color: rgba(255, 248, 225, 0.45);
  font-size: clamp(0.65rem, 2vw, 0.75rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.btn-icon {
  font-size: 1.1em;
}

.primary-btn, .secondary-btn {
  padding: clamp(0.72rem, 2.2vw, 0.88rem) clamp(1.15rem, 3.5vw, 2rem);
  font-size: clamp(0.92rem, 2.6vw, 1.05rem);
  font-weight: 800;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  margin: 0.35rem;
}

.primary-btn {
  background: linear-gradient(145deg, var(--gold), var(--gold-dark));
  color: var(--wood-deep);
  box-shadow: 0 4px 0 #b8860b, 0 6px 16px rgba(0, 0, 0, 0.28);
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 #b8860b, 0 10px 22px rgba(0, 0, 0, 0.34);
}

.primary-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 #b8860b;
}

.secondary-btn {
  background: linear-gradient(145deg, #FFCC80, #FFB74D);
  color: #5D4037;
  border: 2px solid #FF8F00;
  box-shadow: 0 4px 0 #E65100;
}

.secondary-btn:hover {
  background: linear-gradient(145deg, #FFE0B2, #FFCC80);
  transform: translateY(-1px);
}

.secondary-btn.ghost {
  background: rgba(255, 236, 179, 0.12);
  color: var(--cream);
  border-color: rgba(255, 193, 7, 0.35);
  box-shadow: none;
}

.secondary-btn.ghost:hover {
  background: rgba(255, 236, 179, 0.22);
}

/* Settings */
.panel-content {
  padding: clamp(1.25rem, 4vw, 2rem);
  width: var(--panel-max-w);
  max-width: 100%;
  animation: fadeInUp 0.4s ease;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.setting-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
  color: var(--cream);
}

.setting-row label {
  font-weight: 700;
  font-size: clamp(0.82rem, 2.4vw, 0.95rem);
  opacity: 0.92;
}

.setting-control {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.setting-value {
  min-width: 2.75rem;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.setting-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--gold);
  height: 6px;
}

.setting-row select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 243, 224, 0.95);
  color: #5D4037;
  border: 1px solid #FF8F00;
  font-family: inherit;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  cursor: pointer;
  color: var(--cream);
  padding: 0.15rem 0;
}

.toggle-row input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-label {
  font-weight: 700;
  font-size: clamp(0.82rem, 2.4vw, 0.95rem);
}

.toggle-track {
  position: relative;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.2s ease;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #FFF3E0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle-row input:checked + .toggle-track {
  background: linear-gradient(145deg, var(--gold), var(--gold-dark));
}

.toggle-row input:checked + .toggle-track::after {
  transform: translateX(20px);
  background: #fff;
}

#back-from-settings {
  margin-top: 0.25rem;
}

/* HUD */
#game-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
  padding:
    calc(var(--safe-top) + 0.35rem)
    calc(var(--safe-right) + 0.35rem)
    0
    calc(var(--safe-left) + 0.35rem);
}

#game-hud:not(.hidden) {
  display: block;
}

.hud-bar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: clamp(0.35rem, 1.5vw, 0.65rem);
}

.hud-pill {
  pointer-events: auto;
  background: linear-gradient(180deg, rgba(62, 39, 35, 0.78), rgba(30, 18, 8, 0.72));
  border: 1px solid rgba(255, 215, 0, 0.22);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.4rem 0.65rem;
}

.hud-lives-wrap {
  justify-self: start;
}

.hud-score-wrap {
  justify-self: center;
  text-align: center;
  min-width: clamp(5.5rem, 22vw, 8rem);
  padding: 0.35rem 0.85rem 0.45rem;
}

.hud-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.45rem 0.35rem 0.55rem;
}

.hud-mini-label {
  display: block;
  font-size: clamp(0.55rem, 1.8vw, 0.65rem);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 236, 179, 0.72);
  margin-bottom: 0.12rem;
}

.lives {
  display: flex;
  gap: 0.15rem;
  flex-wrap: wrap;
}

.life-icon {
  font-size: clamp(1.1rem, 3.8vw, 1.55rem);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.45));
  transition: transform 0.25s ease, opacity 0.25s ease, filter 0.25s ease;
}

.life-icon.lost {
  opacity: 0.22;
  transform: scale(0.65);
  filter: grayscale(1);
}

.score {
  font-family: 'Bangers', cursive;
  font-size: clamp(2rem, 7vw, 3.2rem);
  color: var(--gold);
  text-shadow:
    2px 2px 0 #E65100,
    0 0 18px var(--gold-glow);
  text-align: center;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

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

@keyframes scorePop {
  0% { transform: scale(1); }
  45% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.combo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.1rem;
  animation: comboPulse 0.3s ease;
}

.combo-text {
  font-weight: 900;
  color: #fff;
  font-size: clamp(0.62rem, 2vw, 0.78rem);
  letter-spacing: 0.08em;
  text-shadow: 1px 1px 3px #000;
}

#combo-count {
  font-family: 'Bangers', cursive;
  font-size: clamp(1.1rem, 3.5vw, 1.65rem);
  color: #ff6b6b;
  text-shadow: 2px 2px 0 #000;
  line-height: 1;
}

.timer {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-family: 'Bangers', cursive;
  color: #FFB74D;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
  padding: 0 0.15rem;
}

.timer-icon {
  font-size: 0.95em;
  opacity: 0.85;
}

.timer-value {
  font-size: clamp(1.25rem, 4vw, 1.85rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer.warning .timer-value {
  color: var(--red);
  animation: timerBlink 0.5s ease infinite;
}

.icon-btn {
  width: clamp(36px, 9vw, 42px);
  height: clamp(36px, 9vw, 42px);
  border-radius: 10px;
  border: 1px solid rgba(255, 143, 0, 0.55);
  background: linear-gradient(180deg, rgba(255, 236, 179, 0.95), rgba(255, 204, 128, 0.9));
  color: #E65100;
  font-size: clamp(0.95rem, 2.8vw, 1.1rem);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 3px 0 #BF360C;
}

.icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 0 #BF360C, 0 6px 12px rgba(0, 0, 0, 0.2);
}

.icon-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 #BF360C;
}

.mode-badge {
  display: inline-flex;
  margin: 0.35rem auto 0;
  padding: 0.22rem 0.75rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 215, 0, 0.2);
  color: rgba(255, 248, 225, 0.9);
  font-size: clamp(0.62rem, 2vw, 0.75rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-align: center;
  width: fit-content;
  left: 50%;
  position: relative;
  transform: translateX(-50%);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

@keyframes comboPulse {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

@keyframes timerBlink {
  50% { opacity: 0.45; }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 18, 8, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding:
    calc(var(--safe-top) + var(--ui-pad))
    calc(var(--safe-right) + var(--ui-pad))
    calc(var(--safe-bottom) + var(--ui-pad))
    calc(var(--safe-left) + var(--ui-pad));
}

.overlay-content {
  padding: clamp(1.15rem, 3.5vw, 2rem) clamp(1.15rem, 4vw, 2rem);
  text-align: center;
  animation: fadeInUp 0.4s ease;
  width: var(--panel-max-w);
  max-width: 100%;
}

.overlay-content h2 {
  color: var(--cream);
  font-size: clamp(1.55rem, 5vw, 2.35rem);
  margin-bottom: 0.5rem;
  font-family: 'Bangers', cursive;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  line-height: 1.1;
}

.game-over-badge {
  font-size: clamp(2rem, 7vw, 2.75rem);
  margin-bottom: 0.15rem;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
  animation: bounce 2s ease infinite;
}

.final-score {
  margin: 1rem 0 0.85rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.16);
  border: 1px solid rgba(255, 215, 0, 0.15);
}

.final-score .label {
  display: block;
  color: rgba(255, 236, 179, 0.8);
  font-size: clamp(0.72rem, 2.2vw, 0.85rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

.final-score .value {
  font-family: 'Bangers', cursive;
  font-size: clamp(2.25rem, 9vw, 3.6rem);
  color: var(--gold);
  text-shadow: 0 0 24px var(--gold-glow);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.85rem 0 1rem;
  padding: 0.75rem 0.85rem;
  background: rgba(0, 0, 0, 0.14);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: clamp(0.82rem, 2.4vw, 0.92rem);
}

.stat-label {
  color: rgba(255, 248, 225, 0.85);
  font-weight: 700;
  text-align: left;
}

.stat-value {
  color: var(--gold);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 224, 178, 0.22) 0%, transparent 55%),
    linear-gradient(165deg, #3E2723 0%, #5D4037 38%, #4E342E 100%);
  overflow: hidden;
  padding:
    calc(var(--safe-top) + var(--ui-pad))
    calc(var(--safe-right) + var(--ui-pad))
    calc(var(--safe-bottom) + var(--ui-pad))
    calc(var(--safe-left) + var(--ui-pad));
  transition: opacity 0.45s ease, visibility 0.45s ease;
}

.loading-screen.loading-exit {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-bg-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 80%, rgba(255, 193, 7, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 80% 20%, rgba(255, 87, 34, 0.1) 0%, transparent 38%);
}

.loading-fruits {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.loading-fruit {
  position: absolute;
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  opacity: 0.35;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  animation: loadingFloat 3.5s ease-in-out infinite;
}

.loading-fruit.f1 { top: 12%; left: 8%; animation-delay: 0s; }
.loading-fruit.f2 { top: 18%; right: 10%; animation-delay: 0.6s; }
.loading-fruit.f3 { bottom: 16%; left: 12%; animation-delay: 1.1s; }
.loading-fruit.f4 { bottom: 20%; right: 14%; animation-delay: 0.3s; }
.loading-fruit.f5 { top: 42%; right: 6%; animation-delay: 1.8s; font-size: clamp(1.3rem, 4vw, 2rem); }

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

.loading-card {
  position: relative;
  width: min(92vw, 440px);
  text-align: center;
  padding: clamp(1.25rem, 4vw, 2rem) clamp(1rem, 4vw, 1.75rem);
}

.loading-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(0.4rem, 2vw, 0.75rem);
  margin-bottom: 0.35rem;
}

.loading-logo-fruit {
  font-size: clamp(1.6rem, 5vw, 2.2rem);
  animation: loadingBounce 1.2s ease-in-out infinite;
}

.loading-logo-fruit:last-child {
  animation-delay: 0.2s;
}

@keyframes loadingBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-6px) scale(1.08); }
}

.loading-title {
  font-family: 'Bangers', cursive;
  font-size: clamp(2rem, 8vw, 3rem);
  color: var(--gold);
  letter-spacing: 2px;
  text-shadow: 2px 3px 0 #8B4513, 0 0 20px rgba(255, 215, 0, 0.35);
  line-height: 1.1;
}

.loading-tagline {
  font-size: clamp(0.85rem, 2.8vw, 1rem);
  color: rgba(255, 248, 225, 0.85);
  margin-bottom: clamp(1rem, 3vw, 1.35rem);
  font-weight: 700;
}

.loading-screen.enter-ready .loading-tagline {
  color: var(--gold);
  animation: enterPulse 1.4s ease-in-out infinite;
}

@keyframes enterPulse {
  0%, 100% { opacity: 0.75; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

.loading-bar-wrap {
  width: 100%;
}

.loading-bar-track {
  width: 100%;
  height: clamp(10px, 2.5vw, 14px);
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 0, 0.25);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

.loading-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #FFA500, #FFD700, #FFECB3);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.55);
  transition: width 0.35s ease;
  position: relative;
}

.loading-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  animation: loadingShine 1.4s ease-in-out infinite;
}

@keyframes loadingShine {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.loading-bar-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.55rem;
  font-size: clamp(0.75rem, 2.4vw, 0.9rem);
}

.loading-status {
  color: rgba(255, 248, 225, 0.8);
  text-align: left;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.loading-percent {
  color: var(--gold);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 2.5rem;
  text-align: right;
}

.loading-slash {
  position: absolute;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 3px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  border-radius: 2px;
  opacity: 0;
  transform: rotate(-18deg) scaleX(0);
  animation: loadingSlash 2.2s ease-in-out infinite;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.6);
}

@keyframes loadingSlash {
  0%, 100% { opacity: 0; transform: rotate(-18deg) scaleX(0); }
  35% { opacity: 0.9; transform: rotate(-18deg) scaleX(1); }
  55% { opacity: 0; transform: rotate(-18deg) scaleX(1.1); }
}

@media (max-width: 520px) and (orientation: portrait) {
  .loading-card {
    width: min(94vw, 360px);
    padding: 1.1rem 1rem;
  }

  .loading-fruit {
    opacity: 0.25;
  }
}

@media (max-height: 420px) and (orientation: landscape) {
  .loading-card {
    width: min(70vw, 400px);
    padding: 0.85rem 1.25rem;
  }

  .loading-title {
    font-size: clamp(1.6rem, 6vw, 2.2rem);
  }

  .loading-tagline {
    margin-bottom: 0.65rem;
  }

  .loading-fruits .f5 {
    display: none;
  }
}

/* Screen shake */
.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-8px, 4px); }
  40% { transform: translate(8px, -4px); }
  60% { transform: translate(-6px, -2px); }
  80% { transform: translate(6px, 2px); }
}

/* Flash effect for bomb */
.flash {
  animation: flash 0.3s ease;
}

@keyframes flash {
  0% { filter: brightness(3); }
  100% { filter: brightness(1); }
}

@media (max-width: 480px) {
  .game-title {
    letter-spacing: 2px;
    line-height: 1.05;
  }

  .primary-btn, .secondary-btn {
    width: min(100%, 280px);
    margin: 0.35rem auto;
    display: block;
  }
}

@media (max-width: 768px) {
  .menu-credits {
    margin-top: 0.75rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .screen {
    align-items: flex-start;
  }

  .menu-content {
    padding-top: 0.25rem;
  }

  .game-title {
    font-size: clamp(2rem, 8vh, 3rem);
    margin-bottom: 0;
  }

  .subtitle {
    margin-bottom: 0.75rem;
    letter-spacing: 2px;
  }

  .mode-buttons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
    width: min(96vw, 720px);
  }

  .mode-btn {
    padding: 0;
  }

  .mode-btn-inner {
    flex-direction: column;
    text-align: center;
    padding: 0.55rem 0.4rem;
    gap: 0.35rem;
  }

  .mode-text {
    text-align: center;
  }

  .mode-arrow {
    display: none;
  }

  .mode-icon {
    font-size: 1.25rem;
    margin-bottom: 0.15rem;
  }

  .mode-name {
    font-size: 0.9rem;
  }

  .mode-desc {
    display: none;
  }

  .hud-bar {
    padding: 0;
    gap: 0.25rem;
  }

  .hud-mini-label {
    display: none;
  }

  .mode-label,
  .mode-badge {
    margin-top: 0.15rem;
  }

  .overlay-content {
    padding: 1rem 1.25rem;
  }

  .final-score {
    margin: 0.75rem 0;
  }

  .stats {
    margin: 0.75rem 0;
  }
}

@media (min-width: 900px) {
  .mode-buttons {
    max-width: 420px;
  }

  .menu-content {
    width: min(100%, 560px);
  }
}

/* Mobile landscape required */
#rotate-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(30, 18, 8, 0.94);
  backdrop-filter: blur(8px);
  padding:
    calc(var(--safe-top) + var(--ui-pad))
    calc(var(--safe-right) + var(--ui-pad))
    calc(var(--safe-bottom) + var(--ui-pad))
    calc(var(--safe-left) + var(--ui-pad));
}

#rotate-overlay.visible {
  display: flex;
}

.rotate-content {
  text-align: center;
  color: #FFF8E1;
  max-width: 320px;
  padding: 1.5rem 1.25rem;
}

.rotate-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  display: inline-block;
  animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(-90deg); }
  60% { transform: rotate(-90deg); }
}

.rotate-content h2 {
  font-family: 'Bangers', cursive;
  font-size: clamp(1.8rem, 6vw, 2.4rem);
  color: var(--gold);
  margin-bottom: 0.75rem;
  letter-spacing: 1px;
}

.rotate-content p {
  font-size: clamp(0.95rem, 3vw, 1.1rem);
  line-height: 1.5;
  opacity: 0.92;
}