/* Custom styling for Kingdom Trap 9:16 vertical prototype */

:root {
    --bg-dark: #0a0c10;
    --panel-bg: rgba(18, 22, 30, 0.85);
    --border-glow: rgba(255, 190, 11, 0.15);
    --gold: #ffbe0b;
    --gold-glow: rgba(255, 190, 11, 0.4);
    --crimson: #ff4d6d;
    --crimson-glow: rgba(255, 77, 109, 0.4);
    --blue: #00b4d8;
    --blue-glow: rgba(0, 180, 216, 0.4);
    --text-primary: #f8f9fa;
    --text-muted: #a0aec0;
}

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

body {
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at center, #1b2030 0%, #06070a 100%);
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#app-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    perspective: 1000px;
}

/* 9:16 Viewport Device Casing */
#viewport-container {
    width: 360px;
    height: 640px;
    position: relative;
    border-radius: 32px;
    background-color: #12151c;
    box-shadow: 
        0 25px 60px -10px rgba(0, 0, 0, 0.8),
        0 0 0 10px #242936,
        0 0 0 12px rgba(255, 255, 255, 0.05),
        inset 0 0 30px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

/* Game Canvas */
#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* Glassmorphism Styles */
.glassmorphic {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 
        0 8px 32px 0 rgba(0, 0, 0, 0.5),
        inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* ===== Developed By Splash (intro) ===== */
#dev-splash {
    position: absolute;
    inset: 0;
    z-index: 200;
    overflow: hidden;
    background: #05060a;
    display: flex;
    align-items: center;
    justify-content: center;
    /* painel: fade-in 1s, hold 2s, fade-out 1s (4s no total) */
    animation: devPanel 4s ease forwards;
}
.dev-splash-bg {
    position: absolute;
    inset: 0;
    background: url('imagens/intro/fundo-developed.png') center center / cover no-repeat;
    /* Ken Burns: zoom lento 1.0 -> 1.15 */
    animation: devKenBurns 4s ease-out forwards;
}
.dev-splash-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 0 24px;
}
.dev-splash-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 22px;
    letter-spacing: 6px;
    color: #f3e9ff;
    text-shadow: 0 2px 10px rgba(178, 102, 255, 0.7), 0 1px 3px rgba(0, 0, 0, 0.8);
    opacity: 0;
    animation: devTextIn 0.9s ease-out 0.3s forwards;
}
.dev-splash-logo {
    width: 78%;
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.6));
    transform-origin: center center;
    /* entrada com overshoot (1.2s) e depois flutuar+pulsar em loop */
    animation: gpbIn 1.2s cubic-bezier(0.16, 1.3, 0.4, 1) both,
               gpbFloat 2.6s ease-in-out 1.2s infinite;
}
@keyframes devPanel {
    0% { opacity: 0; }
    25% { opacity: 1; }
    75% { opacity: 1; }
    100% { opacity: 0; }
}
@keyframes devKenBurns {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}
@keyframes devTextIn {
    0% { opacity: 0; transform: translateY(-10px); letter-spacing: 2px; }
    100% { opacity: 1; transform: translateY(0); letter-spacing: 6px; }
}
@keyframes gpbIn {
    0% { opacity: 0; transform: scale(0.4); }
    60% { opacity: 1; transform: scale(1.08); }
    100% { opacity: 1; transform: scale(1); }
}
@keyframes gpbFloat {
    0% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-12px) scale(1.02); }
    100% { transform: translateY(0) scale(1); }
}

