/* Balda product UI
 * Loaded after page-local styles so every active screen shares one visual contract.
 * Keep this file structural and semantic; equipped themes still own their accents.
 */

:root {
    --product-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --product-dark-canvas: #071525;
    --product-dark-raised: #0d2036;
    --product-dark-panel: #132a46;
    --product-dark-panel-strong: #193553;
    --product-dark-text: #f8fafc;
    --product-dark-muted: #a9bad0;
    --product-dark-border: rgba(174, 197, 224, 0.22);
    --product-light-canvas: #eaf1f6;
    --product-light-surface: #ffffff;
    --product-light-muted-surface: #f4f7fa;
    --product-light-text: #15304a;
    --product-light-muted: #66788f;
    --product-light-border: #d5e0e9;
    --product-primary: #2563eb;
    --product-primary-hover: #1d4ed8;
    --product-success: #16a34a;
    --product-warning: #d97706;
    --product-danger: #dc2626;
    --product-reward: #f4b000;
    --product-focus: #38bdf8;
    --product-radius-xs: 4px;
    --product-radius-sm: 6px;
    --product-radius: 8px;
    --product-shadow-sm: 0 2px 8px rgba(21, 48, 74, 0.09);
    --product-shadow: 0 10px 28px rgba(21, 48, 74, 0.13);
    --product-nav-height: 74px;
}

html {
    background: var(--product-dark-canvas);
}

body.balda-product {
    margin: 0;
    min-width: 0;
    font-family: var(--product-font);
    font-synthesis: none;
    letter-spacing: 0;
    line-height: 1.45;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.balda-product *,
body.balda-product *::before,
body.balda-product *::after {
    box-sizing: border-box;
    letter-spacing: 0;
}

body.balda-product [hidden] {
    display: none !important;
}

body.balda-product img,
body.balda-product video,
body.balda-product canvas,
body.balda-product svg {
    max-width: 100%;
}

body.balda-product button,
body.balda-product a,
body.balda-product input,
body.balda-product select,
body.balda-product textarea,
body.balda-product [role="button"],
body.balda-product [role="switch"] {
    font: inherit;
    touch-action: manipulation;
}

body.balda-product button,
body.balda-product a,
body.balda-product [role="button"],
body.balda-product [role="switch"] {
    -webkit-tap-highlight-color: transparent;
}

body.balda-product :focus-visible {
    outline: 3px solid var(--product-focus);
    outline-offset: 2px;
}

body.balda-product ::selection {
    background: rgba(37, 99, 235, 0.32);
}

body.balda-product h1,
body.balda-product h2,
body.balda-product h3,
body.balda-product h4,
body.balda-product p {
    overflow-wrap: anywhere;
}

body.balda-product h1,
body.balda-product h2,
body.balda-product h3,
body.balda-product h4 {
    line-height: 1.25;
}

body.balda-product button:not(.cell):not(.keyboard-key),
body.balda-product .btn,
body.balda-product [role="button"] {
    border-radius: var(--product-radius-sm);
}

body.balda-product button:disabled,
body.balda-product .btn:disabled,
body.balda-product [aria-disabled="true"] {
    cursor: not-allowed;
}

body.balda-product .animate-fadeIn,
body.balda-product .animate-fadeInUp,
body.balda-product .animate-fadeInDown,
body.balda-product .animate-popIn,
body.balda-product .animate-slideInLeft,
body.balda-product .animate-slideInRight,
body.balda-product .animate-float,
body.balda-product .animate-heartbeat,
body.balda-product .animate-pulseGlow,
body.balda-product .hover-lift {
    animation: none !important;
    opacity: 1;
    transform: none;
}

body.balda-product .hover-lift:hover {
    transform: none;
}

body.balda-product .loading-screen {
    background: var(--product-dark-canvas) !important;
    color: var(--product-dark-text);
}

body.balda-product .loading-screen .smiley {
    display: none !important;
}

body.balda-product .loading-screen .loading-animation {
    min-width: 210px;
}

body.balda-product .loading-screen .letters {
    display: flex;
    justify-content: center;
    gap: 3px;
}

body.balda-product .loading-screen .letter {
    color: var(--product-dark-text);
    font-weight: 850;
    text-shadow: none;
}

body.balda-product .loading-progress {
    overflow: hidden;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.14);
}

