:root {
    color-scheme: dark;
    --page: #131617;
    --surface: #202527;
    --surface-raised: #2c3336;
    --line: #3a4245;
    --text: #f6faf7;
    --muted: #b0babb;
    --blue: #a9dfff;
    --green: #aaf39a;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--page);
}

html, body, .app {
    background: var(--page);
}

.app {
    --side-inset: max(18px, env(safe-area-inset-left), env(safe-area-inset-right));
    --top-inset: max(12px, env(safe-area-inset-top));
    --bottom-inset: max(10px, env(safe-area-inset-bottom));
    width: min(100%, 840px);
    align-items: stretch;
    padding: var(--top-inset) var(--side-inset) var(--bottom-inset);
}

.topbar {
    width: 100%;
    height: 53px;
}

.site-brand {
    display: grid;
    justify-items: start;
    align-content: center;
    gap: 2px;
}

.site-icon, .site-online-count {
    position: static;
}

.site-icon {
    width: clamp(82px, 23vw, 101px);
    height: auto;
    object-fit: contain;
}

.site-online-count {
    color: var(--muted);
    font-size: 11px;
    line-height: 1;
}

.balance-group {
    position: static;
    gap: 6px;
}

.balance-group .currency, .gram-balance {
    width: auto;
    height: 36px;
    min-width: 42px;
    padding-inline: 8px;
    border: 1px solid #405264;
    border-radius: 999px;
    background: #202c39;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.gram-balance {
    width: clamp(57px, 20vw, 96px);
    padding: 0;
    overflow: hidden;
}

.gram-balance img {
    object-fit: fill;
}

.currency-icon {
    width: 21px;
    height: 21px;
}

.map-banner {
    position: relative;
    z-index: 2;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    overflow: hidden;
    padding: 11px 17px;
    margin-block: 7px 0;
    min-height: 86px;
    border: 1px solid #519477;
    border-radius: 24px;
    color: #f4fff4;
    background:
        radial-gradient(ellipse at 85% 5%, #a6ed9e 0, transparent 49%),
        linear-gradient(115deg, #174631, #247d54 62%, #57b77a);
}

.banner-copy {
    display: grid;
    gap: 8px;
    width: min(100%, 300px);
}

.map-banner .area-counter {
    position: static;
    transform: none;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: clamp(17px, 4.5vw, 22px);
    font-variant-numeric: tabular-nums;
}

.area-label {
    color: inherit;
    font-size: inherit;
    font-weight: 750;
    letter-spacing: -.025em;
}

.map-banner .world-rank {
    position: static;
    width: auto;
    height: auto;
    gap: 9px;
}

.rank-bar {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: #0b392eaa;
}

.rank-progress {
    border-radius: inherit;
    background: #c8fbd0;
}

#rankCounter {
    position: static;
    font: 700 11px/1 system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    color: inherit;
    text-shadow: none;
}

.map-banner .rank-icon {
    width: 57px;
    height: 57px;
    margin: 0;
    filter: drop-shadow(0 4px 6px #10251465);
}

.world-container {
    width: 100%;
    max-width: none;
    height: auto;
    flex: 1 1 0%;
    margin: 9px 0;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: #181d20;
}

.world-hint {
    left: 9px;
    right: 105px;
    bottom: 12px;
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0;
    text-align: left;
}

.world-zoom {
    right: 6px;
    bottom: 5px;
    gap: 1px;
}

.world-zoom button {
    width: 44px;
    height: 44px;
    color: var(--text);
}

.world-zoom span, .menu-toggle, .menu-item {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-raised);
    color: var(--text);
}

.world-zoom button:active span, .menu-toggle:active, .menu-item:active {
    background: #435057;
}

.tools {
    position: fixed;
    top: calc(var(--top-inset) + 163px);
    right: max(calc(var(--side-inset) + 7px), calc((100vw - 840px) / 2 + var(--side-inset) + 7px));
    bottom: auto;
    z-index: 10;
}

.menu-container, .menu-container.open {
    width: 44px;
    height: auto;
    min-height: 44px;
}

.menu-background {
    display: none;
}

.menu-toggle, .menu-item {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
}

.menu-toggle span {
    width: 16px;
    height: 2px;
    border-radius: 9px;
    background: currentColor;
    box-shadow: 0 -5px currentColor, 0 5px currentColor;
    pointer-events: none;
}

.menu-items {
    position: static;
    display: grid;
    justify-content: center;
    padding: 48px 0 0;
}

.menu-item img {
    filter: brightness(0) invert(1);
}

.tap-controls {
    height: auto;
    padding: 0;
    margin: 0;
    gap: 4px;
}

.tap-button {
    width: clamp(57px, 10dvh, 77px);
    height: auto;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 1px solid #b5e6ff;
    background: linear-gradient(145deg, #b5edff, #60bfff 72%);
    color: #143f55;
    box-shadow: 0 5px 16px #60bfff35, inset 0 1px 0 #ffffff80;
}

.tap-button img {
    display: none;
}

.tap-button::before, .tap-button::after {
    position: absolute;
    inset: 25%;
    content: "";
    border: 3px solid currentColor;
    border-left-color: transparent;
    border-radius: 50%;
    rotate: -40deg;
}

.tap-button::after {
    inset: 40%;
    border: 0;
    background: currentColor;
}

.tap-label {
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
}

.bottom-panel {
    position: relative;
    z-index: 2;
    width: 100%;
    margin: 6px 0 0;
    padding: 0;
}

.glass-menu {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: clamp(7px, 3.5vw, 27px);
    width: auto;
    height: auto;
    max-width: 100%;
    padding: 4px 12px;
    border: 1px solid #323a3c;
    border-radius: 24px;
    background: var(--surface);
}

.round-button {
    width: 66px;
    height: auto;
    min-height: 59px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 690;
}

.nav-icon {
    display: block;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: var(--surface-raised) var(--nav-image) center / 23px no-repeat;
}

.nav-market { --nav-image: url("assets/theme/market.png"); }
.nav-map { --nav-image: url("assets/theme/map.png"); }
.nav-cards { --nav-image: url("assets/theme/cards.png"); }

.round-button[aria-current="page"] {
    color: var(--text);
}

.round-button[aria-current="page"] .nav-icon {
    background-color: #276085;
    border-color: #5786a3;
}

.app button:focus-visible, .online-panel button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

body.cart-screen .app > .bottom-panel, body.market-screen .app > .bottom-panel {
    position: absolute;
    inset: auto 0 var(--bottom-inset);
    margin: 0;
    transform: none;
}

.online-panel {
    padding: max(16px, env(safe-area-inset-top)) max(16px, calc((100% - 660px) / 2));
    color: var(--text);
    background: var(--page);
    font-family: inherit;
}

.online-panel > header {
    flex-wrap: nowrap;
    padding: 13px 15px;
    border: 1px solid #519477;
    border-radius: 23px;
    background: linear-gradient(115deg, #174631, #2f885c 82%, #3a9769);
}

.online-panel h1 {
    font-size: clamp(20px, 5vw, 28px);
    letter-spacing: -.03em;
}

.online-panel button, .online-panel input:not([type="checkbox"]), .online-panel select {
    border: 1px solid var(--line);
    border-radius: 999px;
    padding-inline: 14px;
    background: var(--surface);
}

.online-panel button[aria-pressed="true"], .online-panel form button[type="submit"],
.online-panel .skin-item button:not(:disabled) {
    border-color: #a9dfff;
    background: var(--blue);
    color: #142b38;
    font-weight: 700;
}

#closeOnline, .play-menu-close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
}

.online-panel li {
    border-color: var(--line);
}

.online-help, #onlineId {
    color: var(--muted);
}

.skin-catalog {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 136px), 1fr));
    gap: 9px;
}

