@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@300..700&display=swap');

:root {
  --bg-gradient: linear-gradient(135deg, #110e2e 0%, #1c1547 50%, #0d0a21 100%);
  --panel-bg: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.15);
  --text-color: #ffffff;
  --text-muted: #b5b3cd;
  --primary-color: #ff5e97;
  --primary-glow: rgba(255, 94, 151, 0.4);
  --secondary-color: #00f0ff;
  --secondary-glow: rgba(0, 240, 255, 0.4);
  --accent-color: #ffe600;
  --accent-glow: rgba(255, 230, 0, 0.4);
  --success-color: #39ff14;
  --danger-color: #ff3b30;
  --glass-blur: blur(12px);
  --font-family: 'Fredoka', sans-serif;
}

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

html, body {
  height: 100dvh;
  overflow: hidden; /* Prevent page scrolls completely */
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: center;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
  margin: 0;
  padding: 0;
}

#app-container {
  width: 1024px;
  height: 720px;
  background: rgba(13, 10, 33, 0.6);
  border: 2px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 240, 255, 0.1);
  backdrop-filter: var(--glass-blur);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 10;
  padding: 12px; /* Reduced margin space from 32px for larger mobile scale */
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 20;
}

/* Splash/Start Screen */
#start-screen {
  background: radial-gradient(circle at center, #2b1f63 0%, #0d0a21 100%);
  display: flex;
  flex-direction: column;
  justify-content: space-around;
}

.title-container {
  text-align: center;
  margin-bottom: 20px;
}

.title-container h1 {
  font-size: 5rem;
  font-weight: 700;
  background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px var(--primary-glow));
  letter-spacing: 2px;
  animation: floatTitle 4s ease-in-out infinite;
}

.title-container p {
  font-size: 1.5rem;
  color: var(--text-muted);
  margin-top: 10px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.menu-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 20px;
  width: 92%; /* Increased width from 80% to occupy more horizontal space */
  max-width: 600px;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.05);
}

.menu-card h3 {
  text-align: center;
  font-size: 1.4rem;
  margin-bottom: 16px;
  color: var(--accent-color);
  text-shadow: 0 0 10px var(--accent-glow);
}

.rhythmic-select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.btn {
  font-family: var(--font-family);
  background: linear-gradient(135deg, #ff5e62 0%, #ff9966 100%);
  color: white;
  border: none;
  padding: 14px 20px;
  font-size: 1.1rem;
  font-weight: 600;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 94, 98, 0.4);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 10px 25px rgba(255, 94, 98, 0.6);
}

.btn:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: linear-gradient(135deg, #00f0ff 0%, #7000ff 100%);
  box-shadow: 0 6px 20px rgba(0, 240, 255, 0.3);
}

.btn-secondary:hover {
  box-shadow: 0 10px 25px rgba(0, 240, 255, 0.5);
}

/* Play Screen Layout */
#play-screen {
  padding: 0;
  display: flex;
  flex-direction: row;
}


/* Main Playing Area */
#main-play-area {
  flex-grow: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

#canvas-container {
  flex-grow: 1;
  background: #110d29;
  position: relative;
  overflow: hidden;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Bottom Rhythmic Panel */
#rhythmic-panel {
  height: 200px;
  background: rgba(13, 10, 33, 0.95);
  border-top: 2px solid var(--panel-border);
  padding: 8px 16px 32px 16px;
  display: none; /* Hidden by default */
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  gap: 6px;
  z-index: 5;
}

#rhythmic-panel.active {
  display: flex; /* Visible during battles */
}

.rhythmic-task-text {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--secondary-color);
}

