:root {
  color-scheme: light;
  --ink: #1f2937;
  --muted: #485569;
  --link: #264b73;
  --link-hover: #173a5c;
  --link-line: #879fb8;
  --link-strong: #315a84;
  --accent-ink: #24493c;
  --game-button-ink: #193a33;
  --border: #cbd0d8;
  --border-subtle: #d8e0ea;
  --rule: #ecedf0;
  --input-border: #8994a3;
  --nav-border: #b9cce0;
  --nav-surface: #edf3f9;
  --nav-hover: #e2edf7;
  --table-header: #f1f4f7;
  --table-summary: #f5f7f9;
  --table-divider: #c5d7cd;
  --green-border: #a7cbb8;
  --score-border: #92b3a7;
  --ready: #e0f3e8;
  --ready-hover: #cfe9da;
  --score-bg: #eef7f2;
  --score-hover: #dcefe5;
  --accent-hover: #eef5f1;
  --afk: #59636f;
  --danger: #a82222;
  --elo-gain: #176b3a;
  --priority: #9a401f;
  --notice-border: #9dbfae;
  --notice-ink: #17452d;
  --notice-bg: #eff8f2;
  --primary-hover: #374151;
  --popover-border: #cad8d1;
  --page-bg: #fff;
  --surface: #fff;
  --felt: #195546;
  --brand-ink: #195546;
  --brand-tagline: #475e55;
  --backdrop: rgb(31 41 55 / 38%);
  --primary: #1f2937;
  --primary-ink: #fff;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e5eaf2;
  --muted: #afbbcc;
  --link: #a6caff;
  --link-hover: #d1e4ff;
  --link-line: #6e92bc;
  --link-strong: #9cc6ff;
  --accent-ink: #a5ddca;
  --game-button-ink: #c5ebdb;
  --border: #3c4858;
  --border-subtle: #354152;
  --rule: #2b3643;
  --input-border: #556478;
  --nav-border: #45617c;
  --nav-surface: #23354a;
  --nav-hover: #2e4965;
  --table-header: #263342;
  --table-summary: #1f2b37;
  --table-divider: #487263;
  --green-border: #4f796a;
  --score-border: #527c6e;
  --ready: #254b3e;
  --ready-hover: #315c4c;
  --score-bg: #223f35;
  --score-hover: #2e5144;
  --accent-hover: #223a33;
  --afk: #919eaf;
  --danger: #ffaaaa;
  --elo-gain: #86e0a3;
  --priority: #ffc29d;
  --notice-border: #527c66;
  --notice-ink: #b8f0cd;
  --notice-bg: #213b30;
  --primary-hover: #d4e8ff;
  --popover-border: #4b6b61;
  --page-bg: #121820;
  --surface: #1b2531;
  --felt: #17463d;
  --brand-ink: #a9dfcd;
  --brand-tagline: #b0c8c0;
  --backdrop: rgb(0 0 0 / 62%);
  --primary: #a6caff;
  --primary-ink: #132337;
}

html {
  background: var(--page-bg);
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  --page-padding-block: 1rem;
  --page-edge-height: 15vh;
  --page-edge-height: 15dvh;
  --page-rows: minmax(min-content,var(--page-edge-height)) 0 minmax(min-content,1fr);
  --game-title-size: clamp(1.25rem, 2vw, 1.55rem);
  --game-title-line-height: 1.2;
  --game-title-gap: .65rem;
  display: grid;
  grid-template-rows: minmax(min-content,var(--page-edge-height)) 0 auto minmax(min-content,1fr);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: system-ui, sans-serif;
}

