:root {
    --steady-bg: #1a1a2e;
    --steady-canvas: #16213e;
    --steady-path: rgba(255, 255, 255, 0.15);
    --steady-trace: #FFD93D;
    --steady-cursor: #FF6B6B;
    --steady-text: #fff;
    --steady-text-dim: rgba(255, 255, 255, 0.6);
    --color-success: #4CAF50;
    --color-warning: #FFD93D;
    --color-danger: #FF6B6B;
    --font-main: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font-main);
    background-color: var(--steady-bg);
    color: var(--steady-text);
    -webkit-tap-highlight-color: transparent;
}

.game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    width: 100%;
    max-width: 500px;
    padding-bottom: 4rem;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--steady-trace);
}

.level-display {
    font-size: 1rem;
    color: var(--steady-text-dim);
    margin-bottom: 0.5rem;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    max-width: 350px;
    margin: 0 auto 1rem;
}

#canvas {
    width: 100%;
    height: 100%;
    background-color: var(--steady-canvas);
    border-radius: 16px;
    cursor: crosshair;
    touch-action: none;
}

/* Start and end zones */
.start-zone, .end-zone {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.start-zone {
    background: rgba(76, 175, 80, 0.3);
    border: 2px solid var(--color-success);
    color: var(--color-success);
    animation: pulse-start 1.5s ease-in-out infinite;
}

@keyframes pulse-start {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 15px 5px rgba(76, 175, 80, 0.3); }
}

.end-zone {
    background: rgba(255, 107, 107, 0.3);
    border: 2px solid var(--color-danger);
    color: var(--color-danger);
}

.state-idle .start-zone,
.state-idle .end-zone,
.state-tracing .start-zone,
.state-tracing .end-zone {
    opacity: 1;
}

.instruction {
    font-size: 1rem;
    color: var(--steady-text-dim);
    margin-bottom: 0.5rem;
}

.lives-display {
    font-size: 1.5rem;
    margin: 0.25rem 0;
    letter-spacing: 0.25rem;
}

.score {
    font-size: 3rem;
    font-weight: 700;
    margin: 0.5rem 0;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.3s, transform 0.3s;
}

.state-result .score {
    opacity: 1;
    transform: scale(1);
}

.best-score {
    font-size: 1rem;
    color: var(--steady-text-dim);
    margin-bottom: 0.25rem;
    opacity: 0;
}

.state-result .best-score {
    opacity: 1;
}

.share-container {
    margin: 0.5rem 0;
    opacity: 0;
}

.state-result .share-container {
    opacity: 1;
}

/* Override share button for dark theme */
.share-btn {
    background: var(--steady-trace);
    color: #333;
}

.share-btn:hover {
    background: #ffe566;
}

.hint {
    font-size: 0.85rem;
    color: var(--steady-text-dim);
    margin-top: 0.25rem;
    opacity: 0;
}

.state-result .hint {
    opacity: 1;
}

/* Hide instruction during result */
.state-result .instruction,
.state-result .lives-display,
.state-result .level-display {
    display: none;
}

/* Flash effect when touching edge */
.canvas-wrapper.flash {
    animation: edge-flash 0.2s ease-out;
}

@keyframes edge-flash {
    0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.8); }
    100% { box-shadow: 0 0 20px 10px rgba(255, 107, 107, 0); }
}

/* New best animation */
.state-result.new-best .score {
    animation: score-pop 0.5s ease-out;
}

@keyframes score-pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Home link */
.home-link {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--steady-text);
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.85rem;
    transition: background 0.2s, transform 0.1s;
    z-index: 10;
}

.home-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.home-link:active {
    transform: translateX(-50%) scale(0.95);
}

/* Responsive */
@media (max-width: 400px) {
    .title { font-size: 1.5rem; }
    .score { font-size: 2rem; }
    .canvas-wrapper { max-width: 280px; }
    .start-zone, .end-zone { width: 40px; height: 40px; font-size: 0.55rem; }
}

@media (max-height: 600px) {
    .title { font-size: 1.25rem; margin-bottom: 0.15rem; }
    .canvas-wrapper { max-width: 220px; margin-bottom: 0.5rem; }
    .score { font-size: 1.75rem; margin: 0.25rem 0; }
    .content { padding-bottom: 3rem; }
    .start-zone, .end-zone { width: 35px; height: 35px; font-size: 0.5rem; }
}

@media (min-height: 800px) {
    .canvas-wrapper { max-width: 400px; }
}
