:root {
  color-scheme: light;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #171615;
  --muted: #77736e;
  --line: #d8d4ce;
  --paper: #f7f6f3;
  --white: #fffefd;
  --ivory: #eee8d9;
  --red: #9f1021;
  --red-dark: #660813;
  --black: #171717;
  --green: #416052;
  --amber: #b45d08;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
}

body {
  min-height: 100vh;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  border: 0;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(159, 16, 33, 0.24);
  outline-offset: 2px;
}

.home-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(390px, 0.78fr);
  min-height: 100vh;
  background: var(--white);
}

.home-visual {
  position: relative;
  min-height: 620px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: #f1f0ed;
}

.home-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 48% center;
}

.brand-mark {
  position: absolute;
  top: 30px;
  left: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 6px;
  background: rgba(19, 18, 17, 0.78);
  color: white;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  backdrop-filter: blur(10px);
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #c51c2f;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.45);
}

.setup-shell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  padding: 56px clamp(34px, 5vw, 76px);
}

.setup-shell h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(60px, 6vw, 92px);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: 0;
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #efede9;
}

.mode-switch button {
  min-height: 44px;
  border-radius: 5px;
  background: transparent;
  color: #6c6863;
  cursor: pointer;
  font-weight: 700;
}

.mode-switch button.active {
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(28, 25, 22, 0.12);
}

.mode-switch .party-tab {
  color: var(--red);
}

.mode-switch .party-tab.active {
  color: var(--red);
}

.party-setup .party-face-list {
  margin: 0 0 24px;
  padding: 0;
  border: 0;
}

.party-shell {
  min-height: 100svh;
  background: #f8f9fb;
  letter-spacing: 0;
}

.party-topbar {
  background: #fff;
  border-color: #e2e4e8;
}

.party-topbar .round-chip {
  background: transparent;
  border: 0;
  color: #7c8189;
}

.party-play-area {
  width: 100%;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.party-stage {
  position: relative;
  width: 100%;
  height: 400px;
  max-height: 46svh;
  min-height: 260px;
}

#party-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.party-fallback {
  position: absolute;
  inset: 0;
  width: 250px;
  height: 250px;
  margin: auto;
  background: #fff;
  border: 1px solid #e2e4e8;
  border-radius: 8px;
  box-shadow: 8px 10px 0 #e1e3e7;
}

.party-controls {
  width: min(100%, 440px);
  margin: 0 auto;
  padding: 0 22px;
}

.party-result {
  display: grid;
  min-height: 93px;
  align-content: center;
  justify-items: center;
  gap: 8px;
  margin: 0 0 16px;
  text-align: center;
}

.party-result-label {
  color: #858991;
  font-size: 12px;
}

.party-result h1 {
  margin: 0;
  color: #161a20;
  font-size: 32px;
  font-weight: 850;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.party-result.is-rolling h1 {
  color: #7c8189;
}

.party-shell .party-roll-button {
  min-height: 56px;
  background: #a81730;
  font-size: 17px;
  box-shadow: 0 5px 14px rgba(168, 23, 48, 0.15);
  touch-action: manipulation;
}

.party-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
}

.party-sound {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: #70757e;
  font-size: 12px;
  cursor: pointer;
}

.party-sound input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #a81730;
}

.party-voice {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #70757e;
  font-size: 12px;
}

.party-voice select {
  min-height: 30px;
  padding: 3px 7px;
  border: 1px solid #d8dce2;
  border-radius: 5px;
  background: white;
  color: #242831;
  font: inherit;
  cursor: pointer;
}

.party-fullscreen-close {
  display: none;
}

.party-face-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  margin: 0;
  padding: 17px 0 0;
  border-top: 1px solid #e2e4e8;
  list-style: none;
}

.party-face-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 42px;
  color: #70757e;
  font-size: 13px;
  line-height: 1.4;
}

.party-face-item img {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
}

.party-face-item span {
  overflow-wrap: anywhere;
}

.party-face-item.is-result {
  color: #a81730;
  font-weight: 750;
}

@media (min-width: 761px) {
  .party-stage {
    height: 470px;
    max-height: 50svh;
  }
}

@media (max-width: 360px) {
  .party-controls {
    padding: 0 16px;
  }

  .party-face-list {
    column-gap: 8px;
  }

  .party-face-item {
    gap: 5px;
    font-size: 12px;
  }
}

