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

body {
    background-color: #050811;
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(6, 182, 212, 0.12) 0%, transparent 60%),
        linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 100% 100%, 32px 32px, 32px 32px;
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "HarmonyOS Sans SC", sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px 12px;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Console Chassis */
.console-body {
    width: 100%;
    max-width: 420px;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 3px solid #334155;
    border-radius: 36px 36px 48px 48px;
    padding: 20px 22px 28px;
    box-shadow: 
        0 25px 60px -15px rgba(0, 0, 0, 0.9),
        0 0 0 1px rgba(255, 255, 255, 0.08),
        inset 0 2px 4px rgba(255, 255, 255, 0.15),
        inset 0 -4px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Top Bezel */
.console-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding: 0 4px;
}

.power-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
}

.power-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #06b6d4;
    box-shadow: 0 0 8px #06b6d4, 0 0 12px rgba(6, 182, 212, 0.6);
    animation: ledPulse 2s infinite ease-in-out;
}

@keyframes ledPulse {
    0%, 100% { opacity: 0.85; }
    50% { opacity: 1; filter: brightness(1.2); }
}

.power-label {
    font-size: 9px;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.08em;
}

.console-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.brand-name {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 0.12em;
    color: #94a3b8;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.brand-model {
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.16em;
    color: #06b6d4;
}

.console-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 4px 10px;
    border-radius: 12px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
    transition: all 0.15s ease;
}

.console-back-btn:hover {
    background: #1e293b;
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.25);
}

/* Screen Bezel */
.console-screen-bezel {
    background: #080d19;
    border-radius: 18px 18px 24px 24px;
    padding: 12px 14px 16px;
    border: 2px solid #1e293b;
    box-shadow: 
        inset 0 4px 12px rgba(0, 0, 0, 0.8),
        0 2px 4px rgba(255, 255, 255, 0.05);
    position: relative;
    margin-bottom: 22px;
}

.screen-hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 4px;
}

.hud-item {
    display: flex;
    flex-direction: column;
}

.hud-tag {
    font-size: 9px;
    font-weight: 800;
    color: #475569;
    letter-spacing: 0.08em;
}

.hud-val {
    font-size: 15px;
    font-weight: 800;
    color: #38bdf8;
    font-family: 'Courier New', Courier, monospace;
}

.hud-val.high {
    color: #f59e0b;
}

.hud-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #64748b;
}

.canvas-viewport {
    position: relative;
    width: 100%;
    max-height: 400px;
    display: flex;
    justify-content: center;
    background: #050811;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.9);
}

canvas {
    height: 380px;
    width: auto;
    aspect-ratio: 1 / 2;
    display: block;
    background: #020617;
    touch-action: none;
}

/* In-Screen Overlay */
.screen-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 17, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.screen-overlay.hidden {
    display: none;
}

.pause-overlay {
    position: absolute;
    inset: 0;
    background: rgba(5, 8, 17, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9;
    pointer-events: none;
}

.pause-overlay.hidden {
    display: none;
}

.pause-label {
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 0.32em;
    color: #67e8f9;
    text-shadow: 0 0 12px rgba(103, 232, 249, 0.75);
    animation: pauseBlink 1.4s infinite steps(2, end);
}

@keyframes pauseBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.modal-plate {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 14px;
    padding: 20px 24px;
    text-align: center;
    max-width: 240px;
    width: 85%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.modal-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(6, 182, 212, 0.18);
    color: #06b6d4;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.modal-line {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.val-current {
    color: #38bdf8;
    font-weight: 800;
}

.val-best {
    color: #f59e0b;
    font-weight: 800;
}

.modal-button-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.plate-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: block;
}

.plate-btn.primary {
    background: #06b6d4;
    color: #ffffff;
    box-shadow: 0 3px 10px rgba(6, 182, 212, 0.35);
}

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

.plate-btn.secondary {
    background: #1e293b;
    color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Controls Panel */
.controls-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 10px 10px;
    margin-bottom: 16px;
    user-select: none;
    -webkit-user-select: none;
}

/* D-Pad */
.dpad-plate {
    width: 136px;
    height: 136px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dpad-key {
    width: 44px;
    height: 44px;
    background: linear-gradient(180deg, #334155 0%, #1e293b 100%);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.2);
    touch-action: none;
    transition: transform 0.06s ease, background 0.06s ease;
}

.dpad-key svg,
.round-action-btn *,
.chassis-pill-btn * {
    pointer-events: none;
}

.dpad-key.up {
    border-radius: 10px 10px 0 0;
}

.dpad-key.down {
    border-radius: 0 0 10px 10px;
}

.dpad-key.left {
    border-radius: 10px 0 0 10px;
}

.dpad-key.right {
    border-radius: 0 10px 10px 0;
}

.dpad-h-row {
    display: flex;
    width: 132px;
    justify-content: space-between;
    align-items: center;
}

.dpad-pivot {
    width: 44px;
    height: 44px;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(0, 0, 0, 0.4);
}

.dpad-key:active,
.dpad-key.pressed {
    transform: scale(0.92);
    background: #475569;
    color: #ffffff;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

/* Action Buttons (A / B) */
.actions-cluster {
    display: flex;
    gap: 16px;
    transform: rotate(-15deg);
    padding-top: 12px;
}

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

.round-action-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
    color: #ffffff;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5), inset 0 2px 3px rgba(255, 255, 255, 0.35);
    touch-action: manipulation;
    transition: transform 0.06s ease, filter 0.06s ease;
}

.round-action-btn:active,
.round-action-btn.pressed {
    transform: translateY(3px) scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), inset 0 3px 5px rgba(0, 0, 0, 0.6);
    filter: brightness(0.9);
}

.btn-b {
    background: linear-gradient(180deg, #f59e0b 0%, #b45309 100%);
}

.btn-a {
    background: linear-gradient(180deg, #8b5cf6 0%, #6d28d9 100%);
    margin-top: -12px;
}

.btn-caption {
    font-size: 9px;
    font-weight: 800;
    color: #475569;
    letter-spacing: 0.06em;
}

/* Lower Chassis (Start / Select / Speaker) */
.console-lower-chassis {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 10px;
    user-select: none;
    -webkit-user-select: none;
}

.system-buttons {
    display: flex;
    gap: 14px;
}

.pill-btn-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transform: rotate(-25deg);
}

.chassis-pill-btn {
    width: 34px;
    height: 10px;
    background: #334155;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
    touch-action: manipulation;
}

.chassis-pill-btn:active,
.chassis-pill-btn.pressed {
    transform: scale(0.92);
    background: #1e293b;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7);
}

.pill-label {
    font-size: 8px;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.08em;
}

.speaker-grille {
    display: flex;
    gap: 5px;
    transform: rotate(-30deg);
}

.speaker-slot {
    width: 5px;
    height: 32px;
    background: #080d19;
    border-radius: 3px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.9), 0 1px 1px rgba(255, 255, 255, 0.06);
}

@media (max-width: 480px) {
    body {
        padding: 8px 6px;
    }
    .console-body {
        border-radius: 28px;
        padding: 14px 14px 22px;
    }
    .canvas-viewport {
        max-height: 340px;
    }
    canvas {
        height: 320px;
    }
    .dpad-plate {
        width: 110px;
        height: 110px;
    }
    .dpad-key {
        width: 34px;
        height: 34px;
    }
    .dpad-h-row {
        width: 102px;
    }
    .dpad-pivot {
        width: 34px;
        height: 34px;
    }
    .round-action-btn {
        width: 44px;
        height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .power-led,
    .pause-label {
        animation: none;
    }
}