/* Music mute toggle */
.btn-music {
    position: absolute;
    top: 10px;
    left: 8px;
    z-index: 60;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(18, 22, 30, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.2s;
}
.btn-music:hover { transform: scale(1.1); }
.btn-music.muted { opacity: 0.6; }

/* Settings gear (top-right) */
.btn-settings {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 60;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(18, 22, 30, 0.72);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--text-primary);
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s;
}
.btn-settings:hover { transform: rotate(35deg); }
.settings-menu {
    position: absolute;
    top: 52px;
    right: 12px;
    z-index: 61;
    width: 168px;
    background: rgba(20, 24, 34, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.settings-menu-item {
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.settings-menu-item:hover { background: rgba(255, 255, 255, 0.08); }
.settings-menu-item.danger { color: var(--crimson); }

/* Account / Settings modal internals */
.account-info, .settings-section, .account-pass {
    width: 100%;
    margin: 12px 0;
    text-align: left;
}
.account-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 4px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 13px;
}
.account-row span:first-child { color: var(--text-muted); }
.account-pass h3, .settings-section h3 {
    font-size: 13px;
    color: var(--gold);
    margin: 10px 0 8px;
    letter-spacing: 0.5px;
}
.account-pass input {
    width: 100%;
    margin-bottom: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-primary);
    font-size: 13px;
}
.account-msg { font-size: 12px; min-height: 16px; margin: 2px 0 8px; color: var(--gold); }
.lang-options { display: flex; flex-direction: column; gap: 8px; }
.lang-btn {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.lang-btn:hover { background: rgba(255, 255, 255, 0.08); }
.lang-btn.active { border-color: var(--gold); background: rgba(255, 190, 11, 0.12); color: var(--gold); }
.vol-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 10px 0;
}
.vol-row label { width: 72px; font-size: 13px; color: var(--text-muted); }
.vol-row input[type="range"] { flex: 1; accent-color: var(--gold); }
.danger-btn { background: linear-gradient(90deg, #ff4d6d, #c9184a); }

/* HUD Panels */
.hud-panel {
    position: absolute;
    width: 90%;
    left: 5%;
    height: 52px;
    z-index: 10;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-radius: 16px;
    pointer-events: auto;
}

.top-hud {
    top: 16px;
    background: rgba(18, 22, 30, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 15px;
}

.hud-item.hearts {
    color: var(--crimson);
    text-shadow: 0 0 8px var(--crimson-glow);
}

.hud-item.gold {
    color: var(--gold);
    text-shadow: 0 0 8px var(--gold-glow);
}

.hud-item.waves {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

.hud-item.waves .label {
    font-size: 9px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    font-weight: 800;
}

.hud-item.waves span:not(.label) {
    font-size: 14px;
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.2s;
}

.btn-icon:hover {
    transform: scale(1.15);
}

/* Bottom HUD (Thumb Area) */
.bottom-hud {
    bottom: 16px;
    height: 72px;
    background: rgba(18, 22, 30, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.4);
}

/* Next Wave Trigger */
#next-wave-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffe066 0%, var(--gold) 100%);
    border: 3px solid #ffbe0b;
    box-shadow: 0 6px 16px var(--gold-glow);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 12;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: -24px; /* Pull it slightly upwards */
}

#next-wave-trigger:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 0 8px 24px var(--gold-glow);
}

/* No waves left to call: the button becomes inert instead of staying clickable */
#next-wave-trigger.disabled {
    background: radial-gradient(circle, #4a4f5c 0%, #2b303c 100%);
    border-color: #3c4250;
    box-shadow: none;
    cursor: default;
    opacity: 0.55;
    pointer-events: none;
}

#next-wave-trigger.disabled .trigger-label,
#next-wave-trigger.disabled .trigger-badge {
    color: #aab2c0;
}

/* Post-click lockout (3s): the button goes dark and inert, then re-enables */
#next-wave-trigger.cooldown {
    background: radial-gradient(circle, #3a3f4c 0%, #23272f 100%);
    border-color: #333846;
    box-shadow: none;
    cursor: default;
    pointer-events: none;
    transform: none;
}
#next-wave-trigger.cooldown .trigger-label,
#next-wave-trigger.cooldown .trigger-badge {
    color: #8a92a2;
    opacity: 0.8;
}

/* Floating "+Ng" that flies up from the top of the wave button and fades (1.8s) */
#wave-gold-fx {
    position: absolute;
    left: 50%;
    top: -6px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 20;
}
.wave-gold-pop {
    position: absolute;
    left: 0;
    top: 0;
    transform: translateX(-50%);
    white-space: nowrap;
    font-family: 'Outfit', sans-serif;
    font-size: 14px;
    font-weight: 800;
    color: #ffe066;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7), 0 0 10px rgba(255, 190, 11, 0.6);
    animation: waveGoldFloat 1.8s ease-out forwards;
}
@keyframes waveGoldFloat {
    0%   { opacity: 0;   transform: translate(-50%, 0)     scale(0.8); }
    15%  { opacity: 1;   transform: translate(-50%, -10px) scale(1.1); }
    100% { opacity: 0;   transform: translate(-50%, -54px) scale(1);   }
}

