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

:root {
    --bg-color: #0d0d0f;
    --card-bg: rgba(30, 30, 35, 0.7);
    --accent-color: #7289da;
    --accent-glow: rgba(114, 137, 218, 0.4);
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0ab;
    --danger: #ff4757;
    --glass-border: rgba(255, 255, 255, 0.1);
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    font-family: 'Inter', sans-serif;
    color: var(--text-primary);
}

#game-container {
    position: relative;
    width: 450px;
    height: 800px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--glass-border);
    max-width: 100vw;
    max-height: 100vh;
}

#renderer-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    touch-action: none; /* Prevent iOS Safari scroll/zoom interference */
}

#uiCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let clicks pass through to 3D/logic */
    z-index: 5;
}

canvas {
    display: block;
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* HUD Styling */
/* HUD Styling */
#ui-gaming {
    display: flex !important;
    flex-direction: column !important;
    padding: 12px 20px;
    box-sizing: border-box;
    gap: 12px !important;
    pointer-events: none;
    align-items: center; /* Center the column children */
}

.hud-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.hud-top-left {
    display: flex;
    gap: 10px;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#hud-timer-container {
    position: relative;
    width: 150px;
    height: 8px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    overflow: hidden;
}

#hud-timer-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #4fb1f7);
    box-shadow: 0 0 15px var(--accent-glow);
    transition: width 0.3s linear, background-color 0.5s ease;
}

#hud-timer-text {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 4px;
}

#hud-momentum-container {
    position: relative;
    width: 200px;
    height: 12px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 100px;
    border: 1px solid var(--glass-border);
    margin-top: 10px;
    overflow: hidden;
}

#momentumCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#hud-momentum-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 4px;
    height: 18px;
    background: #fff;
    transform: translate(-50%, -50%);
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px rgba(255, 255, 255, 0.4);
    z-index: 2;
    transition: left 0.1s ease-out;
}

.hud-badge {
    pointer-events: auto;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 6px 16px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
}

.hud-badge:hover {
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

/* Pause & Success Screens */
#game-container.is-paused #renderer-container {
    filter: blur(8px) brightness(0.7);
    transition: filter 0.3s ease;
}

.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
    background: rgba(13, 13, 15, 0.6);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.menu-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.btn-secondary {
    background: transparent !important;
    border: 2px solid var(--glass-border) !important;
    box-shadow: none !important;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05) !important;
}

.success-content {
    text-align: center;
    animation: slideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stars-container {
    font-size: 54px;
    margin: 10px 0 20px 0;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.star {
    display: inline-block;
    opacity: 0.3;
    transform: scale(0.8);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.star.earned {
    opacity: 1;
    transform: scale(1.1);
    color: #ffd700;
    animation: starPop 0.5s forwards;
}

.stats-box {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px 40px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.stats-box p {
    margin: 8px 0;
    font-size: 18px;
    color: var(--text-secondary);
}

.stats-box span {
    color: var(--text-primary);
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

/* Core Components Redefined */
.title {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #a0a0ab 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0 0 10px 0;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
    text-align: center;
}

.title-gameover {
    background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 28px;
    color: var(--text-secondary);
    margin-bottom: 48px;
    font-weight: 400;
}

.btn {
    appearance: none;
    background: var(--accent-color);
    border: none;
    border-radius: 16px;
    color: white;
    font-size: 20px;
    font-weight: 700;
    padding: 14px 40px;
    cursor: pointer;
    box-shadow: 0 10px 20px -5px var(--accent-glow);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Outfit', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 20px 25px -5px var(--accent-glow);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(0) scale(0.98);
}

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

@keyframes starPop {
    0% { transform: scale(0.5) rotate(-20deg); }
    70% { transform: scale(1.3) rotate(10deg); }
    100% { transform: scale(1) rotate(0); }
}

#shop-container {
    width: 90%;
    overflow-x: auto;
    padding: 20px 0;
    margin-bottom: 20px;
}

.shop-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-bottom: 20px;
}

.shop-card {
    position: relative;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 15px;
    width: 280px; /* Wider for single column stack */
    text-align: left;
    display: grid;
    grid-template-columns: 1fr 100px;
    align-items: center;
    transition: all 0.3s ease;
}

.level-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 9px;
    font-weight: 900;
    color: var(--accent-color);
}

.shop-info {
    display: flex;
    flex-direction: column;
}

.shop-card h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    font-family: 'Outfit';
}

.shop-card p {
    font-size: 11px;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

.shop-card.maxed {
    border-color: #f1c40f;
    box-shadow: 0 0 15px rgba(241, 196, 15, 0.2);
}

.shop-card.maxed .btn-shop {
    background: #f1c40f !important;
    color: black;
    pointer-events: none;
}

.hud-bottom-right {
    position: absolute;
    bottom: 20px;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    padding: 0 20px;
    box-sizing: border-box;
    z-index: 10;
}

.ability-btn {
    flex: 1;
    max-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 8px 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.ability-btn:hover:not(:disabled) {
    transform: translateX(-5px);
    border-color: var(--accent-color);
    box-shadow: 0 4px 20px var(--accent-glow);
}

.ability-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.ability-count {
    background: var(--accent-color);
    color: white;
    font-weight: 900;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-family: 'Outfit';
}

.ability-label {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Outfit';
}

.shop-section-title {
    font-family: 'Outfit';
    font-weight: 900;
    font-size: 18px;
    color: var(--accent-color);
    margin: 30px 0 15px 0;
    text-align: center;
    letter-spacing: 2px;
}

.btn-shop {
    width: 100%;
    font-size: 12px;
    padding: 8px;
    border-radius: 8px;
}
