* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    width: 100%;
    height: 100vh;
    font-family: 'Courier New', monospace;
    overflow: hidden;
    background: #000;
    color: #00ffcc;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    color: #00ffcc;
    font-family: 'Courier New', monospace;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 3px solid #00ffcc;
    border-top-color: transparent;
    border-radius: 50%;
    margin: 0 auto 30px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-content h2 {
    font-size: 24px;
    margin-bottom: 15px;
    letter-spacing: 2px;
    text-shadow: 0 0 10px #00ffcc;
}

.loading-content p {
    font-size: 14px;
    opacity: 0.8;
    letter-spacing: 1px;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 0.3; }
}

/* Error Screen */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a0000;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.error-screen.active {
    display: flex;
}

.error-content {
    text-align: center;
    color: #ff0055;
    font-family: 'Courier New', monospace;
    max-width: 600px;
    padding: 40px;
    border: 2px solid #ff0055;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.5);
}

.error-content h2 {
    font-size: 22px;
    margin-bottom: 20px;
    letter-spacing: 1px;
    text-shadow: 0 0 10px #ff0055;
}

.error-content p {
    font-size: 14px;
    margin-bottom: 20px;
    opacity: 0.9;
}

.error-steps {
    text-align: left;
    background: rgba(255, 0, 85, 0.1);
    padding: 20px;
    border-radius: 5px;
    margin: 20px 0;
}

.error-steps h3 {
    color: #ffff00;
    margin-bottom: 10px;
    text-shadow: 0 0 5px #ffff00;
}

.error-steps ol {
    margin-left: 20px;
    font-size: 13px;
    line-height: 1.8;
}

.error-steps li {
    margin-bottom: 8px;
    opacity: 0.9;
}

.retry-btn {
    background: #ff0055;
    color: #000;
    border: none;
    padding: 12px 30px;
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 1px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    margin-top: 20px;
}

.retry-btn:hover {
    background: #ff6699;
    box-shadow: 0 0 15px rgba(255, 0, 85, 0.6);
    transform: scale(1.05);
}

.retry-btn:active {
    transform: scale(0.95);
}

/* HUD Styling - Minimalist Design */
.hud-minimal {
    position: fixed;
    top: 40px;
    left: 40px;
    font-family: 'Courier New', monospace;
    color: #00ffcc;
    z-index: 100;
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.hud-accent-line {
    width: 3px;
    height: 120px;
    background: linear-gradient(180deg, #00ffcc 0%, rgba(0, 255, 204, 0.3) 100%);
    box-shadow: 0 0 15px #00ffcc;
}

.hud-top {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 10px;
}

.hud-credits {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.6;
    font-weight: bold;
}

.hud-system-label {
    font-size: 12px;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.8;
    color: #00ffcc;
}

.hud-mode {
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 3px;
    color: #00ffcc;
    text-shadow: 0 0 10px #00ffcc, 0 0 20px rgba(0, 255, 204, 0.5);
}

.hud-bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 300px;
    z-index: 100;
    text-align: left;
}

.hud-bottom-right {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 300px;
    z-index: 100;
    text-align: left;
}

.bio-panel {
    background: rgba(0, 15, 20, 0.85);
    border: 1px solid #00ffcc;
    padding: 15px;
    font-family: 'Courier New', monospace;
    color: #00ffcc;
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.2);
    backdrop-filter: blur(4px);
}

.bio-header {
    font-size: 14px;
    font-weight: bold;
    border-bottom: 2px solid #00ffcc;
    padding-bottom: 8px;
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.bio-row {
    font-size: 11px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    opacity: 0.9;
}

.bio-value {
    font-weight: bold;
    color: #ccfffa;
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.5);
}

.bio-separator {
    height: 1px;
    background: rgba(0, 255, 204, 0.3);
    margin: 8px 0;
}

.bio-title {
    font-size: 10px;
    opacity: 0.7;
    margin-bottom: 4px;
}

.bio-codes {
    font-size: 10px;
    opacity: 0.6;
    line-height: 1.4;
    font-family: monospace;
}

.hud-emotion {
    font-size: 14px;
    font-weight: bold;
    color: #00ffcc;
    margin-top: 8px;
    min-height: 20px;
}

.hud-status-details {
    font-size: 11px;
    line-height: 1.6;
    color: #00ffcc;
    opacity: 0.9;
    white-space: pre-wrap;
    word-break: break-word;
    background: transparent;
    border: none;
    padding: 5px 0;
    border-radius: 0;
    backdrop-filter: none;
}

.hud-gesture-details {
    font-size: 10px;
    line-height: 1.6;
    color: #00ffcc;
    opacity: 0.7;
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    background: transparent;
    border: none;
    padding: 0;
    border-radius: 0;
    backdrop-filter: none;
}