#glowna { align-self: start; width: min(100%, 58rem); min-width: 0; text-align: left; }
#game-title { margin: 0 0 var(--game-title-gap); font-size: var(--game-title-size); line-height: var(--game-title-line-height); }
#dice-game { display: grid; gap: 1rem; --table-panel-height: 27rem; }
#game-jumps { display: none; }
#glowna:has(.game-history) { width: min(100%, 98.5rem); container-type: inline-size; }
@media (min-width: 80rem) {
  #glowna:has(.game-history) { justify-self: end; }
}
.game-history { min-width: 0; align-self: start; }
:is(.game-history h3,.table-chat h2) { margin: 0 0 .5rem; font-size: 1rem; }
.game-history .history-scroll { block-size: var(--table-panel-height); box-sizing: border-box; overflow: auto; scrollbar-gutter: stable; }
.game-history table { table-layout: fixed; }
.game-history th:nth-child(1) { width: 4rem; }
.game-history th:nth-child(2) { width: 27%; }
.game-history th:nth-child(4) { width: 2.75rem; }
.game-history .history-scroll :is(td,th) { box-sizing: border-box; padding: .45rem; vertical-align: top; }
.game-history tr > :last-child:not([colspan]) { text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.game-history small { display: block; color: var(--muted); }
.game-history time { white-space: nowrap; }
.archive-grid .game-history th:nth-child(1) { width: 5.25rem; }
.archive-move-time { display: block; margin-top: .15rem; font-size: .75rem; color: var(--muted); }
.archive-move-time span { display: block; }
.game-history td:first-child { font-variant-numeric: tabular-nums; }
.game-felt { padding: clamp(1rem, 4vw, 2.25rem); background: var(--felt); color: #fff; border-radius: 0.8rem; display: grid; justify-items: start; gap: 1rem; }
.game-players a, .game-players a:hover {
  color: inherit;
  text-decoration-color: currentColor;
}
.dice-tray { display: grid; width: min(100%, 22rem); grid-template-columns: repeat(5,minmax(0,1fr)); gap: clamp(.25rem,1vw,.5rem); }
.dice-tray .game-die { display: grid; grid-template: repeat(3,1fr) / repeat(3,1fr); place-items: center; position: relative; min-width: 0; width: 100%; aspect-ratio: 1; box-sizing: border-box; border: 1px solid #ccc9bb; border-radius: 18%; padding: 12%; background: #fffdf4; color: #13251f; box-shadow: 0 2px 0 #a9a99b; }
.game-die:empty, .game-die:not(:has(.die-pip)) { display: grid; place-content: center; grid-template: 1fr / 1fr; }
.die-pip { display: block; width: 83%; aspect-ratio: 1; background: currentColor; border-radius: 50%; }
.pip-1 { grid-area: 1/1; } .pip-3 { grid-area: 1/3; } .pip-4 { grid-area: 2/1; }
.pip-5 { grid-area: 2/2; } .pip-6 { grid-area: 2/3; } .pip-7 { grid-area: 3/1; } .pip-9 { grid-area: 3/3; }
.dice-tray .game-die.held { background: #f6d180; outline: 3px solid #ecc05c; outline-offset: 2px; }
#dice-game .game-action { justify-self: start; font-weight: 600; color: var(--game-button-ink); }
#dice-game .ready-game:not(:disabled) { padding-inline: 1.25rem; background: var(--ready); border-color: var(--green-border); }
#dice-game .ready-game:not(:disabled):is(:hover,:focus-visible) { background: var(--ready-hover); }
.dice-sheet { position: relative; }
.dice-sheet .score-player {
  font-size: calc(1em - 2px);
  text-align: center;
  white-space: nowrap;
}
.start-countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 1;
  pointer-events: none;
  background: #102a22cb;
  color: #fff;
}
.start-countdown strong {
  font-size: clamp(2.8rem, 8vw, 5.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: .04em;
  text-shadow: 0 .15rem .7rem #081a14;
}
.start-countdown[data-step="START!"] strong { color: #b9f1ca; }
@media (prefers-reduced-motion: no-preference) {
  .start-countdown strong { animation: countdown-pop .24s ease-out both; }
}
@keyframes countdown-pop {
  from { transform: scale(.86); opacity: .55; }
  to { transform: scale(1); opacity: 1; }
}
.dice-sheet thead th:first-child { width: 40%; }
.dice-sheet td { position: relative; text-align: center; font-variant-numeric: tabular-nums; }
.dice-sheet td button {
  position: absolute;
  inset: .15rem 0;
  width: min(calc(100% - .4rem), 5rem);
  margin-inline: auto;
  min-width: 0;
  padding: 0;
  border-color: var(--score-border);
  background: var(--score-bg);
}
.dice-sheet td button:hover,
.dice-sheet td button:focus-visible { background: var(--score-hover); }
.turn-slot { display: grid; width: 100%; }
.turn-slot > * { grid-area: 1 / 1; justify-self: start; }
.turn-spacer { visibility: hidden; }
.turn-actions { display: contents; }
.turn-actions .quick-score-action { display: none; }
.waiting-roster { width: 100%; list-style: none; margin: 0; padding: 0; }
.waiting-roster li { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; align-items: baseline; padding: .4rem 0; border-bottom: 1px solid #ffffff40; overflow-wrap: anywhere; }
.waiting-roster span { font-size: .875rem; }
#game-notice:not(:empty) { margin-top: 1rem; }
.active-tables { grid-column: 1 / -1; min-width: 0; }
.table-chat { grid-column: 1 / -1; min-width: 0; align-self: start; }
.chat-frame { box-sizing: border-box; block-size: var(--table-panel-height); display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: .5rem; padding: .65rem; font-size: calc(1rem - 1px); }
.table-chat form:not([hidden]) { display: flex; gap: .5rem; margin-top: auto; padding-top: .6rem; }
.table-chat input { flex: 1; min-width: 0; }
.table-chat :is(input,button) { font-size: inherit; }
.chat-frame > button { margin-top: auto; align-self: start; }
.table-chat [role="status"]:not(:empty) { margin-top: .5rem; color: var(--danger); font-weight: 700; }
.chat-messages { list-style: none; margin: 0; padding: 0 .25rem 0 0; min-height: 0; overflow-y: auto; scrollbar-gutter: stable; }
.chat-messages li { padding: .4rem .15rem; overflow-wrap: anywhere; }
.chat-messages li + li { border-top: 1px solid var(--rule); }
.chat-meta { display: flex; flex-wrap: wrap; column-gap: .45rem; align-items: baseline; font-size: calc(.85rem - 1px); color: var(--muted); }
.chat-meta strong { color: var(--accent-ink); }
.chat-meta time { font-variant-numeric: tabular-nums; }
.chat-system p { color: var(--danger); font-weight: 700; white-space: pre-line; }
.chat-moderated, .chat-moderated a { color: var(--danger); }
#admin-bans-list { display: grid; gap: .75rem; }
.admin-filters { display: flex; flex-wrap: wrap; align-items: end; gap: .6rem; margin-block: .8rem; }
.admin-filters label { display: grid; gap: .3rem; }
.admin-filters input[type="number"] { width: 9rem; }
.ban-review-form { display: grid; gap: .6rem; }
.ban-review-form textarea { width: 100%; }
.ban-evidence-log { list-style: none; padding: 0; }
.ban-evidence-log li { padding: .5rem; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
.ban-evidence-log p { white-space: pre-wrap; }
.ban-evidence-selected { border-inline-start: .2rem solid var(--link-strong); }
#preview-user-label:not([hidden]) { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
:root[data-portal-starting] :is(header,#glowna,.online-bar) { visibility: hidden; }
.chat-system .chat-elo-change:not(.elo-gain,.elo-loss) { color: var(--ink); }
.chat-paused:not([hidden]) { margin-top: auto; padding-top: .5rem; color: var(--muted); }
.chat-typing { min-height: 1.4em; margin-top: .25rem; color: var(--muted); font-size: .85rem; }
.captcha-image-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .55rem; }
.captcha-image-row img:not([hidden]) { display: block; border: 1px solid var(--border); border-radius: .4rem; }
.captcha-status:not(:empty) { margin-top: .4rem; }
.chat-frame > .chat-privacy:not([hidden]) { margin-top: .5rem; padding: .3rem .5rem; }
.archive-link { color: var(--link); padding: .2rem .45rem; white-space: nowrap; }
#archived-table { width: min(76rem, calc(100% - 2rem)); --table-panel-height: 22rem; }
.archive-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
#archived-table-content > * + * { margin-top: .6rem; }
.archive-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit,minmax(min(100%,18rem),1fr)); }
.archive-grid > * { min-width: 0; grid-column: auto; }
.archive-grid h3 { margin: 0 0 .5rem; font-size: 1rem; }
.archive-grid .game-history { width: min(100%, 22rem); }
.archive-grid .dice-sheet :is(th,td) { padding: .36rem .55rem; }
.archive-chat .table-history-pages { margin-top: auto; padding-top: .5rem; }
.active-tables h2 { margin-bottom: .5rem; }
.online-bar { margin-inline: clamp(1rem, 4vw, 3rem); display: grid; justify-items: end; }
#people-menu { box-sizing: border-box; width: min(22rem, 100%); height: 8rem; margin-top: .5rem; border: 1px solid var(--border); border-radius: .5rem; display: flex; flex-direction: column; }
#people-menu[hidden] { display: none; }
#people-title { margin: 0; padding: .5rem 1rem .25rem; color: var(--link); font-size: 1rem; }
#game-people { flex: 1; min-height: 0; padding: 0 1rem; overflow-y: scroll; scrollbar-gutter: stable; }
#people-notice:not(:empty) { padding: .5rem 1rem; }
#game-people h2 { font-size: 1.1rem; }
#game-people h2:not(:first-child) { margin-top: 1rem; }
.game-person { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .65rem 0; border-bottom: 1px solid var(--rule); }
.game-person strong { margin-right: auto; overflow-wrap: anywhere; }
.game-person span { font-size: .875rem; color: var(--muted); }
.player-entry { display: flex; align-items: center; gap: .2rem; }
.player-entry + .player-entry { border-top: 1px solid var(--rule); }
.player-entry .player-nick { display: flex; align-items: center; gap: .55rem; min-width: 0; border: 0; background: transparent; padding: .45rem .25rem; text-align: left; font-weight: 600; color: var(--accent-ink); overflow-wrap: anywhere; }
.player-rating { color: var(--ink); font-size: .76rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] .player-rating { color: #fff; }
.player-nick::before { content: ''; flex: 0 0 .45rem; height: .45rem; border-radius: 50%; background: #398065; }
.player-entry .player-nick:hover, .player-entry .player-nick:focus-visible { background: var(--accent-hover); }
.player-actions { position: fixed; inset: auto; margin: 0; box-sizing: border-box; width: min(13rem, calc(100vw - 1rem)); padding: .5rem; border: 1px solid var(--popover-border); border-radius: .5rem; box-shadow: 0 .25rem 1rem #193a331f; background: var(--surface); font-size: .875rem; }
.player-actions:popover-open { display: grid; }
.player-actions > * { padding: .45rem .55rem; text-align: left; overflow-wrap: anywhere; }
.player-actions :is(button,a) { border: 0; border-radius: .3rem; background: var(--surface); color: var(--accent-ink); font: inherit; text-decoration: none; }
.player-actions :is(button,a):hover, .player-actions :is(button,a):focus-visible { background: var(--accent-hover); }
#player-profile > * + * { margin-top: .8rem; }
#profile-admin-details > * + * { margin-top: .55rem; }
.player-stats { margin-block: 1rem; }
.player-stats > * + * { margin-block-start: .65rem; }
.player-stats th, .player-stats td { text-align: left; }
#profile-games-table table { table-layout: fixed; min-width: 49rem; line-height: 1.35; }
#profile-games-table col:nth-child(1) { width: 7%; }
#profile-games-table col:nth-child(2), #profile-games-table col:nth-child(3) { width: 16%; }
#profile-games-table col:nth-child(4), #profile-games-table col:nth-child(5) { width: 21%; }
#profile-games-table col:nth-child(6) { width: 19%; }
#profile-games-table tbody tr { height: 5.25rem; }
#profile-games-table td { padding-block: .5rem; }
#profile-games-table td:nth-child(3), #profile-games-table td:last-child { overflow-wrap: normal; }
#profile-games-table td:last-child, #profile-games-table time { font-variant-numeric: tabular-nums; }
#profile-games-table time span { display: block; white-space: nowrap; }
.elo-gain { color: var(--elo-gain); }
.elo-loss { color: var(--danger); }
@media (min-width: 64rem) {
  body:has(#people-menu:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem);
    grid-template-rows: var(--page-rows);
  }
  body:has(#people-menu:not([hidden])) > :is(header, hr) { grid-column: 1 / -1; }
  body:has(#people-menu:not([hidden])) > main { grid-column: 1; grid-row: 3; }
  .online-bar:has(#people-menu:not([hidden])) {
    grid-column: 2;
    grid-row: 3;
    min-height: 0;
    margin-block: var(--online-inset, var(--page-padding-block));
    margin-inline: 0 clamp(1rem, 4vw, 3rem);
  }
  body:has(#glowna:not([hidden])) .online-bar {
    --online-inset: calc(var(--page-padding-block) + var(--game-title-size) * var(--game-title-line-height) + var(--game-title-gap));
  }
  .online-bar #people-menu { height: auto; min-height: 0; margin-top: 0; }
  #game-people { contain: size; }
}
.at-table .game-felt { align-content: start; padding: clamp(1rem, 2.5vw, 1.5rem); overflow-wrap: anywhere; }
.at-table .dice-sheet { min-width: 0; background: var(--surface); }
.at-table .dice-sheet :is(th, td) { padding: .36rem .55rem; }
.dice-sheet thead .score-player-afk { color: var(--afk); }
.dice-sheet .score-lower tr:first-child > * { border-top: 2px solid var(--table-divider); }
.dice-sheet .score-summary { background: var(--table-summary); }
.dice-sheet .score-total { font-weight: 700; }
.table-result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.table-result-actions p { flex-basis: 100%; }
#table-expiry { font-variant-numeric: tabular-nums; }
#turn-clock { font-variant-numeric: tabular-nums; }
:is(#create-room,#join-private-room) {
  width: min(31rem, calc(100% - 1.5rem));
  max-block-size: calc(100dvh - 1.5rem);
}
:is(#create-room,#join-private-room) form { display: grid; gap: 1rem; }
:is(#create-room,#join-private-room) h2 { margin: 0; }
#join-private-room label { display: grid; gap: .35rem; }
.lobby-game-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.private-room-pin { letter-spacing: .12em; font-variant-numeric: tabular-nums; }
#create-room fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.room-mode legend { margin-bottom: .45rem; padding: 0; color: var(--muted); font-size: .875rem; }
.room-mode-options { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: .45rem; }
.room-mode-options label { position: relative; min-width: 0; cursor: pointer; }
.room-mode-options input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; margin: 0; }
.room-mode-options label span {
  display: grid;
  place-items: center;
  min-block-size: 2.75rem;
  padding-inline: .35rem;
  border: 1px solid var(--input-border);
  border-radius: .5rem;
  text-align: center;
  font-weight: 600;
}
.room-mode-options label:hover span { background: var(--table-header); }
.room-mode-options input:checked + span {
  border-color: var(--link-strong);
  background: var(--nav-surface);
  color: var(--link);
}
.room-mode-options input:focus-visible + span { outline: 2px solid var(--link-strong); outline-offset: 2px; }
.room-mode-options input:disabled + span { opacity: .5; cursor: default; }
#professional-rules {
  padding: .8rem;
  border: 1px solid var(--border);
  border-radius: .5rem;
  color: var(--muted);
  font-size: .875rem;
}
#professional-rules p + p { margin-top: .5rem; }
.room-rule-summary {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: .4rem;
  margin: 0 0 .65rem;
}
.room-rule-summary div { padding: .4rem; border-radius: .35rem; background: var(--table-header); text-align: center; }
.room-rule-summary dt { font-size: .75rem; }
.room-rule-summary dd { margin: 0; color: var(--ink); font-weight: 700; }
#create-room .custom-table-options:not([hidden]) { display: grid; gap: .7rem; }
.custom-table-options label { display: grid; gap: .35rem; align-content: start; font-size: .9rem; }
.custom-table-options .room-private-chat { display: flex; align-items: center; gap: .5rem; min-block-size: 2rem; }
.room-private-chat input { margin: 0; accent-color: var(--link-strong); }
.room-form-actions { display: flex; flex-wrap: wrap; gap: .5rem; padding-top: .85rem; border-top: 1px solid var(--border); }
.room-form-actions button:is([value="create"],[value="join"]) { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.room-form-actions button:is([value="create"],[value="join"]):hover { background: var(--primary-hover); }
@media (min-width: 32rem) {
  #create-room .custom-table-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .room-player-limit, .room-private-chat { grid-column: 1 / -1; }
}
@media (min-width: 48rem) {
  .turn-actions > .game-action, .turn-actions + .turn-slot { order: 1; }
  #dice-game.at-table {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "sheet play" "sheet leave";
    align-items: start;
  }
  .at-table .dice-sheet { grid-area: sheet; }
  .at-table .game-felt { grid-area: play; }
  .at-table > :is(.game-action,.table-result-actions) { grid-area: leave; }
  .at-table > .game-history { grid-column: 1 / -1; }
}
@container (min-width: 42rem) {
  #dice-game.at-table:has(.game-history):has(.table-chat) {
    grid-template-columns: minmax(0, 4fr) minmax(0, 3fr);
    grid-template-rows: auto auto auto;
    grid-template-areas: "sheet play" "sheet leave" "history chat";
  }
  #dice-game.at-table > .game-history { grid-area: history; width: min(100%, 22rem); justify-self: end; }
  #dice-game.at-table > .table-chat { grid-area: chat; width: min(100%, 16.5rem); justify-self: start; }
}
@container (min-width: 60rem) {
  #dice-game.at-table:has(.game-history):has(.table-chat) {
    grid-template-columns: minmax(0, 1.45fr) minmax(0, .9fr) minmax(0, .85fr) minmax(0, .6375fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "sheet play history chat" "sheet leave history chat";
  }
  #dice-game.at-table > :is(.game-history,.table-chat) { width: 100%; justify-self: stretch; }
}

a {
  color: var(--link);
  text-decoration-color: var(--link-line);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--link-hover);
  text-decoration-color: currentColor;
}

header, main {
  display: grid;
  padding: var(--page-padding-block) clamp(1rem, 4vw, 3rem);
  place-items: center;
  text-align: center;
}

header {
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
}

.site-brand {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: .8rem;
  color: var(--brand-ink);
  line-height: 1.1;
  white-space: nowrap;
}

.brand-wordmark {
  display: grid;
  text-align: left;
  gap: .15rem;
}

.brand-stamp {
  align-self: flex-start;
  margin: .2rem 0 0 -.25rem;
  padding: .22rem .33rem;
  border: 3px double currentColor;
  border-radius: .2rem;
  background: #fffdf4;
  color: #805c2e;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .07em;
  transform: rotate(-9deg);
}

.site-brand strong {
  font-size: clamp(1.35rem, 1.8vw, 1.7rem);
  font-weight: 850;
  letter-spacing: .06em;
}
@media (max-width: 29rem) {
  header > .site-brand { grid-area: 1 / 1 / auto / -1; }
  header > .home-link { grid-area: 2 / 1; justify-self: start; }
  header > .header-controls { grid-row: 3; }
  .site-brand .brand-stamp { padding: .15rem .22rem; border-width: 2px; font-size: .5rem; letter-spacing: .045em; }
}

.brand-mark {
  position: relative;
  width: 2.5rem;
  height: 2.5rem;
  flex: none;
}

.brand-mark::before, .brand-mark::after {
  content: '';
  position: absolute;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: .44rem;
  box-sizing: border-box;
}

.brand-mark::before {
  top: .12rem;
  right: .08rem;
  border: 1px solid #9bc2b4;
  background: #edf5f1;
  transform: rotate(15deg);
}

.brand-mark::after {
  bottom: .12rem;
  left: .12rem;
  background:
    radial-gradient(circle at 29% 29%, #fffdf4 0 .11rem, transparent .13rem),
    radial-gradient(circle at 50% 50%, #fffdf4 0 .11rem, transparent .13rem),
    radial-gradient(circle at 71% 71%, #fffdf4 0 .11rem, transparent .13rem),
    linear-gradient(145deg,#2b755f,#195546);
  box-shadow: 0 2px 4px #19554632;
  transform: rotate(-11deg);
}

.brand-tagline {
  color: var(--brand-tagline);
  font-size: .83rem;
  font-weight: 500;
  font-style: italic;
}

.home-link {
  grid-column: 1;
  justify-self: start;
  font-weight: 600;
}

.header-controls, #account-controls:not([hidden]), .account-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-controls {
  justify-self: end;
  grid-column: 3;
  min-width: 0;
  gap: clamp(0.65rem, 2vw, 1.5rem);
}

#admin-controls {
  padding-inline-end: clamp(0.65rem, 2vw, 1.5rem);
  border-inline-end: 1px solid var(--border-subtle);
}

#admin-controls:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
}

#account-summary {
  text-align: right;
  min-width: 0;
}

#account-summary p {
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

#account-name {
  color: var(--ink);
  overflow-wrap: anywhere;
}

:root[data-theme="dark"] [data-theme-toggle] {
  color: var(--link);
  border-color: var(--nav-border);
  background: var(--nav-surface);
}

#open-admin:not([hidden]), #open-settings {
  display: inline-block;
  text-decoration: none;
}

:is(#open-table-history,#open-rankings,#open-rules):not([hidden]) {
  display: inline-block;
  border: 1px solid var(--nav-border);
  border-radius: .5rem;
  padding: .55rem .75rem;
  background: var(--nav-surface);
  color: var(--link);
  text-decoration: none;
}

:is(#open-table-history,#open-rankings,#open-rules):is(:hover,[aria-current="page"]) { background: var(--nav-hover); }

.header-controls #open-admin {
  border-color: var(--nav-border);
  background: var(--nav-surface);
  color: var(--link);
  font-weight: 600;
  white-space: nowrap;
}

.account-actions button, .account-actions #open-settings {
  padding: 0.35rem 0.6rem;
  font-size: 0.875rem;
}

.account-actions #open-settings {
  border-color: var(--nav-border);
  color: var(--link);
}

main:has(:is(#admin-panel, #ustawienia-konta, .table-history-page):not([hidden])) {
  place-items: start center;
  text-align: left;
}

#admin-panel, #ustawienia-konta, .table-history-page {
  width: min(100%, 58rem);
  min-width: 0;
}
.table-history { margin-block: 1rem; }
.table-history > * + * { margin-block-start: .65rem; }
.table-history .accounts-table table { min-width: 38rem; }
.table-history .accounts-table :is(th,td):nth-last-child(2) { white-space: nowrap; }
.table-history .history-participation :is(th,td):nth-child(4) { overflow-wrap: normal; }
.table-history-pages:not([hidden]) { display: flex; align-items: center; flex-wrap: wrap; gap: .65rem; }
#zasady-gry { line-height: 1.55; }
#zasady-gry > section { margin-top: 1.5rem; }
#zasady-gry :is(h1,h2,h3) { line-height: 1.2; }
#zasady-gry :is(p,ul,ol,.accounts-table) { margin-block-start: .6rem; }
#zasady-gry :is(ul,ol) { padding-inline-start: 1.35rem; }
#zasady-gry li + li { margin-top: .3rem; }
#zasady-gry .accounts-table + h3 { margin-top: 1rem; }
.rules-scoring-table { table-layout: fixed; }
.accounts-table .rules-scoring-table th:first-child {
  width: clamp(6.5rem,19vw,12rem);
  box-sizing: border-box;
  overflow-wrap: normal;
}
.rules-dice-examples {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .65rem .85rem;
  margin-top: .5rem;
}
.rules-dice-alternative {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem;
}
.dice-tray.rules-dice {
  display: inline-grid;
  width: auto;
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: clamp(1.45rem,6.5vw,2rem);
  gap: .25rem;
}
.dice-tray.rules-dice .game-die.held { outline-width: 1px; outline-offset: 1px; }
.ranking-section + .ranking-section { margin-top: 1.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border-subtle); }
.ranking-section > h1 + p { margin-top: .45rem; }
.ranking-section > .accounts-table { margin-block-start: .65rem; }
#standard-ranking { margin-block: 1rem; }
#standard-ranking > * + *, #recent-games-title + #recent-games-results { margin-block-start: .65rem; }
#recent-games-results > * + * { margin-block-start: .65rem; }
.rankings-filters { display: flex; flex-wrap: wrap; gap: .8rem 1rem; margin-block: 1rem; align-items: end; }
.rankings-filters > label { display: grid; gap: .35rem; }
.rankings-filters select { font: inherit; padding: .35rem .5rem; }
.ranking-periods { display: flex; flex-wrap: wrap; gap: .45rem .8rem; min-width: 0; margin: 0; padding: .4rem .65rem; border: 1px solid var(--border); border-radius: .45rem; }
.ranking-periods input { padding: 0; }
.ranking-periods label { white-space: nowrap; }
.ranking-empty { color: var(--muted); }



.profile-details {
  padding: 1rem;
  margin-block: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.profile-details dt {
  color: var(--muted);
  font-size: 0.875rem;
}

.profile-details dd {
  margin: 0.25rem 0 0.75rem;
  overflow-wrap: anywhere;
}

.profile-details dd:last-child {
  margin-bottom: 0;
}

#account-edit:not([hidden]), .settings-card:not([hidden]), .settings-card label:not([hidden]) {
  display: grid;
  gap: 0.75rem;
}

.settings-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.settings-card h2 {
  font-size: 1.125rem;
}

#accounts-back:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-block: 0.25rem 0.75rem;
}

#admin-account-edit:not([hidden]), #account-edit:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 1rem;
  margin-block: 1.25rem;
}

.settings-card { align-content: start; }
.email-fields:not([hidden]) {
  display: grid;
  gap: 0.75rem;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.settings-card :is(h2,h3) { margin: 0; font-size: 1.125rem; }
#admin-account-edit p { font-size: 0.9rem; }

.settings-card label {
  gap: 0.35rem;
}

.settings-card input {
  min-width: 0;
}

#profile-ban-fields:not([hidden]) {
  display: grid;
  gap: .7rem;
}

.form-select {
  position: relative;
  display: block;
  min-width: 0;
}

:is(.settings-card,#create-room) .form-select select {
  appearance: none;
  box-sizing: border-box;
  width: 100%;
  min-height: 2.65rem;
  padding-inline-end: 2.4rem;
  cursor: pointer;
}

.form-select::after {
  content: '';
  position: absolute;
  top: 50%;
  inset-inline-end: 1rem;
  width: .45rem;
  height: .45rem;
  border: solid var(--muted);
  border-width: 0 2px 2px 0;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

@media (forced-colors: active) {
  :is(.settings-card,#create-room) .form-select select { appearance: auto; }
  .form-select::after { content: none; }
}

.settings-card button {
  justify-self: start;
}

.settings-card p:empty {
  display: none;
}

#account-password-hint {
  color: var(--muted);
  font-size: 0.875rem;
}

#email-confirmation {
  margin-block: 1rem;
}

#admin-panel section > h2 {
  margin-block: 1.5rem 0.75rem;
  font-size: 1rem;
}

