/* ─────────────────────────────────────────────
   DANDA — Pixel Art UI Styles
   ───────────────────────────────────────────── */

/* ═══ RESET & BASE ═══ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --black:       #000000;
    --dark-blue:   #1d2b53;
    --dark-purple: #7e2553;
    --dark-green:  #008751;
    --brown:       #ab5236;
    --dark-grey:   #5f574f;
    --light-grey:  #c2c3c7;
    --white:       #fff1e8;
    --red:         #ff004d;
    --orange:      #ffa300;
    --yellow:      #ffec27;
    --green:       #00e436;
    --blue:        #29adff;
    --indigo:      #83769c;
    --pink:        #ff77a8;
    --peach:       #ffccaa;
}

html, body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--black);
    font-family: 'Press Start 2P', monospace;
    color: var(--white);
    image-rendering: pixelated;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
}

/* ═══ PRESS START ═══ */
.press-start-title {
    font-size: 24px;
    color: var(--yellow);
    text-shadow: 3px 3px 0 var(--dark-purple), 0 0 15px var(--orange);
    letter-spacing: 6px;
    margin-bottom: 32px;
}

#start-screen {
    background: var(--black);
}

#start-screen .pixel-btn {
    animation: pixelBlink 1.2s step-end infinite;
}

/* ═══ LOADING ═══ */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 16px;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 4px solid var(--dark-grey);
    border-top: 4px solid var(--yellow);
    animation: spinPixel 0.8s steps(8) infinite;
}

@keyframes spinPixel {
    to { transform: rotate(360deg); }
}

.loading-text {
    font-size: 10px;
    color: var(--yellow);
    letter-spacing: 4px;
    animation: pixelBlink 1.2s step-end infinite;
}

/* ═══ SCREENS ═══ */
.screen {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.screen.active {
    display: block;
}

/* Screens that need flex layout (level select, results) */
#level-screen.active,
#results-screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Game screen needs flex for HUD bars */
#game-screen.active {
    display: flex;
    flex-direction: column;
    justify-content: stretch;
}

/* ═══ MAIN MENU ═══ */
.menu-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.title-art {
    font-size: 10px;
    line-height: 1.4;
    color: var(--yellow);
    text-shadow:
        2px 2px 0 var(--dark-purple),
        0 0 10px var(--orange);
    letter-spacing: 2px;
}

.title-line {
    white-space: pre;
}

.subtitle {
    font-size: 8px;
    color: var(--red);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.pixel-blink {
    animation: pixelBlink 1.2s step-end infinite;
}

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

.menu-footer {
    margin-top: 16px;
}

.pixel-small {
    font-size: 6px;
    color: var(--dark-grey);
    letter-spacing: 1px;
}

/* ═══ PIXEL BUTTONS ═══ */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pixel-btn {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: var(--white);
    background: var(--dark-blue);
    border: 3px solid var(--light-grey);
    padding: 12px 24px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    position: relative;
    transition: none;
    image-rendering: pixelated;

    /* Pixel border effect */
    box-shadow:
        3px 3px 0 var(--dark-grey),
        -1px -1px 0 var(--indigo);
}

.pixel-btn:hover {
    background: var(--dark-purple);
    color: var(--yellow);
    border-color: var(--yellow);
    box-shadow:
        3px 3px 0 var(--brown),
        -1px -1px 0 var(--orange),
        0 0 8px var(--yellow);
}

.pixel-btn:active {
    transform: translate(2px, 2px);
    box-shadow:
        1px 1px 0 var(--dark-grey);
}

.pixel-btn-sm {
    font-size: 8px;
    padding: 8px 14px;
}

.pixel-btn-danger {
    border-color: var(--red);
}

.pixel-btn-danger:hover {
    background: var(--red);
    color: var(--white);
}

/* ═══ LEVEL SELECT ═══ */
.level-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
}

.pixel-title {
    font-size: 14px;
    color: var(--yellow);
    text-shadow: 2px 2px 0 var(--dark-purple);
    letter-spacing: 2px;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.level-cell {
    width: 56px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--dark-blue);
    border: 2px solid var(--dark-grey);
    font-size: 12px;
    cursor: pointer;
    gap: 4px;
}

.level-cell:hover {
    border-color: var(--yellow);
    background: var(--dark-purple);
}

.level-cell.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

.level-cell.completed {
    border-color: var(--green);
}

.level-stars {
    font-size: 6px;
    color: var(--yellow);
}

.level-stars.empty {
    color: var(--dark-grey);
}

/* ═══ GAME SCREEN ═══ */

#game-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: var(--dark-blue);
}

#game-canvas canvas {
    display: block;
    image-rendering: pixelated;
}

/* ═══ HUD BARS ═══ */
.hud-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: var(--black);
    border-bottom: 2px solid var(--dark-grey);
    min-height: 36px;
    z-index: 10;
}

