/* ------------------------------------------------------
   GLOBAL STYLE
------------------------------------------------------ */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Orbitron', sans-serif;
    user-select: none;
    touch-action: manipulation;
    background: radial-gradient(circle at center, #0a0a0a 0%, #050505 40%, #000 100%);
    color: #0ff;
}

* {
    box-sizing: border-box;
}

/* ------------------------------------------------------
   START SCREEN
------------------------------------------------------ */
#start {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: url('city-bg.jpg') center/cover no-repeat, rgba(0,0,0,0.65);
    background-blend-mode: darken;
    text-align: center;
    z-index: 100;
}

.start-wrapper {
    display: flex;
    flex-direction: column;
    gap: 3vmin;
    align-items: center;
    padding: 2vmin;
}

/* Glitchy Title */
.title {
    margin: 0;
    font-size: clamp(28px, 9vmin, 70px);
    letter-spacing: 0.5vmin;
    color: #f0f;
    text-shadow: 
        0 0 10px #f0f,
        0 0 20px #f0f,
        0 0 40px #0ff;
    position: relative;
    animation: glitch-flicker 2.5s infinite;
}

/* Create ghost layers */
.title::before,
.title::after {
    content: attr(data-text);
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0.6;
    mix-blend-mode: screen;
}

.title::before {
    color: #0ff;
    transform: translate(3px, 0);
    animation: glitch-anim-1 2s infinite;
}

.title::after {
    color: #f0f;
    transform: translate(-3px, 0);
    animation: glitch-anim-2 1.8s infinite;
}

/* Flicker */
@keyframes glitch-flicker {
    0%, 15%, 100% { opacity: 1; }
    16% { opacity: 0.7; }
    17% { opacity: 1; }
    45% { opacity: 0.9; }
    46% { opacity: 0.4; }
    47% { opacity: 1; }
}

/* Glitch shifts */
@keyframes glitch-anim-1 {
    0%, 100% { clip-path: inset(0 0 0 0); transform: translate(3px, 0); }
    10% { clip-path: inset(20% 0 60% 0); transform: translate(5px, -2px); }
    20% { clip-path: inset(40% 0 20% 0); transform: translate(-3px, 2px); }
    30% { clip-path: inset(10% 0 70% 0); transform: translate(3px, -1px); }
}

@keyframes glitch-anim-2 {
    0%, 100% { clip-path: inset(0 0 0 0); transform: translate(-3px, 0); }
    15% { clip-path: inset(70% 0 5% 0); transform: translate(-6px, 1px); }
    25% { clip-path: inset(30% 0 30% 0); transform: translate(2px, -1px); }
    40% { clip-path: inset(90% 0 0 0); transform: translate(-3px, 2px); }
}

.subtitle, 
.difficulty-title {
    opacity: 0.85;
    font-size: clamp(12px, 3vmin, 22px);
}

/* Difficulty buttons */
#difficultySelect {
    display: flex;
    flex-wrap: wrap;
    gap: 2vmin;
    justify-content: center;
}

.diff-btn {
    padding: 2vmin 4vmin;
    border: 2px solid #0ff;
    border-radius: 12px;
    opacity: 0.7;
    cursor: pointer;
    font-size: clamp(12px, 3vmin, 22px);
    background: rgba(0,0,0,0.35);
    transition: 0.15s;
}

.diff-btn.active {
    opacity: 1;
    background: rgba(0,255,255,0.2);
    box-shadow: 0 0 15px #0ff;
}

#startButton {
    margin-top: 4vmin;
    padding: 2vmin 6vmin;
    border: 2px solid #0ff;
    border-radius: 14px;
    font-size: clamp(16px, 4vmin, 28px);
    cursor: pointer;
    background: rgba(0,0,0,0.4);
    transition: 0.2s;
}

#startButton:hover {
    transform: scale(1.12);
    background: rgba(0,255,255,0.2);
    box-shadow: 0 0 15px #0ff;
}

.credits {
    opacity: 0.5;
    font-size: clamp(10px, 2vmin, 16px);
    margin-top: 4vmin;
}

/* --- Matrix Background --- */
#matrixCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ------------------------------------------------------
   HUD
------------------------------------------------------ */
#score, 
#timer {
    position: absolute;
    top: 2vh;
    font-size: clamp(14px, 3vmin, 26px);
    text-shadow: 0 0 10px #0ff;
    z-index: 20;
}
#score { left: 2vw; }
#timer { right: 2vw; }

.pause-btn {
    display: none;
    position: fixed;
    top: 7vh;       
    right: 2vw;     
    padding: 10px 18px;
    background: rgba(0, 255, 255, 0.15);
    border: 2px solid cyan;
    border-radius: 10px;
    color: cyan;
    font-family: "Orbitron", sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    z-index: 8000;  /* ensures the pause button stays above all game layers */
    user-select: none;
    transition: 0.15s;
}

