/* Cyberpunk 16-Bit Pixel Racing Style Guide for Eye-Controlled Car Dodger */

:root {
    --primary: #00f2fe;
    --secondary: #4facfe;
    --accent: #ef4444;
    --gold: #ffd700;
    --bg-dark: #000000;
    --panel-bg: rgba(6, 8, 16, 0.82);
    --border-glow: rgba(0, 242, 254, 0.2);
    --font: 'Press Start 2P', monospace, cursive;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font);
}

body {
    background-color: #000000;
    background: url('background.jpg') center center / cover no-repeat fixed;
    color: #ffffff;
    font-family: var(--font);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Gold Headings & Accents */
.gold-heading {
    color: #ffd700 !important;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Main Layout container */
#app-container {
    display: flex;
    flex-direction: row;
    gap: 24px;
    align-items: center;
    justify-content: center;
    position: relative;
    max-width: 1020px;
    width: 100%;
    margin: auto;
    padding: 12px;
    box-sizing: border-box;
}

/* Main Game screen layout */
#game-window-wrapper {
    position: relative;
    width: var(--game-width, 470px);
    height: var(--game-height, 630px);
    border-radius: 0px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.15);
    background-color: rgba(6, 8, 16, 0.82);
    flex-shrink: 0;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: #1c1d22;
}

/* Screens Overlaid on Canvas */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 8, 16, 0.88);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 0px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: safe center;
    align-items: center;
    padding: clamp(10px, 4cqw, 24px);
    overflow-y: auto;
    visibility: hidden;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform: scale(0.98);
    text-align: center;
}

.menu-overlay.active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

/* Typography & Visual Accents */
h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 12px;
    color: #ffd700;
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.3;
}

p.subtitle {
    font-size: 0.65rem;
    color: #ffffff;
    margin-bottom: 20px;
    line-height: 1.5;
}

h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.35);
    line-height: 1.3;
}

/* Cyber Button Styling */
.btn-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    max-width: 320px;
}

.cyber-btn {
    position: relative;
    padding: 14px 20px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.4;
    color: #ffffff;
    background: #000000;
    border: 2px solid var(--primary);
    border-radius: 0px;
    cursor: pointer;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.cyber-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.4s ease;
}

.cyber-btn:hover::before {
    left: 100%;
}

.cyber-btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #000000;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.4);
}

.cyber-btn.primary:hover {
    box-shadow: 0 4px 25px rgba(0, 242, 254, 0.7);
    transform: translateY(-2px);
}

.cyber-btn.secondary {
    border-color: #475569;
    color: #ffffff;
}

.cyber-btn.secondary:hover {
    border-color: #94a3b8;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

/* HUD Overlay on playing canvas */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    z-index: 5;
}

.hud-panel {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 0px;
    display: flex;
    flex-direction: column;
}

.hud-label {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffd700;
    margin-bottom: 4px;
}

.hud-val {
    font-size: 0.85rem;
    font-weight: 700;
    color: #ffffff;
}

/* Control Panel widget (Right sidebar) */
#control-sidebar {
    width: var(--game-width, 470px);
    height: var(--game-height, 630px);
    background: rgba(6, 8, 16, 0.82);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 0px;
    padding: 18px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.15);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    box-sizing: border-box;
    flex-shrink: 0;
}

#control-sidebar.in-game {
    justify-content: flex-start;
}

body[data-mode="HAND"] #control-sidebar.in-game #instructions-section {
    display: none;
}

body[data-mode="HAND"] #control-sidebar.in-game #webcam-preview-container {
    display: block;
    flex: 1;
    height: 100%;
    margin-top: 4px;
}

.panel-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffd700;
}

/* Badges styling */
.badge {
    padding: 4px 8px;
    border-radius: 0px;
    font-size: 0.55rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.keyboard {
    background: rgba(71, 85, 105, 0.4);
    border: 1px solid #475569;
    color: #ffffff;
}

.badge.hand {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid #10b981;
    color: #34d399;
}

/* Webcam Preview area */
#webcam-preview-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 0px;
    overflow: hidden;
    background: #000000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: none;
}

