/**
 * Fruit Ninja 3D - Dojo Aesthetics, Responsive UI & Visual Effects
 */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,400;0,700;0,900;1,900&family=Noto+Sans+JP:wght@700;900&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #1a0f0a;
  font-family: 'Montserrat', 'Noto Sans JP', sans-serif;
  color: #fff;
}

/* ==========================================
   DOJO BACKGROUND WALL THEMES
   ========================================== */

body.dojo-wood {
  background: radial-gradient(circle at center, #4a2818 0%, #2b140b 60%, #150905 100%),
              repeating-linear-gradient(0deg, rgba(0,0,0,0.15), rgba(0,0,0,0.15) 2px, transparent 2px, transparent 40px);
  background-blend-mode: multiply;
}

body.dojo-zen {
  background: radial-gradient(circle at 50% 30%, #1b3a27 0%, #0d1e14 60%, #050a07 100%),
              repeating-linear-gradient(90deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 4px, transparent 4px, transparent 80px);
}

body.dojo-fuji {
  background: radial-gradient(circle at 50% 40%, #4a223e 0%, #250f20 60%, #10060e 100%);
}

body.dojo-cyber {
  background: radial-gradient(circle at center, #131b38 0%, #0b0e1d 60%, #05070d 100%),
              linear-gradient(rgba(0, 229, 255, 0.05) 1px, transparent 1px),
              linear-gradient(90deg, rgba(0, 229, 255, 0.05) 1px, transparent 1px);
  background-size: 100% 100%, 40px 40px, 40px 40px;
}

/* Screen vignette framing */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  cursor: crosshair;
}

#game-container::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  box-shadow: inset 0 0 100px rgba(0,0,0,0.85);
  pointer-events: none;
  z-index: 5;
}

/* ==========================================
   CANVAS LAYERING
   ========================================== */

#splatter-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 1;
  pointer-events: none;
}

#webgl-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2;
  outline: none;
}

#blade-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 3;
  pointer-events: auto;
}

/* Flash and Power-up Vignettes */
#screen-flash {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 8;
  pointer-events: none;
  transition: opacity 0.3s ease-out;
}

.powerup-vignette {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 6;
  pointer-events: none;
}

#vignette-freeze {
  box-shadow: inset 0 0 80px #00e5ff, inset 0 0 160px rgba(0, 229, 255, 0.4);
  animation: pulseVignette 1.5s infinite alternate ease-in-out;
}

#vignette-frenzy {
  box-shadow: inset 0 0 80px #ff3d00, inset 0 0 160px rgba(255, 61, 0, 0.4);
  animation: pulseVignette 0.8s infinite alternate ease-in-out;
}

#vignette-double {
  box-shadow: inset 0 0 80px #7c4dff, inset 0 0 160px rgba(124, 77, 255, 0.4);
  animation: pulseVignette 1.2s infinite alternate ease-in-out;
}

@keyframes pulseVignette {
  0% { opacity: 0.6; }
  100% { opacity: 1.0; }
}

/* ==========================================
   GAME HUD
   ========================================== */

#game-hud {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 10;
  pointer-events: none;
}

.hud-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 24px 36px;
}

.hud-score-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.score-icon {
  font-size: 2.2rem;
  filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.6));
}

#hud-score {
  font-size: 3.5rem;
  font-weight: 900;
  color: #ffeb3b;
  text-shadow: 0 4px 12px rgba(0,0,0,0.8), 0 0 20px rgba(255, 215, 0, 0.5);
  letter-spacing: 1px;
}

#hud-timer-container {
  background: rgba(0, 0, 0, 0.55);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  padding: 8px 24px;
  backdrop-filter: blur(8px);
}

#hud-timer {
  font-size: 2.4rem;
  font-weight: 900;
  color: #00e5ff;
  text-shadow: 0 0 14px #00e5ff;
  letter-spacing: 2px;
}

/* 3 Strikes Indicators */
#hud-strikes {
  display: flex;
  gap: 12px;
}

.strike-x {
  font-size: 2.4rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.2);
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.strike-x.active {
  color: #ff1744;
  text-shadow: 0 0 20px #ff1744, 0 0 40px #d50000;
  transform: scale(1.3) rotate(8deg);
}

