:root {
  color-scheme: dark;
  --ink: #06131b;
  --ink-2: #091c25;
  --panel: rgba(8, 29, 38, 0.94);
  --felt: #08353a;
  --felt-2: #06272e;
  --line: rgba(220, 178, 94, 0.38);
  --line-soft: rgba(220, 178, 94, 0.16);
  --gold: #e3bb6b;
  --gold-bright: #f4d58d;
  --text: #f5f2e9;
  --muted: #91a9ae;
  --blue: #57bfe6;
  --red: #f06458;
  --green: #4ee38a;
  --win: #7df0aa;
  --shadow: 0 20px 55px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  background: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 14px;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 75% 0%, rgba(20, 104, 111, 0.22), transparent 34rem),
    radial-gradient(circle at 0% 80%, rgba(196, 137, 49, 0.09), transparent 30rem),
    linear-gradient(145deg, #071b25 0%, #041018 65%, #02090e 100%);
  color: var(--text);
  font-family: "Pretendard", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button { touch-action: manipulation; }

.table {
  width: min(1480px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line-soft);
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(7, 25, 34, 0.92), rgba(3, 14, 21, 0.96));
  box-shadow: var(--shadow);
  overflow: clip;
}

/* ------------------------------------------------------------ 헤더 */

.topbar {
  min-height: 68px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(2, 12, 18, 0.62);
}

.title,
.brand-copy,
.round-state,
.wallet,
.wallet-item { display: flex; align-items: center; }

.title { gap: 11px; min-width: 0; }

.brand-mark {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(227, 187, 107, 0.18), rgba(227, 187, 107, 0.03));
  transform: rotate(45deg);
}

.brand-mark i {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 8px rgba(244, 213, 141, 0.38);
  transform: rotate(-45deg);
}

.brand-mark i:nth-child(1) { top: 9px; left: 9px; }
.brand-mark i:nth-child(2) { top: 17px; left: 17px; }
.brand-mark i:nth-child(3) { right: 9px; bottom: 9px; }

.brand-copy { align-items: flex-start; flex-direction: column; line-height: 1; }
.brand-copy strong { color: var(--gold-bright); font-size: 21px; letter-spacing: 0.08em; }
.brand-copy small { margin-top: 6px; color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: 0.17em; }

.round-state {
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(78, 227, 138, 0.24);
  border-radius: 999px;
  background: rgba(78, 227, 138, 0.07);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
  animation: breathe 1.7s ease-in-out infinite;
}

.table[data-phase="rolling"] .round-state { color: var(--gold-bright); border-color: var(--line); background: rgba(227, 187, 107, 0.08); }
.table[data-phase="payout"] .round-state { color: var(--blue); border-color: rgba(87, 191, 230, 0.28); background: rgba(87, 191, 230, 0.08); }

@keyframes breathe { 50% { opacity: .42; } }

.wallet { justify-content: flex-end; gap: 8px; }

.wallet-item {
  min-width: 108px;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 11px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
}

.wallet-item span { color: var(--muted); font-size: 10px; font-weight: 800; }
.wallet-item strong { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; }
.wallet-item.staked strong { color: var(--gold-bright); }

/* ------------------------------------------------------------ 메인 레이아웃 */

.game-layout {
  display: grid;
  grid-template-areas: "betting stage";
  grid-template-columns: minmax(0, 1fr) 350px;
  align-items: stretch;
  min-height: 620px;
}

.betting-area {
  grid-area: betting;
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line-soft);
}

.stage {
  grid-area: stage;
  position: relative;
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  padding: 18px 16px;
  overflow: hidden;
  background:
    linear-gradient(rgba(4, 19, 27, 0.48), rgba(4, 19, 27, 0.9)),
    repeating-linear-gradient(90deg, transparent 0 34px, rgba(227, 187, 107, 0.025) 35px 36px);
}

.stage-heading,
.history-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.stage-heading b { color: var(--gold); font-size: 9px; }

/* ------------------------------------------------------------ 주사위 무대 */

.shaker {
  position: relative;
  display: grid;
  place-items: center;
  width: min(300px, 92%);
  aspect-ratio: 1.28;
  margin: 18px auto 8px;
  isolation: isolate;
}

