:root {
    --bg-color: #2c003e;
    --primary: #ff00cc;
    --secondary: #33ccff;
    --accent: #ffff00;
}

body {
    background-color: var(--bg-color);
    color: white;
    font-family: 'Press Start 2P', cursive;
    cursor: none;
    overflow-x: hidden;
    image-rendering: pixelated;
}

/* --- Custom Cursor --- */
#custom-cursor {
    position: fixed;
    width: 40px;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%) rotate(-15deg);
    transition: transform 0.1s;
}

#custom-cursor img {
    width: 100%;
    filter: drop-shadow(2px 2px 0px rgba(0, 0, 0, 0.5));
}

.cursor-active {
    transform: translate(-50%, -50%) rotate(0deg) scale(0.9) !important;
}

/* --- Stars Background Animation --- */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background:
        radial-gradient(white 2px, transparent 0) 0 0,
        radial-gradient(white 1px, transparent 0) 0 0;
    background-size: 75px 75px, 25px 25px;
    opacity: 0.3;
    transition: background-position 0.1s ease-out;
}

/* --- Nyan Cat & Rainbow Animation --- */
.nyan-container {
    position: fixed;
    top: 15%;
    left: -100%;
    z-index: 5;
    display: flex;
    align-items: center;
    animation: flyAcross 15s linear infinite;
}

.rainbow-trail {
    display: flex;
    flex-direction: row;
    height: 40px;
    width: auto;
    margin-right: -5px;
}

.trail-segment {
    width: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.rainbow-stripe {
    flex: 1;
    width: 100%;
}

.r-red {
    background: #ff0000;
}

.r-orange {
    background: #ff9900;
}

.r-yellow {
    background: #ffff00;
}

.r-green {
    background: #33ff00;
}

.r-blue {
    background: #0099ff;
}

.r-indigo {
    background: #4b0082;
}

.r-violet {
    background: #6633ff;
}

@keyframes waveTrail {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(4px);
    }

    100% {
        transform: translateY(0);
    }
}

.trail-segment {
    animation: waveTrail 0.3s steps(1) infinite;
}

.trail-segment:nth-child(even) {
    animation-delay: 0.15s;
}

@keyframes flyAcross {
    0% {
        left: -1000px;
    }

    100% {
        left: 110%;
    }
}

.nyan-cat-img {
    height: 60px;
    image-rendering: pixelated;
    z-index: 2;
    animation: waveTrail 0.3s steps(1) infinite;
    animation-delay: 0.15s;
}

#balloon-cat {
    transition: transform 0.1s linear;
}

/* --- Layout Utilities --- */
.pixel-box {
    background: rgba(0, 0, 0, 0.6);
    border: 4px solid #fff;
    box-shadow: 8px 8px 0px var(--primary);
    padding: 2rem;
    margin-bottom: 2rem;
    transition: transform 0.2s;
}

.pixel-box:hover {
    transform: translate(-2px, -2px);
    box-shadow: 10px 10px 0px var(--secondary);
}

.pixel-btn {
    background: var(--primary);
    color: white;
    border: 4px solid white;
    padding: 15px 20px;
    display: inline-block;
    text-transform: uppercase;
    font-size: 0.8rem;
    box-shadow: 4px 4px 0px #000;
    transition: all 0.1s;
}

.pixel-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px #000;
}

.hacker-text {
    color: #0f0;
    text-shadow: 2px 2px 0 #000;
}

/* --- Matrix Mode --- */
body.matrix-mode {
    --bg-color: #000000;
    --primary: #00ff00;
    --secondary: #003300;
    --accent: #00cc00;
    color: #00ff00;
}

body.matrix-mode .pixel-box {
    border-color: #00ff00;
    box-shadow: 8px 8px 0px #003300;
    background: rgba(0, 20, 0, 0.9);
}

body.matrix-mode .text-yellow-300,
body.matrix-mode .text-pink-300,
body.matrix-mode .text-blue-300,
body.matrix-mode .text-purple-400 {
    color: #00ff00 !important;
}

body.matrix-mode .stars {
    display: none;
}