html.party-page-immersive,
html.party-page-immersive body {
  overflow: hidden;
  background: #000;
}

.party-shell.party-immersive {
  position: fixed;
  z-index: 1000;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #000;
}

.party-shell.party-immersive .party-topbar,
.party-shell.party-immersive .party-controls {
  display: none;
}

.party-shell.party-immersive .party-play-area {
  height: 100%;
  padding: 0;
}

.party-shell.party-immersive .party-stage {
  width: 100%;
  height: 100%;
  max-height: none;
  min-height: 0;
  cursor: pointer;
  touch-action: manipulation;
}

.party-shell.party-immersive .party-fallback {
  width: min(60vmin, 440px);
  height: min(60vmin, 440px);
}

.party-shell.party-immersive .party-fullscreen-close {
  position: absolute;
  z-index: 30;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 50%;
  background: rgba(35, 35, 35, 0.8);
  color: #fff;
  cursor: pointer;
  font-size: 32px;
  line-height: 1;
}

.setup-form {
  margin-top: 28px;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field > span,
.section-label {
  display: block;
  margin-bottom: 8px;
  color: #5f5b56;
  font-size: 12px;
  font-weight: 750;
}

.field input,
.name-edit input,
.join-code {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  border: 1px solid #cbc6bf;
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
}

.field input::placeholder,
.name-edit input::placeholder {
  color: #aaa59e;
}

.dice-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 20px;
}

.dice-pick {
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: #77726c;
  cursor: pointer;
  font-weight: 800;
}

.dice-pick.active {
  border-color: var(--ink);
  background: var(--ink);
  color: white;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, background-color 160ms ease, opacity 160ms ease;
}

.primary-button {
  background: var(--red);
  color: white;
  box-shadow: 0 7px 18px rgba(102, 8, 19, 0.16);
}

.primary-button:hover:not(:disabled) {
  background: #b21327;
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid #bbb5ad;
  background: transparent;
  color: var(--ink);
}

.danger-button {
  border: 1px solid #d5b3b6;
  background: transparent;
  color: #81111e;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.full-button {
  width: 100%;
}

.join-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  color: #98928a;
  font-size: 12px;
}

.join-divider::before,
.join-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 9px;
}

.join-code {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 6px;
}

.microcopy {
  margin: 14px 0 0;
  color: #8a857e;
  font-size: 11px;
  line-height: 1.5;
}

.game-shell {
  min-height: 100vh;
  background: var(--paper);
}

.game-topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  height: 66px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 254, 253, 0.92);
  backdrop-filter: blur(12px);
}

.top-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 21px;
  font-weight: 700;
}

.round-chip {
  color: #625e58;
  font-size: 13px;
  font-weight: 700;
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.text-button,
.copy-button {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 5px;
  background: transparent;
  color: #5d5954;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.text-button:hover,
.copy-button:hover {
  background: #ece9e4;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  min-height: calc(100vh - 66px);
}

.game-layout.solo-layout {
  grid-template-columns: minmax(0, 1fr);
}

.table-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background-color: #f6f4f0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.91), rgba(247, 245, 241, 0.94)),
    url("/dice-game/assets/reference-dice-set.png");
  background-position: center;
  background-size: cover;
}

.table-area::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: repeating-linear-gradient(96deg, rgba(36, 32, 29, 0.018) 0, rgba(36, 32, 29, 0.018) 1px, transparent 1px, transparent 8px);
  content: "";
}

.dice-stage {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 390px;
  isolation: isolate;
}

.dice-stage.gesture-ready {
  cursor: ns-resize;
  touch-action: none;
  user-select: none;
}

.dice-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.table-shadow {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(430px, 76vw);
  height: 92px;
  border-radius: 50%;
  background: rgba(27, 23, 20, 0.09);
  filter: blur(18px);
  transform: translate(-50%, -50%);
}

.dice-field {
  position: absolute;
  z-index: 2;
  left: 50%;
  top: 54%;
  display: flex;
  width: min(440px, 82vw);
  min-height: 126px;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.4vw, 16px);
  transform: translate(-50%, -50%);
  transition: opacity 140ms ease, transform 420ms ease;
}