.rhythmic-sequence {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

.sequence-bubble {
  width: 45px;
  height: 45px;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid var(--panel-border);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.25rem;
  font-weight: bold;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.sequence-bubble.missing {
  border: 2px dashed var(--accent-color);
  background: rgba(255, 230, 0, 0.15);
  width: 50px;
  height: 50px;
  color: var(--accent-color);
  font-size: 1.5rem;
  animation: pulseTarget 1.5s infinite alternate;
}

.rhythmic-options {
  display: flex;
  gap: 12px;
}

.option-btn {
  font-family: var(--font-family);
  min-width: 50px;
  height: 45px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--panel-border);
  color: white;
  border-radius: 12px;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0 16px;
}

.option-btn:hover {
  background: var(--accent-color);
  color: #110e2e;
  border-color: var(--accent-color);
  transform: scale(1.1);
  box-shadow: 0 0 15px var(--accent-glow);
}

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

/* Custom Notification Overlay */
.toast-msg {
  position: absolute;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 12px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: var(--glass-blur);
  color: white;
  font-weight: bold;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(-50px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.toast-msg.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success {
  border-left: 5px solid var(--success-color);
  box-shadow: 0 5px 15px rgba(57, 255, 20, 0.2);
}

.toast-error {
  border-left: 5px solid var(--danger-color);
  box-shadow: 0 5px 15px rgba(255, 59, 48, 0.2);
}

/* Modals */
.modal-screen {
  background: rgba(13, 10, 33, 0.9);
  backdrop-filter: var(--glass-blur);
}

.modal-content {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid var(--panel-border);
  border-radius: 24px;
  padding: 40px;
  text-align: center;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 15px 30px rgba(0,0,0,0.4);
}

.modal-content h2 {
  font-size: 3rem;
  margin-bottom: 16px;
}

.modal-content p {
  color: var(--text-muted);
  font-size: 1.2rem;
  margin-bottom: 24px;
}

.score-display {
  font-size: 1.5rem;
  color: var(--accent-color);
  margin-bottom: 24px;
  font-weight: bold;
}

/* Game Info overlays inside main play area */
.hud-wave-alert {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  opacity: 0;
  font-size: 3.5rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--secondary-color);
  text-shadow: 0 0 20px var(--secondary-glow);
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 30;
}

.hud-wave-alert.show {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
}

/* Animation keyframes */
@keyframes floatTitle {
  0% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

@keyframes pulseTarget {
  0% { transform: scale(1); box-shadow: 0 0 5px var(--accent-glow); }
  100% { transform: scale(1.1); box-shadow: 0 0 15px var(--accent-glow); }
}

/* Saga World Map Selector Tabs */
.world-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: 30px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: bold;
  transition: all 0.3s ease;
}

.world-tab-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transform: translateY(-2px);
}

.world-tab-btn.active {
  background: var(--secondary-color);
  color: #0d0a21;
  border-color: var(--secondary-color);
  box-shadow: 0 0 15px var(--secondary-glow);
}

/* Saga Map Level Nodes */
.map-node {
  position: absolute;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(20, 15, 45, 0.9);
  border: 3px solid var(--panel-border);
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 5;
}

.map-node:hover {
  transform: scale(1.15);
  box-shadow: 0 0 15px var(--secondary-glow);
  border-color: var(--secondary-color);
}

.map-node.locked {
  background: rgba(30, 30, 40, 0.9);
  border-color: #555;
  color: #777;
  cursor: not-allowed;
  box-shadow: none;
}

.map-node.locked:hover {
  transform: none;
  box-shadow: none;
  border-color: #555;
}

.map-node.completed {
  background: var(--success-color);
  border-color: #fff;
  color: #0d0a21;
  box-shadow: 0 0 12px rgba(57,255,20,0.4);
}

.map-node.active-node {
  border-color: var(--accent-color);
  box-shadow: 0 0 20px var(--accent-glow);
  animation: pulseTarget 1.2s infinite alternate;
}

/* Map connecting path lines */
.map-path-line {
  position: absolute;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  transform-origin: 0 50%;
  z-index: 1;
}

.map-path-line.unlocked {
  background: linear-gradient(90deg, var(--secondary-color), var(--accent-color));
  box-shadow: 0 0 8px var(--secondary-glow);
}

/* Rescued Friends Cards Grid styling */
.friend-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  height: 120px;
  box-sizing: border-box;
}

.friend-card.locked {
  opacity: 0.3;
  filter: grayscale(100%);
}

.friend-card.unlocked {
  background: linear-gradient(135deg, rgba(255,94,151,0.05) 0%, rgba(0,240,255,0.05) 100%);
  border-color: var(--secondary-color);
}

.friend-card.unlocked:hover {
  transform: translateY(-3px);
  border-color: var(--accent-color);
  box-shadow: 0 5px 15px rgba(0,240,255,0.15);
}

.friend-card-emoji {
  font-size: 2.2rem;
  margin-bottom: 5px;
}

.friend-card-name {
  font-size: 0.85rem;
  font-weight: bold;
  color: #fff;
  margin-bottom: 2px;
}

.friend-card-title {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Mini custom tooltip description on hover */
.friend-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  background: rgba(10,5,20,0.95);
  border: 1.5px solid var(--accent-color);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.75rem;
  line-height: 1.3;
  z-index: 20;
  box-shadow: 0 4px 15px rgba(0,0,0,0.8);
  pointer-events: none;
  margin-bottom: 5px;
}

.friend-card.unlocked:hover .friend-tooltip {
  display: block;
}

/* Sliced Sprite Avatar Icon */
.friend-avatar-sprite {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 2px solid var(--secondary-color);
  box-shadow: 0 0 10px var(--secondary-glow);
  display: block;
  background-repeat: no-repeat;
}

/* Sliced Sprite Detail Avatar */
.friend-detail-sprite {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--accent-color);
  box-shadow: 0 0 20px var(--accent-glow);
  margin: 0 auto;
  background-repeat: no-repeat;
}

/* Corrupted Scenery Filter */
.corrupted-scenery {
  filter: hue-rotate(275deg) brightness(0.35) saturate(1.2) contrast(1.1);
}




