:root {
    --bg: #07111f;
    --bg-elevated: rgba(10, 20, 36, 0.88);
    --bg-soft: rgba(18, 32, 54, 0.78);
    --border: rgba(132, 164, 214, 0.24);
    --text: #eef4ff;
    --muted: #9bb0d1;
    --accent: #5cf2c4;
    --accent-2: #8b5cf6;
    --shadow: 0 24px 50px rgba(2, 9, 18, 0.45);
    --danger: #ff5f7a;
    --warning: #fbbf24;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Inter", system-ui, sans-serif;
    background:
        radial-gradient(circle at top left, rgba(92, 242, 196, 0.16), transparent 28%),
        radial-gradient(circle at top right, rgba(139, 92, 246, 0.22), transparent 34%),
        linear-gradient(180deg, #0b1525 0%, #07111f 100%);
    color: var(--text);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
    background-size: 32px 32px;
    pointer-events: none;
}

button,
select {
    font: inherit;
}

.app-shell {
    position: relative;
    min-height: 100vh;
    padding: 24px;
    overflow: hidden;
}

.ambient {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.45;
    pointer-events: none;
}

.ambient-a {
    top: -80px;
    right: -70px;
    width: 220px;
    height: 220px;
    background: rgba(92, 242, 196, 0.28);
}

.ambient-b {
    left: -80px;
    bottom: 70px;
    width: 240px;
    height: 240px;
    background: rgba(139, 92, 246, 0.26);
}

.topbar,
.hero-panel,
.games-section,
.game-list-item,
.board-panel,
.hud-panel,
.mini-panel,
.stat-card {
    position: relative;
    backdrop-filter: blur(18px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding: 18px 20px;
    border-radius: 18px;
}

.brand-kicker,
.panel-kicker,
.eyebrow,
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0;
}

.brand-title,
.hero-title,
.panel-header h2,
.game-list-item h3,
.games-section-title {
    margin: 0;
}

.brand-title {
    margin-top: 8px;
    font-family: "Press Start 2P", monospace;
    font-size: clamp(18px, 3vw, 26px);
    line-height: 1.35;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.toolbar-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-soft);
    color: var(--muted);
}

.toolbar-field select {
    border: 0;
    background: transparent;
    color: var(--text);
    min-width: 58px;
    outline: none;
}

.icon-button,
.primary-button,
.secondary-button,
.ghost-button,
.control-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, opacity 0.16s ease;
}

.icon-button,
.ghost-button {
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--bg-soft);
    color: var(--text);
    border-color: var(--border);
}

.icon-button[data-active="false"] {
    opacity: 0.65;
}

.icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
}

.icon svg,
.control-button svg {
    width: 100%;
    height: 100%;
}

.primary-button,
.secondary-button,
.ghost-button {
    min-height: 46px;
    font-weight: 700;
}

.primary-button {
    padding: 0 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(92, 242, 196, 0.92), rgba(45, 212, 191, 0.92));
    color: #042014;
}

.secondary-button {
    padding: 0 18px;
    border-radius: 14px;
    background: rgba(14, 25, 42, 0.8);
    border-color: var(--border);
    color: var(--muted);
}

.ghost-button {
    color: var(--muted);
}

.icon-button:hover,
.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.control-button:hover {
    transform: translateY(-1px);
}

.app-main {
    margin-top: 20px;
}

.screen {
    display: none;
}

.screen.is-active {
    display: block;
}

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

.hero-title {
    margin-top: 8px;
    font-size: clamp(28px, 4vw, 44px);
    line-height: 1.08;
    max-width: 12ch;
}

.hero-copy {
    margin: 14px 0 0;
    max-width: 62ch;
    color: var(--muted);
    line-height: 1.6;
}

.games-section {
    margin-top: 20px;
    padding: 24px;
    border-radius: 20px;
}

.games-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
}

.games-section-title {
    margin-top: 8px;
    font-size: clamp(22px, 3vw, 30px);
}

.games-section-copy {
    margin: 0;
    max-width: 44ch;
    color: var(--muted);
    line-height: 1.6;
}

