@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@500;600;700&family=Inter:wght@300;400;500;700&display=swap');

/* Reset and Core Variables */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

:root {
    --bg-dark: #07040f;
    --bg-surface: rgba(18, 12, 36, 0.7);
    --bg-surface-solid: #120c24;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(255, 255, 255, 0.25);
    
    /* Neon Colors */
    --neon-blue: #05d9e8;
    --neon-purple: #b026ff;
    --neon-green: #39ff14;
    --neon-yellow: #f5ee30;
    --neon-red: #ff2a5f;
    --neon-orange: #ff5f1f;
    --neon-pink: #ff007f;
    --neon-cyan: #00ffff;
    
    --glow-blue: 0 0 12px rgba(5, 217, 232, 0.6), 0 0 24px rgba(5, 217, 232, 0.2);
    --glow-green: 0 0 12px rgba(57, 255, 20, 0.6), 0 0 24px rgba(57, 255, 20, 0.2);
    --glow-purple: 0 0 12px rgba(176, 38, 255, 0.6), 0 0 24px rgba(176, 38, 255, 0.2);
    --glow-yellow: 0 0 12px rgba(245, 238, 48, 0.6), 0 0 24px rgba(245, 238, 48, 0.2);
    --glow-red: 0 0 12px rgba(255, 42, 95, 0.6), 0 0 24px rgba(255, 42, 95, 0.2);

    --font-heading: 'Orbitron', sans-serif;
    --font-sub: 'Rajdhani', sans-serif;
    --font-body: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(176, 38, 255, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(5, 217, 232, 0.15) 0%, transparent 40%),
        linear-gradient(rgba(255, 255, 255, 0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.01) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 40px 40px, 40px 40px;
    font-family: var(--font-body);
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    padding: 20px;
}

/* CRT monitor lines for retro gamified feel */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 9999;
    pointer-events: none;
    opacity: 0.3;
}

/* App Core Container */
.app-container {
    width: 100%;
    max-width: 1200px;
    min-height: 750px;
    background: var(--bg-surface);
    border: 2px solid rgba(255, 255, 255, 0.05);
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.8),
        0 0 30px rgba(176, 38, 255, 0.05);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Canvas Celebration overlay */
#celebration-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Header design */
.app-header {
    padding: 24px 40px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(10, 6, 22, 0.4);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    fill: var(--neon-blue);
    filter: drop-shadow(0 0 5px var(--neon-blue));
    animation: rotateLogo 8s linear infinite;
}

.logo-text {
    font-family: var(--font-heading);
    font-weight: 900;
    font-size: 1.8rem;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 10px rgba(5, 217, 232, 0.3));
    cursor: pointer;
}

.system-status {
    font-family: var(--font-sub);
    font-size: 0.95rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--neon-green);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(57, 255, 20, 0.6);
    animation: pulse 1.5s infinite;
}

/* Action Buttons style */
.btn-primary {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 900;
    padding: 16px 40px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    color: #fff;
    cursor: pointer;
    box-shadow: var(--glow-blue);
    letter-spacing: 2px;
    text-transform: uppercase;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 30%;
    height: 200%;
    background: rgba(255, 255, 255, 0.15);
    transform: rotate(30deg);
    transition: all 0.5s;
}

.btn-primary:hover::after {
    left: 140%;
}

.btn-primary:hover:not(:disabled) {
    transform: scale(1.03);
    box-shadow: 0 0 25px rgba(5, 217, 232, 0.5), 0 0 15px rgba(176, 38, 255, 0.5);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    font-family: var(--font-sub);
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 28px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: #94a3b8;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-secondary:hover {
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

/* Screen Wrapper */
.screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 40px;
    animation: slideIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Playground General Layout */
.playground-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 30px;
    flex: 1;
}

.game-stage-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px;
    position: relative;
    min-height: 480px;
}

.stage-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
}

.active-turn-announcer {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.active-turn-announcer span {
    color: var(--active-player-color, var(--neon-blue));
    text-shadow: 0 0 8px var(--active-player-color, rgba(5, 217, 232, 0.3));
}

/* Sidebar Panel */
.sidebar-panel {
    background: rgba(18, 12, 36, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar-header h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: #fff;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.game-panel-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar for sidebars */
.game-panel-list::-webkit-scrollbar {
    width: 6px;
}
.game-panel-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 3px;
}
.game-panel-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
.game-panel-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.player-panel-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s ease;
    border-left: 4px solid var(--player-color, #777);
}

.player-panel-card.active {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--player-color);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.03);
    animation: pulseBorder 1.5s infiniteAlternate;
}

.panel-card-avatar {
    width: 36px;
    height: 36px;
    fill: var(--player-color, #777);
    filter: drop-shadow(0 0 3px var(--player-color));
}

.panel-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.panel-card-name {
    font-family: var(--font-sub);
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.panel-card-score {
    font-size: 0.8rem;
    color: #94a3b8;
}

.panel-card-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: transparent;
}

.player-panel-card.active .panel-card-indicator {
    background-color: var(--player-color);
    box-shadow: 0 0 8px var(--player-color);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Winner Overlay Modal */
.winner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 4, 15, 0.85);
    backdrop-filter: blur(8px);
    z-index: 900;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px;
    animation: fadeIn 0.3s forwards;
}

.winner-card {
    background: rgba(18, 12, 36, 0.95);
    border: 2px solid var(--winner-color, var(--neon-blue));
    box-shadow: 0 0 30px var(--winner-color, rgba(5, 217, 232, 0.4));
    border-radius: 20px;
    padding: 40px;
    max-width: 480px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transform: scale(0.9);
    animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.winner-avatar {
    width: 80px;
    height: 80px;
    fill: var(--winner-color, var(--neon-blue));
    filter: drop-shadow(0 0 8px var(--winner-color));
}

.winner-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #fff;
}

.winner-name {
    font-family: var(--font-sub);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--winner-color, var(--neon-blue));
    text-shadow: 0 0 6px var(--winner-color);
}

.winner-desc {
    font-size: 0.95rem;
    color: #94a3b8;
    line-height: 1.5;
}

/* Animations */
@keyframes rotateLogo {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0.8; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseBorder {
    0% { border-color: rgba(255, 255, 255, 0.1); }
    100% { border-color: var(--player-color); }
}

@keyframes slideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

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

@keyframes scaleUp {
    to { transform: scale(1); }
}

/* Simulation Tip Box */
.simulation-tip-box {
    margin-top: 15px;
    padding: 10px 16px;
    background: rgba(18, 12, 36, 0.45);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 500px;
    box-sizing: border-box;
}

.tip-label {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--neon-yellow);
    text-shadow: 0 0 6px rgba(245, 238, 48, 0.4);
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.tip-text {
    font-family: var(--font-body);
    color: #94a3b8;
}

@media(max-width: 900px) {
    .playground-container {
        grid-template-columns: 1fr;
    }
}
@media(max-width: 600px) {
    .screen {
        padding: 20px;
    }
    .app-header {
        padding: 16px 20px;
    }
}