.trigger-label {
    white-space: nowrap;
}

.trigger-badge {
    font-size: 22px;
    line-height: 1;
}
.trigger-badge-img {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.trigger-label {
    font-size: 7px;
    font-weight: 800;
    color: #3e2700;
    text-transform: uppercase;
}

/* Spells Slot Layout */
.spell-btn {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #1c222e;
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}

.spell-btn:hover {
    border-color: var(--blue);
    transform: scale(1.05);
}

.spell-btn.active {
    border-color: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
}

.spell-icon {
    font-size: 20px;
    z-index: 2;
}

.spell-icon-img {
    width: 34px;
    height: 40px;
    object-fit: contain;
    z-index: 2;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
    pointer-events: none;
}

.spell-label {
    font-size: 7px;
    color: var(--text-muted);
    font-weight: 800;
    z-index: 2;
    margin-top: 1px;
}

.cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: rgba(0, 180, 216, 0.35);
    z-index: 3;
    transition: height 0.1s linear;
}

/* Semicircular Build Menu */
#build-menu {
    position: absolute;
    z-index: 50;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(18, 22, 30, 0.65);   /* círculo ~20% mais transparente (botões ficam intactos) */
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
}

#build-menu.active {
    transform: translate(-50%, -50%) scale(1);
}

.build-option {
    position: absolute;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(24, 30, 42, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.build-option:hover {
    border-color: var(--gold);
    transform: scale(1.12);
}

.build-option.archer {
    top: 10px;
    left: 10px;
}

.build-option.mage {
    top: -12px;
    left: 58px;
}

.build-option.barracks {
    top: 10px;
    right: 10px;
}

.build-icon {
    font-size: 16px;
    line-height: 1;
}

.build-icon-img {
    width: 38px;
    height: 34px;
    object-fit: contain;
    border-radius: 6px;
    margin-bottom: 2px;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.5));
    pointer-events: none;
}

.build-cost {
    font-size: 8px;
    color: var(--gold);
    font-weight: 800;
}

.build-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 10px;
    cursor: pointer;
    z-index: 10;
    margin-top: 24px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Contextual Upgrade/Sell Menu */
#upgrade-menu {
    position: absolute;
    z-index: 50;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(18, 22, 30, 0.65);   /* círculo ~20% mais transparente (botões ficam intactos) */
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
}

#upgrade-menu.active {
    transform: translate(-50%, -50%) scale(1);
}

.upgrade-option {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(24, 30, 42, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.upgrade-option:hover {
    border-color: var(--gold);
    transform: scale(1.12);
}

.upgrade-option.upgrade {
    top: 10px;
    left: 6px;
    border-color: rgba(0, 180, 216, 0.3);
}

.upgrade-option.repair {
    top: -15px;
    left: 46px;
    border-color: rgba(46, 196, 182, 0.45);
}

.upgrade-option.sell {
    top: 10px;
    right: 6px;
    border-color: rgba(255, 190, 11, 0.3);
}

.upgrade-option.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: rgba(220, 53, 69, 0.2);
}

.menu-icon {
    font-size: 16px;
    line-height: 1.1;
}

.menu-label {
    font-size: 6px;
    font-weight: 800;
    color: var(--text-muted);
}

.menu-cost {
    font-size: 7px;
    color: var(--gold);
    font-weight: 800;
}

.upgrade-close {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.9);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    cursor: pointer;
    margin-top: 16px;
    z-index: 10;
}

/* Modals and Overlays */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 10, 14, 0.85);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
}

.modal-content {
    width: 100%;
    max-width: 300px;
    padding: 32px 24px;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.text-center {
    text-align: center;
}

.logo-text {
    font-family: 'Outfit', sans-serif;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-primary);
    line-height: 1.1;
    margin-bottom: 4px;
}

.logo-text .highlight {
    color: var(--gold);
    text-shadow: 0 0 12px var(--gold-glow);
}

.subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 24px;
}

/* Loading Screen */
#loading-overlay.loading-screen {
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 0;
    /* Dark veil over the wallpaper so the logo and panel stay legible */
    background:
        linear-gradient(rgba(8, 10, 14, 0.55), rgba(8, 10, 14, 0.75)),
        url('imagens/wallpaper.jpeg') center center / cover no-repeat,
        radial-gradient(circle at 50% 35%, #131a26 0%, #080a0e 100%);
}