.dice-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  width: 100%;
  height: 100%;
  outline: 0;
}

.shaker.is-3d .dice-canvas { display: block; }
.shaker.is-3d .dome-glow,
.shaker.is-3d .shaker-base,
.shaker.is-3d > .dice { visibility: hidden; }

.shaker.is-3d::after {
  content: "";
  position: absolute;
  inset: 8% 5% 3%;
  z-index: 1;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 80%, rgba(66, 213, 220, .14), transparent 58%);
  opacity: .58;
  transform: scale(.96);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease, filter .14s ease;
}

.shaker.is-3d.rolling-3d::after { opacity: 1; }
.shaker.is-3d.impact::after { opacity: 1; filter: brightness(1.8); }
.shaker.is-3d.shake-pulse::after { opacity: 1; transform: scale(1.045); filter: brightness(1.45); }

.dome-glow {
  position: absolute;
  inset: 0 7% 10%;
  z-index: -1;
  border: 2px solid rgba(227, 187, 107, 0.42);
  border-bottom-width: 5px;
  border-radius: 50% 50% 44% 44% / 58% 58% 36% 36%;
  background:
    radial-gradient(circle at 50% 76%, rgba(20, 102, 102, 0.72), rgba(4, 17, 25, 0.88) 58%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.13), transparent 40%);
  box-shadow:
    inset 16px 4px 22px rgba(255, 255, 255, 0.035),
    inset -20px -15px 30px rgba(0, 0, 0, 0.55),
    0 20px 35px rgba(0, 0, 0, 0.42);
}

.dome-glow::before {
  content: "";
  position: absolute;
  inset: 9% 18% 36% 13%;
  border-top: 2px solid rgba(255, 255, 255, 0.17);
  border-radius: 50%;
  transform: rotate(-11deg);
}

.shaker-base {
  position: absolute;
  left: 2%;
  right: 2%;
  bottom: 4%;
  height: 20%;
  z-index: -2;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: linear-gradient(#17323a, #020b10 58%, #a27335 62%, #271b0c 76%);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.48);
}

.shaker:not(.is-3d).shaking { animation: shake .24s linear infinite; }

@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-5px, 3px) rotate(-1.2deg); }
  50% { transform: translate(4px, -3px) rotate(1.1deg); }
  75% { transform: translate(-3px, -2px) rotate(-.8deg); }
}

.dice {
  display: flex;
  gap: 10px;
  margin-top: 29%;
  perspective: 500px;
}

.die { display: block; filter: drop-shadow(0 8px 7px rgba(0, 0, 0, .46)); }
.die:nth-child(1) { transform: rotate(-7deg); }
.die:nth-child(2) { transform: translateY(-5px) rotate(3deg); }
.die:nth-child(3) { transform: rotate(8deg); }

.die-empty {
  width: 58px;
  height: 58px;
  border: 1px dashed rgba(227, 187, 107, .4);
  border-radius: 14px;
  background: rgba(255, 255, 255, .035);
}

