/* Neon Maze Escape — Cyber Labyrinth Styling & Mobile Layout */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: radial-gradient(circle at center, #0f172a 0%, #020617 100%);
    color: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

/* Container wrapper with bottom clearance for outer bottom ad */
.game-wrapper {
    width: 100%;
    max-width: 480px;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 8px 10px 65px; /* 65px ensures bottom ad never covers controls */
}

/* Top HUD */
.game-hud {
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(56, 189, 248, 0.2);
    border-radius: 14px;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.hud-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 2px 8px;
    min-width: 54px;
}

.hud-label {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    color: #94a3b8;
}

.hud-val {
    font-size: 1.05rem;
    font-weight: 900;
    color: #38bdf8;
    line-height: 1.2;
}

.timer-card .hud-val {
    color: #f59e0b;
}

.best-card .hud-val {
    color: #10b981;
}

.hud-controls {
    display: flex;
    gap: 4px;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(56, 189, 248, 0.3);
    color: #f8fafc;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(56, 189, 248, 0.2);
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    width: 100%;
    position: relative;
    border-radius: 16px;
    background: #020617;
    border: 2px solid rgba(56, 189, 248, 0.3);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8), 0 8px 32px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    touch-action: none;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

/* Virtual D-Pad for Mobile Touch */
.virtual-dpad {
    position: absolute;
    bottom: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 20;
    opacity: 0.75;
    transition: opacity 0.2s;
}

.virtual-dpad:hover,
.virtual-dpad:active {
    opacity: 1;
}

.dpad-middle {
    display: flex;
    align-items: center;
    gap: 3px;
}

.dpad-center {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(56, 189, 248, 0.5);
    font-size: 0.8rem;
}

.dpad-btn {
    width: 44px;
    height: 44px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    border-radius: 10px;
    color: #38bdf8;
    font-size: 1.1rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s, background 0.1s;
}

.dpad-btn:active {
    transform: scale(0.92);
    background: rgba(56, 189, 248, 0.35);
    color: white;
}

/* Swipe Hint */
.swipe-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.4);
    padding: 8px 16px;
    border-radius: 20px;
    color: #38bdf8;
    font-weight: 700;
    font-size: 0.85rem;
    pointer-events: none;
    transition: opacity 0.4s;
    animation: pulse-hint 1.5s infinite;
}

@keyframes pulse-hint {
    0%, 100% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.98); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); }
}

.swipe-hint.hidden {
    animation: none;
    opacity: 0 !important;
    pointer-events: none;
    visibility: hidden;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    padding: 16px;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: #0f172a;
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 18px;
    width: 100%;
    max-width: 330px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
    transform: scale(0.92);
    transition: transform 0.25s ease;
}

.modal.active .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 900;
    margin-bottom: 8px;
}

.win-title { color: #10b981; }
.lose-title { color: #ef4444; }

.modal-text {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.score-summary {
    background: #020617;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-around;
    font-size: 0.95rem;
    color: #cbd5e1;
}

.score-summary strong {
    color: #38bdf8;
    font-size: 1.15rem;
}

.record-badge {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    font-weight: 900;
    font-size: 0.82rem;
    padding: 6px;
    border-radius: 8px;
    margin-bottom: 14px;
}

.action-btn {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(135deg, #0ea5e9, #38bdf8);
    border: none;
    color: #020617;
    font-weight: 900;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.35);
    transition: transform 0.2s;
}

.action-btn:hover {
    transform: translateY(-2px);
}
