:root {
    --neon-blue: #00f3ff;
    --neon-pink: #ff0055;
    --term-bg: #050508;
    --peg-color: #3a3a4a;
    --gold: #ffd700;
}

body {
    background: var(--term-bg);
    color: var(--neon-blue);
    font-family: 'Courier New', monospace;
    margin: 0;
    text-transform: uppercase;
    overflow-x: hidden;
}

/* --- Centering Fix for Login/Setup --- */
#setup-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    gap: 20px;
    text-align: center;
}

#setup-screen input {
    background: #000;
    border: 1px solid var(--neon-blue);
    color: var(--neon-blue);
    padding: 10px;
    font-family: inherit;
    text-align: center;
    width: 200px;
    margin: 10px 0;
}

.container { 
    padding: 20px; 
    max-width: 900px; 
    margin: auto; 
}

.terminal-box { 
    border: 1px solid var(--neon-blue); 
    padding: 30px; 
    background: rgba(0, 50, 50, 0.1); 
    box-shadow: inset 0 0 20px rgba(0, 243, 255, 0.05);
}

/* --- Viewport & Canvas --- */
.viewport {
    height: 450px; 
    border: 1px solid #222; 
    margin: 20px 0;
    background: radial-gradient(circle, #0a0a0f 0%, #000 100%);
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    position: relative;
    overflow: hidden;
}

canvas {
    display: block;
    max-width: 100%;
}

/* --- Scoreboard & Stats --- */
.scoreboard { display: flex; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.node { width: 48%; padding: 10px; border: 2px solid #222; background: #000; }
.pA { color: var(--neon-blue); border-color: var(--neon-blue); }
.pB { color: var(--neon-pink); border-color: var(--neon-pink); }

.stat-window { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    font-size: 13px; /* increased for readability */
    margin-top: 5px; 
    color: #ddd;
    gap: 6px;
}

.name { font-size: 1.3rem; font-weight: bold; margin: 5px 0; border-bottom: 1px solid #333; }

/* --- Buttons --- */
.cyber-btn {
    background: #000; 
    color: var(--neon-blue); 
    border: 1px solid var(--neon-blue);
    padding: 15px 40px; 
    cursor: pointer; 
    font-family: inherit; 
    font-weight: bold;
    letter-spacing: 2px;
}
.cyber-btn:hover { 
    background: var(--neon-blue); 
    color: #000; 
    box-shadow: 0 0 20px var(--neon-blue); 
}

/* --- Visual Modules --- */
.coin-grid {
    display: grid; 
    grid-template-columns: repeat(5, 1fr); 
    gap: 15px;
    justify-items: center;
    align-items: center;
}

.coin-wrap { perspective: 1000px; }

@keyframes coinJump {
    0% { transform: translateY(0) rotateX(0); }
    50% { transform: translateY(-100px) rotateX(720deg); }
    100% { transform: translateY(0) rotateX(1440deg); }
}

/* Use CSS transition for per-coin transforms so JS can set final rotation per coin */
.coin {
    transform-style: preserve-3d;
    transition: transform 3.2s cubic-bezier(0.1, 0, 0.2, 1);
}

.coin.flipping {
    /* flipping class used to trigger the transition; final transform is set inline by JS */
}

/* --- Wheel Pointer --- */
.wheel-container { position: relative; }
.wheel-pointer {
    position: absolute; 
    top: -20px; 
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0; 
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 25px solid var(--gold);
    z-index: 10;
}

/* Larger, high-contrast labels for wheel */
.wheel-label{
    background: rgba(255,255,255,0.95);
    padding: 6px 10px;
    border-radius: 6px;
    box-shadow: 0 0 12px rgba(0,0,0,0.6);
}

/* --- Result Sheet (Manifest) --- */
#result-sheet {
    background: rgba(5, 5, 15, 0.98);
    border: 2px solid var(--gold);
    box-shadow: 0 0 50px #000;
    color: #fff;
}

#result-sheet .stat-block { font-size: 1rem; }

/* --- Utility --- */
#terminal-log { 
    font-size: 12px; 
    color: #00ff41; 
    height: 60px; 
    overflow-y: hidden; 
    margin-top: 10px; 
    border-top: 1px solid #222; 
    padding-top: 5px;
}

.hidden { display: none !important; }

/* Dice Pulse Animation */
.dice-rolling {
    animation: dicePulse 0.4s infinite alternate;
}

@keyframes dicePulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.1); filter: brightness(1.5); }
}

.scanline {
    width: 100%; height: 2px; z-index: 100;
    background: rgba(0, 243, 255, 0.05);
    position: absolute; pointer-events: none; 
    animation: scan 4s linear infinite;
}
@keyframes scan { from { top: 0%; } to { top: 100%; } }

/* Stat animation glow */
@keyframes statGlow {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.15); filter: brightness(1.8) drop-shadow(0 0 8px currentColor); }
    100% { transform: scale(1); filter: brightness(1); }
}
.stat-animate {
    animation: statGlow 0.6s ease-out;
}