.games-list {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.game-list-item {
    display: grid;
    grid-template-columns: 84px minmax(0, 1fr) auto;
    gap: 18px;
    align-items: center;
    padding: 18px;
    border-radius: 18px;
}

.game-list-icon {
    display: grid;
    place-items: center;
    width: 84px;
    height: 84px;
    border-radius: 18px;
    background:
        radial-gradient(circle at top right, rgba(92, 242, 196, 0.14), transparent 34%),
        linear-gradient(180deg, rgba(7, 17, 31, 0.36), rgba(7, 17, 31, 0.12));
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.game-list-icon svg {
    width: 64px;
    height: 64px;
}

.candy-icon {
    background:
        radial-gradient(circle at top right, rgba(251, 113, 133, 0.16), transparent 34%),
        linear-gradient(180deg, rgba(21, 17, 31, 0.4), rgba(7, 17, 31, 0.12));
}

.game2048-icon {
    background:
        radial-gradient(circle at top right, rgba(245, 158, 11, 0.18), transparent 34%),
        linear-gradient(180deg, rgba(36, 18, 10, 0.48), rgba(14, 12, 24, 0.16));
}

.game4096-icon {
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.18), transparent 34%),
        linear-gradient(180deg, rgba(8, 31, 24, 0.52), rgba(13, 19, 34, 0.18));
}

.snake-icon {
    background:
        radial-gradient(circle at top right, rgba(132, 204, 22, 0.18), transparent 34%),
        linear-gradient(180deg, rgba(18, 34, 22, 0.58), rgba(10, 16, 28, 0.18));
}

.plane-icon {
    background:
        radial-gradient(circle at top right, rgba(96, 165, 250, 0.22), transparent 34%),
        linear-gradient(180deg, rgba(10, 28, 54, 0.58), rgba(12, 18, 34, 0.18));
}

.color-sort-icon {
    background:
        radial-gradient(circle at top right, rgba(244, 114, 182, 0.2), transparent 34%),
        linear-gradient(180deg, rgba(32, 22, 50, 0.58), rgba(12, 18, 34, 0.18));
}

.game-list-body {
    min-width: 0;
}

.game-card-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.chip {
    padding: 7px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
}

.chip-live {
    color: var(--accent);
}

.game-list-item p {
    margin: 10px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.game-list-action {
    min-width: 172px;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.95fr);
    gap: 20px;
}

.board-panel,
.hud-panel {
    border-radius: 20px;
    padding: 20px;
}

.panel-header,
.mini-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.panel-header h2 {
    margin-top: 8px;
    font-size: 28px;
}

.header-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.board-frame,
.match3-board-shell {
    position: relative;
    margin-top: 18px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        linear-gradient(180deg, rgba(6, 14, 26, 0.84), rgba(10, 19, 35, 0.94));
}

.board-frame {
    min-height: min(70vh, 700px);
}

#boardCanvas {
    display: block;
    width: min(100%, 420px);
    height: auto;
    margin: 0 auto;
    aspect-ratio: 1 / 2;
}

.overlay-message {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 12px;
    text-align: center;
    padding: 24px;
    background: rgba(4, 10, 20, 0.72);
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 2;
}

.overlay-message:not(.is-visible) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-message h3 {
    margin: 0;
    font-size: clamp(26px, 4vw, 34px);
}

.overlay-message p {
    margin: 0;
    max-width: 38ch;
    color: var(--muted);
    line-height: 1.6;
}

.mobile-controls {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin-top: 16px;
}

.control-button {
    min-height: 58px;
    border-radius: 14px;
    background: rgba(14, 25, 42, 0.88);
    color: var(--text);
    border-color: var(--border);
}

button:disabled {
    opacity: 0.52;
    cursor: not-allowed;
}

.control-button-accent {
    background: rgba(92, 242, 196, 0.14);
    border-color: rgba(92, 242, 196, 0.28);
}

.hud-panel {
    display: grid;
    gap: 18px;
    align-content: start;
}

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

.stat-card,
.mini-panel {
    border-radius: 16px;
}

.stat-card {
    padding: 16px;
    background: rgba(12, 23, 42, 0.92);
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(24px, 4vw, 34px);
    line-height: 1;
}

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

.mini-panel {
    padding: 16px;
}

#nextCanvas,
#holdCanvas {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    height: auto;
    margin-top: 8px;
}

.control-list {
    display: grid;
    gap: 10px;
    padding: 0;
    margin: 14px 0 0;
    list-style: none;
}

.control-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