/* Floating Combo & Score Text */
.floating-score-text {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  font-weight: 900;
  font-style: italic;
  pointer-events: none;
  z-index: 20;
  animation: floatFade 1.1s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes floatFade {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.25);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -120%) scale(1.0);
  }
}

/* ==========================================
   MAIN MENU OVERLAY
   ========================================== */

#menu-screen {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px 40px;
}

.menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.menu-title-block {
  display: flex;
  flex-direction: column;
}

.game-title {
  font-size: 3.2rem;
  font-weight: 900;
  font-style: italic;
  background: linear-gradient(180deg, #fff 0%, #ffeb3b 50%, #f57f17 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.8));
  letter-spacing: 2px;
}

.game-subtitle {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 6px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
}

.menu-top-actions {
  display: flex;
  gap: 16px;
  pointer-events: auto;
}

.starfruit-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 215, 0, 0.4);
  border-radius: 20px;
  padding: 8px 18px;
  font-weight: 900;
  color: #ffd700;
  font-size: 1.1rem;
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.icon-btn {
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 46px;
  height: 46px;
  font-size: 1.3rem;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(6px);
}

.icon-btn:hover {
  border-color: #ffeb3b;
  transform: scale(1.08);
  box-shadow: 0 0 15px rgba(255, 235, 59, 0.4);
}

/* Interactive Menu Floating Labels */
#menu-labels-container {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}

.menu-slice-label {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  white-space: nowrap;
}

.slice-action-hint {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: #ffeb3b;
  animation: pulseHint 1.2s infinite alternate;
  text-shadow: 0 0 8px rgba(255, 235, 59, 0.8);
}

.slice-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 1px;
  color: #ffffff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.9), 0 0 15px rgba(255,255,255,0.4);
}

@keyframes pulseHint {
  0% { opacity: 0.5; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1.05); }
}

.menu-bottom-hint {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
}

/* ==========================================
   MODALS (SHOP, LEADERBOARD, SETTINGS, GAMEOVER)
   ========================================== */

.modal-backdrop {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.25s ease;
}

.modal-backdrop.hidden, .hidden {
  display: none !important;
}

.modal-window {
  background: #1e130c;
  border: 3px solid #8d6e63;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9), inset 0 0 20px rgba(0, 0, 0, 0.6);
  border-radius: 18px;
  width: 90%;
  max-width: 780px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.25);
}

.modal-header h2 {
  font-size: 1.8rem;
  font-weight: 900;
  color: #ffeb3b;
  letter-spacing: 2px;
}

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

.tab-btn {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: #bbb;
  font-weight: 700;
  padding: 6px 18px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active, .tab-btn:hover {
  border-color: #ffd700;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #aaa;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close-btn:hover { color: #fff; }

/* Shop Items Grid */
.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 20px;
}

.shop-card {
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
}

.shop-card:hover {
  border-color: rgba(255, 215, 0, 0.5);
  transform: translateY(-2px);
}

.shop-card.equipped {
  border-color: #4caf50;
  box-shadow: 0 0 15px rgba(76, 175, 80, 0.3);
}

.shop-card-preview {
  height: 90px;
  border-radius: 10px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  overflow: hidden;
}

.blade-slash-preview {
  width: 70%;
  height: 6px;
  border-radius: 3px;
  transform: rotate(-25deg);
}

.blade-particle-badge {
  position: absolute;
  bottom: 6px; right: 8px;
  font-size: 0.65rem;
  font-weight: 900;
  background: rgba(0,0,0,0.6);
  padding: 2px 6px;
  border-radius: 4px;
  color: #ddd;
}

.shop-card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
}

.shop-card-desc {
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.3;
  margin-bottom: 14px;
}

