/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --red: #E30613;
    --red-dark: #B0050F;
    --black: #000000;
    --white: #FFFFFF;
    --gray: #888888;
    --gray-dark: #333333;
    --gray-light: #CCCCCC;
    --people-color: #4CAF50;
    --practice-color: #FF9800;
    --perspective-color: #E30613;
    --font-primary: 'Exo 2', sans-serif;
    --font-secondary: 'Open Sans', sans-serif;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--black);
    color: var(--white);
    font-family: var(--font-primary);
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ========== SCREENS ========== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.screen.active {
    display: flex;
}

.screen-content {
    width: 100%;
    max-width: 480px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    overflow-y: auto;
    max-height: 100%;
}

/* ========== BUTTONS ========== */
.btn {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 18px;
    padding: 14px 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: transform 0.1s, background 0.2s;
    min-width: 200px;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--red);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--red-dark);
}

.btn-secondary {
    background: transparent;
    color: var(--white);
    border: 2px solid var(--white);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-back {
    background: transparent;
    color: var(--gray);
    border: 1px solid var(--gray);
    font-size: 14px;
    padding: 10px 30px;
    min-width: auto;
}

/* ========== MAIN MENU ========== */
.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.logo-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.ipma-logo {
    width: 160px;
    height: auto;
}

.game-title {
    font-family: var(--font-primary);
    font-weight: 900;
    font-size: 36px;
    text-align: center;
    line-height: 1.1;
    letter-spacing: 4px;
    color: var(--white);
}

.game-title br + * {
    color: var(--red);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.lang-switcher {
    display: flex;
    align-items: center;
    gap: 12px;
}

.lang-btn {
    background: none;
    border: none;
    color: var(--gray);
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s;
}

.lang-btn.active {
    color: var(--white);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.lang-divider {
    color: var(--gray);
}

/* ========== CHARACTER SELECTION ========== */
.character-selection {
    display: flex;
    gap: 30px;
    justify-content: center;
}

.character-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border: 2px solid var(--gray-dark);
    border-radius: 12px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}

.character-option:hover,
.character-option.selected {
    border-color: var(--red);
    transform: scale(1.05);
}

.character-option.selected {
    background: rgba(227, 6, 19, 0.1);
}

.character-preview svg {
    width: 80px;
    height: 120px;
}

.character-option span {
    font-family: var(--font-secondary);
    font-size: 14px;
    color: var(--gray-light);
}

h2 {
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 28px;
    letter-spacing: 2px;
    text-align: center;
}

/* ========== TUTORIAL ========== */
.tutorial-content {
    gap: 20px;
}

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

.tutorial-step {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
}

.tutorial-icon {
    font-size: 28px;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.tutorial-step p {
    font-family: var(--font-secondary);
    font-size: 14px;
    line-height: 1.4;
}

/* ========== GAME SCREEN ========== */
#screen-game {
    flex-direction: column;
    justify-content: flex-start;
}

#game-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: max(8px, env(safe-area-inset-top)) 16px 8px 16px;
    width: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10;
    min-height: 44px;
}

.hud-lives {
    display: flex;
    gap: 4px;
    font-size: 18px;
}

.hud-lives .heart.lost {
    opacity: 0.2;
}

.hud-round {
    font-weight: 800;
    font-size: 16px;
    color: var(--red);
    letter-spacing: 2px;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-ammo {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--red);
}

.hud-ammo.reloading {
    color: #FFD700;
    animation: ammoFlash 0.5s ease-in-out infinite;
}

@keyframes ammoFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.hud-score {
    font-weight: 700;
    font-size: 20px;
    letter-spacing: 1px;
}

#game-targets-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    width: 100%;
    background: rgba(227, 6, 19, 0.15);
    font-size: 11px;
    overflow-x: auto;
    white-space: nowrap;
    z-index: 10;
    min-height: 32px;
}

.targets-label {
    font-weight: 700;
    color: var(--red);
    flex-shrink: 0;
}

#targets-list {
    font-family: var(--font-secondary);
    color: var(--gray-light);
    font-size: 11px;
}

#targets-list .target-done {
    text-decoration: line-through;
    opacity: 0.4;
}

#game-canvas {
    flex: 1;
    width: 100%;
    display: block;
    background: var(--black);
}

