:root {
    --primary-color: #3190ff;
    --text-color: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Prevent browser handling of gestures */
}

body {
    overflow: hidden;
    background: linear-gradient(180deg, #078ff0 0%, #2fc3f4 48%, #8be9f7 100%);
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

#game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none; /* Let clicks pass through except on buttons */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: max(42px, calc(env(safe-area-inset-top) + 28px)) 20px max(18px, calc(env(safe-area-inset-bottom) + 14px));
}

#hud-top {
    position: relative;
    width: 100%;
    pointer-events: none;
}

#score-container {
    text-align: center;
    position: relative;
    top: 38px;
}

#pause-wrap {
    position: absolute;
    top: 0;
    right: 0;
    pointer-events: auto;
}

#pause-wrap.hidden {
    visibility: hidden;
    pointer-events: none;
}

#pause-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.09);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
    color: #fff;
    -webkit-tap-highlight-color: transparent;
}

#pause-btn:active {
    transform: scale(0.96);
    opacity: 0.92;
}

#pause-btn .icon-play {
    display: none;
}

#pause-btn.is-paused .icon-pause {
    display: none;
}

#pause-btn.is-paused .icon-play {
    display: block;
}

#pause-overlay {
    position: fixed;
    inset: 0;
    z-index: 15;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

#pause-overlay.visible {
    display: flex;
}

.pause-label {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.92);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

#score {
    font-size: clamp(64px, 17vw, 82px);
    font-weight: 900;
    line-height: 0.9;
    letter-spacing: -0.045em;
    color: var(--text-color);
    text-shadow: 0 7px 6px rgba(28, 86, 126, 0.38);
}

#score-unit {
    font-size: clamp(27px, 7.2vw, 35px);
    font-weight: 800;
    color: var(--text-color);
    margin-left: 6px;
    text-shadow: 0 5px 5px rgba(28, 86, 126, 0.34);
}

#controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 5.3vw;
    pointer-events: auto;
}

.control-btn {
    width: clamp(92px, 20.5vw, 126px);
    height: clamp(92px, 20.5vw, 126px);
    border-radius: 27%;
    background:
        radial-gradient(circle at 28% 12%, rgba(255,255,255,0.42), rgba(255,255,255,0) 44%),
        linear-gradient(155deg, #45bdff 0%, #178cff 43%, #0758e5 100%);
    border: 5px solid rgba(255, 255, 255, 0.96);
    box-shadow:
        0 11px 17px rgba(21, 55, 89, 0.38),
        0 3px 0 rgba(255,255,255,0.85) inset,
        0 -9px 13px rgba(0, 40, 180, 0.28) inset;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    transition: transform 0.05s, box-shadow 0.05s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.arrow-icon {
    display: block;
    width: 58%;
    height: 58%;
    overflow: visible;
    filter: drop-shadow(0 4px 3px rgba(0, 53, 145, 0.34));
}

.arrow-icon path {
    fill: #fff;
}

.arrow-right {
    transform: scaleX(-1);
}

.control-btn:active, .control-btn.active {
    transform: scale(0.92) translateY(4px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3), inset 0 2px 4px rgba(255,255,255,0.4);
}

#flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: white;
    opacity: 0;
    z-index: 100;
    pointer-events: none;
    transition: opacity 0.5s ease-out;
}

#flash.active {
    opacity: 1;
    transition: none; /* Instant on, fade out */
}