.face {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 12%;
  border-radius: 17%;
  background: linear-gradient(145deg, #fffefa, #dce3e2 72%, #bcc9c8);
  box-shadow: inset 0 -3px 5px rgba(0, 0, 0, .2), inset 0 2px 3px rgba(255, 255, 255, .82);
}

.face i { display: block; aspect-ratio: 1; border-radius: 50%; }
.face i.on { background: #172126; box-shadow: inset 0 1px 1px rgba(255, 255, 255, .26); }
.face[data-face="1"] i.on, .face[data-face="4"] i.on { background: #d73f39; }
.face-lg { width: 58px; height: 58px; }
.face-sm { width: 21px; height: 21px; gap: 1px; border-radius: 23%; }

.banner {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: min(290px, 96%);
  margin: 0 auto;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(2, 12, 18, .88);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.banner b { color: var(--text); font-size: 23px; font-weight: 950; font-variant-numeric: tabular-nums; }
.banner .tag { padding: 3px 8px; border-radius: 99px; background: rgba(227, 187, 107, .12); color: var(--gold-bright); font-size: 11px; }
.banner .verdict { color: var(--text); font-size: 13px; font-weight: 950; font-variant-numeric: tabular-nums; }
.banner.win { border-color: rgba(125, 240, 170, .62); }
.banner.win .verdict { color: var(--win); }
.banner.lose .verdict { color: #ff9189; }
.banner.rolling { color: var(--gold-bright); }

.history-panel {
  min-width: 0;
  margin-top: auto;
  padding-top: 20px;
}

.history-heading { margin-bottom: 9px; padding-bottom: 7px; border-bottom: 1px solid var(--line-soft); }
.history-heading span { color: var(--text); }

.history {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  min-height: 34px;
}

.bead {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 30px;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.bead i { font-size: 8px; font-style: normal; opacity: .76; }
.bead.small { border-color: rgba(87, 191, 230, .42); background: rgba(87, 191, 230, .1); color: #8edcff; }
.bead.big { border-color: rgba(240, 100, 88, .44); background: rgba(240, 100, 88, .1); color: #ff948a; }
.bead.triple { border-color: var(--line); background: rgba(227, 187, 107, .12); color: var(--gold-bright); }

/* ------------------------------------------------------------ 베팅판 */

.bet-tabs {
  display: flex;
  width: fit-content;
  margin-bottom: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  overflow: hidden;
}

.bet-tab {
  min-width: 92px;
  min-height: 38px;
  padding: 8px 18px;
  border: 0;
  border-right: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .025);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.bet-tab:last-child { border-right: 0; }
.bet-tab.on { background: rgba(227, 187, 107, .12); color: var(--gold-bright); box-shadow: inset 0 -2px var(--gold); }
.bet-tab:focus-visible { outline: 2px solid var(--gold); outline-offset: -3px; }

.board { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.board.locked { pointer-events: none; filter: saturate(.65); }

.group { min-width: 0; grid-column: 1 / -1; }
.group[data-group="main"] { grid-row: 1; }
.group[data-group="total"] { grid-row: 2; }
.group[data-group="triple"] { grid-column: 1 / 7; grid-row: 3; }
.group[data-group="double"] { grid-column: 7 / -1; grid-row: 3; }
.group[data-group="single"] { grid-column: 1 / 4; grid-row: 4; }
.group[data-group="combo"] { grid-column: 4 / -1; grid-row: 4; }

.group-title {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .12em;
}

.cells {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 5px;
}

.group[data-group="main"] { --cols: 4; }
.group[data-group="triple"] { --cols: 7; }
.group[data-group="total"] { --cols: 14; }
.group[data-group="double"] { --cols: 6; }
.group[data-group="combo"] { --cols: 15; }
.group[data-group="single"] { --cols: 6; }

.cell {
  position: relative;
  min-width: 0;
  min-height: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 7px 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(30, 117, 117, .13), transparent 75%),
    linear-gradient(160deg, rgba(9, 60, 63, .72), rgba(5, 35, 42, .82));
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  transition: transform .13s ease, border-color .13s ease, background .13s ease;
}

.cell:hover { border-color: var(--line); background-color: rgba(227, 187, 107, .08); }
.cell:active { transform: scale(.97); }
.cell:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 1px; }

.cell-faces { min-width: 0; display: flex; justify-content: center; gap: 2px; }
.cell-label { font-size: 13px; font-weight: 900; letter-spacing: -.01em; }
.cell-sub { color: var(--muted); font-size: 9px; font-weight: 800; white-space: nowrap; }
.cell-payout { color: var(--gold); font-size: 9px; font-weight: 900; white-space: nowrap; }

.cell-main { min-height: 92px; }
.cell-main .cell-label { font-size: 25px; }
.cell-main .cell-sub { font-size: 11px; }
.cell-main[data-bet="small"] .cell-label { color: var(--blue); }
.cell-main[data-bet="big"] .cell-label { color: var(--red); }
.cell-main[data-bet="even"] .cell-label { color: #71e0c6; }
.cell-total .cell-label { font-size: 18px; font-variant-numeric: tabular-nums; }
.cell-single .cell-label, .cell-combo .cell-label, .cell-double .cell-label, .cell-triple .cell-label { display: none; }
.cell-combo .face-sm { width: 17px; height: 17px; }
.cell-combo .cell-payout { font-size: 8px; }

.cell.has-bet { border-color: var(--gold-bright); background: rgba(227, 187, 107, .12); box-shadow: inset 0 0 0 1px rgba(227, 187, 107, .1); }

.cell-chip {
  position: absolute;
  right: 3px;
  bottom: 3px;
  max-width: calc(100% - 6px);
  padding: 2px 6px;
  overflow: hidden;
  border: 1px dashed rgba(255, 255, 255, .45);
  border-radius: 99px;
  background: #b84038;
  color: white;
  font-size: 8px;
  font-weight: 950;
  line-height: 1.35;
  text-overflow: ellipsis;
  box-shadow: 0 3px 8px rgba(0, 0, 0, .46);
}

.cell.hit { border-color: rgba(125, 240, 170, .62); background: rgba(78, 227, 138, .12); }
.cell.win { border-color: var(--win); background: rgba(78, 227, 138, .24); animation: pop .44s ease; }

@keyframes pop { 40% { transform: scale(1.045); } }

/* ------------------------------------------------------------ 선택 요약 */

.bet-summary {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-top: 1px solid var(--line-soft);
  background: rgba(5, 21, 29, .98);
}

.bet-summary-title { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; color: var(--muted); font-size: 9px; font-weight: 800; }
.bet-summary-title strong { color: var(--gold-bright); font-size: 11px; }
.bet-summary-title i { font-style: normal; }
.bet-summary-list { min-width: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.bet-summary-list::-webkit-scrollbar { display: none; }
.empty-summary { color: #718b91; font-size: 11px; white-space: nowrap; }

.summary-bet {
  flex: 0 0 auto;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
}

.summary-bet strong { color: var(--gold-bright); font-size: 10px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ 하단 도크 */

.dock {
  position: sticky;
  z-index: 20;
  bottom: 0;
  display: grid;
  grid-template-columns: minmax(220px, .8fr) minmax(310px, 1fr) minmax(270px, .8fr);
  align-items: center;
  gap: 12px;
  min-height: 94px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 28, 37, .97), rgba(2, 12, 18, .995));
  box-shadow: 0 -12px 28px rgba(0, 0, 0, .28);
}

.dock-tools, .chips, .roll-wrap { display: flex; align-items: center; }
.dock-tools { gap: 6px; }

.dock-tools button,
.reset {
  min-width: 66px;
  min-height: 52px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  font-family: inherit;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.dock-tools button span { color: var(--muted); font-size: 22px; line-height: 1; }
.dock-tools button:hover:not(:disabled) { background: rgba(255, 255, 255, .09); }
.dock-tools button:disabled { opacity: .3; cursor: not-allowed; }

.chips-wrap { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dock-label { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .18em; }
.chips { max-width: 100%; justify-content: center; gap: 8px; }

.chip {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  padding: 0;
  border: 4px dashed rgba(255, 255, 255, .5);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #4b5664, #202a34 63%);
  color: white;
  font-family: inherit;
  font-size: 10px;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .2), 0 4px 9px rgba(0, 0, 0, .34);
  cursor: pointer;
  transition: transform .13s ease, box-shadow .13s ease;
}

.chip-0 { background-color: #303944; }
.chip-1 { background: radial-gradient(circle at 50% 38%, #34985a, #15512d 65%); }
.chip-2 { background: radial-gradient(circle at 50% 38%, #2e8dd0, #17456f 65%); }
.chip-3 { background: radial-gradient(circle at 50% 38%, #a14a4a, #591f25 65%); }
.chip.on { transform: translateY(-5px); border-color: var(--gold-bright); box-shadow: 0 0 0 2px rgba(227, 187, 107, .36), 0 8px 15px rgba(0, 0, 0, .45); }
.chip:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }

.roll-wrap { min-width: 0; justify-content: flex-end; gap: 10px; }
.dock-total { min-width: 84px; display: flex; flex-direction: column; align-items: flex-end; }
.dock-total span { color: var(--muted); font-size: 8px; font-weight: 900; letter-spacing: .08em; }
.dock-total strong { margin-top: 3px; font-size: 19px; font-weight: 950; font-variant-numeric: tabular-nums; }

.primary {
  min-width: 132px;
  min-height: 58px;
  padding: 10px 20px;
  border: 1px solid var(--gold-bright);
  border-radius: 10px;
  background: linear-gradient(150deg, #edc773, #a87325);
  color: #241704;
  font-family: inherit;
  font-size: 18px;
  font-weight: 950;
  box-shadow: inset 0 0 0 3px rgba(39, 23, 2, .2), 0 7px 18px rgba(0, 0, 0, .32);
  cursor: pointer;
}

.primary:hover:not(:disabled) { filter: brightness(1.08); }
.primary:disabled { filter: grayscale(.75); opacity: .38; cursor: not-allowed; }
.reset { grid-column: 1 / -1; min-height: 40px; color: #ff9c94; border-color: rgba(240, 100, 88, .4); }

.notice { margin: 0; padding: 8px 14px 10px; color: #58747b; font-size: 9px; text-align: center; }

.toast {
  position: fixed;
  z-index: 80;
  left: 50%;
  bottom: calc(112px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 28px);
  padding: 10px 17px;
  transform: translate(-50%, 12px);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(5, 22, 29, .97);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transition: opacity .17s ease, transform .17s ease;
}

.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ 태블릿 */

@media (max-width: 1099px) {
  body { padding: 10px; }
  .game-layout { grid-template-areas: "stage" "betting"; grid-template-columns: minmax(0, 1fr); min-height: 0; }
  .betting-area { border-top: 1px solid var(--line-soft); border-right: 0; }
  .stage { min-height: 310px; display: grid; grid-template-columns: minmax(270px, .8fr) minmax(330px, 1.2fr); grid-template-rows: auto 1fr auto; column-gap: 20px; }
  .stage-heading { grid-column: 1; }
  .shaker { grid-column: 1; grid-row: 2 / 4; width: min(300px, 100%); margin: 8px auto 0; }
  .banner { grid-column: 2; grid-row: 2; align-self: end; margin-bottom: 18px; }
  .history-panel { grid-column: 2; grid-row: 3; width: 100%; margin-top: 0; }
  .history { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .group[data-group="triple"], .group[data-group="double"], .group[data-group="single"], .group[data-group="combo"] { grid-column: 1 / -1; grid-row: auto; }
  .group[data-group="main"] { grid-row: 1; }
  .group[data-group="total"] { grid-row: 2; }
  .group[data-group="triple"] { grid-row: 3; }
  .group[data-group="double"] { grid-row: 4; }
  .group[data-group="single"] { grid-row: 5; }
  .group[data-group="combo"] { grid-row: 6; }
  .dock { grid-template-columns: auto 1fr auto; }
}

/* ------------------------------------------------------------ 모바일: 결과 → 탭형 베팅 → 고정 조작 */

@media (max-width: 767px) {
  body { padding: 0; background: var(--ink); }
  .table { border: 0; border-radius: 0; box-shadow: none; }

  .topbar {
    min-height: 58px;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 8px 11px;
  }

  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .brand-mark i { width: 5px; height: 5px; }
  .brand-mark i:nth-child(1) { top: 7px; left: 7px; }
  .brand-mark i:nth-child(2) { top: 14px; left: 14px; }
  .brand-mark i:nth-child(3) { right: 7px; bottom: 7px; }
  .brand-copy strong { font-size: 16px; }
  .brand-copy small { margin-top: 4px; font-size: 7px; }

  .round-state {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    margin-bottom: -29px;
    z-index: 3;
    padding: 5px 10px;
    font-size: 9px;
  }

  .wallet { gap: 5px; }
  .wallet-item { min-width: auto; flex-direction: column; align-items: flex-end; gap: 1px; padding: 5px 7px; }
  .wallet-item span { font-size: 8px; }
  .wallet-item strong { font-size: 12px; }
  .wallet-item.staked { display: none; }

  .stage {
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto;
    gap: 0;
    padding: 15px 11px 10px;
  }

  .stage-heading { display: none; }
  .shaker { grid-column: 1; grid-row: 1; width: min(230px, 72vw); margin: 2px auto 0; }
  .banner { grid-column: 1; grid-row: 2; width: min(260px, 90%); min-height: 40px; margin-top: -4px; padding: 6px 12px; }
  .banner b { font-size: 20px; }
  .history-panel { grid-column: 1; grid-row: 3; min-width: 0; margin-top: 12px; padding-top: 0; }
  .history-heading { margin-bottom: 6px; }
  .history {
    display: flex;
    gap: 5px;
    min-width: 0;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .history::-webkit-scrollbar { display: none; }
  .bead { flex: 0 0 44px; min-height: 28px; scroll-snap-align: start; }

  .die-empty, .face-lg { width: 48px; height: 48px; }
  .dice { gap: 8px; }

  .betting-area { padding: 0 10px 12px; border-top: 1px solid var(--line-soft); }
  .bet-tabs { position: sticky; z-index: 12; top: 0; width: 100%; margin: 0 0 10px; border-top: 0; border-radius: 0 0 10px 10px; background: rgba(5, 22, 30, .98); }
  .bet-tab { flex: 1; min-width: 0; min-height: 46px; padding: 8px; }

  .board { display: block; }
  .group { margin-bottom: 10px; }
  .group[data-group] { grid-row: auto; }
  .board .group { display: none; }
  .board[data-active-tab="main"] [data-tab-panel="main"],
  .board[data-active-tab="totals"] [data-tab-panel="totals"],
  .board[data-active-tab="combos"] [data-tab-panel="combos"] { display: block; }

  .group-title { margin: 0 0 6px; }
  .group[data-group="main"] { --cols: 2; }
  .group[data-group="total"] { --cols: 4; }
  .group[data-group="triple"] { --cols: 4; }
  .group[data-group="double"] { --cols: 3; }
  .group[data-group="combo"] { --cols: 3; }
  .group[data-group="single"] { --cols: 3; }

  .cell { min-height: 62px; border-radius: 9px; }
  .cell-main { min-height: 88px; }
  .cell-main .cell-label { font-size: 23px; }
  .cell-total { min-height: 70px; }
  .cell-combo .face-sm { width: 22px; height: 22px; }
  .cell-combo .cell-payout { font-size: 9px; }

  .bet-summary {
    position: sticky;
    z-index: 18;
    bottom: calc(111px + env(safe-area-inset-bottom));
    display: flex;
  }

  .dock {
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 7px;
    min-height: 111px;
    padding: 8px 9px calc(8px + env(safe-area-inset-bottom));
  }

  .dock-tools { gap: 4px; }
  .dock-tools button { min-width: 38px; min-height: 42px; padding: 3px; font-size: 0; }
  .dock-tools button span { font-size: 23px; }

  .chips-wrap { align-items: stretch; overflow: hidden; }
  .dock-label { text-align: center; }
  .chips { min-width: 0; justify-content: flex-start; gap: 6px; overflow-x: auto; padding: 4px 2px 7px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { width: 45px; height: 45px; border-width: 3px; font-size: 9px; }

  .roll-wrap { gap: 6px; }
  .dock-total { display: none; }
  .primary { min-width: 78px; min-height: 56px; padding: 8px 10px; font-size: 15px; }
  .reset { grid-column: 1 / -1; }
  .notice { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(126px + env(safe-area-inset-bottom)); }
}

@media (max-width: 374px) {
  .title { gap: 8px; }
  .brand-copy small { display: none; }
  .wallet-item { padding-inline: 5px; }
  .shaker { width: 210px; }
  .die-empty, .face-lg { width: 44px; height: 44px; }
  .chip { width: 42px; height: 42px; }
  .primary { min-width: 70px; }
}

@media (prefers-reduced-motion: reduce) {
  .shaker.shaking, .cell.win, .state-dot { animation: none; }
  .cell, .chip, .toast { transition: none; }
  :focus { scroll-behavior: auto; }
}
