:root {
    --primary-color: #00f2ff;
    --secondary-color: #ff0055;
    --accent-color: #ffe600;
    --bg-dark: #0a0a12;
    --glass-bg: rgba(20, 20, 30, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #ffffff;
    --text-dim: #8899a6;

    --font-display: 'Orbitron', sans-serif;
    --font-ui: 'Rajdhani', sans-serif;
}

#ascend-wrapper * {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#ascend-wrapper {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    width: 100%;
    height: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 1000;
    margin: 20px auto;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Background Effects */
.bg-gradient {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 50% 30%, #1a1a2e 0%, #000000 100%);
    z-index: -2;
}

/* Menu Screens */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
        url('bg-home.jpg') center center / cover no-repeat;
    z-index: 20;
    padding: 20px;
}

h1.game-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    margin: 0 0 2rem 0;
    background: linear-gradient(to bottom, #fff, #aaa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.5);
    letter-spacing: 4px;
}

h2 {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 2.8rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 2rem;
    text-transform: none;
    text-shadow: none;
    /* STRICT: No outline/shadow/decorations */
    background: none;
    letter-spacing: normal;
}

button {
    display: block;
    width: 100%;
    max-width: 300px;
    padding: 16px;
    margin-bottom: 16px;
    border: none;
    border-radius: 12px;
    font-family: var(--font-ui);
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(135deg, var(--primary-color), #00a8ff);
    color: #000;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3);
    position: relative;
    overflow: hidden;
}

button::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg) translateY(-100%);
    transition: 0.3s;
}

button:hover::after {
    transform: rotate(45deg) translateY(0);
}

button:active {
    transform: scale(0.95);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}

.btn-small {
    padding: 12px 24px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    box-shadow: none;
    backdrop-filter: blur(5px);
    width: auto;
    margin: 10px 0;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 15px rgba(0, 242, 255, 0.2);
}

/* Layout Restoration & Refinement */
.settings-list {
    width: 100%;
    max-width: 350px;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.manual-scroll-area {
    width: 95%;
    max-width: 500px;
    max-height: 65vh;
    overflow-y: auto;
    padding: 20px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.manual-scroll-area::-webkit-scrollbar {
    width: 6px;
}

.manual-scroll-area::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.manual-scroll-area::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

.manual-content {
    text-align: left;
    font-size: 1rem;
    line-height: 1.7;
    color: #fff;
}

.manual-content h3 {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1.4rem;
    font-weight: bold;
    color: #fff;
    text-decoration: underline;
    margin-top: 25px;
    margin-bottom: 15px;
    text-transform: none;
    text-shadow: none;
    letter-spacing: normal;
}

.manual-spacing {
    height: 40px;
}

/* HUD */
#hud {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    justify-content: space-between;
    padding: 20px;
    z-index: 10;
}

.hud-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    overflow: hidden;
    position: relative;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
    margin-bottom: 10px;
}

.score-box,
.level-box,
.diff-box,
.next-box {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: 10px 15px;
    border-radius: 8px;
    clip-path: polygon(0 0, 100% 0, 100% 70%, 85% 100%, 0 100%);
    box-shadow: inset 0 0 10px rgba(0, 242, 255, 0.1);
}

.level-box {
    align-items: center;
}

/* HUD & Difficulty Refinement */
.diff-box {
    align-items: center;
    min-width: 100px;
}

.next-box {
    align-items: flex-end;
}

.label {
    font-size: 0.8rem;
    color: var(--text-dim);
    letter-spacing: 2px;
}

#score-val,
#level-val {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--text-main);
}

#diff-val {
    font-family: var(--font-ui);
    font-size: 0.9rem !important;
    /* Smaller font for full names */
    color: var(--primary-color);
    letter-spacing: 1px;
    font-weight: 700;
}

canvas {
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 10px rgba(0, 242, 255, 0.2);
    border: 1px solid #333;
    border-top: 2px solid var(--primary-color);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.3);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* Utility Classes */
.hidden,
#ascend-wrapper .hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    width: 100%;
    color: var(--text-main);
}