.btn-shop-action {
  width: 100%;
  padding: 8px 0;
  border-radius: 8px;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.btn-shop-action.equipped-btn {
  background: #2e7d32;
  color: #fff;
  cursor: default;
}

.btn-shop-action.equip-btn {
  background: #0288d1;
  color: #fff;
}
.btn-shop-action.equip-btn:hover { background: #039be5; }

.btn-shop-action.buy-btn {
  background: #ffb300;
  color: #000;
}
.btn-shop-action.buy-btn:hover { background: #ffc107; }
.btn-shop-action.buy-btn.disabled {
  background: #555;
  color: #888;
  cursor: not-allowed;
}

/* Leaderboard List */
.leaderboard-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  border-left: 4px solid #555;
  font-size: 1.05rem;
  font-weight: 700;
}

.leaderboard-row.gold { border-left-color: #ffd700; color: #ffd700; }
.leaderboard-row.silver { border-left-color: #e0e0e0; color: #e0e0e0; }
.leaderboard-row.bronze { border-left-color: #cd7f32; color: #cd7f32; }

.lb-rank { width: 40px; }
.lb-name { flex: 1; margin-left: 10px; }
.lb-score { font-size: 1.3rem; font-weight: 900; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 20px;
}

.stat-card {
  background: rgba(0, 0, 0, 0.3);
  padding: 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card span { font-size: 0.85rem; color: #aaa; }
.stat-card strong { font-size: 1.3rem; color: #ffeb3b; }

/* Game Over Modal Window */
.gameover-window {
  text-align: center;
  padding: 40px 30px;
  max-width: 520px;
}

.gameover-title {
  font-size: 2.8rem;
  font-weight: 900;
  font-style: italic;
  color: #ff1744;
  text-shadow: 0 0 20px rgba(255, 23, 68, 0.6);
  margin-bottom: 6px;
}

.gameover-reason {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffb74d;
  letter-spacing: 2px;
  margin-bottom: 24px;
}

.gameover-score-circle {
  width: 140px;
  height: 140px;
  margin: 0 auto 24px auto;
  border-radius: 50%;
  border: 4px solid #ffd700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
  background: radial-gradient(circle, rgba(255,215,0,0.15) 0%, rgba(0,0,0,0.4) 100%);
}

.gameover-score-circle span { font-size: 0.8rem; font-weight: 700; color: #aaa; }
.gameover-score-circle strong { font-size: 2.8rem; font-weight: 900; color: #fff; }

.save-score-form {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  justify-content: center;
}

.save-score-form input {
  padding: 10px 16px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 1rem;
  font-family: inherit;
  width: 180px;
  text-align: center;
}

.save-score-form button {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: #ffd700;
  color: #000;
  font-weight: 900;
  cursor: pointer;
}

.gameover-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.btn-primary {
  padding: 12px 28px;
  border-radius: 24px;
  font-size: 1.1rem;
  font-weight: 900;
  background: linear-gradient(135deg, #ff9800 0%, #e65100 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(230, 81, 0, 0.5);
  transition: all 0.15s ease;
}

.btn-primary:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(230, 81, 0, 0.7);
}

.btn-secondary {
  padding: 12px 28px;
  border-radius: 24px;
  font-size: 1.1rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  cursor: pointer;
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.25); }

/* Settings Form */
.settings-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-group label {
  font-size: 0.95rem;
  font-weight: 700;
  color: #ffeb3b;
}

.settings-group input, .settings-group select {
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 0.95rem;
}

.settings-group small {
  font-size: 0.8rem;
  color: #aaa;
}

@media (max-width: 768px) {
  .game-title { font-size: 2.2rem; }
  .hud-top-bar { padding: 16px 20px; }
  #hud-score { font-size: 2.6rem; }
  .shop-grid { grid-template-columns: 1fr; }
}

/* Dojo Previews in Shop */
.dojo-wood-preview {
  background: radial-gradient(circle at center, #4a2818 0%, #150905 100%),
              repeating-linear-gradient(0deg, rgba(0,0,0,0.2) 0px, rgba(0,0,0,0.2) 2px, transparent 2px, transparent 15px);
}
.dojo-zen-preview {
  background: radial-gradient(circle at center, #1b3a27 0%, #050a07 100%),
              repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0px, rgba(255,255,255,0.03) 3px, transparent 3px, transparent 25px);
}
.dojo-fuji-preview {
  background: radial-gradient(circle at center, #4a223e 0%, #10060e 100%);
}
.dojo-cyber-preview {
  background: radial-gradient(circle at center, #131b38 0%, #05070d 100%),
              linear-gradient(rgba(0, 229, 255, 0.1) 1px, transparent 1px),
              linear-gradient(90deg, rgba(0, 229, 255, 0.1) 1px, transparent 1px);
  background-size: 100% 100%, 15px 15px, 15px 15px;
}