body.balda-product .loading-progress-bar {
    border-radius: inherit;
    background: linear-gradient(90deg, var(--product-reward), #f59e0b);
    box-shadow: none;
}

body.balda-product .loading-text {
    color: var(--product-dark-muted);
    font-size: 14px;
    font-weight: 650;
}

/* Light product workspace: shop, inventory, profile and settings. */
body.balda-product.game-ui:not(.hub-page) {
    color: var(--product-light-text);
    background: var(--product-light-canvas);
}

body.balda-product.game-ui:not(.hub-page)::before {
    opacity: 1;
    background:
        linear-gradient(rgba(21, 48, 74, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(21, 48, 74, 0.035) 1px, transparent 1px);
    background-size: 28px 28px;
}

body.balda-product.game-ui .container,
body.balda-product.game-ui .app {
    position: relative;
    z-index: 1;
    width: min(100%, 1180px);
    max-width: none;
    margin-inline: auto;
    padding: 16px 16px calc(var(--product-nav-height) + 24px + min(env(safe-area-inset-bottom), 14px));
}

body.balda-product.game-ui .header,
body.balda-product.game-ui .profile-header,
body.balda-product.game-ui .section,
body.balda-product.game-ui .currency-section,
body.balda-product.game-ui .panel {
    margin: 0 0 12px;
    padding: 16px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--product-shadow-sm);
    backdrop-filter: blur(12px);
}

body.balda-product.game-ui .header h1,
body.balda-product.game-ui .profile-name,
body.balda-product.game-ui .currency-title,
body.balda-product.game-ui .section-title,
body.balda-product.game-ui .panel h2 {
    color: var(--product-light-text);
}

body.balda-product.game-ui .header p,
body.balda-product.game-ui .sub,
body.balda-product.game-ui .caption,
body.balda-product.game-ui .muted,
body.balda-product.game-ui .currency-desc,
body.balda-product.game-ui .stat-label {
    color: var(--product-light-muted);
}

body.balda-product.game-ui .btn,
body.balda-product.game-ui .buy-button,
body.balda-product.game-ui .active-badge,
body.balda-product.game-ui .back-button,
body.balda-product.game-ui .back-btn {
    min-height: 44px;
    border-radius: var(--product-radius-sm);
    box-shadow: none;
}

body.balda-product.game-ui .btn-primary,
body.balda-product.game-ui .buy-button:not(:disabled),
body.balda-product.game-ui .shop-detail-action:not(:disabled) {
    border-color: var(--product-primary);
    background: var(--product-primary);
    color: #fff;
}

body.balda-product.game-ui .btn-primary:hover,
body.balda-product.game-ui .buy-button:not(:disabled):hover,
body.balda-product.game-ui .shop-detail-action:not(:disabled):hover {
    background: var(--product-primary-hover);
}

body.balda-product.game-ui .btn-secondary,
body.balda-product.game-ui .back-button,
body.balda-product.game-ui .back-btn {
    border: 1px solid var(--product-light-border);
    background: var(--product-light-surface);
    color: var(--product-light-text);
}

body.balda-product.game-ui .btn.danger,
body.balda-product.game-ui .danger {
    border-color: rgba(220, 38, 38, 0.34);
}

body.balda-product.game-ui .empty-state,
body.balda-product.game-ui .empty {
    border: 1px dashed #c4d2df;
    border-radius: var(--product-radius);
    background: var(--product-light-muted-surface);
    color: var(--product-light-muted);
}

/* Hub */
body.screen-hub {
    color: var(--product-dark-text);
    background: var(--product-dark-canvas);
}

body.screen-hub .hub {
    width: min(100%, 600px);
    max-width: 600px;
    gap: 10px;
    padding: 12px 14px calc(var(--product-nav-height) + 20px + min(env(safe-area-inset-bottom), 14px));
}

body.screen-hub .hub-header {
    min-height: 44px;
}

body.screen-hub .lang-btn,
body.screen-hub .pill {
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--product-dark-border);
    border-radius: var(--product-radius);
    background: rgba(19, 42, 70, 0.88);
    box-shadow: none;
    backdrop-filter: blur(12px);
}

body.screen-hub .app-logo {
    font-size: 34px;
    letter-spacing: 0;
    animation: none;
    filter: none;
}

