/* Local Outfit Font */
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url('fonts/Outfit.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
        U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
        U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 400 900;
    font-display: swap;
    src: url('fonts/Outfit-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
        U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
        U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #22d3ee;
    --accent: #f472b6;
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --bg-dark: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-elevated: #252542;
    --text-primary: #ffffff;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.1);
}

html,
body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
}

.game-wrapper {
    width: 100%;
    height: 100%;
    max-width: 600px;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #0f0f1a 0%, #1a1a2e 100%);
}

.game-wrapper.shake {
    animation: shake 0.4s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translateX(-1px);
    }

    20%,
    80% {
        transform: translateX(2px);
    }

    30%,
    50%,
    70% {
        transform: translateX(-3px);
    }

    40%,
    60% {
        transform: translateX(3px);
    }
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: clamp(16px, 4vw, 32px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.screen.hidden {
    opacity: 0;
    transform: scale(0.95);
    visibility: hidden;
    pointer-events: none;
}

/* ===== START SCREEN ===== */
.start-screen {
    background: linear-gradient(180deg, rgba(99, 102, 241, 0.1) 0%, transparent 50%);
}

.logo-container {
    text-align: center;
    margin-bottom: 32px;
}

.logo-blocks {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
}

.logo-block {
    height: 16px;
    border-radius: 4px;
    animation: stackDrop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards,
        stackFloat 3s ease-in-out infinite;
    animation-delay: calc(var(--delay) * 0.1s), calc(0.4s + var(--delay) * 0.1s);
}

.logo-block:nth-child(1) {
    background: linear-gradient(180deg, #34d399 0%, #22c55e 100%);
    width: 60px;
    box-shadow: 0 4px 12px rgba(52, 211, 153, 0.3);
}

.logo-block:nth-child(2) {
    background: linear-gradient(180deg, #fbbf24 0%, #f59e0b 100%);
    width: 75px;
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.logo-block:nth-child(3) {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
    width: 90px;
    box-shadow: 0 4px 12px rgba(248, 113, 113, 0.3);
}

@keyframes stackDrop {
    0% {
        opacity: 0;
        transform: translateY(-40px) scale(0.8);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes stackFloat {

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

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

.start-screen h1 {
    font-size: 4rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: 8px;
    line-height: 1;
    animation: titleReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.35s backwards;
}

@keyframes titleReveal {
    0% {
        opacity: 0;
        transform: translateY(20px);
        letter-spacing: 20px;
    }

    100% {
        opacity: 1;
        transform: translateY(0);
        letter-spacing: 8px;
    }
}

.tagline {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: -8px;
    animation: taglineReveal 0.3s ease-out 0.5s backwards;
}

@keyframes taglineReveal {
    0% {
        opacity: 0;
        transform: translateX(-10px);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 40px;
    font-weight: 400;
    animation: fadeUp 0.4s ease-out 0.6s backwards;
}

@keyframes fadeUp {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }

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

.instructions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
    width: 100%;
    max-width: 280px;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: transform 0.2s ease, background 0.2s ease;
    animation: slideInLeft 0.4s ease-out backwards;
}

.instruction-item:nth-child(1) {
    animation-delay: 0.7s;
}

.instruction-item:nth-child(2) {
    animation-delay: 0.8s;
}

@keyframes slideInLeft {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.instruction-item:hover {
    transform: translateX(4px);
    background: var(--bg-elevated);
}

.instruction-icon {
    font-size: 1.2rem;
}

.instruction-item span:last-child {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.instruction-item kbd {
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Outfit', monospace;
    font-size: 0.8rem;
    color: var(--text-primary);
    border: 1px solid var(--border);
}

/* Primary Button */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--primary);
    color: var(--text-primary);
    border: none;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    animation: buttonPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.9s backwards;
}

@keyframes buttonPop {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.15) 0%, transparent 100%);
    border-radius: 16px 16px 0 0;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 12px 32px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.btn-secondary:active {
    transform: translateY(1px);
}

.btn-download {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
    color: #a78bfa;
    border: 1px solid rgba(168, 85, 247, 0.4);
    padding: 12px 28px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.btn-download:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(168, 85, 247, 0.25) 100%);
    border-color: rgba(168, 85, 247, 0.6);
    color: #c4b5fd;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(168, 85, 247, 0.2);
}

.btn-download:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-download .btn-icon {
    font-size: 1.1rem;
}

.btn-icon {
    font-size: 1.2rem;
}

.stats-bar {
    margin-top: 32px;
    animation: fadeUp 0.4s ease-out 1s backwards;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 12px 24px;
    border-radius: 50px;
    border: 1px solid var(--border);
}

.stat-icon {
    font-size: 1.1rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-value {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
}

/* ===== GAME SCREEN ===== */
.game-screen {
    padding: 0;
}

.game-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    pointer-events: none;
}

.hud-left,
.hud-right {
    flex: 1;
    display: flex;
    min-width: 90px;
    max-width: 90px;
}

.hud-center {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
}

.hud-right {
    justify-content: flex-end;
}

/* Shared HUD element style */
.hud-element {
    background: var(--bg-card);
    padding: 10px 20px;
    border-radius: 50px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    gap: 2px;
}

.hud-element-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.hud-element-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.score-display {
    background: var(--bg-card);
    padding: 10px 24px;
    border-radius: 50px;
    border: 1px solid var(--border);
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.score-display .score-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.combo-display {
    background: var(--bg-card);
    padding: 10px 0;
    border-radius: 50px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 52px;
    width: 90px;
    gap: 2px;
    animation: comboPopIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-display.hidden {
    display: none;
}

@keyframes comboPopIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.combo-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.combo-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--warning);
    line-height: 1;
}

.speed-indicator {
    background: var(--bg-card);
    padding: 10px 0;
    border-radius: 50px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 52px;
    width: 90px;
    gap: 4px;
}

.speed-label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.speed-bar {
    width: 60px;
    height: 5px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.speed-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning), var(--danger));
    background-size: 60px 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 20%;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.tap-hint {
    position: absolute;
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    animation: tapPulse 1.5s ease-in-out infinite;
}

.tap-hint .tap-icon {
    font-size: 2rem;
    animation: tapBounce 1s ease-in-out infinite;
}

.tap-hint span:last-child {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 2px;
}

@keyframes tapPulse {

    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

@keyframes tapBounce {

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

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

/* ===== GAME OVER SCREEN ===== */
.gameover-screen {
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(20px);
}

.gameover-content {
    text-align: center;
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }

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

.gameover-title {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--danger);
    letter-spacing: 4px;
    margin-bottom: 32px;
}

.score-breakdown {
    margin-bottom: 40px;
}

.score-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 16px;
}

.score-number {
    font-size: 5rem;
    font-weight: 900;
    color: var(--text-primary);
    line-height: 1;
}

.score-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 4px;
}

.score-best {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 12px 24px;
    border-radius: 50px;
    border: 1px solid var(--border);
}

.best-icon {
    font-size: 1.1rem;
}

.best-label {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.best-value {
    color: var(--warning);
    font-size: 1.2rem;
    font-weight: 700;
}

.new-record {
    margin-top: 16px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--warning), #f59e0b);
    border-radius: 50px;
    color: #1a1a2e;
    font-weight: 700;
    font-size: 1rem;
    animation: recordPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275), recordShine 2s ease-in-out infinite;
}

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

@keyframes recordPop {
    0% {
        transform: scale(0);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes recordShine {

    0%,
    100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.1);
    }
}

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

/* ===== RESPONSIVE ===== */

/* Large Desktop optimizations */
@media (min-width: 769px) {
    .game-wrapper {
        box-shadow: 0 0 60px rgba(99, 102, 241, 0.25);
        \n border-radius: 20px;
        \n overflow: hidden;
    }

    .start-screen h1 {
        font-size: 5rem;
    }

    .tagline {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1.1rem;
    }

    .score-number {
        font-size: 6.5rem;
    }

    .btn-primary {
        padding: 18px 56px;
        font-size: 1.2rem;
    }
}

/* Desktop optimizations */
@media (min-width: 601px) and (max-width: 768px) {
    .game-wrapper {
        box-shadow: 0 0 50px rgba(99, 102, 241, 0.2);
    }

    .start-screen h1 {
        font-size: 4.5rem;
    }

    .score-number {
        font-size: 6rem;
    }
}

/* Tablet/Medium screens */
@media (max-width: 600px) and (min-width: 451px) {
    .start-screen h1 {
        font-size: 3.5rem;
    }

    .game-hud {
        padding: 14px;
    }
}

/* Mobile screens */
@media (max-width: 450px) {
    .start-screen h1 {
        font-size: 2.8rem;
        letter-spacing: 6px;
    }

    .tagline {
        font-size: 1.1rem;
    }

    .instructions {
        max-width: 100%;
        gap: 10px;
    }

    .instruction-item {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .btn-primary {
        padding: 14px 32px;
        font-size: 0.95rem;
    }

    .gameover-title {
        font-size: 1.8rem;
        letter-spacing: 3px;
    }

    .score-number {
        font-size: 3.5rem;
    }

    .game-hud {
        padding: 12px;
    }

    .hud-left,
    .hud-right {
        min-width: 80px;
        max-width: 80px;
    }

    .combo-display,
    .speed-indicator {
        width: 80px;
        height: 48px;
        padding: 8px 0;
    }

    .score-display {
        padding: 8px 20px;
        height: 48px;
    }

    .score-display .score-value {
        font-size: 1.3rem;
    }
}

/* Very small mobile */
@media (max-width: 380px) {
    .start-screen h1 {
        font-size: 2.3rem;
        letter-spacing: 4px;
    }

    .logo-block {
        height: 14px;
    }

    .logo-block:nth-child(1) {
        width: 50px;
    }

    .logo-block:nth-child(2) {
        width: 65px;
    }

    .logo-block:nth-child(3) {
        width: 80px;
    }

    .subtitle {
        font-size: 0.9rem;
    }

    .instruction-item {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .score-number {
        font-size: 3rem;
    }
}

/* Short screens (landscape phones, small tablets) */
@media (max-height: 650px) {
    .logo-blocks {
        margin-bottom: 8px;
    }

    .start-screen h1 {
        font-size: 2.2rem;
        letter-spacing: 4px;
    }

    .tagline {
        font-size: 1rem;
    }

    .subtitle {
        margin-bottom: 20px;
        font-size: 0.85rem;
    }

    .instructions {
        margin-bottom: 20px;
        gap: 6px;
    }

    .instruction-item {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .btn-primary {
        padding: 12px 28px;
        font-size: 0.9rem;
    }

    .stats-bar {
        margin-top: 16px;
    }

    .gameover-title {
        font-size: 1.8rem;
        margin-bottom: 24px;
    }

    .score-number {
        font-size: 3.5rem;
    }
}

/* Very short screens */
@media (max-height: 550px) {
    .logo-container {
        margin-bottom: 16px;
    }

    .logo-blocks {
        gap: 3px;
        margin-bottom: 6px;
    }

    .logo-block {
        height: 12px;
    }

    .start-screen h1 {
        font-size: 1.8rem;
        letter-spacing: 3px;
    }

    .tagline {
        font-size: 0.9rem;
    }

    .subtitle {
        margin-bottom: 16px;
        font-size: 0.75rem;
    }

    .instructions {
        margin-bottom: 16px;
        gap: 4px;
    }

    .instruction-item {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    .instruction-icon {
        font-size: 1rem;
    }

    .btn-primary {
        padding: 10px 24px;
        font-size: 0.85rem;
        gap: 8px;
    }

    .stats-bar {
        margin-top: 12px;
    }

    .stat-item {
        padding: 8px 16px;
    }
}