:root {
    --bg-dark: #0f0a1c;
    --bg-card: rgba(25, 18, 46, 0.7);
    --primary: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.4);
    --secondary: #bd00ff;
    --secondary-glow: rgba(189, 0, 255, 0.4);
    --text-color: #f3efff;
    --text-muted: #a39bb8;
    --accent: #ff007a;
    --accent-glow: rgba(255, 0, 122, 0.4);
    --blue-progress: #0088ff;
    --success: #39ff14;
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body.theme-forest {
    --bg-dark: #132219;
    --bg-card: rgba(32, 53, 39, 0.75);
    --primary: #52d681;
    --primary-glow: rgba(82, 214, 129, 0.4);
    --secondary: #dfb02a;
    --secondary-glow: rgba(223, 176, 42, 0.4);
    --text-color: #f0f7f2;
    --text-muted: #9ba89e;
    --accent: #e76f51;
    --accent-glow: rgba(231, 111, 81, 0.4);
    --blue-progress: #8ab17d;
    --success: #ffeb3b;
}

body.theme-ocean {
    --bg-dark: #07152b;
    --bg-card: rgba(13, 35, 66, 0.75);
    --primary: #00f0ff;
    --primary-glow: rgba(0, 240, 255, 0.4);
    --secondary: #0066ff;
    --secondary-glow: rgba(0, 102, 255, 0.4);
    --text-color: #e0f2ff;
    --text-muted: #8faec4;
    --accent: #ff00aa;
    --accent-glow: rgba(255, 0, 170, 0.4);
    --blue-progress: #00aaff;
    --success: #00ff88;
}

/* Floating Combo Multiplier Badge */
#hud-combo-container {
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 0, 122, 0.15);
    border: 1px dashed var(--accent);
    border-radius: 8px;
    padding: 2px 6px;
    margin-left: 5px;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

#hud-combo-container.active {
    opacity: 1;
    transform: scale(1);
    display: flex;
}

.combo-text {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.5px;
    text-shadow: 0 0 5px var(--accent-glow);
}

.combo-pop-animation {
    animation: comboPop 0.25s ease-out;
}

@keyframes comboPop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}


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

body {
    background-color: var(--bg-dark);
    color: var(--text-color);
    font-family: var(--font-family);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 10px progress bar at the very top of the screen */
#bonus-progress-bar-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    z-index: 1000;
}

#bonus-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--blue-progress), #00d2ff);
    box-shadow: 0 0 10px var(--primary-glow);
    transition: width 0.3s ease;
}

/* Wrapper to maintain mobile aspect ratio on desktop */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 800px;
    background-color: #0b0716;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 451px) {
    #game-wrapper {
        border-radius: 20px;
        height: 95vh;
        border: 2px solid rgba(0, 240, 255, 0.2);
    }
}

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

/* Floating overlay panels (Welcome, Leaderboard, GameOver, Powerup choice) */
.overlay-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(10, 6, 21, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay-panel.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

/* Premium glassmorphic card styles */
.glass-card {
    background: var(--bg-card);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 100%;
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 90%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.glass-card::-webkit-scrollbar {
    width: 6px;
}

.glass-card::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

/* Titles and subtitle styles */
.game-title {
    font-size: 2.8rem;
    font-weight: 800;
    letter-spacing: 4px;
    margin-bottom: 5px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 240, 255, 0.3);
    text-align: center;
    animation: pulseGlow 3s infinite ease-in-out;
}

.game-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 30px;
    text-align: center;
    letter-spacing: 1px;
}

.panel-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 20px;
    letter-spacing: 2px;
    text-align: center;
    background: linear-gradient(135deg, #fff, var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.text-danger {
    background: linear-gradient(135deg, #ff4c4c, var(--accent)) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

/* Inputs & Form Groups */
.input-group {
    width: 100%;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
    letter-spacing: 1.5px;
}

.input-group input {
    width: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 14px 18px;
    color: #fff;
    font-family: var(--font-family);
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow), inset 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Buttons */
button {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
    margin-bottom: 12px;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    box-shadow: 0 4px 15px rgba(189, 0, 255, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 240, 255, 0.5);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
}

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

/* Instructions */
.how-to-play {
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
}

.how-to-play h3 {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-bottom: 12px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.how-to-play ul {
    list-style-type: none;
}

.how-to-play li {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    line-height: 1.4;
    position: relative;
    padding-left: 15px;
}

.how-to-play li::before {
    content: "•";
    color: var(--secondary);
    font-weight: bold;
    display: inline-block;
    width: 1em;
    margin-left: -1em;
    position: absolute;
}

/* HUD Overlay on play screen */
#hud-overlay {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    height: auto;
    background: rgba(15, 10, 28, 0.8);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 15px;
    z-index: 50;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

#hud-overlay.hidden {
    display: none !important;
}

.hud-item {
    display: flex;
    flex-direction: column;
}

.hud-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.hud-val {
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
}

#hud-score {
    color: var(--primary);
}

#hud-bonus {
    color: var(--blue-progress);
}

#hud-word-preview-container {
    flex-grow: 1.5;
    max-width: 65%;
}

#hud-word {
    color: var(--success);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-size: 1.2rem;
    text-shadow: 0 0 10px rgba(57, 255, 20, 0.4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: right; /* Align right to match flex-end container */
}

/* Active Powerups */
#active-powerups-container {
    position: absolute;
    bottom: 10px; /* Adjusted down from 80px to accommodate the taller 2-row HUD */
    right: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 50;
    pointer-events: none;
}

#active-powerups-container.hidden {
    display: none !important;
}

.active-powerup-badge {
    background: rgba(25, 18, 46, 0.9);
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 10px var(--accent-glow);
    animation: slideIn 0.3s ease-out;
}