.dice-stage.covered .dice-field {
  opacity: 0;
  transform: translate(-50%, -44%) scale(0.48);
}

.die {
  position: relative;
  display: grid;
  width: clamp(56px, 7vw, 78px);
  aspect-ratio: 1;
  flex: 0 1 78px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px;
  border: 1px solid #d9d0be;
  border-radius: 16%;
  background: #f0eadc;
  box-shadow:
    inset 8px 9px 13px rgba(255, 255, 255, 0.88),
    inset -8px -9px 13px rgba(166, 149, 120, 0.22),
    0 12px 18px rgba(53, 46, 37, 0.16);
  transform: rotate(var(--tilt, 0deg));
  transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.die:nth-child(1) { --tilt: -7deg; }
.die:nth-child(2) { --tilt: 5deg; }
.die:nth-child(3) { --tilt: -2deg; }
.die:nth-child(4) { --tilt: 8deg; }
.die:nth-child(5) { --tilt: -5deg; }

.pip {
  align-self: center;
  justify-self: center;
  width: clamp(8px, 1vw, 12px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #171717;
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, 0.25), 0 1px 1px rgba(0, 0, 0, 0.22);
  opacity: 0;
}

.die.red-pips .pip.on {
  background: #c71425;
}

.pip.on {
  opacity: 1;
}

.cup {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 53%;
  width: clamp(210px, 26vw, 286px);
  height: clamp(235px, 29vw, 310px);
  transform: translate(-50%, -50%);
  transform-origin: 50% 85%;
  transition: transform 620ms cubic-bezier(0.2, 0.75, 0.18, 1), filter 300ms ease;
}

.cup-body {
  position: absolute;
  inset: 12% 5% 7%;
  overflow: hidden;
  border: 2px solid #080808;
  border-radius: 45% 45% 16% 16% / 13% 13% 8% 8%;
  background:
    linear-gradient(95deg, #0b0b0b 0%, #272727 18%, #151515 52%, #303030 83%, #0b0b0b 100%);
  box-shadow:
    inset 10px 0 18px rgba(255, 255, 255, 0.06),
    inset -16px 0 20px rgba(0, 0, 0, 0.54),
    0 22px 29px rgba(18, 15, 13, 0.3);
  clip-path: polygon(12% 0, 88% 0, 100% 100%, 0 100%);
}

.cup-body::before {
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(112deg, transparent 0, transparent 4px, rgba(255, 255, 255, 0.027) 5px, transparent 7px);
  content: "";
}

.cup-top {
  position: absolute;
  z-index: 2;
  left: 16%;
  top: 7%;
  width: 68%;
  height: 19%;
  border: 10px solid #171717;
  border-radius: 50%;
  background: var(--red-dark);
  box-shadow: inset 0 7px 13px rgba(0, 0, 0, 0.64), 0 2px 0 #5c5a57;
  transition: opacity 180ms ease;
}

.cup-top::after {
  position: absolute;
  inset: 11% 9%;
  border: 2px dashed rgba(239, 230, 210, 0.64);
  border-radius: 50%;
  content: "";
}

.cup-stitch {
  position: absolute;
  z-index: 3;
  left: 10%;
  right: 10%;
  bottom: 10%;
  height: 13px;
  border-top: 2px dashed rgba(238, 229, 211, 0.67);
  border-bottom: 1px solid rgba(0, 0, 0, 0.65);
  transform: perspective(220px) rotateX(55deg);
}

.cup.closed .cup-top {
  opacity: 0;
}

.cup.closed {
  transform: translate(-50%, -50%) scale(1.05);
}

.cup.open {
  filter: drop-shadow(12px 15px 14px rgba(24, 20, 16, 0.2));
  transform: translate(calc(-50% - min(30vw, 340px)), -43%) rotate(-13deg) scale(0.86);
}

.dice-stage.shaking .cup {
  animation: cup-shake 135ms linear infinite;
}

.dice-stage.shaking .dice-field {
  animation: field-rattle 210ms linear infinite;
}

.dice-stage.shaking .table-shadow {
  animation: shadow-pulse 270ms ease-in-out infinite alternate;
}

@keyframes cup-shake {
  0% { transform: translate(-53%, -51%) rotate(-4deg) scale(1.05); }
  25% { transform: translate(-46%, -53%) rotate(5deg) scale(1.06); }
  50% { transform: translate(-52%, -48%) rotate(-2deg) scale(1.04); }
  75% { transform: translate(-47%, -51%) rotate(6deg) scale(1.06); }
  100% { transform: translate(-53%, -51%) rotate(-4deg) scale(1.05); }
}

@keyframes field-rattle {
  0% { transform: translate(-52%, -49%) rotate(-1deg); }
  50% { transform: translate(-48%, -52%) rotate(1deg); }
  100% { transform: translate(-52%, -49%) rotate(-1deg); }
}

@keyframes shadow-pulse {
  from { opacity: 0.55; transform: translate(-50%, -50%) scaleX(0.9); }
  to { opacity: 1; transform: translate(-50%, -50%) scaleX(1.08); }
}

.control-dock {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(220px, 360px) minmax(180px, 280px);
  align-items: end;
  justify-content: center;
  gap: 20px;
  padding: 0 30px 32px;
}

.control-dock .dice-picker {
  margin: 0;
}

.room-dice-rule {
  display: grid;
  min-height: 54px;
  align-content: center;
  justify-items: center;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 254, 253, 0.62);
  color: #7b756e;
  font-size: 11px;
}

.room-dice-rule strong {
  color: var(--ink);
  font-size: 17px;
}

.main-action {
  min-height: 54px;
  font-size: 16px;
}

.gesture-affordance {
  display: grid;
  min-height: 54px;
  place-items: center;
  color: #706a63;
}

.gesture-affordance span {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #cfc8bf;
  border-radius: 50%;
  background: rgba(255, 254, 253, 0.72);
  font-size: 26px;
  line-height: 1;
  animation: gesture-breathe 1.7s ease-in-out infinite;
}

@keyframes gesture-breathe {
  0%, 100% { opacity: 0.52; transform: translateY(3px); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.room-panel {
  min-width: 0;
  padding: 26px 24px;
  border-left: 1px solid var(--line);
  background: var(--white);
}

.invite-block {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.invite-label {
  margin: 0 0 8px;
  color: #77716a;
  font-size: 11px;
  font-weight: 800;
}

.invite-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.invite-code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 5px;
}

.invite-note {
  margin: 8px 0 0;
  color: #918b83;
  font-size: 11px;
  line-height: 1.45;
}

.name-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 7px;
  margin: 22px 0;
}

.name-edit input {
  height: 40px;
}

.name-edit button {
  min-height: 40px;
  padding: 0 8px;
}

.roster-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 6px;
  font-size: 14px;
}

.roster-title span {
  color: #8a847d;
  font-size: 11px;
}

.member-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 64px;
  align-items: center;
  border-bottom: 1px solid #e9e5df;
}

