:root {
    --bg-deep: #08111b;
    --bg-mid: #102033;
    --bg-card: rgba(9, 17, 29, 0.78);
    --bg-card-strong: rgba(255, 255, 255, 0.08);
    --line-soft: rgba(255, 255, 255, 0.12);
    --text-strong: #f8fafc;
    --text-body: #d7e2ee;
    --text-muted: #98a8ba;
    --accent: #ffb547;
    --accent-strong: #f59e0b;
    --accent-cool: #38bdf8;
    --success: #5dd39e;
    --surface: #f4f7fb;
    --surface-strong: #ffffff;
    --shadow-deep: 0 24px 60px rgba(0, 0, 0, 0.28);
}

* {
    box-sizing: border-box;
}

html {
    background: linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Outfit", sans-serif;
    user-select: none;
    color: var(--text-strong);
    background:
        radial-gradient(circle at top left, rgba(255, 181, 71, 0.18), transparent 28%),
        radial-gradient(circle at 80% 10%, rgba(56, 189, 248, 0.14), transparent 24%),
        linear-gradient(180deg, var(--bg-mid) 0%, var(--bg-deep) 100%);
}

a,
button {
    font: inherit;
}

button {
    border: 0;
    cursor: pointer;
    touch-action: manipulation;
}

#game {
    position: relative;
    min-height: calc(100vh - 84px);
}

#menu {
    min-height: 100vh;
    padding: 88px 24px 120px;
}

.hero-shell,
.product-strip,
.difficulty-section,
.support-section {
    width: min(1120px, 100%);
    margin: 0 auto 24px;
}

.hero-shell {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.9fr);
    gap: 24px;
    align-items: stretch;
}

.hero-copy,
.hero-panel,
.strip-card,
.difficulty-section,
.support-section,
#rules {
    background: var(--bg-card);
    border: 1px solid var(--line-soft);
    box-shadow: var(--shadow-deep);
    backdrop-filter: blur(18px);
}

.hero-copy,
.hero-panel {
    border-radius: 28px;
    padding: 28px;
}

.eyebrow {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#menu-heading {
    margin: 18px 0 12px;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(42px, 7vw, 76px);
    line-height: 0.96;
    letter-spacing: -0.04em;
}

#menu-subheading {
    max-width: 640px;
    margin: 0;
    font-size: 19px;
    line-height: 1.6;
    color: var(--text-body);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 28px;
}

.hero-button,
.inline-link,
.support-links a,
#back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    padding: 0 20px;
    border-radius: 18px;
    text-decoration: none;
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
}

.hero-button:hover,
.inline-link:hover,
.support-links a:hover,
#back:hover {
    transform: translateY(-1px);
}

.hero-button.primary,
.inline-link,
#back {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
    color: #111827;
    font-weight: 700;
}

.hero-button.secondary,
.support-links a {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-strong);
    font-weight: 600;
}

.hero-panel {
    display: grid;
    gap: 14px;
}

.hero-stat {
    padding: 16px 18px;
    border-radius: 20px;
    background: var(--bg-card-strong);
}

.stat-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-stat strong {
    font-size: 24px;
    line-height: 1.2;
}

.product-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.strip-card {
    padding: 20px;
    border-radius: 24px;
}

.strip-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 18px;
}

.strip-card span {
    color: var(--text-body);
    line-height: 1.6;
}