.hud-bottom {
    border-bottom: none;
    border-top: 2px solid var(--dark-grey);
}

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

.hud-icon {
    font-size: 10px;
}

.hud-icon:first-child {
    color: var(--red);
}

.hud-value {
    color: var(--white);
    font-size: 8px;
}

.hud-phase {
    font-size: 10px;
    color: var(--green);
    text-shadow: 0 0 6px var(--green);
    letter-spacing: 3px;
    animation: phaseGlow 2s ease-in-out infinite;
}

@keyframes phaseGlow {
    0%, 100% { text-shadow: 0 0 6px var(--green); }
    50% { text-shadow: 0 0 14px var(--green), 0 0 20px var(--dark-green); }
}

.hud-phase.attack {
    color: var(--red);
    animation-name: phaseGlowAttack;
}

@keyframes phaseGlowAttack {
    0%, 100% { text-shadow: 0 0 6px var(--red); }
    50% { text-shadow: 0 0 14px var(--red), 0 0 20px var(--dark-purple); }
}

/* ═══ SHOP PANEL ═══ */
.shop-panel {
    display: flex;
    gap: 6px;
    align-items: center;
}

.shop-item {
    width: 40px;
    height: 40px;
    background: var(--dark-blue);
    border: 2px solid var(--dark-grey);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 6px;
    gap: 2px;
    position: relative;
}

.shop-item:hover {
    border-color: var(--yellow);
    background: var(--dark-purple);
}

.shop-item.selected {
    border-color: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.shop-item .shop-icon {
    font-size: 14px;
}

.shop-item .shop-cost {
    font-size: 5px;
    color: var(--yellow);
}

.hud-actions {
    display: flex;
    gap: 6px;
}

/* ═══ RESULTS SCREEN ═══ */
.results-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.stars-display {
    font-size: 28px;
    color: var(--yellow);
    text-shadow: 0 0 10px var(--orange);
    letter-spacing: 8px;
}

.stars-display .star-empty {
    color: var(--dark-grey);
    text-shadow: none;
}

.results-scores {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 8px;
    min-width: 200px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--dark-grey);
}

.score-total {
    color: var(--yellow);
    font-size: 10px;
    border-bottom: none;
    border-top: 2px solid var(--yellow);
    padding-top: 8px;
}

/* ═══ COMIC SFX TEXT (for later phases) ═══ */
.comic-fx {
    position: absolute;
    font-size: 24px;
    font-family: 'Press Start 2P', monospace;
    color: var(--yellow);
    text-shadow:
        3px 3px 0 var(--red),
        -1px -1px 0 var(--orange);
    pointer-events: none;
    z-index: 100;
    animation: comicPop 0.6s ease-out forwards;
}

@keyframes comicPop {
    0% { transform: scale(0.3) rotate(-10deg); opacity: 1; }
    40% { transform: scale(1.3) rotate(5deg); opacity: 1; }
    100% { transform: scale(1.5) rotate(0deg) translateY(-20px); opacity: 0; }
}

/* ═══ SCROLLBAR HIDE ═══ */
::-webkit-scrollbar { display: none; }

/* ═══ MOBILE RESPONSIVE ═══ */
@media (max-width: 768px) {
    /* Menu canvas fills entire screen */
    #menu-screen canvas,
    #game-canvas canvas {
        width: 100vw !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .hud-bar {
        padding: 6px 6px;
        min-height: 40px;
    }
    .hud-item { font-size: 9px; gap: 3px; }
    .hud-icon { font-size: 12px; }
    .hud-value { font-size: 9px; }
    .hud-phase { font-size: 11px; letter-spacing: 2px; }

    .shop-item {
        width: 44px;
        height: 44px;
        font-size: 7px;
    }
    .shop-item .shop-icon { font-size: 16px; }
    .shop-item .shop-cost { font-size: 6px; }

    .pixel-btn-sm {
        font-size: 9px;
        padding: 10px 14px;
    }

    .level-cell {
        width: 48px;
        height: 48px;
        font-size: 10px;
    }

    .pixel-title { font-size: 12px; }

    .results-scores { font-size: 10px; }
    .score-total { font-size: 12px; }
    .stars-display { font-size: 32px; }

    .pixel-btn {
        font-size: 10px;
        padding: 14px 20px;
    }

    /* Fullscreen vertical */
    #game-screen.active {
        height: 100vh;
        height: 100dvh;
    }
    #game-canvas {
        flex: 1;
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .hud-bar {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: center;
    }
    .shop-panel { gap: 4px; }
    .hud-actions { gap: 4px; }
    .level-grid { grid-template-columns: repeat(5, 1fr); gap: 4px; }
    .level-cell { width: 42px; height: 42px; }
}