.member-name {
  overflow: hidden;
  font-size: 13px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}

.member-remove {
  color: var(--red);
  font-size: 11px;
}

.me-label {
  margin-left: 5px;
  color: var(--red);
  font-size: 10px;
}

.member-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  margin-top: 4px;
  padding: 4px 8px;
  border: 1px solid #d8d1c8;
  border-radius: 5px;
  background: #f4f1ec;
  color: #706a63;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.member-state::before {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.member-state.waiting {
  border-color: #f0bd75;
  background: #fff2d9;
  color: var(--amber);
  box-shadow: 0 2px 8px rgba(180, 93, 8, 0.12);
}

.member-state.shaken {
  border-color: #e5cf91;
  background: #fff9e9;
  color: #927019;
}

.member-state.ready {
  border-color: #9bd2b5;
  background: #e3f6ea;
  color: #167248;
  box-shadow: 0 2px 8px rgba(22, 114, 72, 0.12);
}

.member-state.pending {
  border-color: #d8d4ce;
  background: #f0efec;
  color: #77736e;
}

.roster-heading {
  display: grid;
  gap: 7px;
  margin-bottom: 9px;
}

.roster-heading .roster-title {
  margin-bottom: 0;
}

.roster-progress {
  display: block;
  color: #69635c;
  font-size: 11px;
  font-weight: 750;
}

.mini-dice {
  display: flex;
  max-width: 136px;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 3px;
}

.mini-die,
.hidden-die {
  display: grid;
  width: 22px;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #d6cfc1;
  border-radius: 5px;
  background: var(--ivory);
  color: #222;
  font-size: 10px;
  font-weight: 900;
  box-shadow: inset 2px 2px 3px white;
}