.active-powerup-icon {
    font-size: 0.9rem;
}

.active-powerup-text {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-color);
    letter-spacing: 0.5px;
}

/* Powerup Modal Choices */
.powerup-card-container {
    max-width: 400px;
}

.powerup-title {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
    margin-bottom: 5px;
    text-align: center;
}

.powerup-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 25px;
    text-align: center;
}

#powerup-choices {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.powerup-card {
    background: rgba(36, 27, 66, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.powerup-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent);
}

.powerup-card:hover {
    transform: scale(1.02);
    background: rgba(50, 38, 92, 0.9);
    border-color: var(--primary);
    box-shadow: 0 8px 25px var(--primary-glow);
}

.powerup-card:active {
    transform: scale(0.98);
}

.powerup-card-icon {
    font-size: 2.2rem;
    background: rgba(0, 0, 0, 0.3);
    width: 55px;
    height: 55px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.powerup-card-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.powerup-card-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.powerup-card-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
    text-align: left;
}

/* Leaderboard Details */
#leaderboard-list-container {
    width: 100%;
    margin-bottom: 25px;
    max-height: 400px;
    overflow-y: auto;
}

#leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

#leaderboard-table th {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

#leaderboard-table td {
    padding: 12px 8px;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

#leaderboard-tbody tr:nth-child(1) td {
    color: #ffd700;
    /* Gold */
    font-weight: 600;
}

#leaderboard-tbody tr:nth-child(2) td {
    color: #c0c0c0;
    /* Silver */
    font-weight: 600;
}

#leaderboard-tbody tr:nth-child(3) td {
    color: #cd7f32;
    /* Bronze */
    font-weight: 600;
}

.rank-cell {
    font-weight: 800;
}

/* Gameover Stats */
.gameover-stats {
    width: 100%;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.stat-row span:first-child {
    color: var(--text-muted);
}

.text-highlight {
    color: var(--primary);
    font-weight: 700;
}

/* Floating Banner Alert for Shuffles */
#shuffle-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(255, 0, 122, 0.9);
    border: 2px solid #ff5ebb;
    box-shadow: 0 0 30px rgba(255, 0, 122, 0.8);
    border-radius: 12px;
    padding: 15px 25px;
    text-align: center;
    z-index: 200;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
}

#shuffle-banner.show-banner {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#shuffle-banner span {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Animations */
@keyframes pulseGlow {

    0%,
    100% {
        text-shadow: 0 0 15px rgba(0, 240, 255, 0.2), 0 0 30px rgba(189, 0, 255, 0.2);
    }

    50% {
        text-shadow: 0 0 30px rgba(0, 240, 255, 0.5), 0 0 50px rgba(189, 0, 255, 0.5);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Glitch Jitter effect */
.glitch-jitter {
    animation: jitter 0.15s infinite;
}

@keyframes jitter {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-2px, 2px); }
    40% { transform: translate(-2px, -2px); }
    60% { transform: translate(2px, 2px); }
    80% { transform: translate(2px, -1px); }
}

/* Frenzy Mode visual styles */
#bonus-progress-bar.frenzy-active {
    background: linear-gradient(90deg, #ff00ff, #ffaa00, #ff00ff) !important;
    background-size: 200% 100% !important;
    animation: frenzyBarFlow 1.5s infinite linear, pulseGlow 1.5s infinite ease-in-out !important;
    box-shadow: 0 0 15px rgba(255, 0, 255, 0.8), 0 0 30px rgba(255, 0, 255, 0.4) !important;
}

#game-wrapper.frenzy-border {
    border: 2px solid #ff00ff !important;
    box-shadow: 0 0 25px rgba(255, 0, 255, 0.4), inset 0 0 15px rgba(255, 0, 255, 0.2) !important;
    animation: frenzyBorderFlash 2s infinite ease-in-out;
}

@keyframes frenzyBarFlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}

@keyframes frenzyBorderFlash {
    0%, 100% { border-color: #ff00ff; box-shadow: 0 0 20px rgba(255, 0, 255, 0.4); }
    50% { border-color: #ffaa00; box-shadow: 0 0 35px rgba(255, 170, 0, 0.6); }
}

/* Detailed Run Recap screen styling */
.recap-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    width: 100%;
}

.recap-section-title {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 4px;
}

/* Scrollable Word list */
.recap-words-container {
    max-height: 80px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.recap-words-container::-webkit-scrollbar {
    width: 4px;
}
.recap-words-container::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.recap-word-item {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 2px 6px;
    color: var(--text-color);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Relics & Upgrades List */
.recap-upgrades-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recap-upgrade-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 0, 122, 0.08);
    border: 1px solid rgba(255, 0, 122, 0.2);
    border-radius: 12px;
    padding: 4px 8px;
}

.recap-upgrade-icon {
    font-size: 0.95rem;
}

.recap-upgrade-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-color);
}

/* Playstyle Badges list */
.recap-badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.recap-badge-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 240, 255, 0.08);
    border: 1px solid rgba(0, 240, 255, 0.2);
    border-radius: 12px;
    padding: 4px 8px;
    cursor: help;
}

.recap-badge-icon {
    font-size: 0.95rem;
}

.recap-badge-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-color);
}

.recap-empty-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Synergy badges style update */
.synergy-badge {
    background: rgba(255, 235, 59, 0.1) !important;
    border: 1px solid #ffeb3b !important;
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.3) !important;
    animation: pulseGlowYellow 2s infinite ease-in-out;
}

@keyframes pulseGlowYellow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 235, 59, 0.2); }
    50% { box-shadow: 0 0 12px rgba(255, 235, 59, 0.5); }
}