.admin-tabs:not([hidden]) {
  flex-wrap: wrap;
  display: flex;
  gap: 1rem;
  margin-block: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.admin-tabs a {
  padding: 0.55rem 0.75rem;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.admin-tabs a[aria-current="page"] {
  border-bottom-color: var(--link-strong);
  color: var(--link);
  font-weight: 600;
}

#todo-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

#todo-list li + li {
  border-top: 1px solid var(--rule);
}

#todo-list li {
  padding: 0.8rem 0;
}

.todo-details {
  display: block;
  margin-top: 0.25rem;
  color: var(--muted);
}

.todo-priority {
  margin-inline-start: 0.5rem;
  color: var(--priority);
  font-size: 0.875rem;
}

.accounts-table {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

.accounts-table table {
  width: 100%;
  border-collapse: collapse;
}

.accounts-table :is(th, td) {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--rule);
  overflow-wrap: anywhere;
}

.accounts-table th {
  background: var(--table-header);
}

p, h1, h2 {
  margin: 0;
}

hr {
  align-self: center;
  height: 1px;
  margin: 0 clamp(1rem, 4vw, 3rem);
  border: 0;
  background: linear-gradient(to right, var(--rule), var(--border) 15% 85%, var(--rule));
}

button, input, .form-select select, #open-admin, #open-settings {
  font: inherit;
  color: inherit;
  border: 1px solid var(--input-border);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  background: var(--surface);
}

