@import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,400;0,600;0,800;0,900;1,800&display=swap');

:root {
    --bg-primary: #0f1423;
    --bg-secondary: #1a233a;
    --accent-gold: #ffd200;
    --accent-gold-dark: #b8860b;
    --royal-purple: #5c2494;
    --royal-blue: #185a9d;
    --board-bg: #151c2e;
    --cell-bg: #1f2942;
    --cell-border: #2e3d5e;
}

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

body, html {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background: radial-gradient(circle at 50% 20%, #251b3d 0%, #0d111d 100%);
    font-family: 'Rubik', -apple-system, BlinkMacSystemFont, sans-serif;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    max-height: 920px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at 50% 10%, #202b48 0%, #0e1320 85%);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

/* --- HEADER HUD --- */
.header-hud {
    padding: 12px 14px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-pill {
    background: linear-gradient(180deg, #2b395a 0%, #172033 100%);
    border: 2px solid #4a6194;
    border-radius: 20px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 800;
    font-size: 14px;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.2), 0 3px 6px rgba(0,0,0,0.4);
}

.stat-pill .icon {
    font-size: 18px;
    filter: drop-shadow(0 2px 2px rgba(0,0,0,0.5));
}

.level-badge {
    background: linear-gradient(180deg, #ff9900 0%, #cc5500 100%);
    border: 2px solid #ffd200;
    border-radius: 12px;
    padding: 4px 12px;
    font-weight: 900;
    font-size: 15px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    box-shadow: 0 4px 10px rgba(255, 153, 0, 0.4);
}

/* --- GOALS & MOVES PANEL --- */
.game-info-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(180deg, rgba(32, 45, 75, 0.8) 0%, rgba(18, 25, 43, 0.95) 100%);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 18px;
    padding: 8px 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.goals-container {
    display: flex;
    gap: 12px;
    align-items: center;
}

.goal-item {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.goal-item .gem-preview {
    width: 32px;
    height: 32px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.goal-item .goal-count {
    font-weight: 900;
    font-size: 16px;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.moves-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, #ff416c 0%, #ff4b2b 100%);
    border: 2px solid #ff9999;
    border-radius: 14px;
    padding: 2px 14px;
    box-shadow: 0 4px 8px rgba(255, 75, 43, 0.4);
}

.moves-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.9);
}

.moves-value {
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

/* --- BOARD WRAPPER --- */
.board-wrapper {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    position: relative;
    touch-action: none;
}

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

.board {
    width: 96%;
    aspect-ratio: 1 / 1;
    max-width: 440px;
    background: #111827;
    border: 5px solid #283758;
    border-radius: 20px;
    padding: 6px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    gap: 4px;
    box-shadow: 
        inset 0 4px 10px rgba(0,0,0,0.8),
        0 10px 25px rgba(0,0,0,0.6),
        0 0 20px rgba(74, 97, 148, 0.2);
    position: relative;
    user-select: none;
    touch-action: none;
}

.cell {
    background: linear-gradient(135deg, #1b2438 0%, #141b2c 100%);
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.4);
    touch-action: none;
}

.gem {
    width: 90%;
    height: 90%;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    filter: drop-shadow(0 3px 5px rgba(0,0,0,0.5));
}

.gem svg {
    width: 100%;
    height: 100%;
}

.gem.selected {
    transform: scale(1.18);
    filter: drop-shadow(0 0 10px #ffd700);
    z-index: 10;
}

.gem.hint {
    animation: pulseHint 1s infinite alternate;
}

@keyframes pulseHint {
    0% { transform: scale(1); }
    100% { transform: scale(1.12); filter: drop-shadow(0 0 8px #ffd700); }
}

/* --- BOTTOM HUD & CONTROLS --- */
.bottom-hud {
    padding: 8px 14px 16px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10;
}

.booster-btn {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: linear-gradient(180deg, #2c3a5e 0%, #182136 100%);
    border: 2px solid #4a6194;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4), inset 0 2px 4px rgba(255,255,255,0.2);
    transition: transform 0.1s active;
}

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

.booster-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff3b30;
    color: white;
    font-size: 11px;
    font-weight: 900;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 2px solid #fff;
}

/* --- MODAL POPUPS --- */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 12, 22, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    width: 88%;
    max-width: 380px;
    background: linear-gradient(180deg, #1f2a44 0%, #111728 100%);
    border: 3px solid #ffd200;
    border-radius: 28px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0,0,0,0.8), 0 0 30px rgba(255, 210, 0, 0.3);
    transform: scale(0.85);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
    transform: scale(1);
}

.modal-ribbon {
    margin-top: -38px;
    background: linear-gradient(180deg, #ffd700 0%, #ff8800 100%);
    padding: 8px 30px;
    border-radius: 20px;
    font-size: 22px;
    font-weight: 900;
    color: #3d1a00;
    text-shadow: 0 1px 2px rgba(255,255,255,0.4);
    box-shadow: 0 6px 14px rgba(255, 136, 0, 0.5);
    border: 2px solid #fff;
    margin-bottom: 16px;
}

.stars-row {
    display: flex;
    gap: 8px;
    font-size: 40px;
    margin-bottom: 16px;
}

.primary-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(180deg, #28cd41 0%, #009922 100%);
    border: 2px solid #70ff83;
    border-radius: 18px;
    color: white;
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 6px 15px rgba(40, 205, 65, 0.4);
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
    margin-top: 14px;
    transition: transform 0.1s;
}

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

.secondary-btn {
    background: transparent;
    border: none;
    color: #8fa0c9;
    font-weight: 700;
    font-size: 14px;
    margin-top: 12px;
    cursor: pointer;
}
