:root {
    --bg-color: #1a1a1a;
    --panel-bg: rgba(40, 40, 40, 0.4);
    --primary: #06b6d4;
    --primary-hover: #22d3ee;
    --accent: #22d3ee;
    --text-main: #ffffff;
    --text-muted: #d4d4d4;
    --grid-color: rgba(255, 255, 255, 0.05);
    --point-color: #ffffff;
    --line-user: #22d3ee;
    --line-correct: #34d399;
    --handle-bg: rgba(34, 211, 238, 0.2);
}

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

body {
    font-family: 'Jost', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, rgba(30, 30, 30, 0.5) 0%, var(--bg-color) 100%);
}

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

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

canvas.grabbing { cursor: grabbing !important; }
canvas.grab { cursor: grab; }

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform: scale(0.95);
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.hidden { display: none !important; }

/* Reduced blur so gameplay is visible */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    width: 90%;
    max-height: 95vh;
    overflow-y: auto;
}

.glass-panel::-webkit-scrollbar {
    width: 6px;
}
.glass-panel::-webkit-scrollbar-track {
    background: transparent;
}
.glass-panel::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.result-panel { padding: 4rem 3rem; }

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--point-color), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

h2 { font-size: 2.5rem; font-weight: 600; margin-bottom: 1rem; }

h3.final-score {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#score-text {
    font-size: 5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary), var(--primary-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2rem; }
#feedback-text, #final-feedback-text { font-size: 1.5rem; color: var(--text-main); font-weight: 400; margin-bottom: 2rem; }

.round-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.round-result {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.1rem;
}
.round-label {
    width: 80px;
    text-align: right;
    font-weight: 600;
    color: var(--text-muted);
}
.score-bar-bg {
    flex-grow: 1;
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    overflow: hidden;
}
.score-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.round-score-val {
    width: 40px;
    text-align: left;
    font-weight: 800;
}

button { font-family: inherit; cursor: pointer; outline: none; border: none; transition: all 0.2s ease; }

.primary-btn {
    background: var(--primary);
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    box-shadow: 0 10px 15px -3px rgba(6, 182, 212, 0.4);
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 15px 20px -3px rgba(6, 182, 212, 0.5);
}

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

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1.1rem;
    font-weight: 400;
    padding: 1rem 2rem;
    border-radius: 50px;
}

.secondary-btn:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-2px); }

.btn-group { display: flex; gap: 1rem; justify-content: center; margin-top: 1rem; }

.menu-settings { margin: 2rem 0; text-align: left; }
.menu-settings label { display: block; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); margin-bottom: 0.75rem; text-align: center; }

/* Mode selectors */
.mode-selector { display: flex; gap: 0.5rem; background: rgba(0, 0, 0, 0.2); padding: 0.5rem; border-radius: 12px; margin-top: 0.5rem; }
.diff-btn { flex: 1; padding: 0.75rem; border-radius: 8px; background: transparent; color: var(--text-muted); font-weight: 600; font-size: 1rem; }
.diff-btn.active { background: rgba(255, 255, 255, 0.1); color: white; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.diff-btn[data-diff="hard"].active { background: rgba(239, 68, 68, 0.15); color: var(--mode-hard, #ef4444); }

.shape-btn { flex: 1; padding: 0.75rem; border-radius: 8px; background: transparent; color: var(--text-muted); font-weight: 600; font-size: 1rem; }
.shape-btn.active { background: rgba(255, 255, 255, 0.1); color: white; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.shape-btn[data-shape="parabola"].active { background: rgba(255, 255, 255, 0.2); color: #ffffff; }

/* Language selector */
.lang-selector {
    position: absolute;
    top: 2rem;
    right: 2rem;
    display: flex;
    gap: 0.5rem;
    z-index: 20;
    pointer-events: auto;
}
.lang-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}
.lang-btn.active {
    background: var(--primary);
    color: white;
}

#ingame-ui { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; }
.top-bar { position: absolute; top: 2rem; left: 50%; transform: translateX(-50%); background: var(--panel-bg); backdrop-filter: blur(8px); padding: 0.5rem 1.5rem; border-radius: 50px; border: 1px solid rgba(255, 255, 255, 0.05); font-weight: 600; letter-spacing: 1px; color: var(--text-main); }
#instruction-text { position: absolute; top: 6rem; left: 50%; transform: translateX(-50%); background: var(--panel-bg); backdrop-filter: blur(4px); padding: 0.75rem 1.5rem; border-radius: 50px; margin: 0; font-size: 1rem; border: 1px solid rgba(255, 255, 255, 0.05); }
.mode-badge { position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%); background: rgba(6, 182, 212, 0.2); color: #22d3ee; padding: 0.25rem 1rem; border-radius: 50px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; border: 1px solid rgba(6, 182, 212, 0.3); }

/* Glitch effect on title */
.glitch { position: relative; }
@keyframes glitch-anim { 
    0% { clip: rect(44px, 9999px, 51px, 0); }
    10% { clip: rect(93px, 9999px, 35px, 0); }
    20% { clip: rect(10px, 9999px, 63px, 0); }
    30% { clip: rect(54px, 9999px, 12px, 0); }
    40% { clip: rect(42px, 9999px, 6px, 0); }
    50% { clip: rect(18px, 9999px, 55px, 0); }
    60% { clip: rect(33px, 9999px, 11px, 0); }
    70% { clip: rect(27px, 9999px, 39px, 0); }
    80% { clip: rect(84px, 9999px, 16px, 0); }
    90% { clip: rect(14px, 9999px, 81px, 0); }
    100% { clip: rect(38px, 9999px, 69px, 0); }
}

#notification-container {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 1rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    z-index: 100;
    transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    text-align: center;
}
#notification-container.show {
    top: 2rem;
}

#mobile-confirm-btn {
    position: absolute;
    bottom: 8rem;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    z-index: 20;
}

@media (pointer: coarse), (max-width: 768px) {
    #mobile-confirm-btn {
        display: block;
    }
}

@media (max-width: 768px), (max-height: 850px) {
    .glass-panel { padding: 1.5rem; }
    .result-panel { padding: 2rem 1.5rem; }
    h1 { font-size: 2.2rem; }
    h2 { font-size: 1.8rem; margin-bottom: 0.5rem; }
    h3.final-score { font-size: 2.5rem; margin-bottom: 0.5rem; }
    #score-text { font-size: 4rem; }
    p { margin-bottom: 1rem; font-size: 1rem; }
    #feedback-text, #final-feedback-text { font-size: 1.2rem; margin-bottom: 1rem; }
    .round-breakdown { padding: 1rem; margin-bottom: 1rem; gap: 0.5rem; }
    .round-result { font-size: 0.95rem; }
    .menu-settings { margin: 1rem 0; }
    .primary-btn { font-size: 1.1rem; padding: 0.75rem 1.5rem; }
    .secondary-btn { font-size: 1rem; padding: 0.75rem 1.2rem; }
    .lang-selector { top: 1rem; right: 1rem; }
}