button {
  cursor: pointer;
}

button:hover, .form-select select:hover, #open-admin:hover, #open-settings:hover {
  background: var(--table-header);
}

:is(button, input, select, a):focus-visible {
  outline: 2px solid var(--link-strong);
  outline-offset: 2px;
}

dialog {
  box-sizing: border-box;
  width: min(24rem, calc(100% - 2rem));
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: clamp(1rem, 5vw, 1.5rem);
  color: inherit;
  background: var(--surface);
  box-shadow: 0 1rem 3rem rgb(31 41 55 / 20%);
}

dialog::backdrop {
  background: var(--backdrop);
}

:is(#login-form, #account-captcha-form), :is(#login-form, #account-captcha-form) label {
  display: grid;
}

:is(#login-form, #account-captcha-form) {
  gap: 1rem;
}

:is(#login-form, #account-captcha-form) label {
  gap: 0.35rem;
}

#login-form label[hidden] {
  display: none;
}

#login-form input {
  min-width: 0;
}

#login-status:empty {
  margin-top: -1rem;
}

#registration-notice {
  position: fixed;
  inset: 1rem 1rem auto;
  z-index: 1;
  width: fit-content;
  max-width: min(100%, 34rem);
  box-sizing: border-box;
  margin-inline: auto;
  overflow-wrap: anywhere;
  pointer-events: none;
}

