@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@900&display=swap");

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #1a0000;
    font-family: "Nunito", sans-serif;
    font-weight: 900;
}

#canvas-container {
    position: fixed;
    inset: 0;
}
#canvas-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ── HUD ───────────────────────────────────────────────── */

#hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
}

#audio-toggle {
    position: absolute;
    top: 14px;
    right: 14px;
    pointer-events: auto;
    border: 2px solid #501000;
    outline: 2px solid #fcb400;
    background: #3200f8;
    color: #ffffff;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 11px;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 8px 10px;
    cursor: pointer;
    text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 0px;
}

#audio-toggle:focus-visible {
    outline: 2px solid #ffe000;
}

@media (max-width: 780px) {
    #audio-toggle {
        top: auto;
        bottom: 24px;
        right: 50%;
        transform: translateX(50%);
        font-size: 9px;
    }
}

#ring-counter-container,
#time-counter-container {
    align-items: center;
    display: flex;
    position: absolute;
    left: 14px;
}

#ring-counter-container {
    top: 14px;
}

#time-counter-container {
    top: 60px;
}

.ring-counter-cap.left {
    background-color: #fcb400;
    border-bottom-right-radius: 14px;
    border-top-right-radius: 14px;
    flex-shrink: 0;
    height: 39px;
    margin-left: -4px;
    width: 19px;
    rotate: 180deg;
    transform-origin: 50% 50%;
}

.ring-counter-cap.right {
    background-color: #fcb400;
    border-bottom-right-radius: 14px;
    border-top-right-radius: 14px;
    flex-shrink: 0;
    height: 39px;
    margin-left: -4px;
    width: 19px;
    rotate: 0deg;
    transform-origin: 50% 50%;
}

#ring-counter,
#time-counter {
    align-items: center;
    background-color: #3200f8;
    border: 2px solid #501000;
    display: flex;
    gap: 24px;
    outline: 2px solid #fcb400;
    padding: 6px 16px 6px 8px;
    position: relative;
    margin: 0;
}

.ring-counter-label,
#ring-count,
#time-count {
    color: #ffffff;
    display: inline-block;
    flex-shrink: 0;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: 19px;
    letter-spacing: 2px;
    line-height: 19px;
    text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 0px;
    text-transform: uppercase;
}

/* ── Spin Charge Bar ───────────────────────────────────── */

#spin-charge-bar {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 180px;
    height: 14px;
    background: #3200f8;
    border: 2px solid #501000;
    outline: 2px solid #fcb400;
}

#spin-charge-bar.hidden {
    display: none;
}

#spin-charge-fill {
    height: 100%;
    width: 0%;
    background: #ffe000;
    transition: background 0.1s;
}

#spin-charge-fill.full {
    background: #ff4400;
}

/* ── Speed Lines ───────────────────────────────────────── */

#speed-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    background: repeating-conic-gradient(
        from 0deg at 50% 50%,
        transparent 0deg,
        transparent 3deg,
        rgba(255, 255, 255, 0.6) 3.5deg,
        transparent 4deg
    );
    -webkit-mask-image: radial-gradient(circle, transparent 50%, black 100%);
    mask-image: radial-gradient(circle, transparent 50%, black 100%);
}

#speed-lines.active {
    opacity: 1;
    animation: speed-jitter 0.1s infinite;
}

@keyframes speed-jitter {
    0% {
        transform: scale(1.05) rotate(0deg);
    }
    50% {
        transform: scale(1.05) rotate(1.5deg);
    }
    100% {
        transform: scale(1.05) rotate(-1deg);
    }
}

/* ── Title Screen ──────────────────────────────────────── */

#title-screen {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    /* Dark red checkerboard — just like Sonic Jam's title */
    background-color: #1a0000;
    background-image: repeating-conic-gradient(#2d0000 0% 25%, #1a0000 0% 50%);
    background-size: 56px 56px;
    transition: opacity 0.7s ease;
}
#title-screen.out {
    opacity: 0;
    pointer-events: none;
}

.ts-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1;
    user-select: none;
}

.ts-logo-sonic {
    font-family: "Nunito", sans-serif;
    font-weight: 900;
    font-size: clamp(4rem, 12vw, 9rem);
    color: #ffe000;
    text-transform: uppercase;
    letter-spacing: 6px;
    /* Blue outline — just like the real Sonic logo */
    text-shadow:
        -5px -5px 0 #0033aa,
        5px -5px 0 #0033aa,
        -5px 5px 0 #0033aa,
        5px 5px 0 #0033aa,
        0 8px 0 #001166;
}

.ts-logo-sub {
    font-family: "Nunito", sans-serif;
    font-weight: 900;
    font-size: clamp(2rem, 6vw, 4.5rem);
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 8px;
    text-shadow:
        -3px -3px 0 #0033aa,
        3px -3px 0 #0033aa,
        -3px 3px 0 #0033aa,
        3px 3px 0 #0033aa,
        0 5px 0 #001166;
    margin-top: -0.15em;
}

.ts-press {
    margin-top: 3.5rem;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-weight: normal;
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 5px;
    animation: ts-blink 1.1s step-end infinite;
}

@keyframes ts-blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0;
    }
}

/* ── Challenge UI ──────────────────────────────────────── */

#challenge-hint {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    pointer-events: none;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#challenge-hint.hidden {
    display: none;
}

.ch-text {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(0.55rem, 1.5vw, 0.9rem);
    color: #ffffff;
    background-color: #3200f8;
    border: 2px solid #501000;
    outline: 2px solid #fcb400;
    padding: 8px 18px;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    animation: ts-blink 1.4s step-end infinite;
}

.ch-sub {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(0.45rem, 1.1vw, 0.65rem);
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 1px;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
}

#challenge-complete {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    pointer-events: none;
    text-align: center;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    background-color: #3200f8;
    border: 2px solid #501000;
    outline: 2px solid #fcb400;
    padding: 10px 24px;
}

#challenge-complete.hidden {
    display: none;
}

.cc-title {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(0.55rem, 1.5vw, 0.9rem);
    color: #ffe000;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    letter-spacing: 3px;
}

.cc-time {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(0.55rem, 1.5vw, 0.9rem);
    color: #ffffff;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
}

.cc-record {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(0.55rem, 1.5vw, 0.9rem);
    color: #ffe000;
    text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
    letter-spacing: 2px;
    animation: ts-blink 0.5s step-end infinite;
}

.cc-record.hidden {
    display: none;
}

.cc-best {
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-size: clamp(0.45rem, 1.1vw, 0.65rem);
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 1px;
}

.ts-copyright {
    position: absolute;
    bottom: 18px;
    font-family: "Press Start 2P", system-ui, sans-serif;
    font-weight: normal;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 2px;
    text-transform: uppercase;
}