.setting-item label {
    font-weight: 500;
    font-size: 1.1rem;
    text-decoration: none;
    letter-spacing: normal;
}

input,
select {
    background: #333;
    /* Reverted to simpler Rev00 opaque style */
    color: #fff;
    border: 1px solid #555;
    padding: 6px 10px;
    border-radius: 6px;
    font-family: var(--font-ui);
    outline: none;
    transition: 0.2s;
}

input:focus,
select:focus {
    border-color: var(--primary-color);
    background: #444;
}

input[type="range"] {
    width: 120px;
    cursor: pointer;
}

input[type="number"] {
    width: 70px;
    text-align: center;
}

/* Overlays */
#pause-overlay,
#gameover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 30;
    animation: overlayFadeIn 0.5s ease-out;
}

#gameover-overlay h2 {
    font-size: 4rem;
    color: var(--secondary-color);
    text-shadow: 0 0 10px var(--secondary-color), 0 0 20px var(--secondary-color);
    margin-bottom: 0.5rem;
    animation: neonPulse 1.5s infinite alternate, glitchText 3s infinite;
}

.score-display-large {
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid var(--glass-border);
    padding: 24px 40px;
    border-radius: 12px;
    margin: 20px 0;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    position: relative;
    overflow: hidden;
}

#gameover-overlay .score-display-large {
    border: 2px solid var(--secondary-color);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.3), inset 0 0 15px rgba(255, 0, 85, 0.1);
}

#clear-overlay .score-display-large {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 20px rgba(255, 230, 0, 0.3), inset 0 0 15px rgba(255, 230, 0, 0.1);
}

#clear-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(15px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 40;
    animation: overlayFadeIn 0.8s ease-out;
}

#clear-overlay h2.clear-title {
    font-size: 3.5rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px var(--accent-color), 0 0 20px #ffaa00;
    margin-bottom: 0.5rem;
    animation: clearPulse 1s infinite alternate;
}

.congrats-text {
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: #fff;
    letter-spacing: 4px;
    margin-bottom: 20px;
}

@keyframes clearPulse {
    from {
        transform: scale(1);
        text-shadow: 0 0 10px var(--accent-color);
    }

    to {
        transform: scale(1.05);
        text-shadow: 0 0 30px var(--accent-color), 0 0 50px #ffaa00;
    }
}

.score-display-large .label {
    display: block;
    margin-bottom: 5px;
}

#final-score {
    font-family: var(--font-display);
    font-size: 3.5rem;
    color: var(--accent-color);
    text-shadow: 0 0 15px var(--accent-color);
}

/* Animations */
@keyframes overlayFadeIn {
    from {
        opacity: 0;
        transform: scale(1.1);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes neonPulse {
    from {
        text-shadow: 0 0 10px var(--secondary-color), 0 0 20px var(--secondary-color);
        opacity: 1;
    }

    to {
        text-shadow: 0 0 5px var(--secondary-color), 0 0 10px var(--secondary-color);
        opacity: 0.8;
    }
}

@keyframes glitchText {

    0%,
    100% {
        transform: translate(0);
    }

    33% {
        transform: translate(-2px, 1px);
    }

    66% {
        transform: translate(2px, -1px);
    }

    99% {
        transform: translate(-1px, -1px);
    }
}

/* Mobile Controls */
#mobile-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    max-width: 450px;
    padding: 0 10px 20px 10px;
    pointer-events: none;
    /* Let clicks pass through to child buttons */
    margin-bottom: 50px;
    /* Moved up by 30px (half of 60px button size) */
}

#mobile-controls button {
    pointer-events: auto;
    width: 60px;
    height: 60px;
    padding: 0;
    margin: 5px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

#mobile-controls .dpad {
    display: flex;
    align-items: center;
}

#mobile-controls .rotate-btn {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--secondary-color), #ff00ff);
    box-shadow: 0 0 20px rgba(255, 0, 85, 0.4);
}

/* Responsive Tweaks */
@media (min-width: 800px) {
    #mobile-controls {
        display: none !important;
        /* Hide on large desktop screens */
    }
}