.pause-btn:hover {
    background: rgba(0, 255, 255, 0.25);
    transform: scale(1.05);
}

#pausedOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    backdrop-filter: blur(6px);
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

#pausedOverlay div {
    font-family: "Orbitron", sans-serif;
    font-size: 48px;
    color: cyan;
    text-shadow: 0 0 12px cyan;
    letter-spacing: 3px;
}

#pausedOverlay .paused-title {
    font-size: 16vmin;
    color: red;
    text-shadow: 0 0 12px red;
    font-family: "Orbitron", sans-serif;
    margin-bottom: 30px;
}

.resume-btn {
    padding: 12px 28px;
    margin-bottom: 10px;
    background: rgba(0, 255, 255, 0.2);
    border: 2px solid #0ff;
    border-radius: 12px;
    font-family: "Orbitron", sans-serif;
    font-size: 24px;
    color: #0ff;
    cursor: pointer;
    transition: 0.15s;
    text-shadow: 0 0 10px #0ff;
}

.resume-btn:hover {
    background: rgba(0, 255, 255, 0.35);
    transform: scale(1.07);
}

.quitBtn {
    padding: 12px 28px;
    background: rgba(0, 255, 255, 0.2);
    border: 2px solid #0ff;
    border-radius: 12px;
    font-family: "Orbitron", sans-serif;
    font-size: 24px;
    color: #0ff;
    cursor: pointer;
    transition: 0.15s;
    text-shadow: 0 0 10px #0ff;
}

.quitBtn:hover {
    background: rgba(0, 255, 255, 0.35);
    transform: scale(1.07);
}

/* ------------------------------------------------------
   RESTART SCREEN
------------------------------------------------------ */
#restart {
    position: fixed;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(0,0,0,0.85);
    z-index: 100;
}

.restart-btn {
    padding: 2vmin 6vmin;
    margin-top: 2vmin;
    font-size: clamp(16px, 4vmin, 28px);
    border: 2px solid #0ff;
    border-radius: 12px;
    background: rgba(0,0,0,0.5);
    cursor: pointer;
    text-shadow: 0 0 10px #0ff;
    transition: 0.15s;
}

.restart-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 0 25px #0ff;
}

/* ------------------------------------------------------
   TARGET CIRCLE
------------------------------------------------------ */
#circle {
    position: absolute;
    width: 8vmin;
    height: 8vmin;
    min-width: 40px;
    min-height: 40px;
    max-width: 90px;
    max-height: 90px;
    border-radius: 50%;
    display: none;
    z-index: 9999;
    opacity: 1;
    background: radial-gradient(circle at 30% 30%, #66faff, #00bcd4);
    box-shadow: 0 0 30px cyan;
    transition: opacity 0.09s;
    animation:
        jelly 0.25s ease-in-out infinite,
        liquid 0.50s ease-in-out infinite,
        flicker 0.25s infinite;
}

@keyframes jelly {
    0%   { transform: scale(1); }
    30%  { transform: scale(1.08, 0.92) translate(1px, -1px); }
    60%  { transform: scale(0.95, 1.05) translate(-1px, 1px); }
    100% { transform: scale(1); }
}

@keyframes liquid {
    0%   { background-size: 100% 100%; }
    50%  { background-size: 103% 97%; }
    100% { background-size: 100% 100%; }
}

@keyframes flicker {
    0%, 100% { filter: brightness(1); }
    50%      { filter: brightness(1.15); }
}

/* ------------------------------------------------------
   FLOATING TEXT
------------------------------------------------------ */
.floating-text {
    position: absolute;
    font-weight: bold;
    pointer-events: none;
    z-index: 200;
    font-size: clamp(12px, 2.5vmin, 20px);
    transition: transform 0.8s ease-out, opacity 0.8s ease-out;
}

.floating-hit {
    color: #0ff;
    text-shadow: 0 0 8px #0ff, 0 0 16px #0ff;
}

.floating-miss {
    color: #f00;
    text-shadow: 0 0 8px #f00, 0 0 16px #f00;
}

.floating-combo {
    color: #ff0;
    text-shadow: 0 0 8px #ff0, 0 0 16px #ff0;
    font-size: clamp(24px, 5vmin, 40px);
}

/* Explosion Canvas */
#explosionCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Screen shake */
.shake {
    animation: shakeAnim 0.15s ease;
}

@keyframes shakeAnim {
    0% { transform: translate(0,0); }
    25% { transform: translate(4px,-4px); }
    50% { transform: translate(-4px,4px); }
    75% { transform: translate(4px,2px); }
    100% { transform: translate(0,0); }
}