kbd {
    display: inline-flex;
    min-width: 62px;
    justify-content: center;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.match3-layout .board-panel {
    display: grid;
    gap: 18px;
}

.game2048-layout .board-panel {
    display: grid;
    gap: 18px;
}

.snake-layout .board-panel {
    display: grid;
    gap: 18px;
}

.plane-layout .board-panel {
    display: grid;
    gap: 18px;
}

.color-sort-layout .board-panel {
    display: grid;
    gap: 18px;
}

.match3-stage {
    display: grid;
}

.match3-board-shell {
    padding: 16px;
}

.match3-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    aspect-ratio: 1 / 1;
    width: min(100%, 560px);
    margin: 0 auto;
}

.match3-cell {
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    min-height: 54px;
    background: rgba(8, 18, 32, 0.8);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.14s ease, border-color 0.14s ease, opacity 0.22s ease;
    will-change: transform, opacity;
}

.match3-cell::before,
.match3-cell::after {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 50%;
}

.match3-cell::before {
    background: var(--candy-base, #f43f5e);
    box-shadow: inset 0 -8px 12px rgba(0, 0, 0, 0.18), 0 10px 18px rgba(0, 0, 0, 0.2);
}

.match3-cell::after {
    inset: 18% 22% 38% 22%;
    background: rgba(255, 255, 255, 0.26);
    filter: blur(1px);
}

.match3-cell[data-candy="0"] { --candy-base: linear-gradient(180deg, #fb7185, #ef4444); }
.match3-cell[data-candy="1"] { --candy-base: linear-gradient(180deg, #fcd34d, #f59e0b); }
.match3-cell[data-candy="2"] { --candy-base: linear-gradient(180deg, #60a5fa, #2563eb); }
.match3-cell[data-candy="3"] { --candy-base: linear-gradient(180deg, #4ade80, #16a34a); }
.match3-cell[data-candy="4"] { --candy-base: linear-gradient(180deg, #c084fc, #9333ea); }
.match3-cell[data-candy="5"] { --candy-base: linear-gradient(180deg, #f9a8d4, #ec4899); }

.match3-cell.is-selected {
    border-color: rgba(92, 242, 196, 0.9);
    box-shadow: 0 0 0 2px rgba(92, 242, 196, 0.22);
}

.match3-cell:hover {
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.match3-cell.is-clearing::before {
    animation: pop-out 0.25s ease forwards;
}

@keyframes pop-out {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.2); opacity: 0; }
}

.session-stack {
    display: grid;
    gap: 14px;
    margin-top: 8px;
}

.session-row {
    display: grid;
    gap: 6px;
}

.session-row span {
    color: var(--muted);
    font-size: 13px;
}

.session-row strong {
    font-size: 15px;
    line-height: 1.45;
}

.candy-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.game2048-stage {
    display: grid;
}

.game2048-board-shell {
    position: relative;
    margin-top: 18px;
    padding: 18px;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        radial-gradient(circle at top right, rgba(245, 158, 11, 0.18), transparent 30%),
        linear-gradient(180deg, rgba(20, 14, 14, 0.92), rgba(15, 18, 32, 0.96));
}

.game4096-board-shell {
    background:
        radial-gradient(circle at top right, rgba(34, 197, 94, 0.18), transparent 30%),
        linear-gradient(180deg, rgba(8, 22, 18, 0.94), rgba(14, 18, 36, 0.98));
}

.snake-phone-shell {
    margin-top: 18px;
    padding: 18px;
    border-radius: 26px;
    background: linear-gradient(180deg, #20242d, #0c1119);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 24px 40px rgba(0,0,0,0.28);
}

.snake-phone-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    color: #b6c2d9;
    font-family: "Press Start 2P", monospace;
    font-size: 11px;
}

.snake-lcd-frame {
    position: relative;
    border-radius: 14px;
    padding: 14px;
    background: linear-gradient(180deg, #98b47e, #7c9965);
    border: 3px solid #4e5e43;
    box-shadow: inset 0 0 0 2px rgba(236, 252, 203, 0.25);
}

#snakeCanvas {
    display: block;
    width: min(100%, 420px);
    height: auto;
    margin: 0 auto;
    aspect-ratio: 7 / 10;
    border-radius: 6px;
    background: #91a97b;
    image-rendering: pixelated;
}

.snake-overlay {
    background: rgba(113, 134, 92, 0.82);
    color: #17210e;
}

.snake-overlay p,
.snake-overlay h3 {
    color: #17210e;
}

.snake-controls {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.plane-stage {
    display: grid;
}

.plane-board-shell {
    position: relative;
    margin-top: 18px;
    padding: 18px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(147, 197, 253, 0.18);
    background:
        radial-gradient(circle at top right, rgba(125, 211, 252, 0.2), transparent 30%),
        linear-gradient(180deg, rgba(10, 28, 55, 0.94), rgba(8, 16, 30, 0.98));
}

#planeCanvas {
    display: block;
    width: min(100%, 760px);
    height: auto;
    margin: 0 auto;
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    background: linear-gradient(180deg, #66b9ff, #0d3a68 68%, #08243f);
}

.plane-overlay {
    background: rgba(9, 24, 44, 0.58);
}

.plane-overlay p {
    color: rgba(226, 232, 240, 0.86);
}

.plane-controls {
    grid-template-columns: minmax(0, 220px);
    justify-content: center;
}

.color-sort-stage {
    display: grid;
}

.color-sort-board-shell {
    position: relative;
    margin-top: 18px;
    padding: 20px;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(244, 114, 182, 0.16);
    background:
        radial-gradient(circle at top right, rgba(192, 132, 252, 0.18), transparent 30%),
        linear-gradient(180deg, rgba(24, 16, 40, 0.94), rgba(12, 16, 30, 0.98));
}

.color-sort-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 18px 14px;
    align-items: end;
    width: min(100%, 760px);
    min-height: 380px;
    margin: 0 auto;
    padding: 6px 2px 12px;
}

.color-sort-animation-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 3;
}

.color-bottle {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    min-height: 260px;
    padding: 0 8px 12px;
    border: 0;
    background: transparent;
    cursor: pointer;
    transition: transform 0.18s ease;
    overflow: visible;
    transform-origin: center bottom;
}

.color-bottle:hover {
    transform: translateY(-4px);
}

.color-bottle.is-selected {
    transform: translateY(-10px);
}

.color-bottle.is-hint-source .color-bottle-shell,
.color-bottle.is-hint-target .color-bottle-shell {
    box-shadow: 0 0 0 2px rgba(250, 204, 21, 0.24), 0 18px 28px rgba(250, 204, 21, 0.14);
}

.color-bottle.is-hint-source {
    animation: hint-source-pulse 0.9s ease 2;
}

.color-bottle.is-hint-target {
    animation: hint-target-pulse 0.9s ease 2;
}

.color-bottle.is-pouring-target {
    animation: bottle-target-catch 0.42s ease;
}

.color-bottle.is-hidden-source {
    opacity: 0;
}

.color-bottle.is-receiving .color-bottle-shell {
    border-color: rgba(192, 132, 252, 0.92);
    box-shadow: 0 18px 28px rgba(192, 132, 252, 0.18);
}

.color-bottle.is-selected .color-bottle-shell {
    border-color: rgba(244, 114, 182, 0.82);
    box-shadow: 0 16px 30px rgba(236, 72, 153, 0.18);
}

.color-bottle.is-complete .color-bottle-shell {
    border-color: rgba(134, 239, 172, 0.92);
    box-shadow: 0 16px 28px rgba(34, 197, 94, 0.18);
}

.color-bottle-shell {
    position: relative;
    display: flex;
    flex-direction: column-reverse;
    justify-content: flex-start;
    gap: 4px;
    width: 64px;
    height: 220px;
    padding: 10px 8px 10px;
    border-radius: 0 0 22px 22px;
    border: 3px solid rgba(226, 232, 240, 0.84);
    border-top: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.08), rgba(148,163,184,0.02)),
        linear-gradient(180deg, rgba(8, 15, 28, 0.52), rgba(5, 10, 22, 0.3));
    overflow: hidden;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.color-bottle-shell.is-sealed::before,
.color-bottle-shell.is-sealed::after {
    border-color: rgba(134, 239, 172, 0.92);
}

.color-bottle-shell::before,
.color-bottle-shell::after {
    content: "";
    position: absolute;
    top: -8px;
    width: 14px;
    height: 16px;
    border: 3px solid rgba(226, 232, 240, 0.84);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
}

.color-bottle-shell::before {
    left: 6px;
    border-right: 0;
}

.color-bottle-shell::after {
    right: 6px;
    border-left: 0;
}

.color-segment {
    position: relative;
    height: calc((100% - 12px) / 4);
    border-radius: 10px;
    background: rgba(148, 163, 184, 0.12);
    border: 1px solid rgba(255,255,255,0.06);
    transition: transform 0.18s ease, opacity 0.18s ease, background 0.18s ease;
    overflow: hidden;
}

.color-segment.is-filled {
    background: var(--liquid, linear-gradient(180deg, #60a5fa, #2563eb));
    box-shadow: inset 0 -10px 12px rgba(0,0,0,0.16), inset 0 8px 10px rgba(255,255,255,0.14);
}

.color-segment.is-filled::after {
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.02) 40%, transparent 60%),
        radial-gradient(circle at 20% 0%, rgba(255,255,255,0.32), transparent 44%);
    transform: translateY(0);
    animation: liquid-wave 1.9s ease-in-out infinite;
    pointer-events: none;
}

.color-segment.is-pour-target {
    animation: liquid-fill-pop 0.42s ease;
}

.color-sort-overlay {
    background: rgba(17, 11, 31, 0.6);
}

.color-bottle-cap {
    position: absolute;
    top: 2px;
    left: 50%;
    width: 48px;
    height: 14px;
    border-radius: 999px;
    background: linear-gradient(180deg, #dcfce7, #86efac);
    border: 2px solid rgba(22, 101, 52, 0.48);
    box-shadow: 0 6px 12px rgba(34, 197, 94, 0.18);
    transform: translateX(-50%);
    animation: cap-close 0.34s ease;
}

.color-bottle-badge {
    position: absolute;
    top: -14px;
    right: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 9px;
    border-radius: 999px;
    background: linear-gradient(180deg, #dcfce7, #86efac);
    color: #14532d;
    border: 1px solid rgba(22, 101, 52, 0.24);
    box-shadow: 0 10px 20px rgba(34, 197, 94, 0.16);
    font-size: 11px;
    font-weight: 800;
    animation: badge-pop-in 0.28s ease;
}

.color-bottle-badge svg {
    width: 14px;
    height: 14px;
}

.color-pour-stream {
    position: absolute;
    top: 22px;
    width: 16px;
    height: 128px;
    border-radius: 999px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.4), rgba(255,255,255,0.02)),
        var(--liquid, linear-gradient(180deg, #60a5fa, #2563eb));
    box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 10px 18px rgba(15, 23, 42, 0.18);
    opacity: 0;
    transform-origin: top center;
    animation: pour-stream-flow 0.42s ease forwards;
    pointer-events: none;
}

.color-bottle.is-animating-clone {
    position: absolute;
    min-height: 0;
    margin: 0;
    padding: 0 8px 12px;
    pointer-events: none;
    z-index: 4;
}

.color-bottle.is-animating-clone:hover,
.color-bottle.is-animating-clone.is-selected,
.color-bottle.is-animating-clone.is-pouring-target {
    transform: none;
    animation: none;
}

.color-sort-particle {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 4px;
    box-shadow: 0 8px 12px rgba(15, 23, 42, 0.18);
    animation: color-sort-confetti 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    pointer-events: none;
    z-index: 5;
}

.color-bottle[data-pour-direction="right"] .color-pour-stream {
    --stream-tilt: 54deg;
    left: calc(50% + 18px);
    transform: rotate(var(--stream-tilt)) scaleY(0.2);
}

.color-bottle[data-pour-direction="left"] .color-pour-stream {
    --stream-tilt: -54deg;
    right: calc(50% + 18px);
    transform: rotate(var(--stream-tilt)) scaleY(0.2);
}

@keyframes bottle-target-catch {
    0%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px) scale(1.01); }
    56% { transform: translateY(-2px) scale(1.02); }
}

@keyframes hint-source-pulse {
    0%, 100% { transform: translateY(0) scale(1); }
    30% { transform: translateY(-8px) scale(1.02); }
}

@keyframes hint-target-pulse {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-4px) scale(1.03); }
}

@keyframes pour-stream-flow {
    0% { opacity: 0; transform: rotate(var(--stream-tilt)) scaleY(0.2); }
    18% { opacity: 1; transform: rotate(var(--stream-tilt)) scaleY(0.7); }
    32%, 78% { opacity: 1; transform: rotate(var(--stream-tilt)) scaleY(1); }
    100% { opacity: 0; transform: rotate(var(--stream-tilt)) scaleY(0.3); }
}

@keyframes liquid-fill-pop {
    0% { transform: scaleY(0.5); opacity: 0.3; }
    48% { transform: scaleY(1.06); opacity: 1; }
    100% { transform: scaleY(1); opacity: 1; }
}

@keyframes liquid-wave {
    0%, 100% { transform: translateY(1px); opacity: 0.95; }
    50% { transform: translateY(-2px); opacity: 1; }
}

@keyframes cap-close {
    0% { opacity: 0; transform: translateX(-50%) translateY(-14px); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes badge-pop-in {
    0% { opacity: 0; transform: scale(0.4) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes color-sort-confetti {
    0% {
        opacity: 0;
        transform: translate3d(0, 0, 0) rotate(0deg) scale(0.4);
    }
    20% {
        opacity: 1;
        transform: translate3d(calc(var(--drift-x) * 0.25), calc(var(--drift-y) * -0.2), 0) rotate(80deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate3d(var(--drift-x), var(--drift-y), 0) rotate(220deg) scale(0.84);
    }
}

.game2048-board {
    --gap: 12px;
    --tile-size: calc((100% - (var(--gap) * 3)) / 4);
    position: relative;
    width: min(100%, 560px);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
}

.game2048-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--gap);
    pointer-events: none;
}

.game2048-grid span {
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.game2048-tile-layer {
    position: absolute;
    inset: 0;
}

.game2048-tile {
    position: absolute;
    width: var(--tile-size);
    height: var(--tile-size);
    left: calc(var(--col) * (var(--tile-size) + var(--gap)));
    top: calc(var(--row) * (var(--tile-size) + var(--gap)));
    display: grid;
    place-items: center;
    border-radius: 18px;
    font-weight: 800;
    font-size: clamp(20px, 4vw, 32px);
    letter-spacing: 0;
    color: #fff7ed;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.16);
    box-shadow: inset 0 -10px 16px rgba(0, 0, 0, 0.16), 0 14px 28px rgba(0, 0, 0, 0.18);
    transition: left 180ms cubic-bezier(0.22, 1, 0.36, 1), top 180ms cubic-bezier(0.22, 1, 0.36, 1), transform 180ms cubic-bezier(0.22, 1, 0.36, 1), opacity 180ms ease;
}

.game2048-tile[data-value="2"] { background: linear-gradient(180deg, #f8fafc, #e2e8f0); color: #334155; }
.game2048-tile[data-value="4"] { background: linear-gradient(180deg, #fde68a, #fbbf24); color: #5b3908; }
.game2048-tile[data-value="8"] { background: linear-gradient(180deg, #fdba74, #f97316); }
.game2048-tile[data-value="16"] { background: linear-gradient(180deg, #fb7185, #ef4444); }
.game2048-tile[data-value="32"] { background: linear-gradient(180deg, #f472b6, #db2777); }
.game2048-tile[data-value="64"] { background: linear-gradient(180deg, #c084fc, #9333ea); }
.game2048-tile[data-value="128"] { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.game2048-tile[data-value="256"] { background: linear-gradient(180deg, #38bdf8, #0284c7); }
.game2048-tile[data-value="512"] { background: linear-gradient(180deg, #4ade80, #16a34a); }
.game2048-tile[data-value="1024"] { background: linear-gradient(180deg, #34d399, #059669); }
.game2048-tile[data-value="2048"] { background: linear-gradient(180deg, #fde047, #f59e0b); color: #5b3908; }
.game2048-tile[data-value="4096"] { background: linear-gradient(180deg, #facc15, #ca8a04); color: #4a3410; }

.game2048-tile.is-new {
    animation: tile-spawn 220ms ease;
}

.game2048-tile.is-merged {
    animation: tile-merge 240ms ease;
}

@keyframes tile-spawn {
    0% { transform: scale(0.2); opacity: 0.3; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes tile-merge {
    0% { transform: scale(0.9); }
    55% { transform: scale(1.14); }
    100% { transform: scale(1); }
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}

.legend-candy {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-block;
    box-shadow: inset 0 -4px 6px rgba(0, 0, 0, 0.18);
}

.candy-0 { background: linear-gradient(180deg, #fb7185, #ef4444); }
.candy-1 { background: linear-gradient(180deg, #fcd34d, #f59e0b); }
.candy-2 { background: linear-gradient(180deg, #60a5fa, #2563eb); }
.candy-3 { background: linear-gradient(180deg, #4ade80, #16a34a); }
.candy-4 { background: linear-gradient(180deg, #c084fc, #9333ea); }
.candy-5 { background: linear-gradient(180deg, #f9a8d4, #ec4899); }

@media (max-width: 980px) {
    .game-layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .app-shell {
        padding: 16px;
    }

    .topbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar {
        justify-content: stretch;
    }

    .toolbar > * {
        flex: 1 1 auto;
    }

    .hero-panel,
    .games-section,
    .board-panel,
    .hud-panel {
        padding: 16px;
        border-radius: 18px;
    }

    .games-section-header,
    .panel-header {
        flex-direction: column;
        align-items: stretch;
    }

    .panel-header h2 {
        font-size: 24px;
    }

    .game-list-item {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    .game-list-icon {
        width: 72px;
        height: 72px;
    }

    .game-list-action {
        grid-column: 1 / -1;
        width: 100%;
    }

    .header-actions {
        justify-content: stretch;
    }

    .header-actions > * {
        flex: 1 1 auto;
    }

    .board-frame {
        min-height: auto;
    }

    #boardCanvas {
        width: min(100%, 340px);
    }

    .match3-board-shell,
    .game2048-board-shell,
    .plane-board-shell,
    .color-sort-board-shell {
        padding: 14px;
        border-radius: 18px;
    }

    .match3-board {
        width: min(100%, 420px);
        gap: 7px;
    }

    .snake-phone-shell {
        padding: 14px;
        border-radius: 22px;
    }

    .snake-lcd-frame {
        padding: 10px;
    }

    #snakeCanvas {
        width: min(100%, 320px);
    }

    #planeCanvas {
        width: 100%;
        border-radius: 12px;
    }

    .mobile-controls {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }

    .game2048-controls,
    .snake-controls {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .plane-controls {
        grid-template-columns: 1fr;
    }

    .game2048-board {
        --gap: 10px;
        width: min(100%, 420px);
    }

    .color-sort-board {
        grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
        gap: 14px 10px;
        min-height: 320px;
        width: 100%;
    }

    .color-bottle {
        min-height: 228px;
        padding: 0 4px 10px;
    }

    .color-bottle-shell {
        width: 56px;
        height: 190px;
        padding: 8px 7px 8px;
        border-radius: 0 0 18px 18px;
    }
}

@media (max-width: 520px) {
    .mini-panels,
    .stat-grid,
    .candy-legend {
        grid-template-columns: 1fr 1fr;
    }

    .hero-title {
        max-width: none;
    }

    .match3-board {
        gap: 6px;
    }

    .match3-cell {
        min-height: 42px;
        border-radius: 12px;
    }

    .app-shell {
        padding: 12px;
    }

    .hero-panel,
    .games-section,
    .board-panel,
    .hud-panel {
        padding: 14px;
        border-radius: 16px;
    }

    .panel-header h2 {
        font-size: 21px;
    }

    .ghost-button,
    .primary-button {
        min-height: 44px;
        padding: 10px 12px;
    }

    .control-button {
        min-height: 50px;
        border-radius: 12px;
    }

    .mobile-controls {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .game2048-board {
        --gap: 8px;
        width: 100%;
    }

    .game2048-tile {
        border-radius: 14px;
        font-size: clamp(16px, 5vw, 24px);
    }

    .stat-card {
        padding: 14px;
    }

    .stat-card strong {
        font-size: clamp(20px, 6vw, 28px);
    }

    .color-sort-board {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 12px 8px;
        min-height: 280px;
    }

    .color-bottle {
        min-height: 206px;
        padding: 0 2px 8px;
    }

    .color-bottle-shell {
        width: 50px;
        height: 170px;
        padding: 7px 6px 7px;
    }

    .color-bottle-cap {
        width: 40px;
        height: 12px;
    }

    .color-bottle-badge {
        top: -10px;
        padding: 4px 7px;
        font-size: 10px;
    }

    .snake-phone-top {
        font-size: 9px;
    }

    #snakeCanvas {
        width: min(100%, 280px);
    }
}
