/* NES Famicom Retro Style */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: #121216;
    color: #fcfcfc;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 16px;
    overflow-x: hidden;
}

/* Famicom TV Console Container */
.console-wrapper {
    background: linear-gradient(145deg, #d8d4c8, #ece8dc);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 720px;
    width: 100%;
    border: 4px solid #b41824; /* Famicom Dark Red */
}

/* Console Header */
.console-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 8px;
}

.console-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.famicom-badge {
    background: #b41824;
    color: #ffd700;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: bold;
    border-radius: 4px;
    letter-spacing: 1px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.console-title {
    color: #333333;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
}

.head-toggle-btn {
    background: #242424;
    color: #00fcfc;
    border: 2px solid #00fcfc;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 10px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.head-toggle-btn:hover {
    background: #00fcfc;
    color: #000;
}

/* CRT Screen Frame */
.crt-frame {
    background: #000000;
    border-radius: 12px;
    padding: 12px;
    box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.9), 0 4px 10px rgba(0,0,0,0.5);
    border: 6px solid #202020;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

canvas#gameCanvas {
    width: 512px;
    height: 480px;
    max-width: 100%;
    aspect-ratio: 512 / 480;
    background: #008800;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 4px;
}

/* Controller / Virtual Gamepad */
.controller-panel {
    width: 100%;
    margin-top: 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #2a2a2a;
    padding: 16px 20px;
    border-radius: 10px;
    border: 2px solid #444;
}

/* Virtual D-Pad */
.dpad {
    position: relative;
    width: 108px;
    height: 108px;
}

.dpad-btn {
    position: absolute;
    background: #111;
    border: 2px solid #555;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
    transition: background 0.1s;
}

.dpad-btn:active {
    background: #444;
    color: #fff;
}

.dpad-up { top: 0; left: 36px; width: 36px; height: 36px; }
.dpad-down { bottom: 0; left: 36px; width: 36px; height: 36px; }
.dpad-left { top: 36px; left: 0; width: 36px; height: 36px; }
.dpad-right { top: 36px; right: 0; width: 36px; height: 36px; }
.dpad-center { top: 36px; left: 36px; width: 36px; height: 36px; background: #222; border: none; cursor: default; }

/* Middle Action Buttons (Select / Start) */
.middle-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.capsule-btn {
    background: #555;
    color: #ddd;
    border: none;
    border-radius: 14px;
    padding: 6px 14px;
    font-size: 9px;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.capsule-btn:active {
    background: #888;
}

/* Action Buttons (A & B) */
.action-buttons {
    display: flex;
    gap: 16px;
}

.round-btn-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.round-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #b41824; /* Red button */
    border: 3px solid #840e17;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5), inset 0 2px 3px rgba(255,255,255,0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.05s, box-shadow 0.05s;
}

.round-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 3px rgba(0,0,0,0.5);
    background: #90101b;
}

.round-btn-label {
    font-size: 10px;
    color: #aaa;
    font-weight: bold;
}

/* Keyboard Guide */
.key-hints {
    margin-top: 14px;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    color: #555;
    font-size: 10px;
    line-height: 1.6;
}

.key-tag {
    background: #333;
    color: #ffd700;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #555;
}

@media (max-width: 600px) {
    .console-wrapper {
        padding: 12px;
    }
    .controller-panel {
        padding: 10px;
    }
    .dpad {
        width: 90px;
        height: 90px;
    }
    .dpad-up, .dpad-down, .dpad-left, .dpad-right, .dpad-center {
        width: 30px;
        height: 30px;
    }
    .dpad-up { left: 30px; }
    .dpad-down { left: 30px; }
    .dpad-left { top: 30px; }
    .dpad-right { top: 30px; }
    .dpad-center { top: 30px; left: 30px; }
    .round-btn {
        width: 42px;
        height: 42px;
    }
}