body.matrix-mode #matrix-canvas {
    opacity: 0.3;
}

body.matrix-mode .matrix-highlight {
    background-color: rgba(0, 255, 0, 0.6) !important;
}

#music-player {
    font-family: 'Press Start 2P', cursive;
}

.project-card.hidden-project {
    display: none;
}

.skill-tag.active-filter {
    color: var(--accent);
    text-decoration: underline;
}

/* --- Game Overlay Styles --- */
.game-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.85);
}

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

.game-screen {
    width: 100%;
    height: 100%;
    background: #000;
    border: none;
    position: relative;
    overflow: hidden;
    image-rendering: pixelated;
}

.game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    object-fit: contain;
}

.game-hud {
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: 8px;
    right: 8px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    pointer-events: none;
}

.hud-player {
    align-self: flex-end;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.6);
    padding: 4px 10px;
    border: 1px solid #333;
}

.hud-player-avatar {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

.hud-player-name {
    color: #fff;
    font-size: 10px;
}

.hud-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    /* Always push to bottom, even when hud-player is hidden */
}

.hud-left,
.hud-right {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-center {
    text-align: center;
}

.game-score {
    color: #0f0;
    font-size: 12px;
}

.game-high {
    color: #ffcc00;
    font-size: 10px;
    text-align: right;
}

.game-instructions {
    color: #aaa;
    font-size: 10px;
}

/* --- Game Over Screen --- */
.game-over-screen {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.game-over-screen.active {
    opacity: 1;
    pointer-events: auto;
}

.game-over-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 24px;
    color: #ff0066;
    text-shadow: 0 0 10px #ff0066, 0 0 20px #ff0066;
    margin-bottom: 20px;
    animation: glowPulse 1.5s ease-in-out infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        text-shadow: 0 0 10px #ff0066, 0 0 20px #ff0066;
    }

    50% {
        text-shadow: 0 0 20px #ff0066, 0 0 40px #ff0066, 0 0 60px #ff0066;
    }
}

.game-over-stats {
    display: flex;
    gap: 30px;
    margin-bottom: 25px;
}

.stat-box {
    background: linear-gradient(135deg, rgba(255, 0, 102, 0.2), rgba(102, 51, 255, 0.2));
    border: 2px solid #ff0066;
    padding: 15px 25px;
    text-align: center;
}

.stat-label {
    font-size: 8px;
    color: #aaa;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 18px;
    color: #fff;
}

.stat-value.score {
    color: #0f0;
}

.stat-value.ppm {
    color: #ffcc00;
}

.stat-value.time {
    color: #00ccff;
}

.game-over-actions {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.high-scores {
    margin-top: 10px;
    margin-bottom: 15px;
}

.stat-box.highlight {
    border-color: #ffcc00;
    background: linear-gradient(135deg, rgba(255, 204, 0, 0.15), rgba(255, 153, 0, 0.15));
}

.action-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 10px 20px;
    background: transparent;
    border: 2px solid #aaa;
    color: #aaa;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn:hover {
    border-color: #fff;
    color: #fff;
}

.action-btn.primary {
    border-color: #0f0;
    color: #0f0;
}

.action-btn.primary:hover {
    background: rgba(0, 255, 0, 0.1);
}

.action-btn.logout {
    border-color: #ff6666;
    color: #ff6666;
}

.action-btn.logout:hover {
    background: rgba(255, 0, 0, 0.1);
    border-color: #ff0000;
    color: #ff0000;
}

/* --- Pause Menu --- */
.pause-menu {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    backdrop-filter: blur(2px);
}

.pause-menu.active {
    opacity: 1;
    pointer-events: auto;
}

.pause-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 24px;
    color: #ffff00;
    text-shadow: 0 0 10px #ffff00;
    margin-bottom: 30px;
    letter-spacing: 2px;
}

.pause-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 200px;
}

.pause-actions .action-btn {
    width: 100%;
    text-align: center;
}

/* --- Leaderboard Panel --- */
.leaderboard-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 350px;
    max-height: 80%;
    background: rgba(0, 0, 0, 0.98);
    border: 3px solid #ffcc00;
    z-index: 110;
    display: none;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.4);
}