.difficulty-section,
.support-section {
    border-radius: 28px;
    padding: 24px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.section-head h2 {
    margin: 0;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(24px, 4vw, 34px);
    letter-spacing: -0.03em;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.lvl {
    display: grid;
    gap: 10px;
    width: 100%;
    padding: 22px;
    text-align: left;
    border-radius: 24px;
    color: var(--text-strong);
    background: linear-gradient(135deg, rgba(24, 59, 86, 0.96) 0%, rgba(36, 84, 109, 0.96) 52%, rgba(47, 123, 114, 0.96) 100%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.lvl:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 181, 71, 0.32);
    box-shadow: 0 20px 42px rgba(0, 0, 0, 0.24);
}

.lvl-title {
    font-family: "Space Grotesk", sans-serif;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.lvl-meta,
.lvl-progress {
    font-size: 14px;
    font-weight: 600;
    color: #d7eef8;
    letter-spacing: 0.03em;
}

.lvl-summary {
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.55;
}

.support-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

#version-badge,
#level-version-badge {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 20;
    padding: 7px 11px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: white;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    backdrop-filter: blur(14px);
}

#level-version-badge {
    color: #111827;
    background: rgba(255, 255, 255, 0.92);
}

#level {
    z-index: 2;
    height: 100vh;
    width: 100vw;
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 10% 12%, rgba(255, 181, 71, 0.16), transparent 26%),
        radial-gradient(circle at 88% 8%, rgba(56, 189, 248, 0.16), transparent 24%),
        linear-gradient(180deg, #102033 0%, #0a1624 55%, #08111b 100%);
    overflow-y: auto;
    overflow-x: hidden;
    display: none;
}

#level-hero {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    width: min(860px, calc(100vw - 24px));
    padding: 18px 18px 16px;
    border-radius: 28px;
    background: rgba(7, 14, 24, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 22px 50px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
}

#level-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

#lvl-heading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    padding: 0 24px;
    border-radius: 999px;
    background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
    color: #111827;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(28px, 4vw, 38px);
    font-weight: 700;
    letter-spacing: 0.02em;
    box-shadow: 0 14px 30px rgba(245, 158, 11, 0.18);
}

#level-stage,
#win-summary {
    width: 100%;
    color: #d7e2ee;
}

#level-stage {
    margin-top: 12px;
    font-size: 18px;
    font-weight: 700;
}

#level-status,
#win-summary {
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}

#level-status span,
#win-summary span {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f8fafc;
    font-size: 14px;
    font-weight: 700;
}

#level-intent {
    margin-top: 14px;
    max-width: 720px;
    color: #d7e2ee;
    line-height: 1.6;
    font-size: 15px;
    font-weight: 500;
}

#board-surface {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 36px;
    background:
        radial-gradient(circle at top, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72)),
        linear-gradient(180deg, rgba(230, 238, 248, 0.96) 0%, rgba(213, 224, 238, 0.88) 100%);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        0 30px 60px rgba(0, 0, 0, 0.26);
}

.test-tube {
    position: absolute;
    height: 130px;
    width: 40px;
    border: 2px solid rgba(120, 144, 168, 0.9);
    border-radius: 8px 8px 22px 22px;
    background-position: 0 10px;
    overflow: hidden;
    transition: 1s linear;
    transform: rotate(0deg);
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.44) 0%, rgba(255, 255, 255, 0.14) 16%, rgba(255, 255, 255, 0.08) 52%, rgba(255, 255, 255, 0.2) 100%),
        rgba(255, 255, 255, 0.4);
    box-shadow:
        inset 1px 0 0 rgba(255, 255, 255, 0.6),
        inset -1px 0 0 rgba(255, 255, 255, 0.22),
        0 14px 28px rgba(15, 23, 42, 0.12);
    touch-action: manipulation;
}

.test-tube::before {
    content: "";
    position: absolute;
    top: 10px;
    left: 7px;
    width: 4px;
    height: 82px;
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.54) 0%, rgba(255, 255, 255, 0.06) 100%);
    pointer-events: none;
    z-index: 2;
}

.test-tube::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 6px 6px 20px 20px;
    box-shadow: inset 0 -10px 18px rgba(15, 23, 42, 0.08);
    pointer-events: none;
}

.hint-source {
    box-shadow:
        0 0 0 4px rgba(56, 189, 248, 0.34),
        0 0 0 10px rgba(56, 189, 248, 0.12),
        0 16px 32px rgba(15, 23, 42, 0.18);
}

.hint-target {
    box-shadow:
        0 0 0 4px rgba(245, 158, 11, 0.38),
        0 0 0 10px rgba(245, 158, 11, 0.12),
        0 16px 32px rgba(15, 23, 42, 0.18);
}

