* { box-sizing: border-box; }
body {
    --bg: var(--tg-theme-bg-color, #fff);
    --secondary: var(--tg-theme-secondary-bg-color, #eef1f6);
    --fg: var(--tg-theme-text-color, #182232);
    --hint: var(--tg-theme-hint-color, #657084);
    --accent: var(--tg-theme-button-color, #2364d2);
    --on: var(--tg-theme-button-text-color, #fff);
    --border: color-mix(in srgb, var(--fg) 12%, transparent);
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), calc(var(--tg-safe-area-inset-bottom, 0px) + var(--tg-content-safe-area-inset-bottom, 0px)));
    --safe-top: max(env(safe-area-inset-top, 0px), calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px)));
    --safe-left: max(env(safe-area-inset-left, 0px), calc(var(--tg-safe-area-inset-left, 0px) + var(--tg-content-safe-area-inset-left, 0px)));
    --safe-right: max(env(safe-area-inset-right, 0px), calc(var(--tg-safe-area-inset-right, 0px) + var(--tg-content-safe-area-inset-right, 0px)));
    margin: 0;
    background: var(--secondary);
    color: var(--fg);
    font: 16px/1.42 system-ui, -apple-system, sans-serif;
}
main { max-width: 680px; margin: auto; padding: calc(12px + var(--safe-top)) calc(14px + var(--safe-right)) calc(96px + var(--safe-bottom)) calc(14px + var(--safe-left)); }
h1, h2, h3, p { margin: 0 0 8px; }
h1 { font-size: 27px; letter-spacing: -.035em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
section { background: var(--bg); border-radius: 15px; padding: 12px; margin: 8px 0; }
section > :last-child, form > :last-child { margin-bottom: 0; }
button, input, select {
    font: inherit;
    padding: 9px 11px;
    border: 0;
    border-radius: 10px;
    margin: 4px 0;
    min-height: 42px;
    width: 100%;
}
button { background: var(--accent); color: var(--on); font-weight: 600; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.secondary, input, select { background: var(--secondary); color: var(--fg); }
button.link { width: auto; background: transparent; color: var(--accent); padding: 4px; text-align: left; }
small, .muted { color: var(--hint); font-size: 13px; }
label { display: block; font-size: 13px; margin: 3px 0; color: var(--hint); min-width: 0; }
nav {
    position: fixed;
    left: max(calc(12px + var(--safe-left)), calc((100% - 460px) / 2));
    right: max(calc(12px + var(--safe-right)), calc((100% - 460px) / 2));
    bottom: calc(10px + var(--safe-bottom));
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 90%, transparent);
    box-shadow: 0 8px 22px #0002;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    z-index: 2;
}
nav button { margin: 0; padding: 6px 5px; min-width: 0; border-radius: 19px; background: none; color: var(--hint); font-size: 12px; display: grid; justify-items: center; gap: 2px; }
nav .active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--bg)); }
nav svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.game-grid, .choice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.game-tile, .choice-tile { color: var(--fg); background: var(--bg); margin: 0; border: 1px solid var(--border); text-align: left; }
.game-tile { padding: 9px; border-radius: 16px; }
.game-tile > b { display: block; margin: 5px 3px 2px; }
.game-tile > small { display: block; margin: 0 3px 2px; }
.choice-tile { min-height: 74px; padding: 12px; }
.tile-art { display: grid; place-items: center; min-height: 76px; padding: 5px; border-radius: 10px; color: #254480; background: #dceaff; font-size: 33px; letter-spacing: .08em; }
.tile-art.wheel { color: #783870; background: #f3dff2; }
.tile-art.slots { color: #5e461b; background: #f9e9c4; }
.tile-art.crash, .arcade-stage.crash { color: #324e77; background: #dbe9ff; }
.tile-art.limbo, .arcade-stage.limbo { color: #2e6150; background: #d7eee4; }
.tile-art.coinflip { color: #745523; background: #f8e9c2; }
.arcade-stage {
    min-height: 120px;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 6px;
    margin-block: 8px 12px;
    border-radius: 16px;
}
.arcade-stage span { font-size: 26px; }
.arcade-stage strong { font-size: clamp(20px, 7vw, 38px); font-variant-numeric: tabular-nums; }
.duel-card .muted { margin-block: 6px; }
.hero span, .tile-art span, .red { color: #d83c44 !important; }
.settings-list { padding: 0 10px; }
.settings-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 9px;
    text-align: left;
    color: var(--fg);
    background: transparent;
    margin: 0;
    padding: 8px 0;
    min-height: 50px;
    border-radius: 0;
}
.settings-item + .settings-item { border-top: 1px solid var(--border); }
.setting-icon { display: grid; place-items: center; height: 27px; border-radius: 8px; background: color-mix(in srgb, var(--accent) 14%, var(--bg)); color: var(--accent); font-size: 17px; }
.settings-end { color: var(--hint); font-size: 13px; overflow-wrap: anywhere; }
.fields { display: grid; grid-template-columns: repeat(auto-fit,minmax(105px, 1fr)); gap: 6px; }
.metrics { display: flex; justify-content: space-around; padding: 8px 0; text-align: center; }
.metrics b { font-size: 20px; display: block; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; overflow-wrap: anywhere; }
.line + .line { border-top: 1px solid var(--border); }
.line b { text-align: right; font-variant-numeric: tabular-nums; }
.line small { display: block; }
.error { background: var(--bg); color: #d24150; padding: 8px 11px; border-radius: 10px; margin: 0 0 8px; }
.address-qr { display: block; width: min(100%, 182px); margin: 8px auto; }
.requisite { overflow-wrap: anywhere; user-select: all; display: block; margin: 4px 0; }
.wheel-stage { position: relative; display: grid; place-items: center; width: 140px; height: 140px; margin: 12px auto; }
.wheel-board { position: absolute; inset: 0; border: 6px solid var(--secondary); border-radius: 50%; background: conic-gradient(#bbd4fc 0 60%, #91d1bd 60% 85%, #d3b1fa 85% 94%, #ffd079 94% 97.5%, #f4a899 97.5% 99.1%, #d88bdc 99.1% 99.85%, #f8dd65 99.85% 99.97%, #ff8258 99.97%); }
.wheel-stage::after { content: ''; position: absolute; top: 0; border-top: 12px solid var(--accent); border-inline: 7px solid transparent; }
.wheel-stage b { position: relative; color: #182232; background: #fff; border-radius: 50%; min-width: 44px; text-align: center; padding: 10px; }
.reels { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 10px auto; max-width: 290px; }
.reels span { display: grid; place-items: center; min-height: 62px; border-radius: 12px; background: var(--secondary); font-size: 28px; }
.spin-result { text-align: center; }
.table { display: flex; flex-wrap: wrap; gap: 10px; min-height: 115px; align-items: center; justify-content: center; background: var(--secondary); border-radius: 12px; padding: 12px; margin: 10px 0; }
.pair { display: flex; align-items: center; gap: 2px; }
.card { width: 46px; height: 64px; border: 1px solid #d8dce1; border-radius: 7px; background: #fff; color: #24262b; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 650; flex-shrink: 0; }
.hand { display: flex; gap: 6px; flex-wrap: wrap; }
.card.selected { outline: 3px solid var(--accent); transform: translateY(-4px); }
.actions, .opponents { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button, .person { width: auto; flex: 1; }
.person { background: var(--secondary); color: var(--fg); }
.person small { display: block; }
.person.active { outline: 2px solid var(--accent); }
.line .card { width: 30px; height: 42px; font-size: 14px; }
summary { padding: 6px 0; cursor: pointer; }
.back-control { display:inline-flex; align-items:center; gap:7px; width:auto; min-height:38px; padding:4px 8px 4px 0; margin:0 0 8px; color:var(--accent); background:transparent; font-weight:500; }
.back-control span { font-size:28px; line-height:1; }
.friend-list { padding:4px 12px; }
.friend-row,.friend-name,.friend-controls,.listing-top,.seller-link { display:flex; align-items:center; }
.friend-row { justify-content:space-between; gap:8px; border-bottom:1px solid var(--border); }
.friend-row:last-child { border-bottom:0; }
.friend-name,.seller-link { width:auto; min-width:0; gap:10px; text-align:left; background:transparent; color:var(--fg); padding:8px 0; }
.friend-name small { display:block; font-weight:400; }
.friend-avatar { width:34px; height:34px; display:grid; place-items:center; border-radius:50%; background:color-mix(in srgb,var(--accent) 20%,var(--bg)); color:var(--accent); flex:none; }
.friend-controls { gap:6px; }
.friend-controls button { width:auto; padding:5px 10px; }
.friend-controls .friend-remove { background:var(--secondary); color:var(--hint); font-size:22px; width:34px; height:34px; min-height:34px; padding:0; border-radius:50%; }
.listing-card { padding:16px; }
.listing-top { justify-content:space-between; gap:12px; padding-bottom:12px; border-bottom:1px solid var(--border); }
.listing-top strong { font-size:22px; }
.listing-top small { display:block; }
.listing-top button { width:auto; min-width:86px; border-radius:18px; }
.listing-seller { padding:8px 0; }
.listing-details { display:grid; grid-template-columns:1fr auto; gap:5px; font-size:14px; }
.listing-details span { color:var(--hint); }
.listing-details b { font-weight:500; text-align:right; }
.currency-disabled {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin-block: 8px 2px;
    padding: 9px 12px;
    border: 1px solid var(--secondary);
    border-radius: 10px;
    color: var(--hint);
    filter: grayscale(1);
}
.currency-disabled b { font-weight: 500; }