#webcam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    display: none;
}

#webcam-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Instructions section wrapper */
#instructions-section {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    flex: 1;
}

/* How to Play Container */
.how-to-play-container {
    background: rgba(255, 255, 255, 0.03);
    border-left: 3px solid #ffd700;
    padding: 12px 14px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.how-to-play-list {
    list-style-type: square;
    padding-left: 14px;
    color: #ffffff;
    font-size: 0.58rem;
    line-height: 1.7;
}

.how-to-play-list li {
    margin-bottom: 6px;
}

.how-to-play-list li strong {
    color: #ffd700;
}

/* Controls list display */
.keyboard-controls-guide {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.guide-title {
    font-size: 0.65rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.ctrl-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.6rem;
    color: #ffffff;
}

.key-cap {
    background: #111827;
    border: 1px solid #4b5563;
    border-radius: 0px;
    padding: 3px 8px;
    font-size: 0.55rem;
    font-weight: 700;
    color: #ffd700;
}

/* Keep the 470x630 game world intact; only scale its display. */
#play-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

#game-window-wrapper { container-type: inline-size; }
.menu-overlay > * { flex-shrink: 0; }
.menu-overlay h1 { font-size: clamp(0.85rem, 5cqw, 1.5rem); }
.menu-overlay h2 { font-size: clamp(0.8rem, 4.5cqw, 1.25rem); }
.menu-overlay .subtitle, .mode-help, #camera-status {
    font-size: clamp(0.5rem, 2.3cqw, 0.65rem);
    line-height: 1.6;
    margin-bottom: 12px;
}
.mode-help, #camera-status { color: var(--gold); }
.menu-overlay .cyber-btn {
    min-height: 44px;
    font-size: clamp(0.5rem, 2.5cqw, 0.72rem);
    padding: 10px;
}
.menu-overlay .btn-container { gap: 8px; }
.cyber-btn { touch-action: manipulation; }
.cyber-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: -4px; }
.cyber-btn:disabled { opacity: 0.5; cursor: default; }
.badge.touch { border: 1px solid var(--primary); color: var(--primary); }

#touch-controls {
    display: flex;
    gap: 8px;
    width: var(--game-width, 470px);
    height: 62px;
}
#touch-controls[hidden] { display: none; }
#touch-controls button {
    flex: 1;
    min-width: 0;
    min-height: 48px;
    padding: 8px 4px;
    font-size: 0.6rem;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}
#touch-controls button.pressed { background: var(--primary); color: #000; }
#gameCanvas { touch-action: none; }
body[data-mode="HAND"] #btn-steer-left,
body[data-mode="HAND"] #btn-steer-right { display: none; }
body[data-mode="HAND"] #btn-touch-pause { max-width: 180px; margin: auto; }

@media (max-width: 1000px) {
    body { align-items: flex-start; background-attachment: scroll; }
    #app-container { flex-direction: column; gap: 16px; }
    #control-sidebar { width: min(100%, 470px); height: auto; }
    #control-sidebar.in-game { display: none; }
    body[data-mode="HAND"] #control-sidebar.in-game { display: flex; }
    #control-sidebar.in-game #webcam-preview-container { flex: none; height: auto; aspect-ratio: 4 / 3; }
}

@media (max-height: 500px) and (orientation: landscape) {
    #play-area { flex-direction: row; }
    #touch-controls { flex-direction: column; width: 116px; height: var(--game-height); }
    #touch-controls button { flex: 1; }
    #touch-controls[hidden] { display: none; }
    #control-sidebar { display: none; }
    body[data-mode="HAND"] #control-sidebar.in-game { display: flex; }
    .menu-overlay .subtitle, .mode-help { margin-bottom: 8px; }
}

@media (max-width: 400px), (max-height: 500px) {
    #game-hud { padding: 6px; }
    .hud-panel { padding: 5px; }
    .hud-label { font-size: 0.45rem; }
    .hud-val { font-size: 0.55rem; }
}

#app-container {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    padding-left: calc(12px + env(safe-area-inset-left, 0px));
    padding-right: calc(12px + env(safe-area-inset-right, 0px));
}
