* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

:root {
    --primary: #ff6b6b;
    --primary-dark: #ee5a52;
    --secondary: #4ecdc4;
    --accent: #ffe66d;
    --dark: #1a1a2e;
    --dark-light: #16213e;
    --text: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.6);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--dark);
    color: var(--text);
    touch-action: none;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 1;
}

.screen.active {
    display: flex;
}

/* Loading Screen */
#loadingScreen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    align-items: center;
    justify-content: center;
}

.loading-content {
    text-align: center;
    padding: 20px;
}

.loading-fruit {
    font-size: 80px;
    animation: bounce 1.5s ease-in-out infinite;
    margin-bottom: 20px;
}

.loading-content h1 {
    font-size: 28px;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #ff6b6b, #ffe66d, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-bar-wrapper {
    width: 240px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 16px;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff6b6b, #ffe66d, #4ecdc4);
    border-radius: 3px;
    transition: width 0.3s ease;
}

#loadingText {
    font-size: 14px;
    color: var(--text-muted);
}

/* Start Screen */
#startScreen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.start-content {
    text-align: center;
    padding: 20px;
    max-width: 400px;
    width: 100%;
    margin: auto;
}

.game-title {
    font-size: 32px;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ff6b6b, #ffe66d, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleGlow 3s ease-in-out infinite;
}

.game-subtitle {
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.instructions {
    text-align: left;
    margin-bottom: 36px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    font-size: 15px;
}

.instruction-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.instruction-icon {
    font-size: 24px;
    flex-shrink: 0;
}

/* Buttons */
.btn-primary {
    width: 100%;
    padding: 16px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
    margin-bottom: 12px;
}

.btn-primary:active {
    transform: scale(0.96);
    box-shadow: 0 2px 10px rgba(255, 107, 107, 0.3);
}

.btn-secondary {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    color: var(--text);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-secondary:active {
    transform: scale(0.96);
}

.controls-row {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.btn-icon {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, color 0.15s;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-icon:active {
    transform: scale(0.96);
    color: var(--text);
}

.btn-small {
    width: 40px;
    height: 40px;
    font-size: 18px;
    color: var(--text);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.btn-small:active {
    transform: scale(0.92);
}

/* Game Screen */
#gameScreen {
    background: #000;
    overflow: hidden;
}

#video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    z-index: 1;
    filter: brightness(0.5);
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

#poseCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    pointer-events: none;
}

/* HUD */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    padding-top: max(16px, env(safe-area-inset-top));
    pointer-events: none;
}

.hud-left, .hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-right {
    align-items: flex-end;
    flex-direction: row;
    gap: 12px;
}

.score-display {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
}

.score-label {
    font-size: 11px;
    color: var(--text-muted);
}

.score-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
}

.combo-display {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.3), rgba(255, 230, 109, 0.3));
    border: 1px solid rgba(255, 230, 109, 0.4);
    border-radius: 10px;
    padding: 6px 14px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: comboPop 0.3s ease;
}

.combo-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
}

.lives-display {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    gap: 4px;
}

.heart {
    font-size: 18px;
    transition: opacity 0.3s, transform 0.3s;
}

.heart.lost {
    opacity: 0.2;
    filter: grayscale(1);
    transform: scale(0.8);
}

#pauseBtn {
    pointer-events: auto;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.overlay.active {
    display: flex;
}

.overlay-content {
    text-align: center;
    padding: 30px;
    max-width: 320px;
    width: 90%;
    background: linear-gradient(135deg, rgba(26, 26, 46, 0.95), rgba(15, 52, 96, 0.95));
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.overlay-content h2 {
    font-size: 26px;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #ff6b6b, #ffe66d);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-score {
    margin-bottom: 12px;
}

.final-score-label {
    display: block;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.final-score-value {
    font-size: 48px;
    font-weight: 800;
    color: var(--accent);
}

.best-score {
    font-size: 15px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 100;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 14px;
    color: var(--text);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: transform 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* Animations */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

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

@keyframes comboPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes scoreFloat {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-60px); opacity: 0; }
}

/* Fullscreen */
:fullscreen, :-webkit-full-screen {
    width: 100%;
    height: 100%;
}

/* Responsive - Landscape / short screens */
@media (max-height: 500px) {
    .game-title { font-size: 22px; margin-bottom: 4px; }
    .game-subtitle { font-size: 13px; margin-bottom: 16px; }
    .instructions { padding: 12px; margin-bottom: 16px; }
    .instruction-item { font-size: 12px; padding: 4px 0; }
    .instruction-icon { font-size: 18px; }
    .btn-primary { padding: 12px; font-size: 16px; margin-bottom: 8px; }
    .btn-icon { padding: 8px; font-size: 11px; }
    .btn-icon svg { width: 18px; height: 18px; }
    .controls-row { gap: 8px; margin-top: 8px; }
    .start-content { padding: 12px; }
    .loading-fruit { font-size: 50px; margin-bottom: 10px; }
    .loading-content h1 { font-size: 22px; margin-bottom: 16px; }
}

@media (max-height: 380px) {
    .game-title { font-size: 18px; }
    .game-subtitle { display: none; }
    .instructions { padding: 8px; margin-bottom: 10px; }
    .instruction-item { padding: 3px 0; }
    .btn-primary { padding: 10px; font-size: 14px; }
}