.loading-logo-area {
    height: 60%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.loading-logo {
    max-width: 78%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 12px 30px rgba(0, 0, 0, 0.55));
    animation: logoFloat 3.4s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-16px); }
}

.loading-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 16px 24px;
    background: rgba(8, 10, 14, 0.6);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px 24px 0 0;
}

.loading-panel .loader-bar-container,
.loading-panel .loading-status-text,
.loading-panel .btn-action {
    width: 100%;
    max-width: 260px;
}

/* Loader Bar */
.loader-bar-container {
    width: 100%;
    height: 8px;
    background: #1c222e;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--gold) 0%, #ffbe0b 100%);
    box-shadow: 0 0 8px var(--gold-glow);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.loading-status-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* Action Buttons */
.btn-action {
    display: block;
    width: 100%;
    padding: 12px 0;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffe066 0%, var(--gold) 100%);
    border: none;
    color: #12151c;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--gold-glow);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px var(--gold-glow);
}

.btn-action.secondary {
    background: #1c222e;
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: none;
}

.btn-action.secondary:hover {
    background: rgba(255,255,255,0.05);
    box-shadow: none;
}

/* Modal text highlights */
h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.danger-text {
    color: var(--crimson);
    text-shadow: 0 0 10px var(--crimson-glow);
}

.victory-text {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

#pause-modal p, #gameover-modal p, #victory-modal p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* World Select and Map Selection Screens styling */
.screen-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
    overflow-y: auto;
}

.screen-content.map-screen {
    padding-top: 16px;
}

/* ===== Colecionáveis ===== */
.btn-collect {
    position: absolute; top: 12px; right: 54px; z-index: 60;
    width: 34px; height: 34px; border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(18,22,30,0.72);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    color: var(--text-primary); font-size: 17px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.btn-collect:hover { border-color: var(--gold); }
#collect-modal { padding: 0; }
#collect-modal > .screen-content {
    width: 100%; height: 100%; max-width: none; border: none; border-radius: 0; box-shadow: none;
    padding: 16px 12px;
}
.collect-scroll { width: 100%; flex: 1; overflow-y: auto; padding: 4px 4px 24px; }
.collect-section-title { font-size: 15px; font-weight: 800; color: var(--gold); margin: 18px 2px 10px; letter-spacing: .5px; }
.collect-section-title:first-child { margin-top: 4px; }
.collect-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.collect-card { cursor: pointer; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px; overflow: hidden; transition: transform .15s, border-color .15s; }
.collect-card:hover { transform: translateY(-2px); border-color: var(--gold); }
.collect-card img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; background: #12151c; }
.collect-card .cc-name { font-size: 12px; text-align: center; padding: 7px 4px; color: var(--text-primary); line-height: 1.2; }
.collect-image-overlay { display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: rgba(4,5,8,0.95); z-index: 200; padding: 0; }
.collect-image-full { width: 100%; max-width: 100%; height: auto; display: block; }
.collect-image-close { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%;
    background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.3); color: #fff; font-size: 20px; cursor: pointer; z-index: 210; }
.collect-image-name { margin-top: 14px; font-size: 15px; font-weight: 700; color: var(--gold); text-align: center; padding: 0 16px; }