#registration-notice:not(:empty) {
  padding: 0.75rem 1rem;
  border: 1px solid var(--notice-border);
  border-radius: 0.5rem;
  color: var(--notice-ink);
  background: var(--notice-bg);
  box-shadow: 0 0.25rem 1rem rgb(31 41 55 / 12%);
}

.login-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 0.5rem;
}

.login-actions button[type="submit"], .settings-card button[type="submit"] {
  border-color: var(--primary);
  color: var(--primary-ink);
  background: var(--primary);
}

.login-actions button[type="submit"]:hover, .settings-card button[type="submit"]:hover {
  background: var(--primary-hover);
}

.login-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.login-links button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--link-strong);
  text-decoration: underline;
}

@media (max-width: 55rem) {
  header {
    grid-template-columns: auto minmax(0, 1fr);
    text-align: left;
  }

  .site-brand {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: start;
  }

  .header-controls {
    grid-column: 2;
    grid-row: 1;
  }
}

@media (max-width: 34rem) {
  header {
    grid-template-columns: 1fr;
  }

  .header-controls {
    grid-column: 1;
    grid-row: 2;
  }

  .site-brand {
    grid-row: 3;
  }
}

@media (max-width: 47.99rem) {
  body {
    --page-padding-block: .75rem;
    grid-template-columns: minmax(0,1fr);
    grid-template-rows: auto 0 auto minmax(min-content,1fr);
  }

  header, main { padding-inline: .75rem; }
  header {
    grid-template-columns: minmax(0,1fr) auto;
    gap: .65rem;
  }
  .site-brand { grid-area: 1 / 1; gap: .4rem; }
  .site-brand strong { font-size: 1.25rem; }
  .brand-tagline { font-size: .72rem; }
  .brand-mark { width: 1.95rem; height: 1.95rem; }
  .brand-mark::before, .brand-mark::after { width: 1.4rem; height: 1.4rem; }
  .brand-stamp { font-size: .56rem; margin-inline-start: 0; }
  .home-link { grid-area: 1 / 2; justify-self: end; font-size: .82rem; }
  .header-controls {
    grid-area: 2 / 1 / auto / -1;
    justify-self: stretch;
    justify-content: flex-start;
    gap: .4rem;
  }
  .header-controls :is(#open-table-history,#open-rankings,#open-rules,#open-admin,#preview-user) {
    padding: .5rem .35rem;
    font-size: .8rem;
  }
  .header-controls > #admin-controls { padding: 0; border: 0; }
  .header-controls > :is(#account-summary,#account-controls) {
    flex-basis: 100%;
    justify-content: flex-start;
    text-align: left;
  }
  .account-actions { justify-content: flex-start; }

  .online-bar { margin-inline: .75rem; }
  .online-bar #people-menu { width: 100%; height: 5.5rem; margin-top: .65rem; }
  body:has(#dice-game.at-table) #people-menu:not([hidden],:has(.game-person)) {
    display: grid;
    grid-template-columns: auto minmax(0,1fr);
    align-items: center;
    height: auto;
    min-block-size: 2.75rem;
  }
  body:has(#dice-game.at-table) #people-menu:not(:has(.game-person)) :is(#people-title,#game-people) {
    padding: 0 .6rem;
    font-size: .82rem;
  }
  body:has(#dice-game.at-table) #people-menu:not(:has(.game-person)) #game-people {
    display: flex;
    gap: .55rem;
    overflow: auto hidden;
    scrollbar-gutter: auto;
  }
  body:has(#dice-game.at-table) #people-menu:not(:has(.game-person)) .player-entry {
    flex: none;
    border: 0;
    white-space: nowrap;
  }
  body:has(#dice-game.at-table) #people-notice { grid-column: 1 / -1; }
  #glowna { width: 100%; }
  #game-jumps:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
    gap: .25rem;
    position: sticky;
    top: 0;
    z-index: 3;
    padding-block: .35rem;
    margin-block-end: .4rem;
    background: var(--page-bg);
  }
  #game-jumps button {
    min-block-size: 2.75rem;
    min-inline-size: 0;
    padding: .3rem .15rem;
    font-size: .8rem;
  }
  #chat-unread {
    color: var(--notice-ink);
    font-size: .72rem;
    font-weight: 750;
    white-space: nowrap;
  }
  #dice-game > :is(.game-felt,.dice-sheet,.table-chat,.game-history) { scroll-margin-block-start: 3.6rem; }
  #dice-game {
    grid-template-columns: minmax(0,1fr);
    gap: .65rem;
    --table-panel-height: clamp(13rem,38vh,18rem);
    --table-panel-height: clamp(13rem,38svh,18rem);
  }
  #dice-game .game-felt {
    gap: .45rem;
    padding: .75rem;
    border-radius: 1rem;
    background: linear-gradient(145deg,rgb(255 255 255 / .09),transparent 72%),var(--felt);
    box-shadow: 0 .2rem .8rem rgb(0 0 0 / .12);
  }
  #dice-game .game-felt h2 { font-size: clamp(1.16rem,5vw,1.5rem); }
  .game-felt .turn-slot > .turn-spacer, .game-felt .turn-slot:not(:has(> :not(.turn-spacer))) { display: none; }
  .game-felt > p { font-size: .875rem; }
  .game-felt .dice-status, .game-felt .turn-slot:not(.game-turn-title) p { font-size: .82rem; }
  .game-round { color: #e0f3e8; font-variant-numeric: tabular-nums; }
  .game-turn-clock {
    padding: .3rem .6rem;
    border: 1px solid #ffffff60;
    border-radius: 1rem;
    background: #0d3029;
  }
  .game-clocks { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .35rem; }
  .game-clocks li {
    padding: .35rem .5rem;
    gap: .15rem .35rem;
    flex-wrap: nowrap;
    border: 0;
    border-radius: .45rem;
    background: #ffffff16;
  }
  .game-clocks li span { min-width: 0; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
  #dice-game .game-felt > .dice-tray {
    width: min(100%,21rem);
    justify-self: center;
    gap: clamp(.4rem,2vw,.65rem);
    margin-block: .2rem;
  }
  #dice-game .game-action, #dice-game .table-chat button, #create-room :is(select,button) { min-block-size: 2.75rem; }
  #dice-game .table-chat input { min-block-size: 2.75rem; font-size: 1rem; box-sizing: border-box; }
  .turn-actions {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0,1fr);
    width: 100%;
    gap: .5rem;
  }
  .turn-actions > .turn-spacer, .turn-actions:not(:has(button:not(.turn-spacer))) { display: none; }
  #dice-game .turn-actions .game-action {
    width: 100%;
    min-block-size: 3rem;
    padding-inline: .4rem;
    color: #15392f;
    background: #fffdf4;
  }
  #dice-game .turn-actions .quick-score-action { display: block; background: #d9f4e7; }

  #dice-game > .dice-sheet :is(th,td) { height: 2rem; padding: .2rem .4rem; font-size: .83rem; }
  #dice-game > .dice-sheet .score-player { min-width: 3.7rem; font-size: calc(.875rem - 1px); }
  #dice-game > .dice-sheet tr > th:first-child {
    min-width: 6.7rem;
    position: sticky;
    inset-inline-start: 0;
    z-index: 1;
  }
  #dice-game > .dice-sheet td button { width: calc(100% - .2rem); }
  #dice-game > .dice-sheet .start-countdown { z-index: 2; }
  #dice-game > .table-result-actions { order: 1; }
  #dice-game > .table-chat { order: 2; }
  #dice-game > .game-history { order: 3; }
  #dice-game .game-history .history-scroll { scrollbar-gutter: auto; }
  #dice-game .game-history .history-scroll :is(th,td) { padding: .35rem; font-size: .82rem; }
  #dice-game .game-history :is(th,td):first-child { width: 3.2rem; white-space: nowrap; }
  #dice-game .game-history th:nth-child(4) { width: 2.5rem; }

  .active-tables > .accounts-table { border: 0; border-radius: 0; }
  .active-tables table, .active-tables tbody { display: block; }
  .active-tables thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
  .active-tables tbody tr {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: .55rem .7rem;
    margin-bottom: .55rem;
    padding: .8rem;
    border: 1px solid var(--border);
    border-radius: .75rem;
    background: var(--surface);
  }
  .active-tables tbody td { padding: 0; border: 0; }
  .active-tables tbody td:nth-child(-n+2), .active-tables tbody td:last-child { grid-column: 1 / -1; }
  .active-tables tbody td:first-child:not([colspan]) { font-weight: 750; color: var(--accent-ink); }
  .active-tables td[data-label] { font-size: .84rem; }
  .active-tables td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: .74rem;
  }
  .active-tables tbody td:last-child:not([colspan]) {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .4rem;
    padding-top: .5rem;
    border-top: 1px solid var(--border-subtle);
  }

  #score-picker {
    position: fixed;
    inset: auto 0 0;
    width: min(100%,32rem);
    max-height: 78dvh;
    margin: 0 auto;
    padding: 1rem 1rem max(1rem,env(safe-area-inset-bottom));
    border-radius: 1.1rem 1.1rem 0 0;
  }
  .score-picker-heading {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
    margin-bottom: .6rem;
  }
  .score-picker-heading h2 { margin-inline-end: auto; font-size: 1.1rem; }
  .score-picker-heading button, .score-picker-option { min-block-size: 2.75rem; }
  #score-picker-clock { font-variant-numeric: tabular-nums; color: var(--accent-ink); }
  #score-picker-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .4rem; }
  .score-picker-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .25rem;
    text-align: left;
    padding: .4rem .5rem;
    background: var(--score-bg);
    border-color: var(--score-border);
  }
  .score-picker-option span { font-size: .82rem; overflow-wrap: anywhere; }
}