.leaderboard-panel.visible {
    display: flex;
}

.leaderboard-header {
    background: linear-gradient(135deg, #ffcc00, #ff9900);
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.leaderboard-title {
    font-size: 11px;
    color: #000;
    font-weight: bold;
}

.leaderboard-toggle {
    display: flex;
    gap: 5px;
}

.toggle-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid #000;
    color: #000;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: #000;
    color: #ffcc00;
}

.leaderboard-content {
    flex: 1;
    overflow-y: auto;
    /* overflow-x removed */
    padding: 15px;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9px;
    table-layout: auto;
}

.leaderboard-table th {
    color: #ffcc00;
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #333;
}

.leaderboard-table td {
    color: #fff;
    padding: 8px 6px;
    border-bottom: 1px solid #222;
}

.leaderboard-table tr:hover td {
    background: rgba(255, 204, 0, 0.1);
}

.leaderboard-table .rank {
    color: #ffcc00;
    width: 30px;
}

.leaderboard-table .rank-1,
.leaderboard-table .rank-2,
.leaderboard-table .rank-3 {
    color: #ffd700;
}

.leaderboard-table .player-name {
    /* Full name visible, no truncation */
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.leaderboard-table .name-text {
    white-space: nowrap;
    font-size: 9px;
    /* Default */
}

.leaderboard-table .name-text-small {
    font-size: 7px;
}

.leaderboard-table .name-text-tiny {
    font-size: 6px;
    letter-spacing: -0.5px;
    /* Squeeze slightly */
}

.leaderboard-table .score-cell {
    color: #0f0;
    text-align: right;
}

.leaderboard-table .ppm-cell {
    color: #0f0;
    text-align: right;
}

.leaderboard-loading,
.leaderboard-empty {
    text-align: center;
    color: #666;
    padding: 30px;
    font-size: 9px;
}

.leaderboard-loading {
    color: #ffcc00;
    animation: pulse 1s infinite;
}

.leaderboard-close-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    padding: 10px;
    background: transparent;
    border: none;
    border-top: 1px solid #333;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-close-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

/* --- Visit Counter --- */
.visit-counter-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    margin-top: 15px;
}

.visit-counter-cat {
    width: 60px;
    height: auto;
    margin-bottom: -10px;
    z-index: 1;
    image-rendering: pixelated;
    animation: catBounce 0.5s ease-in-out infinite;
}

@keyframes catBounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.visit-counter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, rgba(255, 0, 102, 0.2), rgba(102, 51, 255, 0.2));
    border: 2px solid #ff0066;
    padding: 8px 16px;
    font-size: 10px;
}

.visit-counter-icon {
    font-size: 14px;
}

.visit-counter-label {
    color: #aaa;
}

.visit-counter-value {
    color: #0f0;
    font-size: 12px;
}

