:root {
    color-scheme: light;
    --primary-color: #2563eb;
    --primary-strong: #1d4ed8;
    --secondary-color: #10b981;
    --secondary-strong: #059669;
    --text-color: #172033;
    --muted-color: #64748b;
    --highlight-color: #f97316;
    --danger-color: #ef4444;
    --surface-color: rgba(255, 255, 255, 0.86);
    --surface-strong: #ffffff;
    --background-color: #f7fbff;
    --grid-border-color: #0f172a;
    --tile-color: #f97316;
    --tile-text-color: #ffffff;
    --feedback-black: #1f2937;
    --feedback-white: #e5e7eb;
    --dent-color: #cbd5e1;
    --shadow-soft: 0 24px 80px rgba(37, 99, 235, 0.16);
    --shadow-card: 0 18px 45px rgba(15, 23, 42, 0.14);
    --radius-lg: 28px;
    --radius-md: 18px;
    --animation-speed: 28s;
    --surface: #f7fbff;
    --scroll-thumb: #94a3b8;
    --scroll-track: rgba(15, 23, 42, 0.08);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    background: var(--background-color);
}

body {
    margin: 0;
    color: var(--text-color);
    font-family: var(--font-family, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    position: relative;
    background:
        radial-gradient(circle at 15% 12%, rgba(96, 165, 250, 0.34), transparent 28rem),
        radial-gradient(circle at 88% 8%, rgba(16, 185, 129, 0.22), transparent 24rem),
        radial-gradient(circle at 70% 86%, rgba(249, 115, 22, 0.16), transparent 24rem),
        linear-gradient(135deg, #f8fbff 0%, #edf6ff 48%, #f7fff8 100%);
}

body::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(rgba(37, 99, 235, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(37, 99, 235, 0.055) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 80%);
}

.app-header,
.app-main,
.app-footer {
    position: relative;
    z-index: 1;
}

.app-header {
    flex: 0 0 calc(68px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    width: 100%;
    height: calc(68px + env(safe-area-inset-top));
    min-height: calc(68px + env(safe-area-inset-top));
    max-height: calc(68px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    background: rgba(247, 251, 255, 0.82);
    box-shadow: inset 0 -1px 0 rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(16px);
    box-sizing: border-box;
}

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
}

.app-main > .container,
.app-main > #gameContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    width: 100%;
    padding: 12px max(12px, env(safe-area-inset-right)) 16px max(12px, env(safe-area-inset-left));
    box-sizing: border-box;
}

.app-footer {
    flex: 0 0 auto;
    width: 100%;
    min-height: 52px;
    padding: 8px max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: rgba(247, 251, 255, 0.9);
    box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.18);
    backdrop-filter: blur(16px);
    box-sizing: border-box;
}

.app-main,
.side-nav,
.side-content,
.table-scroll,
.block-row {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

.app-main::-webkit-scrollbar,
.side-nav::-webkit-scrollbar,
.side-content::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar,
.block-row::-webkit-scrollbar {
    height: 11px;
    width: 11px;
}

.app-main::-webkit-scrollbar-track,
.side-nav::-webkit-scrollbar-track,
.side-content::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track,
.block-row::-webkit-scrollbar-track {
    background: var(--scroll-track);
}

.app-main::-webkit-scrollbar-thumb,
.side-nav::-webkit-scrollbar-thumb,
.side-content::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb,
.block-row::-webkit-scrollbar-thumb {
    background: var(--scroll-thumb);
    border-radius: 6px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

.edge-fade {
    position: absolute;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
}

.edge-fade.visible {
    opacity: 1;
}

.edge-fade-top,
.edge-fade-bottom {
    height: 20px;
}

.edge-fade-left,
.edge-fade-right {
    width: 20px;
}

.edge-fade-top {
    background: linear-gradient(var(--surface), rgba(247, 251, 255, 0));
}

.edge-fade-bottom {
    background: linear-gradient(rgba(247, 251, 255, 0), var(--surface));
}

.edge-fade-left {
    background: linear-gradient(to right, var(--surface), rgba(247, 251, 255, 0));
}

.edge-fade-right {
    background: linear-gradient(to left, var(--surface), rgba(247, 251, 255, 0));
}

h1 {
    color: var(--text-color);
    font-size: clamp(1.55rem, 4vw, 3rem);
    line-height: 1.05;
    letter-spacing: -0.045em;
    margin: 0 0 0.45rem;
}

button,
select,
input {
    font: inherit;
}

button,
.btn {
    border: 0;
    border-radius: 999px;
    min-height: 44px;
    padding: 0.72rem 1rem;
    color: #ffffff;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-strong));
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24);
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
    touch-action: manipulation;
}

select,
.app-select {
    appearance: none;
    -webkit-appearance: none;
    border: 1.5px solid rgba(15, 23, 42, 0.16);
    border-radius: 12px;
    min-height: 40px;
    padding: 0.42rem 2.45rem 0.42rem 0.8rem;
    color: var(--text-color);
    background-color: #ffffff;
    background-image:
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'><path d='M4 6.2L8 10.2L12 6.2' stroke='%231d4ed8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>"),
        linear-gradient(90deg, rgba(15, 23, 42, 0.1), rgba(15, 23, 42, 0.1)),
        linear-gradient(#eef3fb, #e8eef8);
    background-repeat: no-repeat;
    background-position: right 0.55rem center, right 2rem top, right top;
    background-size: 0.95rem 0.95rem, 1px 56%, 2rem 100%;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
    touch-action: manipulation;
}

button:hover,
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(37, 99, 235, 0.28);
    filter: saturate(1.05);
}

select:hover,
.app-select:hover {
    border-color: var(--primary-color);
    background-color: #f8fbff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button:active,
.btn:active {
    transform: translateY(0) scale(0.98);
}

button:focus-visible,
select:focus-visible,
.app-select:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(249, 115, 22, 0.75);
    outline-offset: 3px;
}

.app-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: min(100%, 1180px);
    height: 100%;
    margin: 0 auto;
}

.app-nav-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.45rem;
    min-width: 0;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.72rem;
    flex: 0 0 auto;
    font-weight: 950;
    letter-spacing: -0.03em;
    color: var(--text-color);
    text-decoration: none;
}