/* ===== Formulário de login/registro (modal de conta) ===== */
.auth-tabs { display: flex; gap: 8px; margin: 4px 0 14px; }
.auth-tab {
    flex: 1; padding: 8px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
    color: var(--text-muted); border-radius: 10px; font-weight: 700; font-size: 13px; cursor: pointer;
}
.auth-tab.active { background: rgba(255,190,11,0.15); border-color: var(--gold); color: var(--gold); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input[type=text], .auth-form input[type=email], .auth-form input[type=password] {
    width: 100%; padding: 11px 12px; background: #0e1218; border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px; color: var(--text-primary); font-size: 15px;
}
.auth-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); text-align: left; }
.auth-check input { width: auto; }
.btn-action.link-btn { background: none; border: none; box-shadow: none; color: var(--text-muted); font-size: 13px; padding: 4px; }
.btn-action.link-btn:hover { color: var(--gold); }
#auth-msg, #info-update-msg { min-height: 18px; font-size: 13px; margin: 2px 0; }
.auth-social { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.social-sep { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; margin: 6px 0; }
.social-sep::before, .social-sep::after { content: ''; flex: 1; height: 1px; background: rgba(255,255,255,0.1); }
.social-google { background: #fff !important; color: #1a1a1a !important; }
.social-apple { background: #000 !important; color: #fff !important; border: 1px solid #333 !important; }

/* ===== Telas principais em TELA CHEIA (sem card centralizado no meio) ===== */
#world-select-screen,
#upgrade-screen,
#level-select-screen {
    padding: 0;
}
#world-select-screen > .screen-content,
#upgrade-screen > .screen-content,
#level-select-screen > .screen-content {
    width: 100%;
    height: 100%;
    max-width: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

/* Selecao de fases: fundo aereo (vista de cima) do mundo atras dos nos */
#level-select-screen {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
#level-select-screen > .screen-content {
    /* card transparente: mostra a imagem do mundo, com leve scrim p/ leitura */
    background: linear-gradient(to bottom,
        rgba(8,10,14,0.62) 0%,
        rgba(8,10,14,0.18) 20%,
        rgba(8,10,14,0.18) 72%,
        rgba(8,10,14,0.55) 100%);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}
#level-select-screen .levels-map-scroll {
    background: rgba(8,10,14,0.28);
    border: 1px solid rgba(255,255,255,0.06);
}

.stars-counter-badge {
    background: rgba(255, 190, 11, 0.15);
    border: 1px solid var(--gold);
    color: var(--gold);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 800;
    margin-bottom: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 0 10px rgba(255, 190, 11, 0.1);
}

.worlds-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.world-card {
    width: 100%;
    padding: 18px 16px;
    border-radius: 16px;
    background: rgba(25, 30, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, background-color 0.2s;
    text-align: left;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
}

/* Banner de cenário do mundo como fundo do card (opacidade <= 60% p/ manter o
   texto legível). Fica atrás do conteúdo; o texto ganha sombra p/ ler em qualquer bioma. */
.world-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--wbg);
    background-size: cover;
    background-position: center;
    opacity: 0.55;
    z-index: 0;
    border-radius: inherit;
    pointer-events: none;
}
.world-card > * {
    position: relative;
    z-index: 1;
}
.world-card h3,
.world-card p,
.world-card .stars-badge,
.world-card .lock-indicator {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.world-card:not(.locked):hover {
    transform: translateY(-2px);
    border-color: var(--gold);
    background: rgba(35, 42, 58, 0.95);
}

.world-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(18, 20, 26, 0.6);
    border-color: rgba(255, 255, 255, 0.03);
}

.world-card h3 {
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.world-card p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.2;
}

.world-card .lock-indicator {
    position: absolute;
    right: 14px;
    top: 12px;
    font-size: 13px;
    font-weight: 800;
    color: var(--crimson);
}

.world-card .stars-badge {
    position: absolute;
    right: 14px;
    top: 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gold);
}

/* Map Header */
.map-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.map-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
}

.btn-action.secondary.mini {
    width: auto;
    padding: 6px 12px;
    font-size: 11px;
    margin: 0;
}

/* Permanent Upgrades (Star Shop) Screen */
.stars-spent-info {
    font-size: 11px;
    color: var(--text-muted);
    margin: -10px 0 14px 0;
}

#btn-open-upgrades {
    width: auto;
    padding: 10px 18px;
    font-size: 12px;
    margin-bottom: 20px;
}

.upgrades-scroll {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    border-radius: 16px;
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.03);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.upgrade-category-title {
    font-size: 12px;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 1px;
    margin: 8px 4px 0 4px;
    text-align: left;
}

.upgrade-card {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(25, 30, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: border-color 0.2s;
    position: relative;
    overflow: hidden;
    /* overflow:hidden zera o min-height:auto do flex item; sem isto o card é
       ESMAGADO dentro do .upgrades-scroll (flex column de altura fixa). */
    flex-shrink: 0;
}

/* Fundo temático do card (atrás do conteúdo, opacidade <= 60% p/ legibilidade) */
.upgrade-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--ubg);
    background-size: cover;
    background-position: center;
    opacity: 0.45;
    z-index: 0;
    pointer-events: none;
}
.upgrade-card > * {
    position: relative;
    z-index: 1;
}
.upgrade-card .upgrade-name,
.upgrade-card .upgrade-desc {
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.95);
}