/* --- Login/Start Screen --- */
.game-login-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 60;
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #ff0066;
    box-shadow: 0 0 30px rgba(255, 0, 102, 0.4), inset 0 0 60px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.login-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    color: #fff;
    margin-bottom: 8px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.login-subtitle {
    font-size: 10px;
    color: #ff9900;
    margin-bottom: 25px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.login-form.hidden {
    display: none;
}

.login-form-title {
    font-size: 10px;
    color: #88f;
    margin-bottom: 5px;
}

.login-input {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 12px 16px;
    background: #111;
    border: 2px solid #444;
    color: #fff;
    text-align: center;
    width: 100%;
    max-width: 280px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
    border-color: #ff0066;
    box-shadow: 0 0 10px rgba(255, 0, 102, 0.4);
}

.login-input::placeholder {
    color: #555;
}

.login-input.error {
    border-color: #ff0000;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.login-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    padding: 14px 30px;
    background: linear-gradient(135deg, #ff0066, #6633ff);
    border: 2px solid #fff;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 4px 4px 0 #000;
    width: 100%;
    max-width: 280px;
}

.login-btn:hover:not(:disabled) {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
}

.login-btn:active:not(:disabled) {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000;
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-divider {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 280px;
    margin: 8px 0;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #444;
}

.login-divider span {
    font-size: 8px;
    color: #666;
    padding: 0 12px;
}

.guest-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    padding: 12px 24px;
    background: transparent;
    border: 2px solid #666;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 280px;
}

.guest-btn:hover {
    border-color: #fff;
    color: #fff;
}

.login-note {
    font-size: 7px;
    color: #666;
    margin-top: 5px;
}

.login-hint {
    font-size: 8px;
    color: #444;
    margin-top: 20px;
}

/* Logged In State */
.logged-in-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.logged-in-state.hidden {
    display: none;
}

.logged-in-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #0f0;
    padding: 10px 20px;
}

.logged-in-icon {
    font-size: 16px;
}

.logged-in-name {
    font-size: 12px;
    color: #0f0;
}

.play-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    padding: 16px 40px;
    background: linear-gradient(135deg, #00cc00, #009900);
    border: 3px solid #fff;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 4px 4px 0 #000;
}

.play-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
    background: linear-gradient(135deg, #00ff00, #00cc00);
}

.play-btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000;
}

.logout-btn {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #666;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    border-color: #ff0000;
    color: #ff0000;
}

.profile-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.edit-btn {
    background: transparent;
    border: 1px solid #444;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.edit-btn:hover {
    border-color: #ff0066;
    transform: scale(1.1);
}

.profile-editor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
    margin-bottom: 15px;
}

.profile-editor.hidden {
    display: none;
}

/* Avatar Selection */
.avatar-selection {
    margin: 15px 0;
    width: 100%;
    max-width: 280px;
}

.avatar-label {
    font-size: 8px;
    color: #888;
    margin-bottom: 10px;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.avatar-option {
    width: 50px;
    height: 50px;
    border: 2px solid #444;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    margin: 0 auto;
}

.avatar-option img {
    width: 40px;
    height: 40px;
    image-rendering: pixelated;
}

.avatar-option:hover {
    border-color: #888;
    transform: scale(1.1);
}

.avatar-option.selected {
    border-color: #ff0066;
    box-shadow: 0 0 10px rgba(255, 0, 102, 0.5);
}

.logged-in-avatar {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
}

/* Leaderboard Avatar */
.leaderboard-avatar {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
    vertical-align: middle;
    margin-right: 6px;
}

/* Score Submit Status */
.score-submit-status {
    margin-bottom: 15px;
    font-size: 10px;
}

.score-submit-status.success {
    color: #0f0;
}

.score-submit-status.error {
    color: #ff0000;
}

.score-submit-status.guest {
    color: #888;
}

/* GitHub OAuth Button */
.github-btn {
    background: #24292e !important;
    border-color: #24292e !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.github-btn:hover {
    background: #3a3f44 !important;
    border-color: #4a4f54 !important;
}

.github-icon {
    flex-shrink: 0;
}

/* Magic Link Button */
.magic-link-btn {
    background: linear-gradient(135deg, #6633ff, #ff0066) !important;
    border: none !important;
}

.magic-link-btn:hover {
    background: linear-gradient(135deg, #7744ff, #ff1177) !important;
}

.magic-link-status {
    font-size: 9px;
    padding: 8px;
    margin-top: 10px;
    text-align: center;
    border-radius: 4px;
}

.magic-link-status.success {
    color: #0f0;
    background: rgba(0, 255, 0, 0.1);
    border: 1px solid #0f0;
}

.magic-link-status.error {
    color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
    border: 1px solid #ff0000;
}

.magic-link-status.hidden {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .leaderboard-panel {
        width: 90%;
        max-height: 70%;
    }

    .game-over-stats {
        flex-direction: column;
        gap: 15px;
    }

    .game-over-title {
        font-size: 18px;
    }

    .game-login-screen {
        padding: 20px;
    }

    .login-title {
        font-size: 16px !important;
    }
}

.visit-counter-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
}

.visit-counter-cat {
    width: 50px;
    height: auto;
    margin-bottom: -5px;
    /* Overlap slightly with counter */
}

.visit-counter {
    background: #000;
    border: 2px solid #33ff00;
    padding: 5px 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    color: #33ff00;
    box-shadow: 0 0 10px rgba(51, 255, 0, 0.3);
    display: flex;
    gap: 8px;
    align-items: center;
    transition: all 0.3s ease;
}

/* Ensure children inherit or set color explicitly */
.visit-counter span,
.visit-counter .visit-counter-value {
    color: #33ff00;
}

/* Pink theme for normal mode (when matrix is disabled) */
body:not(.matrix-mode) .visit-counter {
    border-color: #ff0066;
    color: #ff0066;
    box-shadow: 0 0 10px rgba(255, 0, 102, 0.3);
}

body:not(.matrix-mode) .visit-counter span,
body:not(.matrix-mode) .visit-counter .visit-counter-value {
    color: #ff0066;
}

/* --- Mobile Controls --- */
.mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: none;
    /* Hidden by default, shown via JS when game is running */
}

.mobile-controls.active {
    display: block;
}

/* Keypad Toggle - positioned at top right */
.keypad-toggle {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 55;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
}

.keypad-toggle.visible {
    display: flex;
}

.keypad-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 1px 1px 0 #000;
}