/* Instruction Overlay - Centered at Bottom */
.instruction-overlay {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
}

.instruction-text {
    padding: 20px 40px;
    border: 2px solid #00ffcc;
    background: rgba(0, 0, 0, 0.9);
    color: #00ffcc;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    letter-spacing: 1px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.4);
    animation: pulse-instruction 2s infinite;
}

@keyframes pulse-instruction {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 20px rgba(0, 255, 204, 0.4);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 30px rgba(0, 255, 204, 0.6);
    }
}

/* Magic Loader */
.magic-loader {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 20px;
    border: 2px solid #ea7023;
    background: rgba(0, 0, 0, 0.8);
    z-index: 100;
}

.magic-loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ea7023, #ffaa00);
    transition: width 0.1s linear;
    box-shadow: 0 0 10px #ea7023;
}

/* Mode-specific Styling */
body.mode-passive {
    background: #000;
}

body.mode-passive .hud-accent-line {
    background: linear-gradient(180deg, #00ffcc 0%, rgba(0, 255, 204, 0.3) 100%);
    box-shadow: 0 0 15px #00ffcc;
}

body.mode-passive .hud-mode,
body.mode-passive .hud-system-label,
body.mode-passive .hud-credits,
body.mode-passive .instruction-text {
    color: #00ffcc;
    text-shadow: 0 0 10px #00ffcc;
}

body.mode-passive .instruction-text {
    border-color: #00ffcc;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.4);
}

body.mode-active {
    background: #1a0000;
}

body.mode-active .hud-accent-line {
    background: linear-gradient(180deg, #ff0055 0%, rgba(255, 0, 85, 0.3) 100%);
    box-shadow: 0 0 15px #ff0055;
}

body.mode-active .hud-mode,
body.mode-active .hud-system-label,
body.mode-active .hud-credits,
body.mode-active .instruction-text {
    color: #ff0055;
    text-shadow: 0 0 10px #ff0055;
}

body.mode-active .instruction-text {
    border-color: #ff0055;
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
}

body.mode-magic {
    background: #2a1a00;
}

body.mode-magic .hud-accent-line {
    background: linear-gradient(180deg, #ea7023 0%, rgba(234, 112, 35, 0.3) 100%);
    box-shadow: 0 0 15px #ea7023;
}

body.mode-magic .hud-mode,
body.mode-magic .hud-system-label,
body.mode-magic .hud-credits,
body.mode-magic .instruction-text {
    color: #ea7023;
    text-shadow: 0 0 10px #ea7023;
}

body.mode-magic .instruction-text {
    border-color: #ea7023;
    box-shadow: 0 0 20px rgba(234, 112, 35, 0.4);
}

body.mode-magic .magic-loader {
    border-color: #ea7023;
}

body.mode-love {
    background: #2a0a1a;
}

body.mode-love .hud-accent-line {
    background: linear-gradient(180deg, #ff0066 0%, rgba(255, 0, 102, 0.3) 100%);
    box-shadow: 0 0 15px #ff0066;
}

body.mode-love .hud-mode,
body.mode-love .hud-system-label,
body.mode-love .hud-credits,
body.mode-love .instruction-text {
    color: #ff0066;
    text-shadow: 0 0 10px #ff0066;
}

body.mode-love .instruction-text {
    border-color: #ff0066;
    box-shadow: 0 0 20px rgba(255, 0, 102, 0.4);
}

body.mode-lightning {
    background: #1a0033; /* Dark Violet */
}

body.mode-lightning .hud-accent-line {
    background: linear-gradient(180deg, #b300ff 0%, rgba(179, 0, 255, 0.3) 100%);
    box-shadow: 0 0 15px #b300ff;
}

body.mode-lightning .hud-mode,
body.mode-lightning .hud-system-label,
body.mode-lightning .hud-credits,
body.mode-lightning .instruction-text {
    color: #b300ff;
    text-shadow: 0 0 10px #b300ff;
}

body.mode-lightning .instruction-text {
    border-color: #b300ff;
    box-shadow: 0 0 20px rgba(179, 0, 255, 0.4);
}

body.mode-bubble {
    background: #001a33; /* Dark Blue */
}

body.mode-bubble .hud-accent-line {
    background: linear-gradient(180deg, #00ffff 0%, rgba(0, 255, 255, 0.3) 100%);
    box-shadow: 0 0 15px #00ffff;
}

body.mode-bubble .hud-mode,
body.mode-bubble .hud-system-label,
body.mode-bubble .hud-credits,
body.mode-bubble .instruction-text {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

body.mode-bubble .instruction-text {
    border-color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.4);
}

/* Animations */
@keyframes glow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(0, 255, 204, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 15px rgba(0, 255, 204, 0.8));
    }
}

/* Debug Panel */
.debug-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    background: rgba(0, 15, 20, 0.9);
    border: 1px solid #ffff00;
    padding: 15px;
    font-family: 'Courier New', monospace;
    color: #ffff00;
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.3);
    backdrop-filter: blur(5px);
    z-index: 1500;
    display: none; /* Hidden by default */
}

.debug-panel.active {
    display: block;
}

.debug-header {
    font-size: 16px;
    font-weight: bold;
    border-bottom: 2px solid #ffff00;
    padding-bottom: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.debug-section h3 {
    font-size: 14px;
    color: #00ffcc;
    margin-bottom: 10px;
}

.debug-row {
    display: grid;
    grid-template-columns: 100px 1fr 40px;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 12px;
}

.debug-row label {
    opacity: 0.8;
}

.debug-row span {
    text-align: right;
    font-weight: bold;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 4px;
    background: rgba(255, 255, 0, 0.3);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 8px;
    background: #ffff00;
    margin-top: -6px;
    cursor: pointer;
}

canvas {
    animation: glow 3s ease-in-out infinite;
}

/* Tutorial Button */
.tutorial-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid #00ffcc;
    background: rgba(0, 0, 0, 0.8);
    color: #00ffcc;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 99;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
}

.tutorial-btn:hover {
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.8);
    transform: scale(1.1);
}

.tutorial-btn:active {
    transform: scale(0.95);
}

/* Tutorial Modal */
.tutorial-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    overflow-y: auto;
    animation: fadeIn 0.3s ease;
}

