:root {
  --app-bg-overlay: rgba(22, 15, 45, 0.4); /* Slight tint over the 3D world */
  --panel-bg: rgba(35, 30, 70, 0.90); /* Deep Purple Glass */
  --panel-border: rgba(255, 255, 255, 0.15);
  
  --primary-gradient: linear-gradient(135deg, #FFD700 0%, #FF8C00 100%); /* Gold to Orange */
  --primary-shadow: 0 6px 0 #cc6600;
  
  --text-white: #ffffff;
  --text-dim: #b0b0d0;
  
  --accent-blue: #4facfe;
  --accent-purple: #8e44ad;
}

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

body {
  overflow: hidden;
  /* Retain the scenic background but overlay UI on top */
  background: url('https://static.wefun.ai/assets/30f3c670-875a-42d0-8e6f-2289b9ce4dfa.png') no-repeat center center fixed;
  background-size: cover;
  font-family: 'Nunito', sans-serif;
  color: var(--text-white);
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 0%, rgba(0,0,0,0.3) 100%);
}

/* --- HUD Top Bar --- */
#top-bar {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: auto;
}

#score-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Score Pill */
#score-pill {
  background: rgba(20, 15, 40, 0.8);
  backdrop-filter: blur(10px);
  padding: 8px 24px;
  border-radius: 50px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  width: fit-content;
}

.score-icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 0 5px gold);
}

#score-display {
  font-size: 1.8rem;
  font-weight: 900;
  background: linear-gradient(to bottom, #fff, #eee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  min-width: 60px;
  text-align: right;
}

/* High Score Pill (HUD) */
#high-score-pill {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  padding: 4px 16px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-left: 10px; /* Indent slightly under the main score */
}

#high-score-pill .label {
  font-size: 0.7rem;
  color: #aaa;
  font-weight: 800;
  letter-spacing: 1px;
}

#hud-high-score {
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffd700;
}


/* Mute Button - Round Glass Style */
#mute-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 1.2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    padding: 0; /* Override default */
}

#mute-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

#mute-btn:active {
    transform: scale(0.95);
}

/* --- Panels (Start / Game Over) --- */
.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 380px;
  perspective: 1000px;
  display: none;
  pointer-events: auto;
}