/* Mobile Layout Optimizations */
@media (max-width: 800px) {
    #ascend-wrapper {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
        z-index: 99999;
    }

    #hud {
        padding: 5px;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    .hud-top {
        padding: 5px;
        margin-bottom: 0px;
        transform: scale(0.85);
        transform-origin: top center;
    }

    .hud-center {
        flex: 1;
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: flex-start;
        /* Shift board UP */
        position: relative;
        overflow: hidden;
    }

    #gameCanvas {
        height: 65.8vh !important;
        /* -8% from 71.5vh */
        width: auto !important;
        margin-top: calc(-30px + 5.7vh);
        /* Anchored bottom by shifting top down by 5.7vh (8% of 71.5) */
        margin-bottom: 0px;
    }

    /* Mobile Overlay Controls */
    #mobile-overlay {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        z-index: 50;
    }

    .overlay-top {
        display: flex;
        justify-content: space-between;
        padding: 10px;
        pointer-events: auto;
    }

    .overlay-btn-small {
        background: rgba(255, 255, 255, 0.15);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.3);
        color: #fff;
        padding: 6px 14px;
        border-radius: 20px;
        font-size: 0.75rem;
        font-weight: bold;
        cursor: pointer;
        width: auto !important;
        margin: 0 !important;
        box-shadow: none !important;
        text-transform: uppercase;
    }

    #mobile-quit {
        background: rgba(255, 50, 50, 0.25);
        border-color: rgba(255, 50, 50, 0.4);
    }

    .overlay-controller {
        padding-bottom: 95px;
        /* Fine-tuned to let button tops touch board bottom exactly */
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        padding-right: 10px;
        /* Shifted 10px to the right (was 20px) */
        pointer-events: auto;
    }

    .ctrl-group-top {
        margin-bottom: 8px;
        padding-right: 0px;
        /* Reset to allow precise alignment */
        display: flex;
        justify-content: flex-end;
        width: 100%;
        margin-right: 5px;
        /* Fine-tuned to align directly over the 'Right' button */
    }

    .ctrl-group-bottom {
        display: flex;
        gap: 12px;
    }

    .ctrl-btn-round {
        width: 62px !important;
        height: 62px !important;
        border-radius: 50%;
        background: rgba(0, 242, 255, 0.2);
        backdrop-filter: blur(10px);
        border: 2px solid rgba(0, 242, 255, 0.5);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.4rem;
        cursor: pointer;
        padding: 0;
        margin: 0;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
    }

    .rotate-btn {
        background: rgba(255, 0, 85, 0.3);
        border-color: rgba(255, 0, 85, 0.5);
        width: 72px !important;
        height: 72px !important;
        font-size: 1.6rem;
    }

    .ctrl-btn-round:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.4);
    }
}

.pc-only {
    display: block;
}

@media (max-width: 800px) {
    .pc-only {
        display: none !important;
    }

    .mobile-only {
        display: flex !important;
    }
}

@media (min-width: 801px) {
    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 500px) {
    .menu-screen {
        background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)),
            url('bg-home.jpg') center top / contain no-repeat;
    }

    h1.game-title {
        font-size: 2.2rem;
    }

    #gameover-overlay h2 {
        font-size: 2.5rem;
        margin-bottom: 0px;
    }

    #clear-overlay h2.clear-title {
        font-size: 2.2rem;
        margin-bottom: 0px;
    }

    .score-display-large {
        padding: 15px 25px;
        width: 85%;
    }

    .congrats-text {
        font-size: 1rem;
        letter-spacing: 2px;
        margin-bottom: 10px;
    }

    #final-score,
    #clear-score {
        font-size: 2.8rem;
    }

    #score-val,
    #level-val,
    #diff-val {
        font-size: 1.5rem;
    }

    .hud-top {
        padding: 0 10px;
    }

    #mobile-controls button {
        width: 50px;
        height: 50px;
    }

    #mobile-controls .rotate-btn {
        width: 70px;
        height: 70px;
    }

    #mobile-controls {
        margin-bottom: 45px;
        /* Adjusted for smaller button size (half of 50px is 25px offset) */
    }
}