:root {
    --bg-gradient: linear-gradient(135deg, #0f172a, #1e293b);
    --text-color: #f8fafc;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --democratic: #10b981;
    --antidemocratic: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1000px;
    width: 100%;
    height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

header {
    text-align: center;
}

header h1 {
    font-size: 2.2rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(90deg, #10b981, #3b82f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
    margin-bottom: 0;
}

header p {
    color: #cbd5e1;
    font-size: 1rem;
    font-weight: 600;
}

.game-area {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 260px;
}

.panel-box {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
    text-align: center;
}

.panel-box h2, .panel-box h3 {
    margin-bottom: 15px;
    color: var(--text-color);
    font-weight: 800;
    text-transform: uppercase;
    font-size: 1.2rem;
    letter-spacing: 1px;
}

.score-box h2 {
    color: var(--accent);
}

#score {
    font-size: 3rem;
    font-weight: 800;
    text-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

.info-box p, .controls-box p {
    font-size: 0.95rem;
    line-height: 1.5;
    text-align: left;
    color: #e2e8f0;
}

.rule-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
    text-align: left;
}

.indicator {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-top: 4px;
    flex-shrink: 0;
}

.indicator.demo { background: var(--democratic); box-shadow: 0 0 10px var(--democratic); }
.indicator.anti { background: var(--antidemocratic); box-shadow: 0 0 10px var(--antidemocratic); }

.key-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 1rem;
    color: #e2e8f0;
}

.key-control span {
    background: rgba(255,255,255,0.1);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 1.1rem;
}

.canvas-container {
    position: relative;
    padding: 15px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 0 50px rgba(0,0,0,0.6);
}

canvas {
    background: rgba(0,0,0,0.8);
    border-radius: 6px;
    display: block;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.9);
}

#next-canvas {
    margin: 0 auto;
}

.value-label {
    margin-top: 15px;
    font-weight: 800;
    font-size: 1.1rem;
    padding: 8px;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.democratic-label {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--democratic);
    border: 1px solid rgba(16, 185, 129, 0.3);
    text-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.antidemocratic-label {
    background-color: rgba(239, 68, 68, 0.15);
    color: var(--antidemocratic);
    border: 1px solid rgba(239, 68, 68, 0.3);
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    z-index: 10;
    backdrop-filter: blur(5px);
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    color: var(--antidemocratic);
    font-size: 2.2rem;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
    text-transform: uppercase;
}

.overlay p {
    color: #e2e8f0;
    font-size: 1.1rem;
    text-align: center;
    max-width: 80%;
}

button {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px rgba(59, 130, 246, 0.4);
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(59, 130, 246, 0.6);
}

.toast {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 18px 35px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1.1rem;
    box-shadow: 0 15px 30px rgba(0,0,0,0.5);
    z-index: 100;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(50px);
    pointer-events: none;
}

.bncc-info {
    position: fixed;
    bottom: 15px;
    right: 20px;
    width: 300px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-align: right;
    line-height: 1.4;
    background: rgba(15, 23, 42, 0.6);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    z-index: 50;
}

.bncc-info strong {
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.system-failure {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.85);
    padding: 30px;
    border: 2px solid var(--antidemocratic);
    border-radius: 12px;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.6);
    max-width: 90%;
}

.system-failure p {
    color: #e2e8f0;
    font-size: 1.1rem;
    text-align: center;
    max-width: 100%;
}

.alert-icon {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: blink 1s infinite;
}

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

.glitch-text {
    color: white;
    font-size: 1.8rem;
    text-transform: uppercase;
    margin-bottom: 15px;
    position: relative;
    text-shadow: 2px 2px var(--antidemocratic), -2px -2px #3b82f6;
    animation: glitch-anim 0.2s infinite;
}

@keyframes glitch-anim {
    0% { transform: translate(0) }
    20% { transform: translate(-2px, 1px) }
    40% { transform: translate(2px, -1px) }
    60% { transform: translate(-1px, 2px) }
    80% { transform: translate(1px, -2px) }
    100% { transform: translate(0) }
}

.terminal-box {
    background: #000;
    color: #10b981;
    font-family: monospace;
    padding: 15px;
    border-radius: 6px;
    width: 100%;
    margin-bottom: 20px;
    text-align: left;
    border: 1px solid #333;
}

.terminal-box p {
    color: #10b981;
    font-size: 0.9rem;
    margin: 5px 0;
    text-align: left;
    line-height: 1.4;
}

.blink-cursor {
    animation: blink 1s infinite;
}

.glitch-effect {
    animation: canvas-glitch 0.3s forwards;
    filter: sepia(1) hue-rotate(300deg) saturate(5);
}

@keyframes canvas-glitch {
    0% { transform: skewX(0deg); }
    25% { transform: skewX(10deg) translate(-10px, 10px); }
    50% { transform: skewX(-10deg) translate(10px, -10px); }
    75% { transform: skewX(5deg) translate(-5px, 5px); }
    100% { transform: skewX(0deg) translate(0, 0); }
}
