.foura-root {
    position: relative;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
}

.foura-screen {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 80vh;
}


.hidden {
    display: none !important;
}

.loading-text {
    margin: auto;
    color: var(--muted);
    text-align: center;
}

.foura-back-link {
    align-self: flex-start;
}

.coin-badge {
    background: var(--panel);
    border-radius: 999px;
    padding: 6px 16px;
    font-weight: bold;
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
}

/* ---------- Menu ---------- */

.menu-coin-badge {
    align-self: flex-end;
    margin-top: -8px;
}

.menu-character-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    position: relative;
}

.side-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: var(--panel);
    color: var(--text);
    border: none;
    border-radius: 16px;
    padding: 14px 10px;
    font-size: 1.8rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.side-button span {
    font-size: 0.7rem;
    color: var(--muted);
}

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

.character-portrait {
    height: min(46vh, 400px);
    width: auto;
    filter: drop-shadow(0 10px 14px rgba(0, 0, 0, 0.4));
}

.character-name-plate {
    background: var(--panel);
    padding: 6px 22px;
    border-radius: 999px;
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--accent);
}

.start-button {
    align-self: flex-end;
    margin: 16px 8px 8px;
    background: linear-gradient(180deg, #7ee787, #35b04a);
    color: #0e1024;
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 1px;
    border: none;
    border-radius: 20px;
    padding: 18px 40px;
    box-shadow: 0 6px 0 #1f7a2f, 0 10px 18px rgba(0, 0, 0, 0.4);
    cursor: pointer;
}

.start-button:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #1f7a2f, 0 4px 10px rgba(0, 0, 0, 0.4);
}

/* ---------- Header wspólny dla galerii / szczegółów ---------- */

.screen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.back-button {
    background: none;
    border: none;
    color: var(--accent-2);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px 0;
}

.screen-title {
    text-align: center;
    margin: 4px 0 16px;
}

/* ---------- Galeria ---------- */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 14px;
}

.gallery-card {
    background: var(--panel);
    border-radius: 14px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    border: 2px solid transparent;
    position: relative;
}

.gallery-card.selected {
    border-color: var(--accent);
}

.gallery-card img {
    width: 100%;
    height: 90px;
    object-fit: contain;
}

.gallery-card .gallery-name {
    font-weight: bold;
    font-size: 0.85rem;
    margin-top: 4px;
}

.gallery-card .gallery-price {
    font-size: 0.75rem;
    color: var(--muted);
}

.gallery-card.locked img {
    filter: grayscale(1) brightness(0.55);
}

.gallery-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.8rem;
}

.gallery-card.affordable::after {
    content: '🔓';
}

/* ---------- Szczegóły postaci ---------- */

.detail-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
}

.detail-portrait {
    height: min(32vh, 260px);
}

.detail-name {
    margin: 4px 0;
    color: var(--accent);
}

.detail-stats {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 8px 0 16px;
}

.detail-stat {
    background: var(--panel);
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 0.9rem;
}

.detail-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 320px;
}

.action-button {
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

.action-button.primary {
    background: var(--accent);
    color: #10132a;
}

.action-button.selected {
    background: #35b04a;
    color: #fff;
}

.action-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---------- Bitwa ---------- */

#screen-battle {
    padding: 0;
    min-height: 0;
    justify-content: center;
}

.battle-viewport {
    position: relative;
    width: 100%;
    touch-action: none;
}

#battle-canvas {
    display: block;
    width: 100%;
    height: auto;
    background: #1a2f1c;
    border-radius: 10px;
}

.battle-hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
}

.hp-bar-wrap {
    width: 140px;
    height: 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.hp-bar-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(180deg, #7ee787, #35b04a);
    transition: width 0.15s ease;
}

.battle-coin-counter {
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: bold;
    color: var(--accent);
}

.joystick {
    position: absolute;
    bottom: 24px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: 2px solid rgba(255, 255, 255, 0.25);
    touch-action: none;
}

.joystick-left { left: 24px; }
.joystick-right { right: 24px; }

.joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 46px;
    height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.55);
}

/* ---------- Koniec walki ---------- */

#screen-gameover {
    align-items: center;
    justify-content: center;
}

.gameover-panel {
    background: var(--panel);
    border-radius: 18px;
    padding: 32px;
    text-align: center;
    max-width: 320px;
}

.gameover-panel h2 {
    color: var(--accent);
    margin-top: 0;
}

.primary-button, .secondary-button {
    display: block;
    width: 100%;
    margin-top: 12px;
    border: none;
    border-radius: 12px;
    padding: 14px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}

.primary-button {
    background: linear-gradient(180deg, #7ee787, #35b04a);
    color: #0e1024;
}

.secondary-button {
    background: transparent;
    color: var(--accent-2);
    border: 1px solid var(--accent-2);
}

@media (max-width: 480px) {
    .character-portrait { height: 38vh; }
    .joystick { width: 90px; height: 90px; }
    .joystick-knob { width: 38px; height: 38px; margin: -19px 0 0 -19px; }
}
