/* Shared game materials; page roles retain their own silhouettes. */
:root {
  --game-line: color-mix(in srgb, var(--accent) 29%, var(--border));
  --game-inlay: color-mix(in srgb, var(--accent) 12%, transparent);
  --game-bevel: inset 0 1px #fff0d72e, inset 0 -2px #00000035, 0 2px 0 #00000040;
}
button:not(.seat, .room-fund, #yourCards, #copyRoomCode, .game-history-row, .summary-player), .link-button {
  box-shadow: var(--game-bevel);
}
button.primary, #resume { box-shadow: inset 0 1px #fff3d6, inset 0 -3px #ab713975, 0 3px 0 #0a080b70; }
button:not(.seat, .room-fund, #yourCards, #copyRoomCode):enabled:active, .link-button:active { translate: 0 1px; }
.game-history-row, .summary-player { box-shadow: none; }
#roomMenu summary .tool-face, .room-fund .tool-face { box-shadow: inset 0 1px #fff0d72b, inset 0 -1px #00000040; }
.dialog-heading, dialog > h2, dialog > form > h2 { border-bottom-style: solid; border-color: var(--game-line); }
.dialog-heading h2, dialog > h2, dialog > form > h2 { letter-spacing: .04em; }
.dialog-heading h2::before, dialog > h2::before, dialog > form > h2::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-inline-end: .45rem;
  background: var(--accent);
  clip-path: polygon(25% 0,75% 0,75% 25%,100% 25%,100% 75%,75% 75%,75% 100%,25% 100%,25% 75%,0 75%,0 25%,25% 25%);
  vertical-align: .12em;
}
.dialog-actions { gap: .6rem; }
input, select, .setup-value { box-shadow: inset 0 2px 2px #00000028; }

/* A room entrance: the existing illustration sits on the same tiled backdrop. */
.app[data-screen="login"] { justify-content: center; padding-block: 1.2rem; }
.app[data-screen="login"] .top { display: none; }
.login-panel { position: relative; border: 0; border-radius: 1rem; box-shadow: 0 8px 24px #00000038; }
.login-content { padding-block: 1rem 1.35rem; }
.login-content h1 { margin-bottom: 1.1rem; color: var(--text); text-shadow: 0 2px #00000045; }
#loginForm { gap: .8rem; }
#loginForm label { gap: .3rem; color: var(--muted); font-size: .86rem; }
#loginForm button { margin-top: .5rem; }

/* Lobby: game entrances above a quieter score ledger. */
.home-stage { margin-top: .25rem; }
.game-actions { gap: .7rem; }
.game-actions > :is(button, a) { position: relative; display: flex; flex-direction: column; align-items: center; gap: .35rem; min-height: 7.2rem; padding: .8rem .4rem; border-radius: .85rem; }
.game-actions #openJoin { border-color: var(--game-line); background: var(--surface-sheen), var(--cloth), var(--surface); background-blend-mode: normal, soft-light, normal; }
.entry-emblem { display: grid; place-items: center; width: 3rem; height: 2.9rem; }
.entry-emblem img { display: block; width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 1px #00000035); }
.game-actions #resume { flex-direction: row; min-height: 4.2rem; gap: .65rem; }
.game-actions #resume .entry-emblem { width: 2.5rem; height: 2.5rem; }
.game-actions > :is(button, a)::after { content: ''; position: absolute; inset: 5px; border: 1px solid currentColor; opacity: .16; border-radius: .58rem; pointer-events: none; }
.game-history-section { position: relative; margin-top: 1.2rem; padding: .85rem .8rem .4rem; border: 1px solid var(--border); border-radius: .75rem; background: var(--surface-sheen), var(--cloth), var(--surface); background-blend-mode: normal, soft-light, normal; box-shadow: inset 3px 0 var(--game-inlay); }
.game-history-section h2 { display: flex; align-items: center; gap: .4rem; font-size: 1rem; color: var(--text); }
.game-history-section h2::before { content: ''; width: 6px; height: 6px; background: var(--accent); rotate: 45deg; }
.history-periods { margin-block: .6rem; padding: .15rem; border-radius: .4rem; border-width: 0 0 1px; }
.history-periods button { border-radius: .3rem; box-shadow: none !important; min-height: 2.2rem; }
.history-total { margin-bottom: .35rem; padding-bottom: .6rem; border-bottom: 1px solid var(--game-line); }
#historyNet[data-sign="win"], .history-entry-net[data-sign="win"], .net-win { color: var(--mint); }
#historyNet[data-sign="loss"], .history-entry-net[data-sign="loss"], .net-loss { color: var(--danger); }
.game-history-row { min-height: 2.8rem; padding-inline: .05rem; font-weight: 400; font-size: .8rem; }
.game-history-row > .history-entry-identity { display: flex; align-items: baseline; gap: .55rem; min-width: 0; }
.history-entry-date { color: var(--muted); font-size: .72rem; min-width: 2.1rem; }
.history-entry-code { font-weight: 650; letter-spacing: .025em; }
.history-entry-hands { color: var(--muted); font-size: .72rem; }
.history-entry-net { flex: none; font-variant-numeric: tabular-nums; }

/* Character staging, shared with the outfit preview. */
#profile { margin-top: clamp(2.5rem, 12vh, 6.5rem); }
.profile-card { position: relative; width: min(100%, 23rem); margin-inline: auto; gap: 0; padding: .6rem .7rem 1rem; }
.profile-stage { display: grid; place-items: center; width: 13rem; margin-bottom: .8rem; }
:root[data-themed="true"] #profileAppearance { width: clamp(8.1rem, 32vw, 9.5rem); border: 0; border-radius: 0; background: none; box-shadow: none; }
#profileAppearance .avatar-art { width: 100%; filter: drop-shadow(0 3px 2px #00000035); }
.profile-identity { position: relative; min-width: 12.6rem; max-width: 100%; padding: .5rem 1rem .6rem; border: 1px solid var(--edge); border-radius: .55rem; background: var(--surface-sheen), var(--surface); box-shadow: var(--game-bevel); }
.profile-identity::before, .profile-identity::after { content: ''; position: absolute; width: 5px; height: 5px; background: var(--accent); top: 50%; rotate: 45deg; }
.profile-identity::before { left: .55rem; }.profile-identity::after { right: .55rem; }
#profileName { font-size: 1.6rem; line-height: 1.35; }
.profile-actions { margin-top: 1rem; }
.profile-actions button { min-width: 6.3rem; font-size: .92rem; }
.profile-editor-identity { grid-template-columns: 6.8rem minmax(0, 1fr); padding-block: .2rem .55rem; border-bottom: 1px solid var(--game-line); }
.profile-form .profile-editor-identity .profile-appearance { width: 6.8rem; height: 7.1rem; border-color: var(--game-line); border-radius: 3rem 3rem .45rem .45rem; background: radial-gradient(ellipse at 50% 20%, var(--raised), var(--surface) 80%); box-shadow: inset 0 -4px var(--game-inlay); }
.profile-form .profile-editor-identity .profile-appearance .avatar-art { width: 6.4rem; }
.profile-editor-identity label { color: var(--muted); font-size: .78rem; }
.profile-editor-identity .muted { font-size: .74rem; line-height: 1.35; }
.avatar-category-options { gap: .3rem; }
.avatar-category-choice { border-radius: .35rem; box-shadow: inset 0 -2px #00000028; }
.appearance-choice { border-radius: .45rem; box-shadow: inset 0 1px #fff0d716; }
.appearance-choice:has(input:checked) { box-shadow: inset 0 -3px var(--game-inlay); }
.palette-swatch { height: 3.2rem; }

/* Clear action budget, stable across all room states at a given viewport. */
.controls { block-size: clamp(10.7rem, 23.4dvh, 11.2rem); }
.controls .your-status { min-height: 2.9rem; }
.controls .chat-composer { --composer-height: 2.7rem; }
#roomLegend { color: var(--muted); font-weight: 400; }
#moves button { box-shadow: var(--game-bevel); }
#moves button.primary { box-shadow: inset 0 1px #fff3d6, inset 0 -2px #ab713975, 0 2px #00000035; }
.setup-group { border-width: 0 0 1px; border-radius: 0; padding: .45rem 0 .8rem; background: transparent; }
.setup-group legend { padding-inline: 0 .45rem; }
.setup-choices label, .setup-choices label span { box-shadow: none; }
.setup-choices label:has(:checked) { box-shadow: none; }
.setup-number input, .setup-value { background: color-mix(in srgb, var(--background) 80%, var(--surface)); }

/* Result presentation leads with the players; the full ledger remains below. */
.standings-leaders { padding: .25rem 0 .8rem; border-bottom: 1px solid var(--game-line); margin-bottom: .6rem; }
.leaders-title { display: flex; align-items: center; justify-content: center; gap: .45rem; color: var(--accent); font-size: .78rem; letter-spacing: .12em; }
.leaders-title::before, .leaders-title::after { content: ''; width: 5px; height: 5px; rotate: 45deg; background: currentColor; }
.leaders-list { display: grid; gap: .4rem; max-height: 12rem; overflow-y: auto; padding: .45rem .1rem .15rem; scrollbar-width: thin; }
.leader-card { display: flex; align-items: center; justify-content: center; gap: .8rem; padding: .4rem .55rem; border: 1px solid var(--game-line); border-radius: .6rem; background: radial-gradient(ellipse at 50% 20%, var(--game-inlay), transparent 85%); }
.leader-portrait { display: grid; place-items: center; width: 4.3rem; height: 4.3rem; flex: none; }
.leader-portrait .avatar-art { width: 4rem; }
.leader-details { min-width: 0; display: grid; gap: .2rem; }
.leader-name { color: var(--text); font-size: 1.15rem; overflow-wrap: anywhere; }
.leader-net { color: var(--accent); font-size: .95rem; font-variant-numeric: tabular-nums; }
.leaders-list[data-shared="true"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.leaders-list[data-shared="true"] .leader-card { flex-direction: column; gap: .2rem; text-align: center; }
.leaders-list[data-shared="true"] .leader-portrait { width: 3.3rem; height: 3.3rem; }
.leaders-list[data-shared="true"] .avatar-art { width: 3.1rem; }
.leaders-list[data-shared="true"] .leader-name { font-size: .85rem; }
.leaders-list[data-shared="true"] .leader-net { font-size: .75rem; }
.standings tbody tr[data-rank="1"] .standing-rank { background: var(--accent); color: var(--accent-text); padding: .05rem .23rem; border-radius: .2rem; }
.standings tbody tr.own-result { background: var(--game-inlay); }
.standings tbody td:last-child { font-weight: 650; }
.standings th { color: var(--muted); font-size: .7rem; font-weight: 500; }
.history-players li { align-items: start; }
.history-hand-text { padding-block: .08rem; }

@media (max-width: 360px) {
  .profile-editor-identity { grid-template-columns: 5.3rem minmax(0, 1fr); gap: .55rem; }
  .profile-form .profile-editor-identity .profile-appearance { width: 5.3rem; height: 5.8rem; }
  .profile-form .profile-editor-identity .profile-appearance .avatar-art { width: 5.1rem; }
  .history-entry-date { min-width: 1.9rem; }
  .game-history-row > .history-entry-identity { gap: .35rem; }
  .game-actions > :is(button, a) { min-height: 6.4rem; }
}
@media (max-height: 620px) {
  .app[data-screen="login"] { justify-content: flex-start; padding-top: .8rem; }
  .login-content { padding-block: .8rem 1rem; }
  .login-content h1 { margin-bottom: .7rem; }
  #loginForm { gap: .55rem; }
  :root[data-themed="true"] #profileAppearance { width: 7.9rem; }
}
@media (forced-colors: active) {
  .leader-card { border-color: CanvasText; }
}

/* Selected opponent and stake share one inset, leaving all three actions aligned. */
#yourCards .card { width: clamp(1.65rem, 9.5vw, 2.2rem); }
#comparePanel:has(#compareForm:not([hidden])) { position: relative; }
#comparePanel:has(#compareForm:not([hidden])) #compareTarget { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
#comparePanel:has(#compareForm:not([hidden])) #cancelCompare, #compareForm { grid-row: 1; }
#compareForm .compare-amount { position: relative; display: block; }
#compareAmountTarget { position: absolute; inset: .18rem .35rem auto; font-size: .61rem; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; color: var(--muted); }
#compareForm .compare-amount input { width: 100%; height: var(--control-height); padding: .85rem .35rem .05rem; }
@container table-stage (max-height: 375px) {
  .seat { --portrait-slot: clamp(1.45rem, calc(var(--slot-height) - 3.7rem), 2.55rem); }
  .seat-cards { --card-height-budget: clamp(1.55rem, calc(var(--slot-height) - var(--portrait-slot) - 1.25rem), 2.45rem); }
}

body { background: var(--background); }
.standings { table-layout: fixed; }
.standings th { white-space: nowrap; }
.standings th:first-child { width: 34%; }
.standings th:nth-child(2) { width: 18%; }
.standings th:nth-child(n+3) { width: 16%; }
.summary-identity { max-width: 100%; min-width: 0; }
.summary-identity > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.standings .long-name .summary-identity { display: flex; flex-wrap: wrap; gap: .15rem .28rem; }
.standings .long-name .summary-identity > span:last-child { flex-basis: 100%; font-size: .76rem; }
.summary-player { display: block; width: 100%; min-height: 0; padding: 0; border: 0; background: transparent; color: var(--accent); font: inherit; font-weight: 400; }
#compareTarget { background: color-mix(in srgb, var(--surface) 75%, transparent); }
.compare-seat-hint { background: var(--selected-surface); border-color: var(--edge); color: var(--text); }

.standings td:not(:first-child) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.standings.wide-amounts { min-width: 28rem; }

/* Two game plaques with fixed chip and card emblems. */
:root[data-themed="true"] .lobby-tabs { gap: .6rem; padding: .2rem 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
.lobby-tabs a { position: relative; min-height: 4rem; gap: .25rem; padding: .3rem; border: 1px solid var(--edge); border-radius: .35rem; background: var(--surface-sheen), var(--cloth), var(--surface); background-blend-mode: normal, soft-light, normal; box-shadow: inset 0 2px #fff0d71c, inset 0 -3px #00000038, 0 2px 0 var(--shadow); font-size: .79rem; }
.lobby-tabs a::before { content: ''; position: absolute; width: 4px; height: 4px; top: 5px; left: 5px; background: var(--edge); box-shadow: 0 0 0 1px var(--surface); }
.lobby-tabs a::after { content: ''; position: absolute; height: 2px; width: 1.8rem; bottom: 3px; background: var(--border); }
.lobby-tabs a[aria-current="page"] { border-color: var(--accent); background: linear-gradient(var(--game-inlay), transparent), var(--surface); box-shadow: inset 0 0 0 2px var(--game-inlay), inset 0 -3px #00000038, 0 2px 0 var(--shadow); }
.lobby-tabs a[aria-current="page"]::before, .lobby-tabs a[aria-current="page"]::after { background: var(--accent); }
.tab-chip, .tab-cards { display: grid; place-items: center; width: 2.2rem; height: 2rem; }
.tab-chip > span { position: relative; width: 1.8rem; height: 1.8rem; translate: 0 -1px; filter: drop-shadow(0 2px 1px #00000035); }
.tab-chip i { position: absolute; width: 1.8rem; height: .48rem; bottom: calc(var(--level) * .35rem); border: 1px solid #8d5d35; border-radius: 45% / 40%; background: repeating-linear-gradient(90deg, #e4b565 0 4px, #f7e3b8 4px 7px, #e4b565 7px 11px); box-shadow: 0 1px #593b26; }
.tab-chip i::before { content: ''; position: absolute; height: .35rem; inset: -.15rem -1px auto; border: 1px solid #8d5d35; border-radius: 50%; background: radial-gradient(ellipse, #e4b565 45%, #f7e3b8 47% 63%, #e4b565 65%); }
.tab-chip i:nth-child(1) { --level: 0; }.tab-chip i:nth-child(2) { --level: 1; }.tab-chip i:nth-child(3) { --level: 2; }.tab-chip i:nth-child(4) { --level: 3; }
.tab-cards img { display: block; width: 2rem; height: 2rem; object-fit: contain; translate: 0 .1rem; }

.game-actions > button { display: grid; grid-template-rows: 2.6rem auto; align-content: center; justify-items: center; row-gap: .6rem; }
.game-actions > button .entry-emblem { width: 2.6rem; height: 2.6rem; min-height: 2.6rem; overflow: hidden; }
#openJoin .entry-emblem img { width: 2.15rem; height: 2.4rem; }
.setup-number :is(input, .setup-value, .setup-infinity) {
  padding-inline: .8rem 1.8rem;
}
.setup-number input[type="number"] { position: relative; }
/* Keep the native stepper beside the text without letting it shift the alignment. */
.setup-number input[type="number"]::-webkit-inner-spin-button {
  position: absolute;
  inset-block: 0;
  inset-inline-end: .8rem;
  block-size: 1.2em;
  margin-block: auto;
}
@supports not selector(input::-webkit-inner-spin-button) {
  .setup-number input[type="number"] { appearance: textfield; }
}
.setup-value, .setup-infinity { display: flex; align-items: center; justify-content: flex-end; }
.history-pagination { display: flex; align-items: center; justify-content: space-between; gap: .45rem; padding-block: .75rem .35rem; }
.history-pagination button { min-height: 2.4rem; padding: .3rem .65rem; font-size: .77rem; }
#historyPageStatus { color: var(--muted); font-size: .77rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