.panel.active {
  display: block;
  animation: floatIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.panel-content {
  background: var(--panel-bg);
  backdrop-filter: blur(20px);
  padding: 40px 30px;
  border-radius: 40px;
  border: 1px solid var(--panel-border);
  box-shadow: 
    0 20px 50px rgba(0,0,0,0.5),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* Avatar Circle */
.avatar-container {
  margin-bottom: -10px;
}
.glow-circle {
  width: 100px;
  height: 100px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(79, 172, 254, 0.2);
  border: 2px solid rgba(255,255,255,0.1);
  animation: pulseGlow 3s infinite ease-in-out;
}

h1 {
  font-size: 2.2rem;
  font-weight: 900;
  margin: 0;
  background: linear-gradient(180deg, #ffffff 0%, #d4d4ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
  text-transform: uppercase;
  letter-spacing: 1px;
}

p {
  color: var(--text-dim);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
}

.start-high-score-box {
  background: rgba(255,255,255,0.1);
  padding: 5px 15px;
  border-radius: 15px;
  font-size: 0.9rem;
  color: #ffd700;
  font-weight: 700;
}

/* Controls Card */
.controls-card {
  display: flex;
  gap: 12px;
  justify-content: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 20px;
  width: 100%;
}

.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.control-item .key {
  font-size: 1.5rem;
  background: rgba(255,255,255,0.1);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-item .label {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  font-weight: 800;
}

/* Big Action Button */
.action-btn {
  background: var(--primary-gradient);
  color: #5a3a00; /* Dark brown text for contrast on yellow/orange */
  border: none;
  padding: 18px 50px;
  font-size: 1.4rem;
  font-weight: 900;
  border-radius: 50px;
  cursor: pointer;
  width: 100%;
  margin-top: 10px;
  box-shadow: 
    0 8px 20px rgba(255, 140, 0, 0.3),
    inset 0 2px 0 rgba(255,255,255,0.4),
    var(--primary-shadow);
  transform: translateY(0);
  transition: all 0.1s;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.action-btn:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  box-shadow: 
    0 12px 25px rgba(255, 140, 0, 0.4),
    inset 0 2px 0 rgba(255,255,255,0.4),
    0 8px 0 #cc6600;
}

.action-btn:active {
  transform: translateY(4px);
  box-shadow: 
    0 2px 5px rgba(0,0,0,0.2),
    inset 0 2px 0 rgba(255,255,255,0.2),
    0 2px 0 #cc6600;
}

/* Score Result in Game Over */
.score-result {
  background: rgba(255,255,255,0.05);
  border-radius: 20px;
  padding: 15px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 5px;
  border: 1px solid rgba(255,255,255,0.1);
}

.result-label {
  font-size: 0.8rem;
  color: #aaa;
  font-weight: 800;
  letter-spacing: 2px;
}

#final-score {
  font-size: 3rem;
  font-weight: 900;
  color: #ffcc00;
  text-shadow: 0 0 20px rgba(255, 204, 0, 0.4);
}

.high-score-row {
  font-size: 0.9rem;
  color: #bbb;
  margin-bottom: 10px;
}
.high-score-row span {
  color: #fff;
  font-weight: bold;
}

/* --- Victory Overlay (Full Screen) --- */
#victory-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  background: url('https://static.wefun.ai/assets/1062b7ae-5735-4135-8a7f-3fee36429083.png') no-repeat center center;
  background-size: cover;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end; /* Push content slightly down/to specific area */
  padding-bottom: 10%; /* Adjust based on where you want text over the image */
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.5s ease-in-out;
}

#victory-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.victory-content {
  background: rgba(0, 0, 0, 0.6); /* Dark semi-transparent box for text legibility */
  backdrop-filter: blur(8px);
  padding: 40px;
  border-radius: 30px;
  text-align: center;
  max-width: 450px;
  width: 90%;
  border: 1px solid rgba(255,255,255,0.2);
  transform: translateY(20px);
  animation: slideUpFade 1s 0.5s forwards; /* Delay to let bg fade in first */
  opacity: 0; /* Start hidden for animation */
}

@keyframes slideUpFade {
  to { transform: translateY(0); opacity: 1; }
}

.victory-title {
  font-size: 3rem;
  margin-bottom: 10px;
  background: linear-gradient(to right, #fff, #ffd700);
  -webkit-background-clip: text;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.victory-score-box {
  margin: 20px 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.victory-label {
  font-size: 0.9rem;
  letter-spacing: 3px;
  color: #ccc;
  text-transform: uppercase;
}

#victory-score-display {
  font-size: 3.5rem;
  font-weight: 900;
  color: #ffcc00;
  text-shadow: 0 4px 0 #b35900;
}

.victory-high-score-row {
  color: #ccc;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.victory-msg {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 30px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Floating Text */
#floating-text-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.floating-score {
  position: absolute;
  color: #ffcc00;
  font-size: 2.5rem;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(0,0,0,0.5), 0 0 15px rgba(255, 204, 0, 0.6);
  animation: floatUp 0.8s ease-out forwards;
  pointer-events: none;
  font-family: 'Nunito', sans-serif;
  z-index: 21;
}

@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
  20% { opacity: 1; transform: translate(-50%, -30px) scale(1.2); }
  100% { transform: translate(-50%, -100px) scale(1); opacity: 0; }
}

@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
  to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes floatIn {
  0% { opacity: 0; transform: translate(-50%, -40%) scale(0.9); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px rgba(79, 172, 254, 0.2); }
  50% { box-shadow: 0 0 40px rgba(79, 172, 254, 0.5); }
}
