/* ============================================
   VOXA — Style System
   ============================================ */

/* --- CSS Variables --- */
:root {
    --bg-primary: #0a0b1e;
    --bg-secondary: #12132d;
    --bg-board: #181a3a;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.6);
    --accent: #6c5ce7;
    --accent-light: #a855f7;

    --tile-1: #29d6d6;
    --tile-1-dark: #1a9e9e;
    --tile-2: #2ecc71;
    --tile-2-dark: #1e9c51;
    --tile-3: #f39c12;
    --tile-3-dark: #c47f0a;
    --tile-4: #e74c6f;
    --tile-4-dark: #b83a58;
    --tile-5: #9b59b6;
    --tile-5-dark: #7a3f96;
    --tile-6: #f1c40f;
    --tile-6-dark: #c9a40c;

    --tile-radius: 8px;
    --board-gap: 2px;
    --tile-size: 60px;
    --board-width: 252px;
    --board-height: 630px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* === SCREENS === */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    pointer-events: all;
}

/* === START SCREEN === */
#start-screen {
    background: radial-gradient(ellipse at center, #1a1b3e 0%, var(--bg-primary) 70%);
    z-index: 10;
}

.start-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: fadeInUp 0.8s ease;
}

.pixelwhot-presents {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(0.75rem, 3vw, 1rem);
    font-weight: 500;
    color: #5271ff;
    letter-spacing: 0.12em;
    margin-bottom: 0.2rem;
    text-shadow: 0 2px 8px rgba(82, 113, 255, 0.3);
}

.game-title {
    font-family: 'Fredoka', sans-serif;
    font-size: clamp(2.5rem, 10vw, 4rem);
    font-weight: 700;
    letter-spacing: 0.25em;
    margin-bottom: 0.4rem;
    display: flex;
    gap: 0.04em;
}

.title-v { color: var(--tile-1); text-shadow: 0 2px 8px rgba(41, 214, 214, 0.4); }
.title-o { color: var(--tile-2); text-shadow: 0 2px 8px rgba(46, 204, 113, 0.4); }
.title-x { color: var(--tile-3); text-shadow: 0 2px 8px rgba(243, 156, 18, 0.4); }
.title-a { color: var(--tile-4); text-shadow: 0 2px 8px rgba(231, 76, 111, 0.4); }

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    letter-spacing: 0.15em;
    margin-bottom: 2rem;
}

.instructions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-bottom: 2.5rem;
    max-width: 280px;
    text-align: center;
    line-height: 1.7;
}

.instructions .dot {
    opacity: 0.3;
}

/* --- Buttons --- */
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    border: none;
    padding: 14px 52px;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
    box-shadow: 0 4px 24px rgba(108, 92, 231, 0.35);
}

.btn-primary:active {
    transform: scale(0.95);
    box-shadow: 0 2px 12px rgba(108, 92, 231, 0.25);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 12px 40px;
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    border-radius: 50px;
    cursor: pointer;
    margin-top: 12px;
    transition: transform 0.12s;
}

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



/* === HUD === */
#game-screen {
    justify-content: flex-start;
    padding-top: 8px;
    background: var(--bg-primary);
}

#hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 6px 20px;
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.hud-label {
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
}

.hud-value {
    font-size: 1.3rem;
    font-weight: 800;
}

.hud-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    display: inline-flex;
    gap: 0.02em;
}

#next-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.preview-label {
    font-size: 0.5rem;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
}

#next-tile-box {
    width: 26px;
    height: 26px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    transition: background 0.3s, box-shadow 0.3s;
}

/* --- Game Area Wrapper (board + side buttons) --- */
#game-area-wrapper {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 10px;
    width: 100%;
    max-width: 100vw;
    flex: 1;
    padding: 4px 8px 0;
    overflow: hidden;
}

.side-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.12s;
    margin-top: 12px;
    flex-shrink: 0;
}

.side-btn:active {
    transform: scale(0.9);
}

.side-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

.side-btn.muted {
    opacity: 0.4;
}

/* --- Timer Display --- */
#timer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    margin-top: 2px;
}

#elapsed-time {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.08em;
}

#score-rate {
    font-size: 0.5rem;
    font-weight: 500;
    color: var(--accent-light);
    letter-spacing: 0.05em;
}

/* === GAME CONTAINER === */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 1 auto;
    max-width: calc(var(--board-width) + 10px);
    position: relative;
    overflow: hidden;
}

/* --- Board Perspective --- */
#board-perspective {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    flex: 1;
    width: 100%;
    padding-top: 4px;
}

#board {
    width: var(--board-width);
    height: var(--board-height);
    background: linear-gradient(180deg, rgba(20, 22, 50, 0.95) 0%, rgba(20, 22, 50, 0.7) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px 10px 4px 4px;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 -15px 40px rgba(108, 92, 231, 0.04),
        inset 0 0 50px rgba(0, 0, 0, 0.25);
}

/* Danger glow */
#board.danger::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 35%;
    background: linear-gradient(to top, rgba(230, 61, 111, 0.18), transparent);
    animation: dangerPulse 1.2s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

/* === SHOOT AREA === */
#shoot-area {
    width: var(--board-width);
    height: 70px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
}

#current-tile-box {
    width: calc(var(--board-width) / 4 - var(--board-gap) * 2);
    height: calc(var(--board-width) / 4 - var(--board-gap) * 2);
    max-height: 56px;
    border-radius: var(--tile-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 900;
    position: absolute;
    transition: left 0.08s ease-out;
    z-index: 3;
    cursor: grab;
}