#freeze-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 150, 255, 0.3);
    border: 3px solid rgba(0, 150, 255, 0.8);
    border-radius: 16px;
    padding: 20px 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 24px;
    letter-spacing: 4px;
    color: #88DDFF;
    z-index: 20;
    pointer-events: none;
}

#freeze-overlay.hidden {
    display: none;
}

#freeze-timer {
    font-size: 36px;
    color: var(--white);
}

/* Mobile controls: hidden by default, shown via .is-mobile class on body */
#game-controls {
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 12px 20px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    width: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10;
}

body.is-mobile #game-controls {
    display: flex;
}

.control-btn {
    width: 80px;
    height: 64px;
    border: 2px solid var(--gray-dark);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.control-shoot {
    width: 90px;
    height: 70px;
    border-color: var(--red);
    font-size: 32px;
}

.control-shoot:active {
    background: rgba(227, 6, 19, 0.3);
}

/* ========== STATS SCREEN ========== */
.stats-content {
    gap: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    gap: 4px;
}

.stat-label {
    font-family: var(--font-secondary);
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
}

.stat-value {
    font-weight: 800;
    font-size: 24px;
    color: var(--white);
}

.bonuses-section {
    width: 100%;
    text-align: center;
}

.bonuses-section h3 {
    font-size: 16px;
    color: var(--red);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

#bonuses-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bonus-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    background: rgba(227, 6, 19, 0.1);
    border-radius: 6px;
    font-family: var(--font-secondary);
    font-size: 14px;
}

.bonus-item .bonus-points {
    color: #4CAF50;
    font-weight: 700;
}

.stats-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* ========== GAME OVER ========== */
.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.final-score span:first-child {
    font-family: var(--font-secondary);
    font-size: 14px;
    color: var(--gray);
    text-transform: uppercase;
}

.big-score {
    font-weight: 900;
    font-size: 56px;
    color: var(--red);
}

.nickname-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.nickname-input label {
    font-family: var(--font-secondary);
    font-size: 14px;
    color: var(--gray);
}

.nickname-input input {
    font-family: var(--font-primary);
    font-weight: 700;
    font-size: 20px;
    text-align: center;
    padding: 10px 20px;
    border: 2px solid var(--gray-dark);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--white);
    width: 200px;
    outline: none;
}

.nickname-input input:focus {
    border-color: var(--red);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

/* ========== LEADERBOARD ========== */
.leaderboard-table {
    width: 100%;
    max-width: 400px;
}

.lb-header {
    display: grid;
    grid-template-columns: 40px 1fr 80px 60px;
    padding: 10px 12px;
    border-bottom: 2px solid var(--red);
    font-weight: 700;
    font-size: 12px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.lb-entry {
    display: grid;
    grid-template-columns: 40px 1fr 80px 60px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 14px;
    align-items: center;
}

.lb-entry:nth-child(1) .lb-rank {
    color: #FFD700;
    font-weight: 800;
}

.lb-entry:nth-child(2) .lb-rank {
    color: #C0C0C0;
    font-weight: 800;
}

.lb-entry:nth-child(3) .lb-rank {
    color: #CD7F32;
    font-weight: 800;
}

.lb-rank {
    font-weight: 700;
}

.lb-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-score {
    font-weight: 800;
    color: var(--red);
    text-align: right;
}

.lb-round {
    text-align: center;
    color: var(--gray);
}

.lb-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray);
    font-family: var(--font-secondary);
}

.hidden {
    display: none !important;
}

/* ========== POINT POPUP ========== */
.point-popup {
    position: absolute;
    font-family: var(--font-primary);
    font-weight: 800;
    font-size: 18px;
    pointer-events: none;
    z-index: 15;
    animation: pointFloat 1s ease-out forwards;
}

.point-popup.positive {
    color: #4CAF50;
}

.point-popup.negative {
    color: #FF5252;
}

@keyframes pointFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(1.3);
    }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 360px) {
    .game-title {
        font-size: 28px;
    }

    .btn {
        font-size: 16px;
        padding: 12px 30px;
        min-width: 170px;
    }

    .control-btn {
        width: 65px;
        height: 55px;
        font-size: 22px;
    }

    .control-shoot {
        width: 75px;
        height: 60px;
    }
}

@media (min-width: 768px) {
    .control-btn {
        width: 100px;
        height: 70px;
    }

    .control-shoot {
        width: 110px;
        height: 76px;
    }
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.screen.active .screen-content > * {
    animation: fadeIn 0.3s ease-out;
}