.tutorial-modal.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tutorial-content {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 30px;
    color: #00ffcc;
    font-family: 'Courier New', monospace;
}

.close-btn {
    position: fixed;
    top: 20px;
    right: 30px;
    background: none;
    border: 2px solid #00ffcc;
    color: #00ffcc;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: all 0.2s ease;
    border-radius: 50%;
}

.close-btn:hover {
    background: rgba(0, 255, 204, 0.1);
    box-shadow: 0 0 15px rgba(0, 255, 204, 0.6);
}

.tutorial-title {
    font-size: 32px;
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 0 0 10px #00ffcc;
    letter-spacing: 2px;
    border-bottom: 2px solid #00ffcc;
    padding-bottom: 20px;
}

.tutorial-section {
    margin-bottom: 40px;
    padding: 20px;
    border-left: 3px solid #00ffcc;
    background: rgba(0, 255, 204, 0.05);
}

.tutorial-section h2 {
    font-size: 22px;
    margin-bottom: 15px;
    text-shadow: 0 0 5px #00ffcc;
    letter-spacing: 1px;
}

.tutorial-section p {
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 10px;
    opacity: 0.9;
}

.tutorial-section ul,
.tutorial-section ol {
    margin-left: 20px;
    font-size: 14px;
    line-height: 1.8;
}

.tutorial-section li {
    margin-bottom: 10px;
    opacity: 0.9;
}

.tutorial-section strong {
    color: #ffff00;
    text-shadow: 0 0 5px #ffff00;
}

/* Gesture Guide */
.gesture-guide {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.gesture-item {
    background: rgba(0, 255, 204, 0.1);
    border: 1px solid #00ffcc;
    padding: 15px;
    border-radius: 5px;
    transition: all 0.2s ease;
}

.gesture-item:hover {
    background: rgba(0, 255, 204, 0.15);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.4);
    transform: translateY(-2px);
}

.gesture-name {
    font-size: 18px;
    font-weight: bold;
    color: #ffff00;
    margin-bottom: 8px;
    text-shadow: 0 0 5px #ffff00;
}

.gesture-desc {
    font-size: 12px;
    color: #00ffcc;
    margin-bottom: 8px;
    opacity: 0.8;
}

.gesture-effect {
    font-size: 12px;
    color: #ff88ff;
    font-style: italic;
    padding-top: 8px;
    border-top: 1px dashed #00ffcc;
}

/* Scrollbar styling for tutorial */
.tutorial-modal::-webkit-scrollbar {
    width: 10px;
}

.tutorial-modal::-webkit-scrollbar-track {
    background: rgba(0, 255, 204, 0.1);
}

.tutorial-modal::-webkit-scrollbar-thumb {
    background: #00ffcc;
    border-radius: 5px;
}

.tutorial-modal::-webkit-scrollbar-thumb:hover {
    background: #00ffff;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.6);
}

.blink-text {
    animation: blink-anim 1s infinite;
}

@keyframes blink-anim {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