.colors {
    position: absolute;
    left: 0;
    height: 30px;
    width: 40px;
    box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.22);
}

#won {
    position: absolute;
    top: 220px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100vw - 40px);
    text-align: center;
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(40px, 7vw, 72px);
    font-weight: 700;
    color: #f8fafc;
    text-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

#white-bg {
    position: absolute;
    left: 0;
    top: 10px;
    width: 40px;
    height: 10px;
    background-color: white;
    z-index: 1000;
    transition: 1s;
}

#colorful-bg {
    position: absolute;
    width: 100%;
    height: 0;
    z-index: 1000;
    transition: 1s;
}

#level-actions {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    width: min(640px, calc(100vw - 24px));
    padding: 14px;
    border-radius: 24px;
    background: rgba(7, 14, 24, 0.64);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 22px 52px rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(16px);
}

.game-buttons {
    min-width: 140px;
    min-height: 54px;
    padding: 0 22px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-align: center;
    border-radius: 18px;
    text-shadow: none;
}

.icon-button {
    min-height: 44px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.action-button {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 12px 28px rgba(2, 6, 23, 0.32);
}

.accent-button {
    background: #0369a1;
    color: #f8fafc;
    border: 1px solid rgba(125, 211, 252, 0.36);
    box-shadow: 0 14px 32px rgba(3, 105, 161, 0.32);
}

#hint,
#undo,
#restart,
#home,
#next-level {
    color: #f8fafc;
}

.action-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#next-level {
    position: fixed;
    left: 50%;
    bottom: max(98px, calc(env(safe-area-inset-bottom) + 84px));
    transform: translateX(-50%);
    background: linear-gradient(135deg, #fde68a 0%, #f59e0b 100%);
    color: #111827;
    border: 0;
}

#rules-page {
    display: none;
    z-index: 1000;
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.68);
    opacity: 0;
    transition: 0.5s linear;
    backdrop-filter: blur(12px);
}

#rules {
    position: absolute;
    top: 50%;
    left: 50%;
    width: min(720px, calc(100vw - 32px));
    padding: 28px;
    transform: translate(-50%, -50%);
    border-radius: 28px;
    color: var(--text-strong);
}

#rules-heading {
    font-family: "Space Grotesk", sans-serif;
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 700;
}

#rules-text {
    margin-top: 14px;
    color: var(--text-body);
    line-height: 1.7;
    font-size: 17px;
}

#rules-points {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.rule-item {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-body);
    line-height: 1.55;
}

#back {
    margin-top: 22px;
}

.swal-onboarding {
    text-align: left;
    line-height: 1.7;
}

.swal-onboarding p {
    margin: 0 0 10px;
}

#site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
}

.footer-brand {
    display: grid;
    gap: 4px;
}

.footer-brand strong {
    color: var(--text-strong);
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.footer-links a {
    color: var(--text-body);
    text-decoration: none;
}

.footer-meta {
    font-size: 14px;
}

@media (max-width: 900px) {
    #menu {
        padding: 80px 16px 110px;
    }

    .hero-shell,
    .product-strip,
    .difficulty-grid {
        grid-template-columns: 1fr;
    }

    .hero-copy,
    .hero-panel,
    .difficulty-section,
    .support-section,
    #rules {
        padding: 22px;
    }
}

@media (max-width: 720px) {
    #level {
        min-height: 100vh;
    }

    #level-hero {
        top: 12px;
        width: calc(100vw - 16px);
        padding: 14px;
    }

    #lvl-heading {
        width: 100%;
        padding: 14px 18px;
        min-height: 52px;
        text-align: center;
    }

    #level-hero-top {
        flex-direction: column;
        align-items: stretch;
    }

    #level-status {
        gap: 8px;
    }

    .test-tube {
        transform-origin: center center;
    }

    #level-actions {
        width: calc(100vw - 20px);
        gap: 10px;
        padding: 12px;
    }

    .game-buttons {
        min-width: calc(50vw - 18px);
    }

    #site-footer {
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}