body.screen-hub .hero-tagline {
    letter-spacing: 0;
    color: #c6b8ff;
}

body.screen-hub .hub-account-strip,
body.screen-hub .chest-card,
body.screen-hub .daily-objectives {
    border: 1px solid var(--product-dark-border);
    border-radius: var(--product-radius);
    background: rgba(13, 32, 54, 0.92);
    box-shadow: none;
}

body.screen-hub .hub-account-strip {
    width: 100%;
    max-width: none;
    min-height: 58px;
    margin: 2px 0 4px;
}

body.screen-hub .hub-account-avatar,
body.screen-hub .hub-account-avatar img {
    border-radius: var(--product-radius-sm);
}

body.screen-hub .chest-card {
    min-height: 82px;
    padding: 9px 12px;
}

body.screen-hub .chest-card.ready {
    border-color: rgba(244, 176, 0, 0.65);
    background: rgba(28, 43, 62, 0.96);
}

body.screen-hub .chest-reward-media {
    border-radius: var(--product-radius-sm);
}

body.screen-hub .chest-claim-btn {
    min-height: 44px;
    border-radius: var(--product-radius-sm);
}

body.screen-hub .lang-btn {
    min-width: 44px;
    min-height: 44px;
}

body.screen-hub .btn-start {
    min-height: 52px;
    border-radius: var(--product-radius);
    background: var(--product-primary);
    box-shadow: 0 8px 22px rgba(37, 99, 235, 0.28);
}

body.screen-hub .btn-start::after {
    display: none;
}

body.screen-hub .btn-start:hover {
    background: var(--product-primary-hover);
}

body.screen-hub .quick-links {
    gap: 8px;
}

body.screen-hub .qlink {
    min-height: 64px;
    border: 1px solid var(--product-dark-border);
    border-radius: var(--product-radius);
    background: rgba(19, 42, 70, 0.9);
    box-shadow: none;
}

body.screen-hub .daily-objectives-head {
    min-height: 48px;
    border-radius: var(--product-radius);
}

body.screen-hub .hub-equipped-item,
body.screen-hub .daily-objectives-reward {
    border-radius: var(--product-radius-xs);
}

body.screen-hub .modal {
    padding: 16px;
    background: rgba(2, 10, 20, 0.72);
    backdrop-filter: blur(8px);
}

body.screen-hub .modal-card {
    width: min(100%, 520px);
    max-height: min(760px, calc(100dvh - 32px));
    overflow: hidden;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: var(--product-light-surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

body.screen-hub .modal-head {
    min-height: 54px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--product-light-border);
    background: var(--product-light-muted-surface);
    color: var(--product-light-text);
}

body.screen-hub .modal-head button {
    width: 44px;
    height: 44px;
    border-radius: var(--product-radius-sm);
}

body.screen-hub .modal-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
}

body.screen-hub .mode-tile,
body.screen-hub .modal-btn {
    min-height: 52px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: var(--product-light-surface);
    color: var(--product-light-text);
    box-shadow: none;
}

/* Shop */
body.screen-shop .container {
    max-width: 1180px;
}

body.screen-shop .header {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 64px;
    padding: 12px 16px;
}

body.screen-shop .header-title {
    justify-self: start;
    font-size: 20px;
}

body.screen-shop .balance {
    min-height: 42px;
    padding: 6px 10px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius-sm);
    background: var(--product-light-muted-surface);
    box-shadow: none;
}

body.screen-shop .tabs {
    position: sticky;
    top: 8px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: rgba(234, 241, 246, 0.94);
    box-shadow: var(--product-shadow-sm);
    backdrop-filter: blur(14px);
}

body.screen-shop .tab {
    min-width: 0;
    min-height: 52px;
    padding: 6px 4px;
    border: 1px solid transparent;
    border-radius: var(--product-radius-sm);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: none;
}

body.screen-shop .tab.active {
    border-color: rgba(37, 99, 235, 0.42);
    background: #fff;
    color: var(--product-primary);
    box-shadow: inset 0 -2px 0 var(--product-primary);
}

body.screen-shop .tab-count {
    border-radius: var(--product-radius-xs);
}

body.screen-shop .items-grid {
    gap: 12px;
}

body.screen-shop .item-card {
    overflow: hidden;
    height: 100%;
    padding: 12px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: var(--product-light-surface);
    box-shadow: var(--product-shadow-sm);
}

