:root {
    --bg-sky: #7fd1ff;
    --bg-sun: #ffe3a1;
    --bg-ground: #f0b07a;
    --text-dark: #2b1d16;
    --text-light: #fff8ec;
    --card: rgba(255, 248, 236, 0.95);
    --accent: #ff7a59;
    --shadow: 0 20px 40px rgba(40, 20, 10, 0.25);
    --piece-height: 26px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Trebuchet MS", "Lucida Sans", "Lucida Sans Unicode", Verdana, sans-serif;
    color: var(--text-dark);
    background:
        radial-gradient(circle at top, var(--bg-sun), var(--bg-sky) 45%, #7bd0ff 60%, #67c4f7 80%),
        repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.12) 0 12px, rgba(255, 255, 255, 0) 12px 24px);
}

.page {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    gap: 16px;
}

.brand-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 1px;
}

.brand-sub {
    font-size: 14px;
    opacity: 0.7;
}

.mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    background: rgba(43, 29, 22, 0.12);
    color: #2b1d16;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.hud {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pause-button {
    border: none;
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 700;
    cursor: pointer;
    background: #2b1d16;
    color: var(--text-light);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.shop-link {
    text-decoration: none;
    font-weight: 700;
    color: var(--text-light);
    background: linear-gradient(120deg, #ff9b6a, #ff6b4a);
    padding: 8px 16px;
    border-radius: 999px;
    box-shadow: 0 8px 16px rgba(255, 107, 74, 0.35);
}

.hud-item {
    background: var(--card);
    border-radius: 14px;
    padding: 8px 14px;
    min-width: 78px;
    text-align: center;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
}

.hud-label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.7;
}

.hud-value {
    font-size: 20px;
    font-weight: 700;
}

.game-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding-bottom: 30px;
}

.game-area {
    position: relative;
    width: min(86vw, 420px);
    height: min(80vh, 640px);
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0));
    border-radius: 26px;
    border: 3px solid rgba(43, 29, 22, 0.4);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.game-area::before,
.game-area::after {
    content: "";
    position: absolute;
    width: 160px;
    height: 60px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    filter: blur(1px);
    opacity: 0.8;
    animation: drift 18s linear infinite;
}

.game-area::before {
    top: 40px;
    left: -40px;
}

.game-area::after {
    top: 140px;
    left: -120px;
    animation-delay: 6s;
}