.upgrade-card:hover {
    border-color: rgba(255, 255, 255, 0.18);
}

.upgrade-icon {
    font-size: 22px;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    background: rgba(255, 190, 11, 0.1);
    border: 1px solid rgba(255, 190, 11, 0.25);
    overflow: hidden;
}
.upgrade-icon-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.upgrade-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
    min-width: 0;
}

.upgrade-name {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
}

.upgrade-desc {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
}

.rank-pips {
    display: flex;
    gap: 4px;
    margin-top: 2px;
}

.rank-pip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.rank-pip.filled {
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 6px var(--gold-glow);
}

.upgrade-buy {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid var(--gold);
    background: rgba(255, 190, 11, 0.15);
    color: var(--gold);
    font-weight: 800;
    font-size: 12px;
    cursor: pointer;
    transition: transform 0.15s, background-color 0.2s, box-shadow 0.2s;
}

.upgrade-buy:hover {
    background: rgba(255, 190, 11, 0.3);
    box-shadow: 0 0 12px var(--gold-glow);
    transform: translateY(-1px);
}

.upgrade-buy.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.upgrade-buy.disabled:hover {
    background: rgba(255, 190, 11, 0.15);
    box-shadow: none;
}

.upgrade-buy.maxed {
    background: rgba(80, 255, 170, 0.12);
    border-color: #50ffaa;
    color: #50ffaa;
    cursor: default;
    box-shadow: none;
    transform: none;
}

/* Scroll Map Viewport */
.levels-map-scroll {
    width: 100%;
    flex: 1;
    overflow-y: auto;
    border-radius: 16px;
    background: rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.03);
    padding: 24px 8px;
}

.levels-map {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    position: relative;
}

/* Dynamic connecting lines */
.levels-map::before {
    content: '';
    position: absolute;
    top: 20px;
    bottom: 20px;
    width: 4px;
    background-image: linear-gradient(to bottom, rgba(255,255,255,0.08) 50%, transparent 50%);
    background-size: 4px 12px;
    z-index: 1;
}

/* Level Node Circle */
.level-node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 2;
}

/* Alternate offset layout to look like winding road */
.level-node-wrapper:nth-child(even) {
    transform: translateX(35px);
}
.level-node-wrapper:nth-child(odd) {
    transform: translateX(-35px);
}

.level-node {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #1c222e;
    border: 3px solid rgba(255,255,255,0.15);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 800;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s, border-color 0.2s;
}

.level-node.unlocked:hover {
    transform: scale(1.1);
    border-color: var(--gold);
    box-shadow: 0 0 15px var(--gold-glow);
}

.level-node.locked {
    opacity: 0.5;
    background: #11141c;
    border-color: rgba(255,255,255,0.05);
    color: #4a5568;
    cursor: not-allowed;
}

.level-node.boss-node {
    background: #2a0e14;
    border-color: var(--crimson);
    color: var(--crimson);
    box-shadow: 0 0 15px var(--crimson-glow);
    font-size: 18px;
}

.level-node.boss-node.unlocked:hover {
    border-color: var(--crimson);
    box-shadow: 0 0 20px var(--crimson-glow);
    transform: scale(1.15);
}

.node-stars {
    font-size: 9px;
    color: var(--gold);
    display: flex;
    gap: 1px;
}

/* Victory Stars Rating Panel */
.stars-display {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0 24px;
    font-size: 32px;
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(255, 190, 11, 0.4));
}

.stars-display span {
    animation: starEnter 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* Stagger animations for stars */
.stars-display span:nth-child(1) { animation-delay: 0.1s; }
.stars-display span:nth-child(2) { animation-delay: 0.2s; }
.stars-display span:nth-child(3) { animation-delay: 0.3s; }
.stars-display span:nth-child(4) { animation-delay: 0.4s; }
.stars-display span:nth-child(5) { animation-delay: 0.5s; }

@keyframes starEnter {
    0% { transform: scale(0) rotate(-30deg); opacity: 0; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}

/* Analysis panel */
.analysis-panel {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.analysis-panel h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-align: center;
    font-weight: 800;
}

.analysis-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    margin-bottom: 8px;
}

.analysis-row:last-child {
    margin-bottom: 0;
}

.analysis-row .highlight {
    font-weight: 600;
    color: var(--text-primary);
}

/* Micro animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 2s infinite ease-in-out;
}