body.screen-shop .item-card:hover {
    transform: translateY(-2px);
    border-color: #b8c9d8;
    box-shadow: var(--product-shadow);
}

body.screen-shop .item-icon {
    overflow: hidden;
    border-radius: var(--product-radius-sm);
    background: var(--product-light-muted-surface);
}

body.screen-shop .item-preview-image,
body.screen-shop .avatar-media {
    object-fit: contain;
}

body.screen-shop .item-name {
    color: var(--product-light-text);
    font-size: 15px;
    line-height: 1.3;
}

body.screen-shop .item-inspect {
    width: 44px;
    height: 44px;
    margin: -6px -6px 0 0;
    border-radius: var(--product-radius-sm);
}

body.screen-shop .item-description {
    color: var(--product-light-muted);
    line-height: 1.4;
}

body.screen-shop .rarity-badge,
body.screen-shop .media-badge {
    min-height: 20px;
    padding: 3px 6px;
    border-radius: var(--product-radius-xs);
    font-size: 9px;
    line-height: 1.2;
}

body.screen-shop .buy-button,
body.screen-shop .active-badge {
    min-height: 44px;
    padding: 9px 10px;
    border-radius: var(--product-radius-sm);
}

body.screen-shop .active-badge {
    background: var(--product-success);
}

body.screen-shop .shop-detail {
    padding: 16px;
    background: rgba(7, 21, 37, 0.72);
    backdrop-filter: blur(8px);
}

body.screen-shop .shop-detail-card {
    width: min(100%, 520px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    box-shadow: 0 24px 70px rgba(7, 21, 37, 0.34);
}

body.screen-shop .shop-detail-preview,
body.screen-shop .shop-detail-effect,
body.screen-shop .shop-detail-close,
body.screen-shop .shop-detail-action {
    border-radius: var(--product-radius-sm);
}

/* Inventory */
body.screen-inventory .container {
    max-width: 920px;
}

body.screen-inventory .header.panel {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(260px, 1fr);
    align-items: center;
    gap: 12px 20px;
    padding: 14px 16px;
}

body.screen-inventory .inventory-title,
body.screen-inventory .header .sub {
    text-align: left;
}

body.screen-inventory .header .sub {
    grid-column: 1;
}

body.screen-inventory .stats {
    grid-column: 2;
    grid-row: 1 / span 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

body.screen-inventory .stat {
    min-height: 54px;
    padding: 8px 10px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius-sm);
    background: var(--product-light-muted-surface);
    box-shadow: none;
}

body.screen-inventory .inventory-filters {
    position: sticky;
    top: 8px;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: rgba(234, 241, 246, 0.94);
    backdrop-filter: blur(14px);
}

body.screen-inventory .inventory-filter {
    min-height: 52px;
    border: 1px solid transparent;
    border-radius: var(--product-radius-sm);
    background: rgba(255, 255, 255, 0.86);
    box-shadow: none;
}

body.screen-inventory .inventory-filter.active {
    border-color: rgba(37, 99, 235, 0.42);
    background: #fff;
    color: var(--product-primary);
    box-shadow: inset 0 -2px 0 var(--product-primary);
}

body.screen-inventory .loadout {
    display: grid;
    margin-bottom: 12px;
    padding: 14px 16px;
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: var(--product-radius);
    background: #f2f7ff;
    box-shadow: none;
}

body.screen-inventory .loadout-chip,
body.screen-inventory .inventory-item,
body.screen-inventory .inventory-inspect-card {
    border-radius: var(--product-radius);
}

body.screen-inventory .section.panel {
    min-height: 120px;
}

body.screen-inventory .empty {
    max-width: 420px;
    margin: 8px auto 0;
    padding: 20px 16px;
    border: 1px dashed var(--product-light-border);
    border-radius: var(--product-radius);
    background: var(--product-light-muted-surface);
    color: var(--product-light-muted);
    text-align: center;
}

body.screen-inventory .empty a {
    display: inline-flex;
    min-height: 44px;
    margin-top: 12px;
    padding: 0 16px;
    align-items: center;
    justify-content: center;
    border-radius: var(--product-radius-sm);
    background: var(--product-primary);
    color: #fff;
    font-weight: 750;
    text-decoration: none;
}

body.screen-inventory .items {
    align-items: stretch;
    justify-content: center;
    gap: 12px;
}

body.screen-inventory .items.items-single,
body.screen-inventory .items:has(> :only-child) {
    justify-content: center;
}

body.screen-inventory .inventory-item {
    border: 1px solid var(--product-light-border);
    background: #fff;
    box-shadow: var(--product-shadow-sm);
}

/* Profile */
body.screen-profile .container {
    max-width: 780px;
}

body.screen-profile .profile-header {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(0, 2fr);
    align-items: center;
    gap: 16px;
}

body.screen-profile .profile-identity {
    min-width: 0;
    justify-content: flex-start;
}

body.screen-profile .profile-avatar {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    overflow: hidden;
    border: 2px solid #d9e5ee;
    border-radius: var(--product-radius);
    background: var(--product-light-muted-surface);
    box-shadow: none;
}

body.screen-profile .profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}