#current-tile-box:active {
    cursor: grabbing;
}

/* --- Aim Line --- */
#aim-line {
    position: absolute;
    width: 2px;
    bottom: 100%;
    height: 0;
    background: linear-gradient(to top, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
    pointer-events: none;
    z-index: 2;
    transition: left 0.08s ease-out, height 0.1s ease;
    border-radius: 1px;
}

/* === TILES === */
.tile {
    position: absolute;
    border-radius: var(--tile-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    z-index: 1;
    transition: top 0.15s ease, left 0.15s ease;
    will-change: transform;
}

.tile .tile-num {
    position: relative;
    z-index: 1;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Tile colour classes */
.tile-1 {
    background: linear-gradient(145deg, var(--tile-1), var(--tile-1-dark));
    box-shadow: 0 3px 10px rgba(41, 214, 214, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #0a3d3d;
}

.tile-2 {
    background: linear-gradient(145deg, var(--tile-2), var(--tile-2-dark));
    box-shadow: 0 3px 10px rgba(46, 204, 113, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #0a3d1a;
}

.tile-3 {
    background: linear-gradient(145deg, var(--tile-3), var(--tile-3-dark));
    box-shadow: 0 3px 10px rgba(243, 156, 18, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #3d2a05;
}

.tile-4 {
    background: linear-gradient(145deg, var(--tile-4), var(--tile-4-dark));
    box-shadow: 0 3px 10px rgba(231, 76, 111, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #3d0f1e;
}

.tile-5 {
    background: linear-gradient(145deg, var(--tile-5), var(--tile-5-dark));
    box-shadow: 0 3px 10px rgba(155, 89, 182, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    color: #2a1240;
}

.tile-6 {
    background: linear-gradient(145deg, var(--tile-6), var(--tile-6-dark));
    box-shadow: 0 3px 12px rgba(241, 196, 15, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.2);
    color: #3d3005;
}

/* === TILE ANIMATIONS === */
.tile-spawn {
    animation: tileSpawn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tile-impact {
    animation: tileImpact 0.25s ease;
}

.tile-merge {
    animation: tileMerge 0.35s ease;
}

.tile-pop-6 {
    animation: tilePop6 0.5s ease;
}

.tile-disappear {
    animation: tileDisappear 0.4s ease forwards;
}

@keyframes tileSpawn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    60% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes tileImpact {
    0% {
        transform: scaleX(1) scaleY(1);
    }

    30% {
        transform: scaleX(1.12) scaleY(0.88);
    }

    60% {
        transform: scaleX(0.95) scaleY(1.05);
    }

    100% {
        transform: scaleX(1) scaleY(1);
    }
}

@keyframes tileMerge {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.25);
        filter: brightness(1.4);
    }

    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes tilePop6 {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.4);
        filter: brightness(1.6);
        box-shadow: 0 0 30px rgba(241, 196, 15, 0.7);
    }

    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}

@keyframes tileDisappear {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.6;
        filter: brightness(2);
    }

    100% {
        transform: scale(0);
        opacity: 0;
    }
}

@keyframes dangerPulse {
    0% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* === OVERLAYS === */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 20, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

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

.overlay-card {
    background: linear-gradient(160deg, rgba(30, 30, 60, 0.95), rgba(15, 15, 35, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 36px 40px;
    text-align: center;
    min-width: 260px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: cardIn 0.4s ease;
}

.overlay-card h2 {
    font-size: 1.6rem;
    letter-spacing: 0.2em;
    margin-bottom: 24px;
    font-weight: 800;
}

.score-row {
    display: flex;
    justify-content: center;
    gap: 36px;
    margin-bottom: 28px;
}

.score-col {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-label {
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.score-value {
    font-size: 1.8rem;
    font-weight: 900;
}

@keyframes cardIn {
    0% {
        transform: scale(0.85) translateY(20px);
        opacity: 0;
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* === EFFECTS === */
#effects-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 15;
    overflow: hidden;
}

.floating-score {
    position: absolute;
    font-size: 1.1rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    animation: floatUp 0.9s ease-out forwards;
    pointer-events: none;
    z-index: 16;
}

.floating-score.big {
    font-size: 1.6rem;
    color: var(--tile-6);
    text-shadow: 0 0 15px rgba(241, 196, 15, 0.6);
}

@keyframes floatUp {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translateY(-60px) scale(0.7);
        opacity: 0;
    }
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    pointer-events: none;
    animation: particleBurst 0.6s ease-out forwards;
}

@keyframes particleBurst {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Screen shake */
.shake {
    animation: screenShake 0.3s ease;
}

@keyframes screenShake {

    0%,
    100% {
        transform: translate(0, 0);
    }

    15% {
        transform: translate(-3px, 2px);
    }

    30% {
        transform: translate(3px, -2px);
    }

    45% {
        transform: translate(-2px, 3px);
    }

    60% {
        transform: translate(2px, -1px);
    }

    75% {
        transform: translate(-1px, 2px);
    }
}

/* Combo indicator */
.combo-text {
    position: absolute;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--accent-light);
    text-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
    animation: comboIn 0.6s ease forwards;
    pointer-events: none;
}

@keyframes comboIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.2);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* General */
@keyframes fadeInUp {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }

    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Landing preview ghost */
.landing-ghost {
    position: absolute;
    border-radius: var(--tile-radius);
    border: 2px dashed rgba(255, 255, 255, 0.12);
    pointer-events: none;
    z-index: 0;
}