.skin-item {
    min-width: 0;
    border-color: var(--line);
    border-radius: 22px;
    background: var(--surface);
}

.skin-art {
    display: grid;
    place-items: center;
    width: 100%;
    height: clamp(94px, 30vw, 143px);
    padding: 10px;
    border-radius: 15px;
    background: radial-gradient(ellipse at 70% 20%, var(--art-light, #547ba7), var(--art-dark, #2c375c));
}

.skin-art[data-skin="violet"] { --art-light: #927cf2; --art-dark: #483a88; }
.skin-art[data-skin="emerald"] { --art-light: #69ba8b; --art-dark: #245a47; }
.skin-art[data-skin="gold"] { --art-light: #c4875e; --art-dark: #804730; }

.skin-art img {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 112px;
    object-fit: contain;
}

.skin-item button {
    padding-inline: 6px;
    font-size: 13px;
}

.play-menu, .match-chat {
    color: var(--text);
    border-color: var(--line);
    background: var(--surface);
}

.game-mode, .match-chat-toggle, .match-chat button, .match-chat input {
    color: var(--text);
    border-color: var(--line);
    border-radius: 20px;
    background: var(--surface-raised);
}

.game-mode[aria-pressed="true"] {
    border-color: var(--blue);
}

@media (max-height: 520px) and (orientation: landscape) {
    .app { --top-inset: max(6px, env(safe-area-inset-top)); --bottom-inset: max(4px, env(safe-area-inset-bottom)); }
    .topbar { height: 39px; }
    .map-banner { min-height: 53px; padding-block: 5px; margin-top: 4px; }
    .map-banner .rank-icon { width: 40px; height: 40px; }
    .banner-copy { gap: 4px; }
    .tools { top: calc(var(--top-inset) + 110px); }
    .tap-button { width: 44px; }
    .tap-controls { gap: 1px; }
    .round-button { min-height: 48px; }
    .nav-icon { width: 29px; height: 29px; background-size: 19px; }
}

@media (prefers-reduced-motion: reduce) {
    .round-button, .tap-button, .rank-progress { transition: none; }
}
