/* ============================================
   CHAOS.CSS - Chaos Mode Visual Effects
   17+4 Retro Kartenspiel - Chaos Expansion
   ============================================ */

/* ---- Chaos Card Overlay ---- */
.chaos-overlay {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

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

.chaos-overlay.active {
    display: flex;
    animation: chaosOverlayIn 0.3s ease-out;
}

.chaos-card-display {
    border: 3px solid var(--accent);
    padding: 24px 32px;
    text-align: center;
    background: var(--bg);
    max-width: 360px;
    width: 90%;
    animation: chaosCardEntry 0.5s ease-out;
    position: relative;
}

.chaos-card-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
    line-height: 1;
}

.chaos-card-name {
    /* Terminal-Schrift: die Pixelschrift zeichnet AE/OE/UE so klein wie ae/oe/ue
       (NASSE HOELZER, ZUENDELN, DEALER SCHLAEFT ...) */
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 2.1rem;
    color: var(--accent);
    margin-bottom: 10px;
    letter-spacing: 3px;
}

.chaos-card-desc {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1.4rem;
    color: var(--text);
    margin-bottom: 12px;
    line-height: 1.3;
}

.chaos-card-category {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1rem;
    padding: 2px 10px;
    display: inline-block;
    border: 1px solid var(--text-dim);
    color: var(--text-dim);
}

.cat-rule-change {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
}

