:root {
  color-scheme: dark;
  --bg: #171410;
  --panel: #201b16;
  --line: #403327;
  --text: #faeedb;
  --muted: #bcaa94;
  --gold: #ecb66e;
  --orange: #f3ae58;
  --green: #a9d6b6;
  --red: #f3a08d;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", "YuMincho", Georgia, serif;
  font-family: "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 300px;
  min-height: 100vh;
  background: radial-gradient(ellipse at 13% 6%, #30241a 0%, transparent 46%), #171410;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid #ffd68e; outline-offset: 4px; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
h1, h2, p { margin: 0; }

.top { border-bottom: 1px solid #3c2d22; background: #18130fec; }
.top-inner {
  max-width: 1248px; padding: 0 30px; min-height: 74px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; font: 700 1.28rem/1.08 var(--serif); letter-spacing: .09em; }
.brand small {
  display: block; margin-top: 5px; color: var(--muted);
  font: 600 .75rem/1 ui-monospace, monospace; letter-spacing: .15em;
}
.brand-die {
  position: relative; display: grid; place-items: center; width: 35px; height: 35px;
  border: 1px solid #ffcf8d; border-radius: 9px; transform: rotate(-11deg);
  background: linear-gradient(145deg, #ffcc87, #da904b 68%, #9b572c);
  box-shadow: 0 3px 0 #704026, 0 0 22px #e7914938;
}
.brand-die i {
  position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #482916;
  box-shadow: inset 0 1px 2px #1b100d, 0 1px #ffe2a8;
}
.brand-die i:first-child { transform: translate(-8px, -8px); }
.brand-die i:last-child { transform: translate(8px, 8px); }
.top-actions { display: flex; gap: 9px; }
.utility {
  color: var(--text); border: 1px solid var(--line); background: #211b15; border-radius: 8px;
  padding: 8px 12px; min-height: 39px; font-size: .875rem;
}
.utility:hover { background: #38291e; border-color: #72563a; }
.online-link { display: inline-flex; align-items: center; color: #ffe0ae; text-decoration: none; border-color: #85603e; white-space: nowrap; }
.sound-mark, .help-mark { color: var(--gold); margin-right: 5px; }
.help-mark {
  display: inline-grid; place-items: center; width: 16px; height: 16px; border: 1px solid #9d774b;
  border-radius: 50%; font-size: .72rem;
}

.page { max-width: 1248px; padding: 31px 30px 42px; margin: 0 auto; }
.page-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 25px; }
.page-title h1 { font: 800 clamp(2.65rem, 5vw, 4.25rem)/1.1 var(--serif); letter-spacing: .09em; }
.page-title p { color: var(--muted); margin-top: 8px; }
.table-tag {
  display: inline-flex; align-items: center; gap: 9px; color: #edc290; white-space: nowrap;
  border: 1px solid #694a31; background: #2b2017; border-radius: 30px; padding: 7px 14px;
  font-size: .875rem; margin-bottom: 1px;
}
.table-tag span { width: 7px; height: 7px; transform: rotate(45deg); background: #eeae64; }
.game-grid { display: grid; grid-template-columns: minmax(0, 2.12fr) minmax(300px, 1fr); gap: 19px; }
.table-column, .controls-column { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.players { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; position: relative; }
.player {
  position: relative; min-width: 0; display: flex; align-items: center; gap: 13px; min-height: 88px;
  padding: 13px 18px; border: 1px solid #795739; border-radius: 13px;
  background: linear-gradient(112deg, #392a1d, #241c15 66%);
  box-shadow: inset 0 1px #ffffff10;
}
.player.dealer { background: linear-gradient(112deg, #2e2820, #221d18 66%); border-color: #554536; }
.player.turn { border-color: #ebad67; box-shadow: inset 0 0 26px #d27d321a, 0 0 19px #fbb25b22; }
.player.gains { border-color: #a9ba7a; box-shadow: inset 0 0 30px #d7e4a025, 0 0 24px #d8e9a022; }
.player.loses { border-color: #815046; }
.player-details { min-width: 0; }
.player h2 { color: #f1c591; font-size: .875rem; font-weight: 700; margin-bottom: 3px; }
.player.dealer h2 { color: #cfbea7; }
.player h2 small { margin-left: 4px; font: 600 .75rem ui-monospace, monospace; color: var(--muted); }
.balance {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; font: 700 clamp(1.38rem, 2.6vw, 2.03rem)/1.05 Georgia, serif;
  color: #ffebcc; font-variant-numeric: lining-nums tabular-nums; white-space: nowrap;
}
.balance .negative { color: var(--red); }
.balance small, .stake-box > span { color: var(--muted); font: 600 .875rem/1.2 "Hiragino Sans", Meiryo, sans-serif; }
.player-delta {
  position: absolute; top: 9px; right: 10px; color: var(--green); font-size: .82rem; font-weight: 700;
  background: #233329; border-radius: 6px; padding: 3px 6px; font-variant-numeric: tabular-nums;
}
.player-delta:empty { display: none; }
.player-delta.negative { color: var(--red); background: #41251f; }
.versus {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  border-radius: 50%; display: grid; place-items: center; width: 29px; height: 29px;
  background: #231b15; border: 1px solid #594130; color: #d6a872; font: 700 .82rem var(--serif);
}
.coin {
  flex: none; display: grid; place-items: center; position: relative; isolation: isolate;
  width: 43px; aspect-ratio: 1; border-radius: 50%; border: 1px solid #e3ae70;
  color: #ffe5b2; font: 800 1.02rem var(--serif); text-shadow: 0 1px #3b210e;
  background: repeating-conic-gradient(from 5deg, #b37241 0 7deg, #edbd7e 7deg 11deg, #9f582d 11deg 16deg);
  box-shadow: 0 3px 0 #603720, 0 4px 8px #0006;
}
.coin::before { content: ""; position: absolute; inset: 4px; border-radius: 50%; z-index: -1; border: 1px solid #ffc989; background: radial-gradient(at 33% 20%, #b87843, #764220 80%); }
.dealer .coin { filter: saturate(.33); }

.arena {
  position: relative; isolation: isolate; overflow: hidden;
  height: clamp(350px, 37vw, 460px); border: 1px solid #64482f; border-radius: 15px;
  background: #271810; box-shadow: 0 9px 31px #0a080658;
}
.arena-roll {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  padding: 0; border: 0; background: transparent; touch-action: manipulation;
}
.arena-roll[aria-disabled="true"] { cursor: default; }
.arena-roll:focus-visible { outline-offset: -4px; z-index: 1; }
@media (hover: hover) {
  .arena-roll:not([aria-disabled="true"]):hover { filter: brightness(1.075); }
}
.arena-roll canvas { display: block; width: 100%; height: 100%; }
.arena-top {
  position: absolute; z-index: 1; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 17px 18px; pointer-events: none; background: linear-gradient(#170d08bc, transparent);
}
.arena-top span {
  color: #edcaa4; background: #1b120ddc; border: 1px solid #ab79555e; padding: 5px 10px;
  border-radius: 6px; font-size: .875rem;
}
#round-number { letter-spacing: .09em; }
.arena-bottom {
  position: absolute; bottom: 0; left: 0; right: 0; text-align: center; padding: 17px 12px 14px;
  background: linear-gradient(transparent, #160d09e3); color: #ffe5c4;
  text-shadow: 0 1px 4px #100c09; font-size: .875rem; font-weight: 700; letter-spacing: .04em; pointer-events: none;
}
.throws {
  position: absolute; left: 16px; right: 16px; bottom: 43px; display: flex;
  align-items: flex-end; justify-content: space-between; pointer-events: none;
}
.throw {
  width: 120px; min-height: 66px; padding: 8px 10px; display: grid; gap: 3px;
  border-radius: 8px; background: #1c130ee0; border: 1px solid #a0724e72; color: #dbc3aa;
  font-size: .8rem;
}
.throw:last-child { text-align: right; }
.throw strong { font: 800 1.24rem/1.20 var(--serif); color: var(--text); }
.throw small { color: var(--gold); font: 700 .82rem/1 ui-monospace, monospace; }
.throw small:empty { display: none; }
.throw.current { border-color: #f9b96f; }

.controls, .outcome, .history { border: 1px solid var(--line); border-radius: 13px; background: var(--panel); }
.controls { padding: 22px; background: linear-gradient(150deg, #2e241a, #201a15 62%); box-shadow: 0 9px 30px #0b09064a; }
.control-head, .history-head { display: flex; gap: 9px; align-items: baseline; justify-content: space-between; }
.control-head h2 { font: 800 1.53rem var(--serif); }
.control-head > span { color: var(--muted); font-size: .83rem; font-variant-numeric: tabular-nums; }
.stake-box {
  display: flex; align-items: baseline; justify-content: center; gap: 9px; padding: 14px 10px;
  margin-top: 17px; border: 1px solid #5f462e; border-radius: 9px; background: #15110d;
  box-shadow: inset 0 2px 9px #08060272;
}
.stake-box:focus-within { border-color: var(--gold); }
.stake-box:has([aria-invalid="true"]) { border-color: var(--red); }
.stake-box input {
  width: 5.25ch; min-width: 0; border: 0; outline: none; padding: 0; text-align: right;
  background: none; color: #ffd297; font: 700 clamp(1.8rem, 3.2vw, 2.7rem)/1 Georgia, serif;
  font-variant-numeric: lining-nums tabular-nums;
}
.stake-box input:focus-visible { outline: 0; }
.wager-error { margin-top: 9px; font-size: .875rem; color: var(--red); }
.slider-wrap { margin: 18px 0 15px; }
input[type="range"] {
  --progress: 9.09%; appearance: none; background: transparent; width: 100%; height: 25px; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 99px;
  background: linear-gradient(to right, #d29156 var(--progress), #51402e var(--progress));
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 17px; height: 17px; border-radius: 50%; margin-top: -6px;
  border: 2px solid #ffe1a9; background: #dc9a58; box-shadow: 0 2px 6px #0008;
}
input[type="range"]::-moz-range-track { height: 5px; border-radius: 99px; background: #51402e; }
input[type="range"]::-moz-range-progress { height: 5px; border-radius: 99px; background: #d29156; }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #ffe1a9; background: #dc9a58; }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font: 600 .82rem ui-monospace, monospace; }
.presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.presets button {
  border-radius: 7px; min-height: 39px; border: 1px solid #594534; background: #261f17;
  color: #dec6aa; font: 650 .92rem ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
.presets button:not(:disabled):hover { border-color: #e1a568; color: #ffdaa8; }
.presets button[aria-pressed="true"] { border-color: #d49b62; background: #51351f; color: #ffe1b1; }
.presets button:disabled { opacity: .49; }
.roll {
  display: flex; justify-content: center; align-items: center; gap: 10px; width: 100%; min-height: 58px;
  margin-top: 20px; border-radius: 9px; border: 1px solid #ffd598; color: #29170d;
  background: linear-gradient(#ffcc83, #e99c51); box-shadow: inset 0 1px #ffe3b1, 0 4px #935127, 0 8px 25px #e995452b;
  font-size: 1.04rem; font-weight: 800; letter-spacing: .04em;
  transition: background .18s, filter .18s, transform .18s;
}
.roll:not([aria-disabled="true"]):hover { filter: brightness(1.12); transform: translateY(-1px); }
.roll:not([aria-disabled="true"]):active { transform: translateY(2px); box-shadow: inset 0 1px #ffe3b1, 0 2px #935127; }
.roll[aria-disabled="true"] { cursor: default; filter: saturate(.42) brightness(.78); box-shadow: inset 0 1px #ffffff50, 0 2px #935127; }
.roll-die { font: 700 1.5rem/1 "Segoe UI Symbol", sans-serif; }
.control-note { margin-top: 17px; text-align: center; color: var(--muted); font-size: .83rem; }
.control-note span { font-size: .65rem; color: #be8f62; }
.new-table { display: block; margin: 12px auto 0; padding: 5px; color: #eec496; font-size: .875rem; background: none; border: 0; text-decoration: underline; text-underline-offset: 4px; }
.outcome { padding: 17px 22px; }
.outcome h2, .history h2 { font: 800 1.1rem var(--serif); }
.outcome-content { display: flex; align-items: center; min-height: 60px; gap: 12px; margin-top: 8px; }
.outcome-symbol {
  display: grid; place-items: center; flex: 0 0 43px; height: 43px; border: 1px solid #745435;
  border-radius: 9px; background: #322519; color: var(--gold); font: 800 1.18rem var(--serif);
}
.outcome-content.win .outcome-symbol { color: var(--green); background: #283629; border-color: #587757; }
.outcome-content.loss .outcome-symbol { color: var(--red); background: #3b2420; border-color: #7b4937; }
.outcome-content p { font-size: .875rem; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.outcome-content strong { font: 800 1.1rem/1.3 var(--serif); }
.outcome-content.win strong { color: var(--green); }
.outcome-content.loss strong { color: var(--red); }
.history { padding: 15px 18px; }
.history-head span { color: var(--muted); font-size: .875rem; }
.history .empty { color: var(--muted); margin-top: 10px; font-size: .875rem; }
.history ol { list-style: none; margin: 0; padding: 0; }
.history li {
  display: grid; grid-template-columns: 50px 52px 1fr auto; align-items: center; gap: 9px;
  border-top: 1px solid #3b3025; padding: 9px 0; font-size: .875rem; color: var(--muted);
}
.history li:first-child { margin-top: 11px; }
.history li:last-child { padding-bottom: 1px; }
.history li b { color: var(--text); }
.history li .change { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history li.win .change { color: var(--green); }
.history li.loss .change { color: var(--red); }

.transfer-layer { pointer-events: none; position: fixed; z-index: 4; inset: 0; overflow: hidden; }
.coin.flying { position: absolute; width: 30px; font-size: .82rem; transform-origin: center; box-shadow: 0 0 20px #ffb24c9c, 0 2px 0 #935826; }
dialog {
  width: min(92%, 535px); max-height: calc(100dvh - 34px); padding: 22px;
  background: #251d16; color: var(--text); border: 1px solid #765233; border-radius: 13px;
  box-shadow: 0 32px 100px #000b;
}
dialog::backdrop { background: #0c0908c9; backdrop-filter: blur(3px); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { font: 800 1.5rem var(--serif); }
.close { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 7px; border: 1px solid #644b36; color: var(--text); background: #30251b; font-size: 1.35rem; }
dialog p { color: #dfcdb6; margin-top: 14px; line-height: 1.65; }
.hands { margin: 15px 0; }
.hands div { display: grid; grid-template-columns: 6em 1fr; gap: 8px; border-top: 1px solid #4b392a; padding: 8px 0; }
.hands dt { font-weight: 750; color: #ffd29e; }
.hands dd { margin: 0; color: #e6d2b7; }
.reset-actions { margin-top: 16px; display: flex; justify-content: end; gap: 9px; }

@media (min-width: 1040px) {
  .players .player-delta { top: auto; bottom: 11px; }
}
@media (max-width: 950px) {
  .page, .top-inner { padding-left: 20px; padding-right: 20px; }
  .game-grid { gap: 13px; }
  .player { gap: 8px; padding: 11px; }
  .player .coin { width: 35px; }
  .balance small { font-size: .75rem; }
  .controls, .outcome { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 740px) {
  .top-inner { min-height: 62px; }
  .page { padding-top: 21px; }
  .page-title { margin-bottom: 16px; }
  .game-grid { display: flex; flex-direction: column; }
  .game-grid .table-column, .game-grid .controls-column { display: contents; }
  .players { order: 0; }
  .arena { order: 1; height: clamp(270px, 73vw, 393px); }
  .controls { order: 2; padding-top: 15px; padding-bottom: 16px; }
  .stake-box { margin-top: 12px; padding-block: 11px; }
  .slider-wrap { margin-block: 10px 11px; }
  .roll { margin-top: 13px; min-height: 54px; }
  .control-note { margin-top: 13px; }
  .outcome { order: 3; }
  .history { order: 4; }
  .presets { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (max-width: 420px) {
  .page, .top-inner { padding-left: 12px; padding-right: 12px; }
  .brand { gap: 8px; font-size: 1.08rem; }
  .brand-die { width: 30px; height: 30px; }
  .top-actions { gap: 5px; }
  .utility { padding: 7px 8px; font-size: .81rem; }
  .table-tag { padding: 5px 8px; gap: 6px; font-size: .78rem; }
  .page-title p { font-size: .875rem; }
  .player { min-height: 72px; }
  .balance { gap: 2px 4px; font-size: 1.26rem; }
  .balance small { font-size: .69rem; }
  .player .coin { width: 29px; font-size: .78rem; }
  .player .coin::before { inset: 3px; }
  .arena-top { padding: 10px; }
  .throws { left: 8px; right: 8px; bottom: 37px; }
  .throw { width: 86px; padding: 5px 6px; min-height: 49px; font-size: .68rem; }
  .throw strong { font-size: 1rem; }
  .arena-bottom { padding-bottom: 9px; }
  .control-head h2 { font-size: 1.3rem; }
  .presets { gap: 4px; }
  .presets button { font-size: .77rem; }
  .history li { grid-template-columns: 36px 39px 1fr auto; gap: 5px; font-size: .75rem; }
}
@media (max-width: 365px) {
  .top-inner { flex-wrap: wrap; padding-block: 9px; }
  .top-actions { flex-wrap: wrap; }
}
@media (max-width: 345px) {
  .player { padding-inline: 8px; gap: 6px; }
  .player-delta { top: 6px; right: 5px; font-size: .69rem; padding: 2px 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; }
}
