* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html, body, #root {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: #0b0f19;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background: radial-gradient(circle at center, #1e1b4b 0%, #090d16 80%);
}

#game-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* HUD Overlay */
.hud-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 20;
}

.hud-topbar {
    position: absolute;
    top: 10px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 960px;
    margin: 0 auto;
    pointer-events: none;
}

.hud-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    padding: 8px 18px;
    border-radius: 12px;
    border: 1px solid rgba(147, 51, 234, 0.4);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    pointer-events: auto;
}

.hud-label {
    font-size: 11px;
    font-weight: 800;
    color: #94a3b8;
    letter-spacing: 0.6px;
}

.moves-count {
    font-size: 24px;
    font-weight: 900;
    color: #f43f5e;
    text-shadow: 0 0 12px rgba(244, 63, 94, 0.6);
    min-width: 28px;
    text-align: right;
}

/* Dynamic Combo Multiplier Badge */
.combo-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 41, 59, 0.9);
    border: 2px solid rgba(250, 204, 21, 0.4);
    border-radius: 12px;
    padding: 6px 20px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s;
    pointer-events: auto;
}

.combo-multiplier {
    font-size: 16px;
    font-weight: 900;
    color: #f1f5f9;
    letter-spacing: 0.5px;
}

.combo-flare {
    font-size: 10px;
    font-weight: 900;
    color: #f59e0b;
    letter-spacing: 1px;
    animation: flash 0.6s infinite alternate;
}

.combo-badge.combo-active {
    border-color: #f59e0b;
    background: linear-gradient(135deg, rgba(88, 28, 135, 0.95), rgba(30, 27, 75, 0.95));
    transform: scale(1.12);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.combo-badge.combo-active .combo-multiplier {
    color: #fde047;
    text-shadow: 0 0 10px rgba(253, 224, 71, 0.8);
}

@keyframes flash {
    0% { opacity: 0.4; }
    100% { opacity: 1; }
}

.sub-stat {
    display: flex;
    align-items: center;
    gap: 8px;
}

.best-stat {
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    padding-left: 12px;
}

.score-value {
    font-size: 18px;
    font-weight: 900;
    color: #38bdf8;
    text-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.best-value {
    font-size: 16px;
    font-weight: 900;
    color: #facc15;
}

/* Modals */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(7, 10, 19, 0.82);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 40px;
    border-radius: 20px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.2);
    min-width: 340px;
    max-width: 460px;
    text-align: center;
    border: 2px solid rgba(168, 85, 247, 0.35);
    background: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
}

.gem-icon-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.gem-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.gem-dot.blue { background-color: #38bdf8; color: #38bdf8; }
.gem-dot.purple { background-color: #a855f7; color: #a855f7; }
.gem-dot.red { background-color: #ef4444; color: #ef4444; }
.gem-dot.yellow { background-color: #facc15; color: #facc15; }
.gem-dot.green { background-color: #22c55e; color: #22c55e; }
.gem-dot.orange { background-color: #f97316; color: #f97316; }
.gem-dot.white { background-color: #e2e8f0; color: #ffffff; }

.game-title {
    font-size: 32px;
    font-weight: 900;
    background: linear-gradient(135deg, #fbcfe8, #a855f7, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
    margin-bottom: 6px;
    text-shadow: 0 4px 12px rgba(168, 85, 247, 0.4);
}

.game-tagline {
    font-size: 13px;
    color: #cbd5e1;
    margin-bottom: 18px;
    max-width: 320px;
    line-height: 1.4;
}

.high-score-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(250, 204, 21, 0.12);
    border: 1px solid rgba(250, 204, 21, 0.4);
    padding: 6px 16px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.pill-label {
    font-size: 11px;
    font-weight: 800;
    color: #facc15;
    letter-spacing: 0.5px;
}

.pill-val {
    font-size: 16px;
    font-weight: 900;
    color: #fef08a;
}

.instructions-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 24px;
    text-align: left;
}

.inst-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: #e2e8f0;
    line-height: 1.3;
}

.inst-badge {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 20px;
    height: 20px;
    background: #7c3aed;
    color: #ffffff;
    font-size: 11px;
    font-weight: 900;
    border-radius: 50%;
    flex-shrink: 0;
}

.action-btn {
    min-height: 56px;
    min-width: 200px;
    padding: 14px 36px;
    border-radius: 14px;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.action-btn:hover {
    transform: translateY(-2px) scale(1.03);
}

.action-btn:active {
    transform: translateY(1px) scale(0.97);
}

.play-btn {
    background: linear-gradient(135deg, #9333ea, #3b82f6);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(147, 51, 234, 0.4);
}

.restart-btn {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    color: #ffffff;
    box-shadow: 0 8px 24px rgba(244, 63, 94, 0.4);
}

.key-hint {
    margin-top: 12px;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
}

/* Game Over Card */
.lose-text {
    font-size: 30px;
    font-weight: 900;
    color: #f43f5e;
    text-shadow: 0 0 16px rgba(244, 63, 94, 0.6);
    margin-bottom: 12px;
}

.new-high-badge {
    background: linear-gradient(90deg, #f59e0b, #eab308);
    color: #000000;
    font-size: 13px;
    font-weight: 900;
    padding: 6px 18px;
    border-radius: 20px;
    margin-bottom: 16px;
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.7);
    animation: bounce 0.8s infinite alternate ease-in-out;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-4px); }
}

.stats-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 24px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #94a3b8;
    font-weight: 700;
}

.stat-row.highlight {
    font-size: 18px;
    color: #ffffff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.stat-row.highlight .stat-val {
    color: #38bdf8;
    font-size: 22px;
}

.stat-val {
    color: #f1f5f9;
    font-weight: 900;
}

.combo-stat {
    color: #facc15;
}