.cat-bonus {
    border-color: var(--chip-gold, #ffd700) !important;
    color: var(--chip-gold, #ffd700) !important;
}

.cat-chaos {
    border-color: var(--danger) !important;
    color: var(--danger) !important;
}

.cat-glut {
    border-color: #ff9a1f !important;
    color: #ff9a1f !important;
}

.cat-minigame {
    border-color: var(--success) !important;
    color: var(--success) !important;
}

.chaos-card-hint {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1rem;
    color: var(--text-dim);
    margin-top: 12px;
    opacity: 0.6;
}

@keyframes chaosOverlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes chaosCardEntry {
    0% {
        transform: translateY(-100px) rotate(-10deg) scale(0.5);
        opacity: 0;
    }
    60% {
        transform: translateY(10px) rotate(2deg) scale(1.05);
        opacity: 1;
    }
    100% {
        transform: translateY(0) rotate(0deg) scale(1);
    }
}

/* ---- Elimination Overlay ---- */
.elimination-overlay {
    position: absolute;
    inset: 0;
    z-index: 110;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

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

.elimination-overlay.active {
    display: flex;
    animation: elimOverlayIn 0.3s ease-out;
}

.elimination-art {
    font-family: 'Courier New', monospace;
    font-size: 0.6rem;
    color: var(--danger);
    white-space: pre;
    line-height: 1.2;
    text-shadow: 0 0 10px var(--danger);
    animation: elimPulse 0.5s ease-in-out 3;
}

.elimination-name {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--text);
    letter-spacing: 2px;
    margin-top: 8px;
}

.elimination-subtitle {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1.3rem;
    color: var(--text-dim);
}

@keyframes elimOverlayIn {
    from { opacity: 0; transform: scale(1.2); }
    to { opacity: 1; transform: scale(1); }
}

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

/* ---- Eliminated Player Spot ---- */
.player-spot.eliminated {
    opacity: 0.3;
    filter: grayscale(0.8);
    position: relative;
    animation: elimSlideOut 0.5s ease-in forwards;
    animation-delay: 0.3s;
    animation-fill-mode: both;
}

.player-spot.eliminated::after {
    content: 'RAUS';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 0.7rem;
    color: var(--danger);
    text-shadow: 0 0 6px var(--danger);
    letter-spacing: 3px;
    z-index: 5;
    pointer-events: none;
}

.eliminated-status {
    color: var(--danger) !important;
}

@keyframes elimSlideOut {
    from { opacity: 0.3; }
    to { opacity: 0.15; }
}

/* ---- Phase Banner Overlay ---- */
.phase-banner {
    position: absolute;
    inset: 0;
    z-index: 105;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
}

.phase-banner.hidden {
    display: none !important;
}

.phase-banner.active {
    display: flex;
    animation: phaseBannerIn 0.4s ease-out;
}

.phase-banner-text {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1.4rem;
    color: var(--accent);
    text-align: center;
    letter-spacing: 4px;
    text-shadow:
        0 0 10px var(--glow-color, var(--accent)),
        0 0 20px var(--glow-color, var(--accent)),
        0 0 40px var(--glow-color, var(--accent));
    animation: phaseGlow 1s ease-in-out infinite alternate;
}

@keyframes phaseBannerIn {
    0% {
        opacity: 0;
        transform: scale(2);
    }
    60% {
        opacity: 1;
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes phaseGlow {
    from { text-shadow: 0 0 10px var(--glow-color, var(--accent)); }
    to {
        text-shadow:
            0 0 10px var(--glow-color, var(--accent)),
            0 0 30px var(--glow-color, var(--accent)),
            0 0 60px var(--glow-color, var(--accent));
    }
}

/* ---- Victory Screen ---- */
#victory-screen {
    text-align: center;
    gap: 16px;
}

#victory-screen h1 {
    animation: victoryGlow 1.5s ease-in-out infinite alternate;
}

.victory-trophy {
    font-size: 3rem;
    margin-bottom: 8px;
    animation: trophyBounce 1s ease-in-out infinite;
}

.victory-winner-name {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1rem;
    color: var(--accent);
    letter-spacing: 2px;
}

.victory-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1.3rem;
    color: var(--text);
}

.victory-ranking {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    width: 100%;
    max-width: 300px;
}

.victory-rank-item {
    display: flex;
    justify-content: space-between;
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1.2rem;
    padding: 3px 8px;
    border-bottom: 1px dashed var(--separator);
}

.rank-pos {
    color: var(--text-dim);
    min-width: 30px;
    flex-shrink: 0;
}

/* Lange Namen mit ... kuerzen, damit sie nicht an der Chipzahl kleben */
.rank-name {
    flex: 1;
    min-width: 0;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rank-name.rank-winner {
    color: var(--accent);
}

.rank-chips {
    color: var(--chip-gold, #ffd700);
    flex-shrink: 0;
    margin-left: 16px;
}

@keyframes victoryGlow {
    from {
        text-shadow: 0 0 5px var(--accent);
        color: var(--accent);
    }
    to {
        text-shadow:
            0 0 10px var(--accent),
            0 0 30px var(--accent),
            0 0 50px var(--accent);
        color: var(--text);
    }
}

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

/* ---- Top Bar: Chaos Info ---- */
/* Aktive Chaos-Karte: Kasten mit Name + Regel, bleibt die ganze Runde stehen.
   Gestapelt unter der Statusleiste, im Tisch-Layout oben rechts (main.css). */
#chaos-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-self: center;
    max-width: 320px;
    margin: 4px auto;
    padding: 6px 12px;
    border: 1px solid var(--danger);
    background-color: var(--bg-light);
    font-family: 'VT323', 'Courier New', monospace;
    text-align: left;
}

.chaos-info-title {
    font-size: 1.2rem;
    color: var(--danger);
    animation: chaosInfoPulse 2s ease-in-out infinite;
}

.chaos-info-desc {
    font-size: 1.1rem;
    color: var(--text);
    line-height: 1.2;
}

#chaos-info.hidden {
    display: none !important;
}

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

/* ---- Phase Info in Top Bar ---- */
.phase-info {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1rem;
    padding: 1px 6px;
    border: 1px solid var(--separator);
}

.phase-matches,
.phase-matches2 {
    color: var(--chip-gold, #ffd700);
    border-color: var(--chip-gold, #ffd700);
}

.phase-warmup {
    color: var(--text-dim);
    border-color: var(--text-dim);
}

.phase-chaos {
    color: var(--danger);
    border-color: var(--danger);
    animation: chaosInfoPulse 1.5s ease-in-out infinite;
}

.phase-showdown {
    color: var(--accent);
    border-color: var(--accent);
    text-shadow: 0 0 6px var(--accent);
}

/* ---- Mini-Game Overlay ---- */
.minigame-overlay {
    position: absolute;
    inset: 0;
    z-index: 120;
    /* 0.9 liess die hell leuchtende Nachrichtenzeile durch den Titel scheinen */
    background: rgba(0, 0, 0, 0.97);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
}

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

.minigame-overlay.active {
    display: flex;
    animation: chaosOverlayIn 0.3s ease-out;
}

.minigame-title {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--accent);
    letter-spacing: 2px;
}

.minigame-instructions {
    font-family: 'VT323', 'Courier New', monospace;
    font-size: 1.3rem;
    color: var(--text-dim);
    text-align: center;
}

/* ---- Slot Machine ---- */
.slot-machine {
    display: flex;
    gap: 12px;
    padding: 16px;
    border: 2px solid var(--accent);
    background: var(--bg);
}

.slot-reel {
    width: 60px;
    height: 60px;
    border: 2px solid var(--text-dim);
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slot-reel-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: slotSpin 0.15s linear infinite;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1.2rem;
    color: var(--text);
}

.slot-reel.stopped .slot-reel-inner {
    animation: none;
}

.slot-reel.stopped {
    border-color: var(--accent);
    box-shadow: 0 0 8px var(--glow-color, var(--accent));
}

@keyframes slotSpin {
    0% { transform: translateY(0); }
    100% { transform: translateY(-60px); }
}

/* ---- Card Catch ---- */
.catch-container {
    width: 80%;
    max-width: 500px;
    position: relative;
}

.catch-track {
    width: 100%;
    height: 60px;
    border: 2px solid var(--text-dim);
    position: relative;
    overflow: hidden;
    background: var(--bg);
}

.catch-target-zone {
    position: absolute;
    top: 0;
    height: 100%;
    background: rgba(0, 255, 0, 0.15);
    border-left: 2px solid var(--success);
    border-right: 2px solid var(--success);
}

.catch-card {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    transition: none;
}

.catch-result {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 8px;
}

/* ---- Bomb Timer ---- */
.bomb-timer-display {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 90;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 1.2rem;
    color: var(--danger);
    text-align: center;
    padding: 6px 16px;
    border: 2px solid var(--danger);
    background: var(--bg);
}

.bomb-timer-display.hidden {
    display: none !important;
}

.bomb-timer-display.warning {
    animation: bombPulse 0.3s ease-in-out infinite;
}

.bomb-ascii {
    font-size: 1.5rem;
    line-height: 1;
}

.bomb-countdown {
    font-size: 1.6rem;
    color: var(--danger);
    margin-top: 4px;
}

@keyframes bombPulse {
    0%, 100% {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    50% {
        opacity: 0.5;
        transform: translateX(-50%) scale(1.1);
    }
}

/* ---- Responsive Adjustments ---- */
@media (max-width: 480px) {
    .chaos-card-display {
        padding: 16px 20px;
    }

    .chaos-card-icon {
        font-size: 2rem;
    }

    .chaos-card-name {
        font-size: 1.5rem;
    }

    .chaos-card-desc {
        font-size: 1.1rem;
    }

    .phase-banner-text {
        font-size: 0.9rem;
    }

    .elimination-art {
        font-size: 0.4rem;
    }

    .slot-reel {
        width: 45px;
        height: 45px;
    }
}