body.screen-profile .profile-name {
    text-align: left;
    font-size: 20px;
}

body.screen-profile .profile-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

body.screen-profile .stat-card {
    min-height: 72px;
    padding: 10px 8px;
    border: 1px solid var(--product-light-border);
    border-top: 3px solid var(--product-primary);
    border-radius: var(--product-radius-sm);
    background: var(--product-light-muted-surface);
    color: var(--product-light-text);
    box-shadow: none;
}

body.screen-profile .stat-value {
    color: var(--product-light-text);
    font-size: 24px;
}

body.screen-profile .stat-label {
    font-size: 11px;
}

body.screen-profile .currency-section {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

body.screen-profile .currency-title,
body.screen-profile .convert-section {
    grid-column: 1 / -1;
}

body.screen-profile .currency-item {
    min-height: 72px;
    margin: 0;
    padding: 10px;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius-sm);
    background: var(--product-light-muted-surface);
    box-shadow: none;
}

body.screen-profile .currency-icon {
    border-radius: var(--product-radius-sm);
}

body.screen-profile .section {
    min-height: 96px;
}

body.screen-profile .achievements-section {
    overflow: hidden;
}

body.screen-profile .achievements-summary {
    display: flex;
    min-height: 44px;
    margin: -8px -8px 8px;
    padding: 8px;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
}

body.screen-profile .achievements-summary::-webkit-details-marker {
    display: none;
}

body.screen-profile .achievements-chevron {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 180ms ease;
}

body.screen-profile .achievements-section[open] .achievements-chevron {
    transform: rotate(180deg);
}

body.screen-profile .achievements-section:not([open]) {
    min-height: 0;
}

body.screen-profile .achievements-section:not([open]) .achievements-summary {
    margin-bottom: -8px;
}

body.screen-profile .action-buttons {
    gap: 10px;
}

/* Settings */
body.screen-settings .app {
    max-width: 700px;
}

body.screen-settings .topbar {
    min-height: 58px;
    margin-bottom: 12px;
}

body.screen-settings .topbar-title h1 {
    color: var(--product-light-text);
    font-size: 22px;
}

body.screen-settings .back-btn {
    min-height: 44px;
    padding: 8px 12px;
}

body.screen-settings .panel {
    padding: 12px 16px;
}

body.screen-settings .panel h2 {
    margin: 0;
    padding: 4px 0 8px;
    text-align: left;
    font-size: 15px;
}

body.screen-settings .row {
    min-height: 58px;
    padding: 8px 0;
}

body.screen-settings .toggle {
    position: relative;
    flex: 0 0 52px;
    width: 52px;
    height: 44px;
    border: 0;
    background: transparent;
}

body.screen-settings .toggle::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 2px;
    width: 48px;
    height: 28px;
    border: 1px solid #b7c5d2;
    border-radius: 14px;
    background: #dbe4eb;
    transition: background-color 180ms ease, border-color 180ms ease;
}

body.screen-settings .toggle::after {
    top: 11px;
    left: 5px;
}

body.screen-settings .toggle.on {
    border: 0;
    background: transparent;
}

body.screen-settings .toggle.on::before {
    border-color: #0f9f6e;
    background: #17b67d;
}

body.screen-settings .lang-select {
    min-height: 44px;
    border-radius: var(--product-radius-sm);
}

body.screen-settings .panel > .btn {
    margin-top: 8px;
    text-align: left;
}

