:root {
  color-scheme: dark;
  --bg: #171417;
  --surface: #211a20;
  --surface-raised: #2b2028;
  --surface-warm: #39232d;
  --ink: #f7f0e3;
  --muted: #aaa09b;
  --muted-strong: #c9b9ad;
  --gold: #e7bd67;
  --gold-light: #ffe9ad;
  --wine: #7f3049;
  --wine-deep: #4b2232;
  --teal: #6ab5a0;
  --line: #4d3a43;
  --line-gold: #8e6748;
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; color: inherit; }
button:disabled { opacity: .6; cursor: wait; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold-light); outline-offset: 3px; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; stroke-width: 1.8; flex-shrink: 0; }
a { color: inherit; text-decoration: none; }

.app { height: 100dvh; min-height: 340px; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.topbar { height: 70px; flex-shrink: 0; display: flex; align-items: center; gap: 20px; padding: 0 clamp(18px, 4vw, 56px); background: linear-gradient(180deg, #5a2c3a 0%, #351e2a 100%); border-bottom: 1px solid #9f724d; box-shadow: 0 3px 18px #0007; z-index: 2; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--gold-light); }
.brand strong { font-size: 22px; letter-spacing: .2px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border: 2px solid var(--gold); font: italic 900 30px Georgia, serif; border-radius: 50%; background: #6d3042; box-shadow: inset 0 0 0 2px #6c3a48, 0 2px 8px #0005; }
.player-bar { display: flex; align-items: center; gap: 12px; margin-left: auto; flex: 0 1 auto; }
.profile-button { display: flex; align-items: center; gap: 9px; padding: 0; border: 0; background: none; text-align: left; }
.profile-button strong { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.profile-button small { display: block; color: #d2b9b4; font-size: 10px; }
.avatar { display: grid; place-items: center; flex-shrink: 0; width: 36px; height: 36px; border: 1px solid #e6c477; border-radius: 50%; background: #f1dba9; color: #582536; font-weight: 800; }
.wallet-button { height: 36px; min-width: 150px; display: flex; align-items: center; gap: 9px; padding: 0 13px; border: 1px solid #ad8150; border-radius: 18px; background: #241a20c9; color: var(--gold-light); font-weight: 800; font-variant-numeric: tabular-nums; box-shadow: inset 0 1px #ffffff12; }
.wallet-button svg { color: var(--gold); }
.header-actions { display: flex; align-items: center; gap: 7px; margin-left: 0; }
.test-label { color: #d5b8ac; font-size: 11px; }
.icon-button { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--gold); }
.icon-button:hover { background: #ffffff16; }

.auth-view { width: min(1100px, 100%); flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); align-items: center; gap: 60px; align-self: center; padding: 32px; }
.auth-art h1 { margin: 0 0 14px; color: var(--gold-light); font-size: 52px; font-weight: 900; }
.preview-games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; max-width: 520px; }
.preview-games img { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 8px 12px #0008); }
.auth-form-panel { padding: 30px 28px; border: 1px solid #876148; border-radius: 16px; background: linear-gradient(160deg, #3a252f, #241e24 70%); box-shadow: 0 16px 46px #0007; }
.auth-tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 23px; }
.auth-tabs button { flex: 1; padding: 12px 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 16px; font-weight: 600; }
.auth-tabs button.active { border-color: var(--gold); color: var(--gold-light); }
label { display: block; margin: 14px 0 7px; color: var(--muted-strong); font-size: 12px; }
.input-wrap { display: flex; align-items: center; gap: 10px; padding: 0 12px; border: 1px solid #634d55; border-radius: 9px; background: #191619; color: #cbb17d; }
.input-wrap input { min-width: 0; width: 100%; height: 44px; border: 0; outline: 0; background: none; color: var(--ink); }
.input-wrap:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px #e7bd6717; }
.input-wrap input::placeholder { color: #81777a; }
.input-wrap .icon-button { width: 28px; }
.primary { width: 100%; height: 46px; display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 22px; border: 1px solid #ffe6a4; border-radius: 9px; background: linear-gradient(180deg, #f1cf80, #c7984e); color: #462531; font-size: 16px; font-weight: 800; box-shadow: 0 7px 18px #0004; }
.primary:hover { filter: brightness(1.08); }
.message { min-height: 20px; margin: 12px 0 0; color: #fda898; font-size: 12px; }

.lobby-view { width: 100%; flex: 1; min-height: 0; display: flex; flex-direction: column; align-self: center; background: radial-gradient(circle at 15% -30%, #6d30421d, transparent 42%), #171417; }
.categories { width: 100%; flex-shrink: 0; padding: 10px clamp(14px, 3vw, 48px); overflow-x: auto; border-bottom: 1px solid #3b2b33; background: #211a20; scrollbar-width: none; }
.categories::-webkit-scrollbar { display: none; }
.categories nav { width: max-content; display: flex; align-items: center; gap: 8px; margin: 0 auto; }
.categories button { min-height: 36px; display: flex; align-items: center; gap: 7px; padding: 7px 15px; border: 1px solid transparent; border-radius: 18px; background: transparent; color: #bcaeaa; font-size: 12px; white-space: nowrap; }
.categories button.active { border-color: #b17b4e; background: linear-gradient(180deg, #79364b, #54283a); color: var(--gold-light); box-shadow: inset 0 1px #ffffff14, 0 3px 10px #0004; }
.categories button:hover { color: var(--gold-light); background: #ffffff0d; }
.categories svg { width: 17px; height: 17px; }

.game-browser { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.game-toolbar { height: 68px; flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 0 clamp(18px, 4vw, 56px); border-bottom: 1px solid #3b2b33; }
.section-title { min-width: 0; display: flex; align-items: baseline; gap: 10px; flex: 1; }
.section-title h2 { margin: 0; color: var(--gold-light); font-size: 20px; font-weight: 800; white-space: nowrap; }
.section-title span { color: #a89087; font-size: 11px; white-space: nowrap; }
.search { width: 230px; }
.search input { height: 34px; font-size: 12px; }
.game-grid { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); align-content: start; gap: 18px; padding: 20px clamp(18px, 4vw, 56px) 30px; scrollbar-color: #805a47 transparent; scrollbar-width: thin; }
.game-card { position: relative; min-width: 0; display: flex; flex-direction: column; }
.game-launch { position: relative; width: 100%; padding: 0; border: 0; border-radius: 14px; background: none; text-align: center; }
.game-launch .art { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 1.35; border: 1px solid #735349; border-radius: 14px; background: radial-gradient(circle at 50% 22%, #74414e 0%, #33212b 58%, #1e1a20 100%); box-shadow: inset 0 1px #ffffff18, 0 7px 16px #0008; isolation: isolate; }
.game-launch .art::after { position: absolute; inset: 0; z-index: 1; pointer-events: none; content: ""; background: linear-gradient(180deg, transparent 55%, #170f14b8 100%); }
.game-launch img { position: relative; z-index: 0; width: 100%; height: 100%; padding: 10px; object-fit: contain; transition: transform .18s ease, filter .18s ease; }
.game-card.legacy .art { background: #291c20; }
.game-card.legacy img { padding: 0; border: 0; border-radius: 13px; object-fit: cover; }
.game-launch:hover .art { border-color: #c18c58; box-shadow: inset 0 1px #ffffff24, 0 10px 20px #0009, 0 0 0 2px #c18c5830; }
.game-launch:hover img { transform: scale(1.035); filter: saturate(1.08) brightness(1.04); }
.game-launch strong { display: block; overflow: hidden; margin-top: 9px; color: #f0d9a2; font-size: 14px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.game-launch small { display: block; margin-top: 2px; color: #9d8b87; font-size: 10px; }
.favorite { position: absolute; top: 9px; right: 9px; z-index: 3; width: 29px; height: 29px; display: grid; place-items: center; padding: 0; border: 1px solid #c19b5b; border-radius: 50%; background: #211a20d9; color: #e5bd65; }
.favorite:hover { background: #603043; }
.favorite svg { width: 15px; height: 15px; }
.favorite.active svg { fill: var(--gold); }
.new-badge { position: absolute; top: 9px; left: 9px; z-index: 2; padding: 3px 7px; border: 1px solid #e2b85c; border-radius: 5px; background: #9a3048e8; color: #ffeab3; font-size: 10px; box-shadow: 0 2px 7px #0006; }
.empty { grid-column: 1 / -1; margin: 40px 0; color: var(--muted); text-align: center; }

.bottom-bar { height: 62px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(18px, 4vw, 56px); border-top: 1px solid #8b6548; background: linear-gradient(180deg, #38232c, #241a21); box-shadow: 0 -4px 16px #0006; z-index: 2; }
.server-state { display: flex; align-items: center; gap: 8px; color: #a99b94; font-size: 11px; }
.server-state > span { width: 7px; height: 7px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 8px #6ab5a0; }
.bottom-bar nav { display: flex; align-items: center; gap: 22px; }
.bottom-bar button { height: 44px; display: flex; align-items: center; gap: 7px; padding: 0 5px; border: 0; border-bottom: 2px solid transparent; background: none; color: #b9aaa5; font-size: 12px; }
.bottom-bar button:hover, .bottom-bar button.active { border-color: var(--gold); color: var(--gold-light); }

dialog { width: min(600px, calc(100% - 32px)); max-height: 85dvh; padding: 24px; border: 1px solid #a18552; border-radius: 14px; background: #282027; color: var(--ink); box-shadow: 0 20px 60px #000b; }
dialog::backdrop { background: #000b; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 10px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; color: var(--gold-light); font-size: 19px; }
.account-values { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.account-values dt { color: var(--muted); font-size: 12px; }
.account-values dd { margin: 0 0 14px; overflow-wrap: anywhere; font-size: 18px; }
.records-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.records-table th { color: var(--muted); font-weight: 400; text-align: left; }
.records-table td, .records-table th { padding: 10px 6px; border-bottom: 1px solid #41343a; }
.records-table td:last-child { text-align: right; white-space: nowrap; }
.positive { color: #8cd5a0; }
.negative { color: #f0a494; }
.toast { position: fixed; left: 50%; bottom: 78px; z-index: 200; width: max-content; max-width: calc(100% - 24px); padding: 12px 18px; transform: translateX(-50%); border: 1px solid #a68451; border-radius: 8px; background: #34242e; color: #ffdea5; font-size: 13px; box-shadow: 0 8px 30px #0008; }

@media (max-height: 560px) and (orientation: landscape) {
  .topbar { height: 52px; padding: 0 18px; }
  .brand strong { font-size: 19px; }
  .brand-mark { width: 30px; height: 30px; font-size: 24px; }
  .avatar { width: 30px; height: 30px; }
  .wallet-button { height: 30px; min-width: 130px; }
  .categories { padding-top: 5px; padding-bottom: 5px; }
  .categories button { min-height: 31px; padding: 5px 11px; }
  .game-toolbar { height: 52px; }
  .game-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: 12px; padding-top: 12px; }
  .game-launch strong { margin-top: 5px; font-size: 12px; }
  .game-launch small { font-size: 9px; }
  .bottom-bar { height: 44px; }
  .bottom-bar button { height: 36px; font-size: 11px; }
}

@media (max-width: 760px) {
  .topbar { height: 58px; padding: 0 12px; gap: 11px; }
  .brand strong { font-size: 18px; }
  .brand-mark { width: 30px; height: 30px; font-size: 23px; }
  .profile-button > span:last-child { display: none; }
  .wallet-button { min-width: 0; height: 32px; padding: 0 10px; font-size: 12px; }
  .wallet-button svg { width: 16px; height: 16px; }
  .test-label { display: none; }
  .header-actions { gap: 0; }
  .icon-button { width: 32px; height: 32px; }
  .categories { padding: 7px 10px; }
  .categories nav { margin: 0; gap: 5px; }
  .categories button { min-height: 32px; gap: 5px; padding: 5px 10px; font-size: 11px; }
  .categories svg { width: 15px; height: 15px; }
  .game-toolbar { height: 54px; padding: 0 12px; gap: 6px; }
  .section-title { gap: 5px; }
  .section-title h2 { font-size: 15px; }
  .section-title span { font-size: 10px; }
  .search { width: 140px; padding: 0 8px; gap: 5px; }
  .search svg { width: 14px; height: 14px; }
  .search input { font-size: 11px; }
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 9px; padding: 12px 10px 20px; }
  .game-launch strong { margin-top: 6px; font-size: 12px; }
  .game-launch small { font-size: 9px; }
  .favorite { top: 5px; right: 5px; width: 25px; height: 25px; }
  .favorite svg { width: 13px; height: 13px; }
  .new-badge { top: 5px; left: 5px; padding: 2px 5px; font-size: 9px; }
  .bottom-bar { height: 53px; justify-content: center; padding: 0 8px; }
  .bottom-bar nav { width: 100%; justify-content: space-around; gap: 4px; }
  .bottom-bar button { gap: 5px; font-size: 10px; }
  .server-state { display: none; }
  .records-table td, .records-table th { padding: 9px 3px; font-size: 10px; }
  dialog { padding: 16px; }
}

@media (max-width: 500px) and (orientation: portrait) {
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 10px; }
  .game-launch .art { aspect-ratio: 1.3; }
}

/* Reference-style game wall: the lobby keeps the same data and actions, but the
   playable area is presented as a dense, framed game stage. */
.lobby-view { position: relative; overflow: hidden; background: #130e16; }
.lobby-view::before { position: absolute; inset: 0; pointer-events: none; content: ""; background: linear-gradient(135deg, #7a263d28, transparent 42%), linear-gradient(315deg, #d08b3f12, transparent 50%); }
.categories { position: absolute; top: 8px; left: 24px; z-index: 9; width: auto; padding: 0; overflow: visible; border: 0; background: transparent; }
.categories nav { gap: 4px; margin: 0; }
.categories button { min-height: 27px; padding: 4px 9px; border: 1px solid #896348; border-radius: 14px; background: #21141dcc; color: #ccb9a1; font-size: 10px; box-shadow: 0 2px 7px #0005; }
.categories button.active { border-color: #e2ae59; background: linear-gradient(180deg, #8c3c4c, #522332); color: #ffe5a4; box-shadow: inset 0 1px #fff4, 0 3px 9px #0008; }
.categories button:hover { background: #603044e8; color: #fff0bd; }
.categories svg { width: 14px; height: 14px; }
.game-browser { position: relative; margin: 8px 14px 0; border: 1px solid #a2784e; border-bottom: 0; border-radius: 24px 24px 0 0; background: linear-gradient(180deg, #4c2032 0%, #30182b 36%, #1a111b 100%); box-shadow: 0 0 0 2px #291826, inset 0 1px #ffddb044, 0 -10px 36px #5f273b33; overflow: hidden; }
.game-browser::before { position: absolute; top: 0; left: 4%; right: 4%; height: 3px; z-index: 2; content: ""; border-radius: 50%; background: linear-gradient(90deg, transparent, #f0c77d, transparent); opacity: .8; }
.game-toolbar { position: absolute; top: 12px; right: 17px; z-index: 8; width: auto; height: 32px; padding: 0; border: 0; pointer-events: none; }
.game-toolbar .section-title { display: none; }
.game-toolbar .search, .game-toolbar #refreshButton { pointer-events: auto; }
.search { width: 174px; height: 30px; border-color: #98704d; border-radius: 16px; background: #160f18c7; box-shadow: inset 0 1px #fff2; }
.search input { height: 28px; font-size: 11px; }
.game-toolbar #refreshButton { width: 30px; height: 30px; color: #f0c478; }
.game-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 4px 3px; padding: 45px 10px 98px; background: radial-gradient(ellipse at 50% -15%, #c15e4b26, transparent 52%), #190f1a; scrollbar-width: thin; scrollbar-color: #a5724d transparent; }
.game-card { z-index: 1; margin: 3px 0; transform: rotate(0deg); transition: transform .18s ease, z-index .18s ease; }
.game-card:nth-child(5n + 1) { transform: rotate(-2deg) translateY(6px); }
.game-card:nth-child(5n + 2) { transform: rotate(1deg) translateY(-2px); }
.game-card:nth-child(5n + 3) { transform: rotate(-1deg) translateY(4px); }
.game-card:nth-child(5n + 4) { transform: rotate(2deg) translateY(-3px); }
.game-card:nth-child(5n) { transform: rotate(-1deg) translateY(5px); }
.game-card:hover { z-index: 4; transform: translateY(-7px) scale(1.025); }
.game-launch { height: 100%; }
.game-launch .art { aspect-ratio: 1.18; border: 2px solid #9d7049; border-radius: 16px; background: #321727; box-shadow: inset 0 1px #fff4, 0 5px 12px #000a, 0 0 0 1px #371d2d; }
.game-launch .art::after { background: linear-gradient(180deg, transparent 56%, #180b15a8 100%); }
.game-launch img, .game-card.legacy img { padding: 0; border: 0; border-radius: 13px; object-fit: cover; filter: saturate(1.08) contrast(1.04); }
.game-launch strong, .game-launch small, .favorite, .new-badge { display: none; }
.game-card:hover .game-launch .art { border-color: #f1c46d; box-shadow: inset 0 1px #fff7, 0 9px 22px #000c, 0 0 0 2px #e8ae5a66; }
.empty { color: #e4c18d; }
.bottom-bar { position: relative; height: 76px; justify-content: center; padding: 0; border-top: 1px solid #ad7e4b; background: linear-gradient(180deg, #3d202c, #1e121c); box-shadow: 0 -8px 28px #000b; }
.server-state { position: absolute; left: 18px; bottom: 14px; font-size: 10px; }
.bottom-bar nav { gap: 10px; height: 100%; align-items: center; }
.bottom-bar button { width: 78px; height: 56px; flex-direction: column; justify-content: center; gap: 4px; padding: 5px 4px 3px; border: 0; border-radius: 9px; color: #d2b999; font-size: 11px; }
.bottom-bar button svg { width: 22px; height: 22px; }
.bottom-bar button:hover, .bottom-bar button.active { border: 1px solid #a6784c; background: #6a304126; color: #ffe2a3; }
.bottom-bar .bank-button { width: 94px; height: 82px; margin: -19px 3px 0; border: 2px solid #c28c51; border-radius: 50% 50% 18px 18px; background: radial-gradient(circle at 50% 24%, #a95a46, #5e2b3e 68%, #321b29); color: #ffe6a4; box-shadow: 0 -2px 0 #f5d18b55, 0 4px 15px #000a, inset 0 1px #fff5; }
.bottom-bar .bank-button svg { width: 28px; height: 28px; }
.bottom-bar .bank-button span { font-size: 13px; font-weight: 800; }
.bottom-bar .bank-button:hover { transform: translateY(-2px); border-color: #f0c77d; background: radial-gradient(circle at 50% 24%, #bd6a4e, #713149 68%, #412030); }
.topbar { height: 54px; padding: 0 20px; background: linear-gradient(180deg, #512439, #291523); border-bottom-color: #9c6b45; }
.brand strong { font-size: 19px; }
.brand-mark { width: 32px; height: 32px; font-size: 25px; }

@media (max-height: 560px) and (orientation: landscape) {
  .topbar { height: 43px; }
  .categories { top: 5px; left: 16px; }
  .categories button { min-height: 23px; padding: 3px 7px; }
  .game-browser { margin: 5px 8px 0; }
  .game-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 35px 7px 73px; }
  .game-launch .art { border-radius: 12px; }
  .bottom-bar { height: 58px; }
  .bottom-bar button { height: 46px; }
  .bottom-bar .bank-button { height: 65px; width: 80px; margin-top: -13px; }
}

@media (max-width: 760px) {
  .topbar { height: 50px; padding: 0 10px; }
  .categories { top: 7px; left: 10px; max-width: calc(100% - 20px); overflow-x: auto; }
  .categories nav { width: max-content; }
  .game-browser { margin: 5px 6px 0; border-radius: 19px 19px 0 0; }
  .game-toolbar { top: 9px; right: 9px; }
  .search { width: 132px; }
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px 2px; padding: 42px 6px 77px; }
  .game-launch .art { aspect-ratio: 1.13; border-radius: 12px; }
  .bottom-bar { height: 64px; }
  .bottom-bar nav { gap: 1px; width: 100%; justify-content: center; }
  .bottom-bar button { width: 61px; height: 48px; font-size: 9px; }
  .bottom-bar button svg { width: 19px; height: 19px; }
  .bottom-bar .bank-button { width: 76px; height: 68px; margin: -15px 0 0; }
  .bottom-bar .bank-button svg { width: 24px; height: 24px; }
  .server-state { display: none; }
}

@media (max-width: 500px) and (orientation: portrait) {
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 3px; }
}

/* The reference uses a compact, centered game-table surface with two rows that
   page horizontally. Keep the same behavior on desktop and touch screens. */
html, body { background: #edf1f7; }
body { display: grid; place-items: center; padding: 14px; }
.app { width: min(932px, 100%); height: min(430px, calc(100dvh - 28px)); min-height: 340px; border: 1px solid #d9dce4; border-radius: 2px; box-shadow: 0 14px 32px #36405a24; }
.topbar { height: 44px; padding: 0 18px; }
.brand { gap: 8px; }
.brand strong { font-size: 18px; }
.brand-mark { width: 32px; height: 32px; font-size: 25px; }
.avatar { width: 30px; height: 30px; }
.wallet-button { height: 30px; min-width: 150px; }
.lobby-view { min-height: 0; }
.categories { top: 0; left: 0; width: 100%; height: 39px; padding: 5px 15px; overflow-x: auto; border-bottom: 1px solid #76503f; background: #271624e8; }
.categories nav { gap: 5px; }
.categories button { min-height: 27px; padding: 3px 9px; }
.game-browser { margin: 39px 0 0; border-width: 1px; border-radius: 18px 18px 0 0; }
.game-grid { grid-template-columns: none; grid-template-rows: repeat(2, minmax(0, 1fr)); grid-auto-flow: column; grid-auto-columns: calc((100% - 12px) / 5); align-content: stretch; gap: 5px 3px; padding: 9px 8px 9px; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: none; }
.game-grid::-webkit-scrollbar { display: none; }
.game-card { min-height: 0; scroll-snap-align: start; }
.game-launch .art { height: 100%; min-height: 0; aspect-ratio: auto; border-radius: 14px; }
.bottom-bar { height: 58px; }
.server-state { bottom: 10px; }
.bottom-bar button { height: 48px; }
.bottom-bar .bank-button { height: 70px; margin-top: -16px; }

@media (max-width: 760px) {
  body { padding: 0; }
  .app { width: 100%; height: 100dvh; min-height: 340px; border: 0; box-shadow: none; }
  .topbar { height: 43px; padding: 0 10px; }
  .categories { height: 36px; padding: 4px 8px; }
  .game-browser { margin-top: 36px; }
  .game-grid { grid-auto-columns: calc((100% - 6px) / 3); padding: 7px 5px; }
  .bottom-bar { height: 62px; }
}

@media (max-width: 500px) and (orientation: portrait) {
  .game-grid { grid-auto-columns: calc((100% - 3px) / 2); }
}

.bank-panel { display: grid; gap: 14px; }
.bank-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.bank-summary > div { min-width: 0; padding: 11px 12px; border: 1px solid #765044; border-radius: 9px; background: linear-gradient(145deg, #3d2330, #241822); }
.bank-summary small { display: block; color: #b9a29a; font-size: 11px; }
.bank-summary strong { display: block; overflow: hidden; margin-top: 4px; color: #ffe2a0; font-size: 18px; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.bank-summary .bank-value-long { font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
.bank-dialog { width: min(720px, calc(100% - 24px)); max-height: calc(100dvh - 24px); border-radius: 8px; }
.bank-dialog .dialog-heading { margin-bottom: 14px; }
.bank-workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
.bank-loading { margin: 25px 0; text-align: center; color: var(--muted); }
.bank-summary > div { border-radius: 6px; }
.bank-panel .bank-tabs { border-radius: 6px; }
.bank-panel .bank-tabs button { border-radius: 4px; }
.bank-quick { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.bank-quick button { border: 1px solid #65454b; border-radius: 4px; background: #281c25; color: #e7c38c; padding: 4px 8px; font-size: 11px; }
.bank-quick span { margin-left: auto; color: #ae9b95; font-size: 11px; }
.bank-quick b { color: #f4d699; }
.bank-message { min-height: 18px; margin: 6px 0 0; color: #f7c08d; font-size: 11px; }
.bank-ledger-result { text-align: right; }
.bank-workspace .bank-ledger { border-top: 0; padding-top: 0; }
.bank-ledger-heading .icon-button { height: 25px; width: 25px; }
.bank-access form { margin-top: 13px; }
.bank-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; padding: 4px; border: 1px solid #65454b; border-radius: 10px; background: #191219; }
.bank-tabs button { height: 34px; border: 0; border-radius: 7px; background: transparent; color: #ae9b95; font-size: 12px; }
.bank-tabs button.active { background: linear-gradient(180deg, #81384c, #542638); color: #ffe4a5; box-shadow: inset 0 1px #fff3; }
.bank-panel label { margin: 0 0 6px; }
.bank-amount { display: flex; align-items: center; gap: 8px; padding: 0 8px 0 12px; border: 1px solid #765044; border-radius: 9px; background: #171118; }
.bank-amount:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px #e7bd6717; }
.bank-amount input { min-width: 0; width: 100%; height: 42px; border: 0; outline: 0; background: transparent; color: #fff0c8; font-size: 16px; font-variant-numeric: tabular-nums; }
.bank-amount input::-webkit-outer-spin-button, .bank-amount input::-webkit-inner-spin-button { margin: 0; appearance: none; }
.bank-amount button { flex-shrink: 0; height: 26px; padding: 0 9px; border: 1px solid #9e744b; border-radius: 6px; background: #3a2330; color: #f5d28b; font-size: 11px; }
.bank-available { margin: 7px 0 0; color: #9d8987; font-size: 11px; }
.bank-available b { color: #e8c67c; font-variant-numeric: tabular-nums; }
.bank-submit { height: 42px; margin-top: 12px; font-size: 14px; }
.bank-ledger { padding-top: 12px; border-top: 1px solid #4d3742; }
.bank-ledger-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 7px; }
.bank-ledger-heading strong { color: #f1d59a; font-size: 13px; }
.bank-ledger-heading small { color: #978482; font-size: 10px; }
.bank-ledger ul { max-height: 145px; overflow: auto; margin: 0; padding: 0; list-style: none; scrollbar-color: #7a5547 transparent; scrollbar-width: thin; }
.bank-ledger-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px solid #392b34; }
.bank-ledger-row span { min-width: 0; }
.bank-ledger-row strong, .bank-ledger-row small { display: block; }
.bank-ledger-row strong { color: #d9c5af; font-size: 12px; font-weight: 600; }
.bank-ledger-row small { margin-top: 2px; color: #8f7c7b; font-size: 10px; }
.bank-ledger-row b { flex-shrink: 0; font-size: 13px; font-variant-numeric: tabular-nums; }
.bank-ledger-empty { padding: 18px 0; color: #938183; font-size: 12px; text-align: center; }

@media (max-width: 520px) {
  dialog { width: min(430px, calc(100% - 20px)); padding: 16px; }
  .bank-summary > div { padding: 9px 8px; }
  .bank-summary strong { font-size: 15px; }
  .bank-summary .bank-value-long { font-size: 11px; }
  .bank-workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

@media (max-height: 480px) and (min-width: 521px) {
  .bank-dialog { padding: 12px 18px; }
  .bank-dialog .dialog-heading { margin-bottom: 8px; padding-bottom: 5px; }
  .bank-panel { gap: 8px; }
  .bank-summary > div { padding: 7px 10px; }
  .bank-ledger ul { max-height: 185px; }
  .bank-tabs button { height: 28px; }
  .bank-access form { margin-top: 8px; }
  .bank-amount input { height: 34px; }
  .bank-submit { height: 34px; margin-top: 9px; }
}

/* Only the lobby uses a landscape stage. Game pages keep their native ratio. */
@media (orientation: landscape) and (max-height: 560px) {
  body.lobby-landscape { padding: 0; overflow: hidden; background: var(--bg); }
  .lobby-landscape .app { width: 100%; height: 100dvh; min-height: 0; border: 0; box-shadow: none; }
  .lobby-landscape .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
}
@media (orientation: portrait) {
  body.lobby-landscape { overflow: hidden; padding: 0; background: var(--bg); }
  .lobby-landscape .app { position: fixed; left: 50%; top: 50%; width: 100dvh; height: 100vw; min-height: 0; max-width: none; border: 0; box-shadow: none; transform: translate(-50%, -50%) rotate(90deg); }
  .lobby-landscape .topbar { height: 43px; padding: 0 12px; }
  .lobby-landscape .categories { height: 36px; max-width: none; padding: 4px 8px; }
  .lobby-landscape .game-browser { margin: 36px 0 0; }
  .lobby-landscape .game-grid { grid-template-columns: none; grid-auto-columns: calc((100% - 12px) / 5); grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 5px 3px; padding: 7px 5px; }
  .lobby-landscape .game-card { transform: none; margin: 0; }
  .lobby-landscape .game-launch .art { height: 100%; aspect-ratio: auto; }
  .lobby-landscape .bottom-bar { height: 58px; }
  .lobby-landscape .bottom-bar nav { gap: 8px; }
  .lobby-landscape .bottom-bar button { width: 78px; height: 46px; font-size: 11px; }
  .lobby-landscape .bottom-bar .bank-button { width: 80px; height: 65px; margin-top: -13px; }
  .lobby-landscape dialog { position: fixed; inset: auto; left: 50%; top: 50%; margin: 0; width: min(600px, calc(100dvh - 24px)); max-width: none; max-height: calc(100vw - 24px); padding: 12px 18px; transform: translate(-50%, -50%) rotate(90deg); }
  .lobby-landscape .bank-dialog { width: min(720px, calc(100dvh - 24px)); }
  .lobby-landscape .dialog-heading { margin-bottom: 8px; padding-bottom: 5px; }
  .lobby-landscape .bank-panel { gap: 8px; }
  .lobby-landscape .bank-workspace { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
  .lobby-landscape .bank-summary > div { padding: 7px 10px; }
  .lobby-landscape .bank-summary strong { font-size: 15px; }
  .lobby-landscape .bank-summary .bank-value-long { font-size: 11px; }
  .lobby-landscape .bank-ledger ul { max-height: 155px; }
  .lobby-landscape .bank-tabs button { height: 28px; }
  .lobby-landscape .bank-access form { margin-top: 8px; }
  .lobby-landscape .bank-amount input { height: 34px; }
  .lobby-landscape .bank-submit { height: 34px; margin-top: 9px; }
  .lobby-landscape .toast { left: 78px; top: 50%; bottom: auto; max-width: calc(100dvh - 24px); transform: translate(-50%, -50%) rotate(90deg); }
}