/* --- STAT UPDATE ANIMATIONS --- */

/* The 'vibrate' effect for when a stat is changing */
.stat-value.updating {
    color: #fff;
    text-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-blue);
    animation: stat-pulse 0.2s ease-in-out;
}

/* --- Overclock (Critical Stat Roll) --- */
.overclock-flash {
    color: #bf00ff !important; /* Cyber Purple */
    font-weight: 900;
    font-size: 1.15em; /* Makes text ~15% larger */
    text-shadow: 0 0 12px #bf00ff;
    /* Removed glitching, shaking, and gold color */
    transition: all 0.1s ease-in-out;
}

/* You can remove the @keyframes glitch-flash entirely as it's no longer used */

/* Ensure the stat containers can handle the scaling animation */
.stat-row span {
    display: inline-block;
    transition: color 0.2s;
}

/* Final Battle Winner Reveal */
.winner-card {
    animation: slide-in-top 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}

@keyframes slide-in-top {
    0% { transform: translate(-50%, -100%); opacity: 0; }
    100% { transform: translate(-50%, -50%); opacity: 1
}

}

/* Color Feedback for Stat Changes */
.stat-increase {
    color: #00ff88 !important; /* Bright Cyber Green */
    text-shadow: 0 0 10px #00ff88;
    transition: color 0.1s;
}

.stat-decrease {
    color: #ff3333 !important; /* Bright Cyber Red */
    text-shadow: 0 0 10px #ff3333;
    transition: color 0.1s;
}

/* Ensure the value returns to normal smoothly */
.stat-value {
    transition: color 0.8s ease-out, transform 0.2s;
    display: inline-block;
}

/* Color Feedback for Luckbattle */
.stat-increase {
    color: #00ff88 !important; /* Cyber Green */
    text-shadow: 0 0 15px #00ff88;
}

.stat-decrease {
    color: #ff3333 !important; /* Cyber Red */
    text-shadow: 0 0 15px #ff3333;
}

.stat-value {
    transition: color 0.6s ease-out; /* Fades color back to white slowly */
}

/* Pulse animation for updates */
.updating {
    animation: stat-pulse 0.3s ease-out;
}

@keyframes stat-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

#overload-hud {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.85);
    border-left: 4px solid var(--neon-blue);
    padding: 15px;
    font-family: 'Courier New', monospace;
    z-index: 1000;
    pointer-events: none;
    border-top-right-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.alert-title {
    color: var(--gold);
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 0.9rem;
    letter-spacing: 2px;
}

.hud-line {
    font-size: 1.2rem;
    font-weight: 900;
    margin: 4px 0;
}

.hud-line.boost {
    color: #bf00ff; /* The purple we set for Overclock */
    text-shadow: 0 0 10px #bf00ff;
}

.hud-line.corrupt {
    color: #ff3333;
    text-shadow: 0 0 10px #ff3333;
}


#coin-overlay {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    perspective: 1000px;
    z-index: 9999;
    pointer-events: none; /* Allows clicks to pass through to the game */
}

/* --- Sudden Death High-Intensity Shake --- */
@keyframes sudden-shake {
    0% { transform: translate(0, 0); }
    10% { transform: translate(-8px, -8px) rotate(-1deg); }
    20% { transform: translate(8px, 8px) rotate(1deg); }
    30% { transform: translate(-8px, 8px) rotate(-1deg); }
    40% { transform: translate(8px, -8px) rotate(1deg); }
    50% { transform: translate(-8px, -8px) rotate(-1deg); }
    100% { transform: translate(0, 0); }
}

.shake-heavy {
    animation: sudden-shake 0.1s infinite;
}

/* --- Red Flash for the viewport --- */
.danger-flash {
    box-shadow: inset 0 0 100px #ff0000 !important;
    border: 2px solid #ff0000 !important;
    transition: all 0.1s;
}

/* --- Large Sudden Death Coin --- */
.coin-large {
    width: 200px !important; /* Bigger than original coins */
    height: 200px !important;
    font-size: 1.4rem;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.coin-large .heads { 
    background: var(--gold) !important; 
    border: 6px solid #fff !important; 
    box-shadow: 0 0 30px var(--gold);
}

.coin-large .tails { 
    background: #e0e0e0 !important; 
    border: 6px solid #fff !important; 
    box-shadow: 0 0 30px #fff;
}

/* Add this to your Luckbattle CSS */
.thorns-glow {
    filter: drop-shadow(0 0 10px #00ff88) contrast(1.2);
    /* Optional: give it a slight "sharp" look */
}

.coin div {
    position: absolute;
    width: 100%; height: 100%;
    border-radius: 50%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border: 4px solid gold;
    box-shadow: 0 0 20px gold;
}

.heads { background: #ffd700; color: #000; }
.tails { background: #c0c0c0; color: #000; transform: rotateY(180deg); }