.keypad-toggle-img {
    width: 60px;
    height: auto;
    image-rendering: pixelated;
    transition: transform 0.1s;
}

.keypad-toggle:active .keypad-toggle-img {
    transform: scale(0.95);
}

/* Game Control Buttons - positioned at top left */
.game-control-buttons {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 55;
    display: none;
    flex-direction: row;
    gap: 8px;
}

.game-control-buttons.visible {
    display: flex;
}

.game-ctrl-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.1s;
    pointer-events: auto;
}

.game-ctrl-btn img {
    width: 60px;
    height: auto;
    image-rendering: pixelated;
}

.game-ctrl-btn:hover {
    transform: scale(1.05);
}

.game-ctrl-btn:active {
    transform: scale(0.95);
}

.mobile-arrows {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.mobile-arrows.hidden {
    display: none;
}

.arrow-row {
    display: flex;
    gap: 5px;
}

.arrow-btn {
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #33ccff;
    border-radius: 8px;
    padding: 8px;
    cursor: pointer;
    transition: all 0.1s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.arrow-btn img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    pointer-events: none;
}

.arrow-btn:active,
.arrow-btn.pressed {
    background: rgba(51, 204, 255, 0.3);
    border-color: #0f0;
    transform: scale(0.95);
}

/* Mobile Responsive Fixes */
@media (max-width: 600px) {

    /* Game login screen fixes */
    .game-login-screen {
        padding: 15px;
        width: 95%;
        max-width: none;
        box-sizing: border-box;
    }

    .login-title {
        font-size: 14px !important;
        margin-bottom: 5px;
    }

    .login-subtitle {
        font-size: 8px;
        margin-bottom: 15px;
    }

    .login-form-title {
        font-size: 8px;
    }

    .login-input {
        font-size: 8px;
        padding: 10px 12px;
        max-width: 100%;
    }

    .login-btn {
        font-size: 9px;
        padding: 10px 15px;
        max-width: 100%;
    }

    .login-btn.github-btn {
        font-size: 8px;
        padding: 10px 12px;
    }

    .github-icon {
        width: 14px;
        height: 14px;
    }

    .login-divider {
        margin: 6px 0;
    }

    .login-divider span {
        font-size: 7px;
        padding: 0 8px;
    }

    .guest-btn {
        font-size: 10px;
        padding: 12px 25px;
    }

    .login-note {
        font-size: 6px;
    }

    .login-hint {
        font-size: 7px;
        margin-top: 15px;
    }

    /* Profile editor mobile fixes */
    .profile-display {
        padding: 8px 12px;
    }

    .logged-in-info {
        gap: 8px;
    }

    .logged-in-avatar {
        width: 28px;
        height: 28px;
    }

    .logged-in-name {
        font-size: 9px;
    }

    .avatar-grid {
        gap: 6px;
    }

    .avatar-option {
        width: 36px;
        height: 36px;
    }

    .play-btn {
        font-size: 12px;
        padding: 12px 30px;
    }

    .logout-btn {
        font-size: 7px;
        padding: 6px 12px;
    }

    /* Game HUD mobile fixes */
    .game-hud {
        top: 5px;
        bottom: 5px;
        left: 5px;
        right: 5px;
    }

    .hud-player {
        display: none;
    }

    .hud-player-avatar {
        width: 18px;
        height: 18px;
    }

    .hud-player-name {
        font-size: 8px;
    }

    .game-score {
        font-size: 9px;
    }

    .game-high {
        font-size: 8px;
    }

    .game-instructions {
        font-size: 7px;
        max-width: 120px;
    }

    /* Game over screen mobile fixes */
    .game-over-screen {
        padding: 15px;
    }

    .game-over-title {
        font-size: 16px;
        margin-bottom: 15px;
    }

    .game-over-stats {
        gap: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .stat-box {
        padding: 10px 15px;
        min-width: 70px;
    }

    .stat-label {
        font-size: 6px;
    }

    .stat-value {
        font-size: 14px;
    }

    .score-submit-status {
        font-size: 7px;
    }

    .game-over-actions {
        gap: 8px;
        margin-top: 12px;
    }

    .action-btn {
        font-size: 8px;
        padding: 8px 12px;
    }

    /* Leaderboard mobile fixes */
    .leaderboard-panel {
        width: 95%;
        max-height: 75%;
    }

    .leaderboard-header {
        padding: 8px 12px;
    }

    .leaderboard-title {
        font-size: 9px;
    }

    .toggle-btn {
        font-size: 6px;
        padding: 3px 6px;
    }

    .leaderboard-content {
        padding: 10px;
    }

    .leaderboard-table {
        font-size: 8px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 6px 4px;
    }

    .leaderboard-avatar {
        width: 16px;
        height: 16px;
    }

    .leaderboard-close-btn {
        font-size: 8px;
        padding: 8px;
    }

    /* Mobile controls positioning - keep centered */
    .mobile-controls {
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
    }

    .arrow-btn {
        width: 50px;
        height: 50px;
        padding: 6px;
    }

    /* Keypad toggle mobile - top right */
    .keypad-toggle {
        top: 8px;
        right: 8px;
    }

    .keypad-label {
        font-size: 6px;
    }

    .keypad-toggle-img {
        width: 50px;
    }

    /* Fix HUD layout for mobile - ensure text doesn't clip */
    .hud-bottom {
        position: absolute;
        bottom: 130px;
        left: 5px;
        right: 5px;
        margin-bottom: 0;
    }

    .hud-left,
    .hud-right {
        background: rgba(0, 0, 0, 0.5);
        padding: 4px 6px;
        border-radius: 3px;
    }

    .hud-player {
        align-self: center;
        position: absolute;
        top: 35px;
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        font-size: 8px;
        padding: 2px 6px;
        white-space: nowrap;
    }

    .hud-player-avatar {
        width: 16px;
        height: 16px;
    }

    .game-score,
    .game-high {
        white-space: nowrap;
    }

    .hud-center {
        display: none;
    }

    /* Game control buttons mobile */
    .game-control-buttons {
        top: 8px;
        left: 8px;
        gap: 5px;
    }

    .game-ctrl-btn img {
        width: 45px;
    }
}

/* Extra small screens */
@media (max-width: 380px) {
    .game-login-screen {
        padding: 12px;
    }

    .login-title {
        font-size: 12px !important;
    }

    .login-btn {
        font-size: 8px;
        padding: 8px 12px;
    }

    .guest-btn {
        font-size: 9px;
        padding: 10px 20px;
    }

    .arrow-btn {
        width: 45px;
        height: 45px;
        padding: 5px;
    }

    .game-over-stats {
        gap: 8px;
    }

    .stat-box {
        padding: 8px 12px;
        min-width: 60px;
    }

    .stat-value {
        font-size: 12px;
    }
}