.mode-select {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.mode-button {
    border: none;
    border-radius: 14px;
    padding: 10px 12px;
    font-weight: 700;
    cursor: pointer;
    background: rgba(43, 29, 22, 0.1);
    color: #2b1d16;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.mode-button.is-active {
    background: linear-gradient(120deg, #ff9b6a, #ff6b4a);
    color: var(--text-light);
    box-shadow: 0 10px 18px rgba(255, 107, 74, 0.35);
    transform: translateY(-1px);
}

.boost-select {
    display: grid;
    grid-template-columns: repeat(3, minmax(90px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.boost-button {
    border: none;
    border-radius: 12px;
    padding: 8px 10px;
    font-weight: 700;
    cursor: pointer;
    background: rgba(43, 29, 22, 0.1);
    color: #2b1d16;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.boost-button.is-active {
    background: linear-gradient(120deg, #ff9b6a, #ff6b4a);
    color: var(--text-light);
    box-shadow: 0 8px 16px rgba(255, 107, 74, 0.35);
}

.toast {
    position: absolute;
    top: 18px;
    right: 18px;
    background: rgba(43, 29, 22, 0.85);
    color: var(--text-light);
    padding: 8px 14px;
    border-radius: 999px;
    font-weight: 700;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 200ms ease, transform 200ms ease;
    pointer-events: none;
    z-index: 4;
}

.powerup-indicator {
    position: absolute;
    top: 18px;
    left: 18px;
    background: rgba(255, 255, 255, 0.9);
    color: #2b1d16;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: 0.4px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.12);
    z-index: 4;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.stack-world {
    position: absolute;
    inset: 0;
    transform: translateY(0px);
    transition: transform 200ms ease;
}

.control-hint {
    font-size: 14px;
    background: rgba(255, 255, 255, 0.75);
    padding: 8px 16px;
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.stack-base {
    position: absolute;
    width: 220px;
    height: 12px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 170px;
    background: linear-gradient(90deg, #9a5a33, #6d3b22);
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.tobin {
    position: absolute;
    width: 220px;
    height: 160px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    background-image: url("tobin.jpg");
    background-size: cover;
    background-position: center;
    border-top-left-radius: 18px;
    border-top-right-radius: 18px;
}

.bacon-piece {
    position: absolute;
    height: var(--piece-height);
    border-radius: 10px;
    border: 1px solid rgba(88, 40, 28, 0.35);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.18);
    transition: transform 120ms ease;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(255, 255, 255, 0.65);
    filter: saturate(1.08) contrast(1.05);
}

.bacon-piece::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0));
    pointer-events: none;
}

.bacon-piece--landing {
    transform: scale(1.02);
}

.bacon-piece--perfect {
    box-shadow: 0 0 0 2px rgba(255, 196, 111, 0.8), 0 10px 18px rgba(0, 0, 0, 0.2);
}

.powerup {
    position: absolute;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    display: grid;
    place-items: center;
    font-weight: 700;
    color: #2b1d16;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.2);
    animation: pulse 1.6s ease-in-out infinite;
    z-index: 2;
}

.powerup--slow {
    background: #cfe7ff;
}

.powerup--wide {
    background: #ffe2c4;
}

.powerup--shield {
    background: #d9f7e1;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

.overlay {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.55);
    backdrop-filter: blur(5px);
    z-index: 10;
}

.overlay[hidden] {
    display: none;
}

.overlay-card {
    background: var(--card);
    padding: 24px 28px;
    border-radius: 20px;
    text-align: center;
    box-shadow: var(--shadow);
    max-width: 320px;
}

.overlay-card h1,
.overlay-card h2 {
    margin: 0 0 12px;
}

.overlay-card p {
    margin: 0 0 14px;
    line-height: 1.4;
}

.btn {
    border: none;
    background: linear-gradient(120deg, #ff9b6a, #ff6b4a);
    color: var(--text-light);
    padding: 10px 18px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(255, 107, 74, 0.35);
}

.btn:active {
    transform: translateY(1px);
}

@keyframes drift {
    0% {
        transform: translateX(0);
    }
    100% {
        transform: translateX(520px);
    }
}

@media (max-width: 600px) {
    .top-bar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .hud {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    .top-actions {
        width: 100%;
        justify-content: center;
    }
}

.page--shop {
    min-height: 100vh;
    background: radial-gradient(circle at top, #ffe4c4, #ffd39a 35%, #ffcc8c 60%, #fbb370 85%);
}

.page[data-theme="diner"] {
    background:
        radial-gradient(circle at top, #ffe1f0, #b7f0e2 40%, #8ddfd0 70%, #6dc8ba 90%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0 10px, rgba(255, 255, 255, 0) 10px 20px);
}

.page[data-theme="sunset"] {
    background:
        radial-gradient(circle at top, #ffd2a8, #ff9b7d 45%, #ff7a59 70%, #e35a4d 90%),
        repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.18) 0 12px, rgba(255, 255, 255, 0) 12px 24px);
}

.page[data-theme="blueprint"] {
    background:
        radial-gradient(circle at top, #cfe7ff, #9dc9ff 45%, #78aef5 70%, #5d8fe0 90%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.22) 0 8px, rgba(255, 255, 255, 0) 8px 16px);
}

.page[data-theme="midnight"] {
    background:
        radial-gradient(circle at top, #1b2437, #101a2c 50%, #0b1220 85%),
        repeating-linear-gradient(120deg, rgba(255, 255, 255, 0.08) 0 10px, rgba(255, 255, 255, 0) 10px 20px);
}

.page[data-theme="forest"] {
    background:
        radial-gradient(circle at top, #d0f2c4, #79c58b 45%, #3d8f6b 75%, #1f5b47 95%),
        repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.18) 0 12px, rgba(255, 255, 255, 0) 12px 24px);
}

.page[data-theme="candy"] {
    background:
        radial-gradient(circle at top, #ffd4f2, #ffb3d9 45%, #ff8fc4 70%, #ff6aa8 90%),
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.2) 0 8px, rgba(255, 255, 255, 0) 8px 16px);
}

.shop-shell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 24px;
}

.shop-section {
    width: min(900px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
}

.shop-title {
    font-size: 32px;
    font-weight: 800;
    margin: 0;
}

.shop-subtitle {
    font-size: 20px;
    margin: 0;
}

.shop-text {
    margin: 0;
    opacity: 0.75;
}

.shop-coins {
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    font-weight: 700;
}

.skin-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
    width: min(900px, 92vw);
}

.boost-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}

.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 18px;
}

.theme-preview {
    height: 70px;
    border-radius: 14px;
    border: 2px solid rgba(88, 40, 28, 0.2);
}

.theme-preview[data-theme="default"] {
    background: linear-gradient(120deg, #ffe3a1, #7fd1ff);
}

.theme-preview[data-theme="diner"] {
    background: linear-gradient(120deg, #ffe1f0, #8ddfd0);
}

.theme-preview[data-theme="sunset"] {
    background: linear-gradient(120deg, #ffd2a8, #ff7a59);
}

.theme-preview[data-theme="blueprint"] {
    background: linear-gradient(120deg, #cfe7ff, #5d8fe0);
}

.theme-preview[data-theme="midnight"] {
    background: linear-gradient(120deg, #1b2437, #0b1220);
}

.theme-preview[data-theme="forest"] {
    background: linear-gradient(120deg, #d0f2c4, #1f5b47);
}

.theme-preview[data-theme="candy"] {
    background: linear-gradient(120deg, #ffd4f2, #ff6aa8);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12);
    font-weight: 700;
}

.stat-card span {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    opacity: 0.7;
}

.skin-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 12px 22px rgba(0, 0, 0, 0.18);
    position: relative;
}

.skin-preview {
    height: 70px;
    border-radius: 14px;
    border: 2px solid rgba(88, 40, 28, 0.3);
}

.skin-name {
    font-weight: 700;
    font-size: 18px;
}

.skin-price {
    font-size: 14px;
    opacity: 0.7;
}

.skin-actions {
    display: flex;
    gap: 10px;
}

.skin-button {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-weight: 700;
    cursor: pointer;
    background: #2b1d16;
    color: var(--text-light);
}

.skin-button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

.skin-selected {
    outline: 3px solid #ff9b6a;
}