/* Leaderboard */
body.screen-leaderboard {
    min-height: 100vh;
    color: var(--product-dark-text);
    background: var(--product-dark-canvas);
}

body.screen-leaderboard .container {
    width: min(100%, 640px);
    max-width: 640px;
    margin: 0 auto;
    padding: 28px 14px calc(var(--product-nav-height) + 24px + min(env(safe-area-inset-bottom), 14px));
}

body.screen-leaderboard .header {
    margin-bottom: 14px;
    text-align: center;
}

body.screen-leaderboard .header h1 {
    margin: 0;
    color: var(--product-dark-text);
    font-size: 24px;
}

body.screen-leaderboard .header p {
    color: var(--product-dark-muted);
}

body.screen-leaderboard .tabs {
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--product-dark-border);
    border-radius: var(--product-radius);
    background: var(--product-dark-raised);
}

body.screen-leaderboard .tab {
    min-height: 44px;
    border-radius: var(--product-radius-sm);
    background: transparent;
    color: var(--product-dark-muted);
}

body.screen-leaderboard .tab.active {
    background: var(--product-primary);
    color: #fff;
}

body.screen-leaderboard .leaderboard-list,
body.screen-leaderboard .my-position {
    overflow: hidden;
    border: 1px solid var(--product-light-border);
    border-radius: var(--product-radius);
    background: var(--product-light-surface);
    box-shadow: none;
}

body.screen-leaderboard .player-row {
    min-height: 64px;
    padding: 10px 14px;
}

body.screen-leaderboard .player-avatar {
    border-radius: var(--product-radius-sm);
    object-fit: contain;
    background: var(--product-light-muted-surface);
}

/* Authentication */
body.screen-auth {
    min-height: 100dvh;
    padding: 24px 16px;
    color: var(--product-dark-text);
    background: var(--product-dark-canvas);
}

body.screen-auth .auth-container {
    width: min(100%, 460px);
    max-width: 460px;
    padding: 24px;
    border: 1px solid var(--product-dark-border);
    border-radius: var(--product-radius);
    background: var(--product-dark-raised);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
    backdrop-filter: none;
}

body.screen-auth .logo {
    margin-bottom: 20px;
}

body.screen-auth .auth-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

body.screen-auth .brand-mark {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border-radius: var(--product-radius);
    background: rgba(37, 99, 235, 0.18);
    color: #a9c5ff;
}