.brand-mark:hover {
    color: var(--primary-strong);
}

.brand-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #10b981);
    color: #fff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.22);
}

.language-selector {
    display: flex;
    align-items: center;
    margin: 0;
    min-width: 0;
}

.app-select {
    min-height: 40px;
    max-width: min(230px, 44vw);
    font-size: 0.88rem;
}

.app-select--language {
    max-width: min(200px, 40vw);
}

.app-footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: min(100%, 1180px);
    margin: 0 auto;
    color: var(--muted-color);
    font-size: 0.88rem;
}

.app-footer-inner p {
    margin: 0;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.release-tag {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom));
    right: max(10px, env(safe-area-inset-right));
    z-index: 40;
    padding: 0.38rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    color: var(--muted-color);
    background: rgba(255, 255, 255, 0.78);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    backdrop-filter: blur(12px);
    cursor: pointer;
}

.release-notes {
    display: none;
    position: absolute;
    right: max(10px, env(safe-area-inset-right));
    bottom: calc(max(10px, env(safe-area-inset-bottom)) + 42px);
    z-index: 40;
    max-width: min(340px, calc(100vw - 24px));
    padding: 0.9rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: var(--radius-md);
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(18px);
    font-size: 0.82rem;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}

@media (max-width: 520px) {
    .app-header {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }

    .brand-name {
        display: none;
    }

    .app-select,
    .app-select--language {
        min-height: 36px;
        max-width: min(160px, 40vw);
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
        font-size: 0.8rem;
    }

    .app-footer-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.15rem;
        font-size: 0.75rem;
        line-height: 1.35;
    }

    .release-tag,
    .release-notes {
        display: none;
    }
}