.mini-die {
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 3px;
}

.mini-pip {
  align-self: center;
  justify-self: center;
  width: 3px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #171717;
  opacity: 0;
}

.mini-pip.on {
  opacity: 1;
}

.mini-die.red-pips .mini-pip.on {
  background: #c71425;
}

.hidden-die {
  border-color: #303030;
  background: #1d1d1d;
  color: #efe9dc;
  box-shadow: none;
}

.room-total {
  margin-top: 18px;
  padding: 14px 0;
  border-top: 2px solid var(--ink);
}

.room-total-label {
  display: block;
  margin-bottom: 11px;
  font-size: 12px;
  font-weight: 800;
}

.face-count-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 13px;
}

.face-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--red);
}

.face-count .mini-die {
  width: 25px;
}

.face-count .mini-pip {
  width: 3.9px;
}

.face-count b {
  min-width: 22px;
  font-size: 14px;
  letter-spacing: 0;
}

.waiting-line {
  margin: 18px 0 0;
  color: #827c74;
  font-size: 11px;
  line-height: 1.55;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 15px;
  border-radius: 6px;
  background: #1b1a19;
  color: white;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }

  .control-dock {
    grid-template-columns: minmax(210px, 330px);
    gap: 12px;
  }

  .dice-stage {
    min-height: 350px;
  }
}

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  .home-shell {
    display: block;
  }

  .home-visual {
    min-height: 0;
    height: 36svh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .home-visual img {
    object-position: 44% 47%;
  }

  .brand-mark {
    top: 18px;
    left: 18px;
  }

  .setup-shell {
    min-height: 64svh;
    justify-content: flex-start;
    padding: 30px 20px calc(42px + env(safe-area-inset-bottom));
  }

  .setup-shell h1 {
    font-size: 56px;
  }

  .game-topbar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    column-gap: 6px;
    height: calc(60px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }

  .top-brand {
    font-size: 18px;
  }

  .round-chip {
    display: block;
    justify-self: center;
    max-width: 132px;
    overflow: hidden;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #f4f2ee;
    color: #625e58;
    font-size: 11px;
    line-height: 1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    min-width: 0;
    gap: 4px;
  }

  .text-button {
    min-width: 44px;
    min-height: 44px;
    padding: 0 7px;
    font-size: 12px;
    white-space: nowrap;
  }

  .party-sound,
  .party-voice select {
    min-height: 44px;
  }

  .party-voice select {
    font-size: 16px;
  }

  .copy-button {
    min-height: 44px;
  }

  .game-layout {
    display: block;
    min-height: calc(100svh - 60px - env(safe-area-inset-top));
  }

  .table-area {
    min-height: calc(100svh - 60px - env(safe-area-inset-top));
  }

  .dice-stage {
    min-height: clamp(330px, 52svh, 470px);
  }

  .cup.open {
    transform: translate(calc(-50% - 29vw), -34%) rotate(-13deg) scale(0.73);
  }

  .control-dock {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 0 16px calc(22px + env(safe-area-inset-bottom));
  }

  .dice-pick {
    min-height: 48px;
  }

  .main-action,
  .gesture-affordance {
    min-height: 56px;
  }

  .room-dice-rule {
    min-height: 48px;
  }

  .room-panel {
    padding: 22px 16px calc(38px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .invite-block {
    padding-bottom: 18px;
  }

  .invite-code {
    font-size: 29px;
  }

  .name-edit {
    margin: 18px 0;
  }

  .member-row {
    min-height: 68px;
  }
}

@media (max-width: 430px) {
  .home-visual {
    height: 31svh;
  }

  .setup-shell {
    min-height: 69svh;
    padding-right: 16px;
    padding-left: 16px;
  }

  .dice-stage {
    min-height: 310px;
  }

  .dice-field {
    width: 91vw;
    gap: 6px;
  }

  .die {
    padding: 8px;
  }

  .cup {
    width: 200px;
    height: 225px;
  }

  .cup.open {
    transform: translate(calc(-50% - 32vw), -31%) rotate(-13deg) scale(0.63);
  }

  .control-dock {
    padding-right: 14px;
    padding-left: 14px;
  }

  .roster-progress {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