body.screen-auth .brand-mark svg,
body.screen-auth .telegram-glyph {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body.screen-auth .logo h1 {
    margin: 0;
    font-size: 34px;
    letter-spacing: 0;
}

body.screen-auth .auth-content {
    margin: 20px 0 0;
}

body.screen-auth .telegram-icon {
    margin: 10px 0;
    color: #65b9f1;
}

body.screen-auth .telegram-icon .telegram-glyph {
    width: 48px;
    height: 48px;
}

body.screen-auth .auth-title {
    font-size: 22px;
}

body.screen-auth .telegram-btn,
body.screen-auth .email-btn {
    width: 100%;
    min-height: 48px;
    justify-content: center;
    border-radius: var(--product-radius-sm);
}

body.screen-auth .telegram-btn-icon {
    display: inline-flex;
    margin-right: 8px;
    vertical-align: middle;
}

body.screen-auth .telegram-btn-icon .telegram-glyph {
    width: 20px;
    height: 20px;
}

body.screen-auth .email-input {
    border-radius: var(--product-radius-sm);
}

body.screen-auth .instructions {
    margin-top: 20px;
    padding: 14px;
    border: 1px solid var(--product-dark-border);
    border-radius: var(--product-radius);
    background: rgba(255, 255, 255, 0.045);
}

/* Gameplay shell. Keep game rules and responsive board math page-local. */
body.game-page {
    min-height: 100dvh;
    padding: 10px;
    color: var(--text-color, var(--product-dark-text));
    background: linear-gradient(160deg, var(--bg-gradient-start, #071525), var(--bg-gradient-end, #10213a));
}

body.game-page:not(.browser-mode) .container {
    width: min(100%, 620px);
    max-width: 620px;
}

body.game-page .solo-match-header,
body.game-page .multiplayer-match-header,
body.game-page .game-board,
body.game-page .input-panel,
body.game-page .moves-log,
body.game-page .today-leaderboard,
body.game-page .multiplayer-panel,
body.game-page .game-over-content,
body.game-page .modal-content,
body.game-page .turn-timeout-card,
body.game-page .profile-modal-content,
body.game-page .tutorial-content,
body.game-page .letter-input-content {
    border-radius: var(--product-radius);
}

body.game-page .solo-match-header,
body.game-page .multiplayer-match-header {
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid var(--card-border, var(--product-dark-border));
    background: var(--card-bg, rgba(19, 42, 70, 0.86));
    box-shadow: none;
}

body.game-page .solo-match-title,
body.game-page .multiplayer-match-title {
    margin: 0;
    font-size: 17px;
}

body.game-page .solo-score-strip,
body.game-page .multiplayer-score-strip {
    min-height: 36px;
    border-radius: var(--product-radius-sm);
}

body.game-page .solo-player-identity,
body.game-page .turn-player-identity {
    border-radius: var(--product-radius-sm);
}

body.game-page .player-avatar {
    border-radius: var(--product-radius-sm);
    object-fit: contain;
    background: rgba(255, 255, 255, 0.08);
}

body.game-page .game-board {
    border: 1px solid var(--card-border, var(--product-dark-border));
    box-shadow: none;
}

body.game-page .board-grid {
    border-radius: var(--product-radius);
}

body.game-page .cell {
    border-radius: var(--product-radius-sm);
}

body.game-page .input-panel {
    border: 1px solid var(--card-border, var(--product-dark-border));
    box-shadow: none;
}

body.game-page .input-controls {
    gap: 8px;
}

body.game-page .input-controls .btn,
body.game-page .quick-actions .btn,
body.game-page .btn-shop,
body.game-page .btn-inventory,
body.game-page .modal-close,
body.game-page .turn-timeout-close,
body.game-page .game-over-btn,
body.game-page .keyboard-confirm,
body.game-page .btn-confirm,
body.game-page .btn-cancel {
    min-height: 44px;
    border-radius: var(--product-radius-sm);
    box-shadow: none;
}

body.balda-product.game-page.browser-mode #quickActions .btn {
    min-height: 44px;
}

body.game-page .moves-log,
body.game-page .today-leaderboard,
body.game-page .multiplayer-panel {
    border: 1px solid var(--card-border, var(--product-dark-border));
    box-shadow: none;
}

body.game-page .move-item,
body.game-page .leaderboard-item,
body.game-page .participant-item,
body.game-page .spectator-item {
    border-radius: var(--product-radius-sm);
}

body.game-page .notification {
    width: min(520px, calc(100vw - 24px));
    max-width: min(520px, calc(100vw - 24px));
    min-height: 44px;
    padding: 11px 14px;
    border-radius: var(--product-radius);
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.35;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
}

body.game-page .modal,
body.game-page .turn-timeout-modal,
body.game-page .letter-input-modal,
body.game-page .tutorial-modal,
body.game-page .game-over-modal,
body.game-page .profile-modal {
    padding: 16px;
    background: rgba(2, 10, 20, 0.74);
    backdrop-filter: blur(8px);
}

body.game-page .modal-content,
body.game-page .turn-timeout-card,
body.game-page .letter-input-content,
body.game-page .tutorial-content,
body.game-page .game-over-content,
body.game-page .profile-modal-content {
    width: min(100%, 520px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 20px;
    border: 1px solid var(--product-light-border);
    background: var(--product-light-surface);
    color: var(--product-light-text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

body.game-page .modal-content h2,
body.game-page .turn-timeout-card h2,
body.game-page .letter-input-content h2,
body.game-page .tutorial-content h2 {
    color: var(--product-light-text);
}

/* .profile-input keeps its old dark-theme white text/near-white background
   (game_singleplayer.html inline styles), but .profile-modal-content above
   is repainted to a light surface here -- without this override the input
   renders white text on a near-white box, i.e. invisible while typing. */
body.game-page .profile-input {
    background: #ffffff;
    border-color: var(--product-light-border);
    color: var(--product-light-text);
}

body.game-page .profile-input::placeholder {
    color: rgba(21, 48, 74, 0.5);
}

body.game-page .profile-input:focus {
    border-color: var(--product-accent, #2563eb);
    background: #ffffff;
}

body.game-page .virtual-keyboard {
    border: 1px solid var(--product-dark-border);
    border-bottom: 0;
    border-radius: var(--product-radius) var(--product-radius) 0 0;
    background: var(--product-dark-raised);
    box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.32);
}

body.game-page .keyboard-key {
    border-radius: var(--product-radius-xs);
}

@media (max-width: 767px) {
    body.balda-product.game-ui .container,
    body.balda-product.game-ui .app {
        padding: 10px 10px calc(var(--product-nav-height) + 18px + min(env(safe-area-inset-bottom), 14px));
    }

    body.screen-shop .tabs {
        top: 4px;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 6px;
        padding: 6px;
    }

    body.screen-shop .tab {
        min-height: 54px;
    }

    body.screen-shop .item-card {
        padding: 9px;
    }

    body.screen-shop .items-grid.has-odd-result > .item-card:last-child {
        grid-column: 1 / -1;
        width: calc((100% - 8px) / 2);
        justify-self: center;
    }

    body.screen-shop .items-grid.has-single-result > .item-card:last-child {
        width: min(100%, 280px);
    }

    body.screen-inventory .header.panel {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    body.screen-inventory .inventory-title,
    body.screen-inventory .header .sub {
        text-align: center;
    }

    body.screen-inventory .header .sub,
    body.screen-inventory .stats {
        grid-column: 1;
        grid-row: auto;
    }

    body.screen-inventory .stats {
        margin-top: 8px;
    }

    body.screen-inventory .inventory-filters {
        top: 4px;
        gap: 6px;
        padding: 6px;
    }

    body.screen-profile .profile-header {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    body.screen-profile .profile-identity {
        justify-content: center;
    }

    body.screen-profile .profile-name {
        text-align: center;
    }

    body.screen-profile .profile-stats {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.screen-profile .currency-section {
        grid-template-columns: 1fr;
    }

    body.screen-profile .currency-title,
    body.screen-profile .convert-section {
        grid-column: 1;
    }

    body.game-page {
        padding: 6px;
    }

    body.game-page .solo-match-header,
    body.game-page .multiplayer-match-header {
        padding: 8px;
    }

    body.game-page .solo-match-title,
    body.game-page .multiplayer-match-title {
        font-size: 16px;
    }

    body.game-page .modal-content,
    body.game-page .turn-timeout-card,
    body.game-page .letter-input-content,
    body.game-page .tutorial-content,
    body.game-page .game-over-content,
    body.game-page .profile-modal-content {
        padding: 18px;
    }
}

@media (max-width: 479px) {
    body.screen-hub .hub {
        padding-inline: 10px;
    }

    body.screen-hub .app-logo {
        font-size: 30px;
    }

    body.screen-hub .lang-btn,
    body.screen-hub .pill {
        padding-inline: 8px;
        font-size: 12px;
    }

    body.screen-hub .quick-links {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body.screen-shop .header {
        min-height: 58px;
        padding: 10px 12px;
    }

    body.screen-shop .header-title {
        font-size: 18px;
    }

    body.screen-shop .balance > span:last-child {
        display: none;
    }

    body.screen-shop .items-grid {
        gap: 8px;
    }

    body.screen-shop .item-name {
        font-size: 13px;
    }

    body.screen-shop .item-description {
        display: none;
    }

    body.screen-inventory .inventory-filters {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    body.screen-inventory .inventory-filter:nth-child(n + 4) {
        grid-column: span 1;
    }

    body.screen-settings .topbar-title h1 {
        font-size: 20px;
    }

    body.screen-leaderboard .container {
        padding-top: 20px;
    }

    body.screen-auth {
        padding: 12px;
        align-items: flex-start;
    }

    body.screen-auth .auth-container {
        margin-top: max(8px, env(safe-area-inset-top));
        padding: 20px 16px;
    }

    body.screen-auth .instructions {
        display: none;
    }
}

@media (max-width: 340px) {
    body.balda-product .bottom-nav .nav-item > div {
        display: block !important;
        font-size: 9px;
    }

    body.screen-hub .lang-flag,
    body.screen-hub .pill .icon {
        display: none;
    }

    body.screen-shop .tab-label,
    body.screen-inventory .filter-label {
        font-size: 9px;
    }

    body.game-page .input-controls {
        gap: 6px;
    }
}

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