/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;700;900&display=swap');

/* Color Variables & Theming */
:root {
    --bg-color: #0f172a; /* Fallback */
    --text-color: #f8fafc;
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --boss-hp-bg: #475569;
    --boss-hp-fill: #ef4444;
}

/* Reset & Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #050b14;
    color: var(--text-color);
    margin: 0;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-image: url('assets/ghibli_bg.png');
    background-size: cover;
    background-position: center bottom;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: transparent; 
}

/* UI Layer - sits on top of canvas overlaying it perfectly */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to canvas by default */
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(8px);
    background: var(--glass-bg);
    pointer-events: auto; /* Catch clicks when screen is active */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 10;
}

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

/* Typography */
h1.game-title {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 0px;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

.subtitle {
    font-size: 1.5rem;
    color: #cbd5e1;
    margin-bottom: 3rem;
    letter-spacing: 5px;
    text-transform: uppercase;
}

h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.screen p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: #e2e8f0;
}

/* Inputs */
.name-input-container {
    margin-bottom: 2rem;
}

#player-name {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1.2rem;
    color: white;
    font-family: 'Outfit', sans-serif;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

#player-name:focus {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.15);
}

#player-name::placeholder {
    color: #94a3b8;
}

/* Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 250px;
}

.btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn.primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.5), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn.primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 10px -1px rgba(59, 130, 246, 0.6), inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn.secondary {
    background-color: rgba(255,255,255,0.1);
    color: white;
    border: 1px solid var(--glass-border);
}

.btn.secondary:hover {
    background-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

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

/* In-Game HUD */
.hud-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 25px;
    pointer-events: none; /* Let clicks pass through */
    transition: opacity 0.3s;
    z-index: 5;
}

.hud-container.hidden {
    opacity: 0;
    visibility: hidden;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.05);
}

.hud-item .label {
    font-weight: 700;
    color: #94a3b8;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.health-stars {
    font-size: 1.2rem;
    letter-spacing: 2px;
}

.level-indicator {
    font-weight: 900;
    font-size: 1.1rem;
    color: #f8fafc;
    letter-spacing: 1px;
}

#score-display {
    font-weight: 900;
    font-size: 1.2rem;
    color: #fbd38d; /* Gold-ish */
}

/* Boss HUD */
.boss-hud-container {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    z-index: 5;
    transition: opacity 0.5s ease;
}

.boss-hud-container.hidden {
    opacity: 0;
    visibility: hidden;
}

.boss-name {
    font-weight: 900;
    font-size: 1.2rem;
    color: #fca5a5;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.boss-hp-bar-bg {
    width: 100%;
    height: 12px;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    overflow: hidden;
}

.boss-hp-bar-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ef4444, #f97316);
    transition: width 0.1s ease-out;
}

/* Leaderboard Sidebar */
.leaderboard-container {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 250px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    z-index: 20; /* Keep it below screens if needed, or above. Make it 20 to always see or just 5 */
    pointer-events: auto;
}

.leaderboard-title {
    font-size: 1.2rem;
    color: #fbd38d;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 8px;
}

#leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#leaderboard-list li {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: #f8fafc;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

#leaderboard-list li .lb-name {
    font-weight: bold;
    color: #93c5fd;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#leaderboard-list li .lb-score {
    color: #fca5a5;
    font-weight: 900;
}

/* Instructions */
.instructions-list {
    list-style: none;
    text-align: left;
    margin-bottom: 2rem;
    padding: 0;
}

.instructions-list li {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

kbd {
    background-color: #334155;
    border: 1px solid #475569;
    border-radius: 6px;
    padding: 4px 10px;
    font-family: monospace;
    font-size: 1rem;
    color: #f8fafc;
    box-shadow: 0 2px 0 #1e293b;
}

/* Utility Animations */
@keyframes shake {
    0% { transform: translate(1px, 1px) rotate(0deg); }
    10% { transform: translate(-1px, -2px) rotate(-1deg); }
    20% { transform: translate(-3px, 0px) rotate(1deg); }
    30% { transform: translate(3px, 2px) rotate(0deg); }
    40% { transform: translate(1px, -1px) rotate(1deg); }
    50% { transform: translate(-1px, 2px) rotate(-1deg); }
    60% { transform: translate(-3px, 1px) rotate(0deg); }
    70% { transform: translate(3px, 1px) rotate(-1deg); }
    80% { transform: translate(-1px, -1px) rotate(1deg); }
    90% { transform: translate(1px, 2px) rotate(0deg); }
    100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.shake {
    animation: shake 0.3s;
}
