:root {
  color-scheme: light;
  --page: #fff4df;
  --ink: #172134;
  --muted: #697183;
  --line: #ead9bd;
  --surface: #fffaf0;
  --surface-strong: #ffffff;
  --green: #149c6c;
  --green-2: #21b57e;
  --gold: #ffc53d;
  --coral: #ff6b62;
  --red: #ef3e48;
  --red-dark: #a31928;
  --blue: #38a5ff;
  --teal: #00b8bd;
  --purple: #7c5cff;
  --shadow: 0 16px 36px rgba(81, 50, 28, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 12%, rgba(56, 165, 255, 0.2), transparent 26%),
    radial-gradient(circle at 88% 18%, rgba(255, 107, 98, 0.24), transparent 26%),
    radial-gradient(circle at 48% 88%, rgba(33, 181, 126, 0.18), transparent 28%),
    var(--page);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-image:
    radial-gradient(circle, rgba(23, 33, 52, 0.06) 1px, transparent 1px);
  background-size: 18px 18px;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.75rem, 15vw, 5rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.screen {
  min-height: calc(100vh - 32px);
}

.hero-strip,
.game-header {
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.helper-copy {
  max-width: 34rem;
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.setup-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.rules-info-button {
  display: grid;
  width: 34px;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  border: 2px solid white;
  border-radius: 999px;
  background: var(--teal);
  color: white;
  font-size: 1rem;
  font-weight: 1000;
  line-height: 1;
  box-shadow: 0 6px 0 rgba(5, 93, 89, 0.18);
}

.setup-card,
.bank-panel,
.input-panel,
.players-panel {
  margin-bottom: 14px;
  border: 2px solid rgba(255, 255, 255, 0.84);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.setup-card {
  padding: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.count-pill,
.sort-pill {
  min-width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--blue);
  color: white;
  font-size: 0.84rem;
  font-weight: 900;
  text-align: center;
}

.sort-pill {
  background: #fff0bf;
  color: var(--ink);
  cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(255, 197, 61, 0.42);
}

.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 86px;
  gap: 8px;
}

input {
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  font-size: 16px;
}

.setup-player-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.setup-player-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.setup-order {
  display: grid;
  height: 34px;
  place-items: center;
  border-radius: 999px;
  background: #fff0bf;
  color: var(--ink);
  font-weight: 900;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#diceModeControls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented-control button,
.primary-button,
.secondary-button,
.icon-button,
.bank-button,
.remove-button,
.menu-popover button {
  min-height: 46px;
  border-radius: 8px;
  font-weight: 900;
}

.segmented-control button {
  border: 2px solid var(--line);
  background: white;
  color: var(--ink);
}

.segmented-control button.selected {
  border-color: transparent;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: white;
}

.primary-button {
  background: linear-gradient(135deg, var(--gold), #ffdf69);
  color: #1c160b;
  box-shadow: 0 8px 0 rgba(175, 122, 14, 0.24);
}

.secondary-button {
  border: 2px solid var(--teal);
  background: white;
  color: #087a86;
}

.start-button {
  width: 100%;
  min-height: 56px;
  margin-top: 2px;
  font-size: 1.04rem;
}

.setup-error {
  min-height: 24px;
  margin: 10px 0 0;
  color: var(--red-dark);
  font-weight: 800;
}

.remove-button {
  background: #ffe1de;
  color: var(--red-dark);
}

.game-header {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.icon-button {
  display: grid;
  width: 46px;
  place-items: center;
  background: #fff0bf;
  color: var(--ink);
  font-size: 1.35rem;
}

.icon-button:disabled {
  color: #a3998a;
}

.menu-popover {
  position: absolute;
  top: 62px;
  right: 0;
  z-index: 4;
  display: grid;
  width: min(240px, 78vw);
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
}

.menu-popover button {
  background: #fff0bf;
  color: var(--ink);
  text-align: left;
  padding: 0 12px;
}

.bank-panel {
  position: relative;
  overflow: visible;
  padding: 16px;
  border-color: rgba(255, 255, 255, 0.9);
  background:
    radial-gradient(circle at 22% 24%, rgba(255, 255, 255, 0.22), transparent 18%),
    linear-gradient(135deg, #21b57e, #1196a8 54%, #2477e8);
  color: white;
  text-align: center;
}

.bank-kicker {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.bank-panel strong {
  display: block;
  margin: 8px 0 2px;
  font-size: clamp(5.2rem, 28vw, 9rem);
  line-height: 0.9;
  text-shadow: 0 8px 0 rgba(0, 0, 0, 0.08);
}

.bank-panel p {
  min-height: 44px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.4;
}

.celebrate-bank {
  animation: pop-bank 520ms ease;
}

.effect-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 30;
  overflow: visible;
}

.floating-effect {
  position: absolute;
  left: 50%;
  top: 42%;
  z-index: 1;
  translate: -50% -50%;
  border-radius: 999px;
  padding: 9px 15px;
  background: white;
  color: #087a86;
  font-size: 1.25rem;
  font-weight: 1000;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  animation: float-away 980ms ease forwards;
}

.floating-effect.from-control {
  translate: -50% -100%;
  animation-name: float-from-control;
}

.floating-effect.celebrate {
  background: var(--gold);
  color: #171307;
  font-size: 1.7rem;
}

.floating-effect.bank {
  background: linear-gradient(135deg, var(--purple), var(--blue));
  color: white;
  font-size: 1rem;
}

.floating-effect.undo {
  background: #ffe1de;
  color: var(--red-dark);
  font-size: 1.55rem;
}

.bank-cap-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 4;
  width: min(88%, 360px);
  translate: -50% 0;
  border: 2px solid rgba(23, 23, 23, 0.16);
  border-radius: 8px;
  padding: 10px 14px;
  background: #fffdfa;
  color: var(--red-dark);
  font-size: 0.96rem;
  font-weight: 1000;
  line-height: 1.2;
  text-align: center;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.24);
  animation: cap-toast 2200ms ease forwards;
}

.floating-effect.celebrate::before,
.floating-effect.celebrate::after {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: inherit;
  border: 3px dotted rgba(255, 255, 255, 0.95);
  animation: sparks 720ms ease forwards;
}

.floating-effect::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: inherit;
  border: 2px dotted rgba(255, 255, 255, 0.88);
  animation: twinkle-ring 680ms ease forwards;
}

.floating-effect.celebrate::after {
  inset: -30px;
  border-color: rgba(216, 160, 47, 0.88);
  animation-delay: 80ms;
}

.input-panel {
  padding: 12px;
  background: linear-gradient(180deg, #fffdfa, #fff0ca);
}

.bottom-input {
  position: sticky;
  bottom: 0;
  z-index: 6;
  margin-bottom: 0;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.keypad-button {
  min-height: 54px;
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 1000;
  box-shadow: inset 0 0 0 2px #ffe1a8, 0 6px 0 rgba(81, 50, 28, 0.08);
}

.keypad-button.good-key {
  background: linear-gradient(135deg, var(--green), var(--green-2));
  color: white;
  box-shadow: none;
}

.keypad-button.danger-key {
  background: linear-gradient(135deg, var(--red), #ff7060);
  color: white;
  box-shadow: none;
}

.keypad-button.wide-key {
  grid-column: span 2;
}

.keypad-button.unavailable-key {
  background: #e8e2d5;
  color: #aaa295;
  box-shadow: inset 0 0 0 2px #ddd4c3;
}

.virtual-dice-stage {
  position: relative;
  display: grid;
  gap: 14px;
  overflow: hidden;
  border-radius: 8px;
  padding: 10px;
  transition: background 180ms ease, box-shadow 180ms ease;
}

.virtual-dice-stage.seven-flash {
  background: var(--red);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.38), 0 0 42px rgba(201, 54, 45, 0.5);
}

.dice-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-height: 132px;
  align-items: center;
}

.dice-face {
  position: relative;
  display: grid;
  aspect-ratio: 1;
  width: min(100%, 136px);
  margin: 0 auto;
  border: 3px solid #171717;
  border-radius: 14px;
  background: linear-gradient(145deg, #ffffff, #fff4df);
  box-shadow: 0 14px 22px rgba(0, 0, 0, 0.18);
  transition: transform 240ms cubic-bezier(0.2, 1.2, 0.24, 1), box-shadow 180ms ease;
}

.dice-face.rolling {
  transition: none;
  overflow: hidden;
  background:
    radial-gradient(circle at 26% 28%, rgba(255, 255, 255, 0.95), transparent 22%),
    radial-gradient(circle at 68% 62%, rgba(23, 23, 23, 0.18), transparent 18%),
    linear-gradient(135deg, #ffffff 0%, #ffe8b8 52%, #f8c85e 100%);
  box-shadow: 0 22px 34px rgba(0, 0, 0, 0.26);
  filter: blur(4px);
  will-change: transform, filter, box-shadow;
}

.dice-face.rolling .dot {
  opacity: 0;
}

.dice-face.rolling::before,
.dice-face.rolling::after {
  content: "";
  position: absolute;
  inset: -18%;
  border-radius: 18px;
  pointer-events: none;
}

.dice-face.rolling::before {
  background:
    linear-gradient(110deg, transparent 18%, rgba(255, 255, 255, 0.72) 42%, transparent 62%),
    repeating-linear-gradient(90deg, rgba(23, 23, 23, 0.1) 0 5px, transparent 5px 16px);
  opacity: 0.65;
  transform: rotate(18deg);
}

.dice-face.rolling::after {
  inset: 14%;
  background: rgba(255, 255, 255, 0.4);
  filter: blur(16px);
  opacity: 0.8;
}

.dice-face.rolling-one {
  animation: dice-roll-one-a 1500ms cubic-bezier(0.2, 0.84, 0.18, 1) both;
}

.dice-face.rolling-two {
  animation: dice-roll-two-a 2500ms cubic-bezier(0.18, 0.86, 0.2, 1) both;
}

.roll-variant-1 .dice-face.rolling-one {
  animation-name: dice-roll-one-a;
}

.roll-variant-1 .dice-face.rolling-two {
  animation-name: dice-roll-two-a;
}

.roll-variant-2 .dice-face.rolling-one {
  animation-name: dice-roll-one-b;
}

.roll-variant-2 .dice-face.rolling-two {
  animation-name: dice-roll-two-b;
}

.roll-variant-3 .dice-face.rolling-one {
  animation-name: dice-roll-one-c;
}

.roll-variant-3 .dice-face.rolling-two {
  animation-name: dice-roll-two-c;
}

.roll-variant-4 .dice-face.rolling-one {
  animation-name: dice-roll-one-d;
}

.roll-variant-4 .dice-face.rolling-two {
  animation-name: dice-roll-two-d;
}

.roll-variant-5 .dice-face.rolling-one {
  animation-name: dice-roll-one-e;
}

.roll-variant-5 .dice-face.rolling-two {
  animation-name: dice-roll-two-e;
}

.seven-flash .dice-face {
  border-color: var(--red-dark);
  box-shadow: 0 18px 26px rgba(129, 26, 23, 0.32);
}

.dot {
  position: absolute;
  display: none;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #111;
}

.dot-1,
.dot-4,
.dot-7 {
  left: 20%;
}

.dot-2,
.dot-5,
.dot-8 {
  left: 50%;
  translate: -50% 0;
}

.dot-3,
.dot-6,
.dot-9 {
  right: 20%;
}

.dot-1,
.dot-2,
.dot-3 {
  top: 20%;
}

.dot-4,
.dot-5,
.dot-6 {
  top: 50%;
  translate: 0 -50%;
}

.dot-5 {
  translate: -50% -50%;
}

.dot-7,
.dot-8,
.dot-9 {
  bottom: 20%;
}

.dice-face[data-value="1"] .dot-5,
.dice-face[data-value="2"] .dot-1,
.dice-face[data-value="2"] .dot-9,
.dice-face[data-value="3"] .dot-1,
.dice-face[data-value="3"] .dot-5,
.dice-face[data-value="3"] .dot-9,
.dice-face[data-value="4"] .dot-1,
.dice-face[data-value="4"] .dot-3,
.dice-face[data-value="4"] .dot-7,
.dice-face[data-value="4"] .dot-9,
.dice-face[data-value="5"] .dot-1,
.dice-face[data-value="5"] .dot-3,
.dice-face[data-value="5"] .dot-5,
.dice-face[data-value="5"] .dot-7,
.dice-face[data-value="5"] .dot-9,
.dice-face[data-value="6"] .dot-1,
.dice-face[data-value="6"] .dot-3,
.dice-face[data-value="6"] .dot-4,
.dice-face[data-value="6"] .dot-6,
.dice-face[data-value="6"] .dot-7,
.dice-face[data-value="6"] .dot-9 {
  display: block;
}

.roll-button {
  min-height: 54px;
}

.players-panel {
  overflow: hidden;
  padding: 14px 0 0;
  background: rgba(255, 250, 240, 0.96);
}

.players-panel .section-heading {
  padding: 0 14px;
}

.players-list {
  display: grid;
}

.player-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 10px;
  align-items: center;
  min-height: 72px;
  padding: 12px 14px;
  border-top: 2px solid rgba(234, 217, 189, 0.72);
  background: var(--surface);
  transition: opacity 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.player-row.current-roller {
  position: relative;
  z-index: 1;
  background: #fffdf7;
  box-shadow: inset 0 0 0 3px white, inset 0 0 0 6px rgba(255, 197, 61, 0.56), 0 0 24px rgba(255, 197, 61, 0.52);
}

.player-row.banked-player {
  background: #ece5d8;
  opacity: 0.58;
}

.player-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.player-text strong {
  overflow-wrap: anywhere;
  font-size: 1.08rem;
}

.player-text span {
  color: var(--muted);
  font-size: 0.9rem;
}

.bank-button {
  background: linear-gradient(135deg, var(--green), var(--teal));
  color: white;
  box-shadow: 0 6px 0 rgba(5, 93, 89, 0.18);
}

.bank-button:disabled {
  background: #c7c2b7;
  color: #fffaf0;
  box-shadow: none;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 28, 24, 0.62);
}

.overlay-card {
  width: min(100%, 520px);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface-strong);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
}

.overlay-card h2 {
  margin-bottom: 10px;
  font-size: clamp(1.8rem, 9vw, 3.5rem);
}

.overlay-card p {
  color: var(--muted);
  line-height: 1.45;
}

.rules-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  max-height: min(86vh, 760px);
  padding: 0;
  overflow: hidden;
  text-align: left;
}

.rules-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.rules-card-header h2 {
  margin: 0;
  font-size: clamp(1.65rem, 8vw, 2.6rem);
}

.rules-close-button {
  display: grid;
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  place-items: center;
  border-radius: 999px;
  background: #ffe1de;
  color: var(--red-dark);
  font-weight: 1000;
}

.rules-content {
  display: grid;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 20px;
}

.rules-section {
  display: grid;
  gap: 7px;
}

.rules-section h3 {
  margin: 0;
  color: var(--teal);
  font-size: 0.86rem;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rules-section p,
.rules-section ul {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.42;
}

.rules-section ul {
  display: grid;
  gap: 6px;
  padding-left: 20px;
}

.dice-rules-grid {
  display: grid;
  grid-template-columns: minmax(74px, 0.85fr) repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.dice-rules-grid > * {
  min-width: 0;
  padding: 9px 8px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.dice-rules-grid > :nth-child(3n) {
  border-right: 0;
}

.dice-rules-grid > :nth-last-child(-n + 3) {
  border-bottom: 0;
}

.dice-rules-grid strong {
  background: #fff0bf;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}

.giant-seven {
  margin: -12px auto 4px;
  color: var(--red);
  font-size: clamp(11rem, 48vw, 20rem);
  font-weight: 1000;
  line-height: 0.82;
  text-shadow: 0 0 32px rgba(201, 54, 45, 0.32);
  animation: seven-smash 580ms cubic-bezier(0.2, 1.4, 0.3, 1) both;
}

.final-standings {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  padding-left: 28px;
  text-align: left;
}

.final-standings li::marker {
  color: var(--blue);
  font-weight: 1000;
}

@keyframes float-away {
  0% {
    opacity: 0.96;
    transform: translateY(4px) scale(0.92);
  }

  20% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(-76px) scale(1.16);
  }
}

@keyframes float-from-control {
  0% {
    opacity: 1;
    transform: translateY(-4px) scale(0.98);
  }

  24% {
    opacity: 1;
    transform: translateY(-24px) scale(1.08);
  }

  100% {
    opacity: 0;
    transform: translateY(-96px) scale(1.18);
  }
}

@keyframes pop-bank {
  0%,
  100% {
    transform: scale(1);
  }

  44% {
    transform: scale(1.1);
  }
}

@keyframes sparks {
  to {
    opacity: 0;
    transform: scale(1.45) rotate(18deg);
  }
}

@keyframes twinkle-ring {
  to {
    opacity: 0;
    transform: scale(1.35) rotate(-12deg);
  }
}

@keyframes cap-toast {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.94);
  }

  12%,
  82% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
}

@keyframes dice-roll-one-a {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  22% {
    filter: blur(7px);
    transform: translate(18px, -14px) rotate(170deg) scale(0.95);
  }

  46% {
    filter: blur(8px);
    transform: translate(-16px, 12px) rotate(350deg) scale(1.03);
  }

  72% {
    filter: blur(6px);
    transform: translate(10px, -8px) rotate(535deg) scale(0.98);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(720deg) scale(1);
  }
}

@keyframes dice-roll-two-a {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  18% {
    filter: blur(8px);
    transform: translate(-22px, 14px) rotate(-160deg) scale(0.96);
  }

  38% {
    filter: blur(9px);
    transform: translate(18px, -16px) rotate(-350deg) scale(1.04);
  }

  60% {
    filter: blur(8px);
    transform: translate(-14px, 10px) rotate(-575deg) scale(0.98);
  }

  82% {
    filter: blur(6px);
    transform: translate(8px, -8px) rotate(-760deg) scale(1.02);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(-900deg) scale(1);
  }
}

@keyframes dice-roll-one-b {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  20% {
    filter: blur(8px);
    transform: translate(-20px, -10px) rotate(-185deg) scale(0.98);
  }

  48% {
    filter: blur(9px);
    transform: translate(16px, 16px) rotate(-365deg) scale(1.04);
  }

  75% {
    filter: blur(6px);
    transform: translate(-8px, -6px) rotate(-560deg) scale(0.99);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(-720deg) scale(1);
  }
}

@keyframes dice-roll-two-b {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  17% {
    filter: blur(8px);
    transform: translate(20px, -12px) rotate(180deg) scale(0.96);
  }

  40% {
    filter: blur(9px);
    transform: translate(-18px, 14px) rotate(390deg) scale(1.04);
  }

  63% {
    filter: blur(8px);
    transform: translate(16px, 8px) rotate(610deg) scale(0.97);
  }

  84% {
    filter: blur(6px);
    transform: translate(-6px, -8px) rotate(800deg) scale(1.02);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(920deg) scale(1);
  }
}

@keyframes dice-roll-one-c {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  24% {
    filter: blur(8px);
    transform: translate(12px, 18px) rotate(155deg) scale(0.96);
  }

  50% {
    filter: blur(9px);
    transform: translate(-18px, -12px) rotate(360deg) scale(1.03);
  }

  74% {
    filter: blur(6px);
    transform: translate(10px, 8px) rotate(545deg) scale(0.99);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(735deg) scale(1);
  }
}

@keyframes dice-roll-two-c {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  16% {
    filter: blur(8px);
    transform: translate(-18px, -16px) rotate(-170deg) scale(0.97);
  }

  36% {
    filter: blur(9px);
    transform: translate(22px, 12px) rotate(-380deg) scale(1.04);
  }

  61% {
    filter: blur(8px);
    transform: translate(-14px, 16px) rotate(-590deg) scale(0.98);
  }

  83% {
    filter: blur(6px);
    transform: translate(6px, -8px) rotate(-785deg) scale(1.02);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(-910deg) scale(1);
  }
}

@keyframes dice-roll-one-d {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  21% {
    filter: blur(8px);
    transform: translate(22px, 8px) rotate(190deg) scale(0.96);
  }

  47% {
    filter: blur(9px);
    transform: translate(-10px, -18px) rotate(385deg) scale(1.04);
  }

  76% {
    filter: blur(6px);
    transform: translate(8px, 10px) rotate(575deg) scale(0.99);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(730deg) scale(1);
  }
}

@keyframes dice-roll-two-d {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  18% {
    filter: blur(8px);
    transform: translate(-20px, 8px) rotate(-185deg) scale(0.96);
  }

  39% {
    filter: blur(9px);
    transform: translate(16px, -18px) rotate(-395deg) scale(1.04);
  }

  62% {
    filter: blur(8px);
    transform: translate(-18px, 12px) rotate(-610deg) scale(0.98);
  }

  85% {
    filter: blur(6px);
    transform: translate(7px, -6px) rotate(-800deg) scale(1.02);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(-930deg) scale(1);
  }
}

@keyframes dice-roll-one-e {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  23% {
    filter: blur(8px);
    transform: translate(-12px, 18px) rotate(-165deg) scale(0.97);
  }

  49% {
    filter: blur(9px);
    transform: translate(20px, -14px) rotate(-370deg) scale(1.04);
  }

  73% {
    filter: blur(6px);
    transform: translate(-8px, 8px) rotate(-555deg) scale(0.99);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(-725deg) scale(1);
  }
}

@keyframes dice-roll-two-e {
  0% {
    filter: blur(2px);
    transform: translate(0, 0) rotate(0deg) scale(1);
  }

  15% {
    filter: blur(8px);
    transform: translate(18px, -18px) rotate(175deg) scale(0.96);
  }

  37% {
    filter: blur(9px);
    transform: translate(-22px, 16px) rotate(375deg) scale(1.04);
  }

  60% {
    filter: blur(8px);
    transform: translate(18px, 10px) rotate(600deg) scale(0.98);
  }

  84% {
    filter: blur(6px);
    transform: translate(-8px, -7px) rotate(790deg) scale(1.02);
  }

  100% {
    filter: blur(4px);
    transform: translate(0, 0) rotate(925deg) scale(1);
  }
}

@keyframes seven-smash {
  0% {
    opacity: 0;
    transform: scale(0.28) rotate(-10deg);
  }

  70% {
    opacity: 1;
    transform: scale(1.08) rotate(2deg);
  }

  100% {
    transform: scale(1) rotate(0deg);
  }
}

@media (min-width: 640px) {
  .app-shell {
    padding: 24px;
  }

  .screen {
    min-height: calc(100vh - 48px);
  }

  .keypad {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .keypad-button {
    min-height: 64px;
  }
}

/* Mockup-matching party game skin */
:root {
  --mock-bg: #fff4df;
  --mock-ink: #172134;
  --mock-coral: #ff6f61;
  --mock-coral-dark: #d84a42;
  --mock-teal: #14b9b3;
  --mock-blue: #39a8ff;
  --mock-yellow: #ffd45a;
  --mock-green: #21b978;
  --mock-red: #ef4c54;
  --mock-cream: #fff9ec;
  --mock-card: #ffffff;
  --mock-line: #f0dbb8;
  --mock-shadow: 0 18px 34px rgba(82, 48, 24, 0.16);
}

html {
  background:
    radial-gradient(circle at 10% 8%, rgba(57, 168, 255, 0.26), transparent 30%),
    radial-gradient(circle at 92% 12%, rgba(255, 111, 97, 0.28), transparent 28%),
    linear-gradient(180deg, #fff8e9, var(--mock-bg));
}

body {
  color: var(--mock-ink);
  background-image:
    radial-gradient(circle, rgba(23, 33, 52, 0.08) 1px, transparent 1px);
  background-position: 0 0;
  background-size: 20px 20px;
}

.app-shell {
  width: min(100%, 460px);
  padding: 14px;
}

.screen {
  min-height: calc(100vh - 28px);
}

.game-header {
  align-items: center;
  padding: 2px 0 12px;
}

.game-header .eyebrow,
.hero-strip .eyebrow {
  color: #168b91;
  font-size: 0.72rem;
  letter-spacing: 0;
}

.game-header h1,
.hero-strip h1 {
  color: var(--mock-ink);
  font-size: clamp(2.45rem, 12vw, 3.85rem);
  font-weight: 1000;
  line-height: 0.92;
  white-space: nowrap;
}

.header-actions {
  padding-top: 0;
}

.icon-button {
  width: 44px;
  min-height: 44px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: #fff1bd;
  color: var(--mock-ink);
  box-shadow: 0 8px 0 rgba(211, 151, 29, 0.14);
}

.menu-popover {
  top: 52px;
  border: 3px solid white;
  background: #fff8df;
}

.bank-panel {
  isolation: isolate;
  margin-bottom: 14px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  border-radius: 18px;
  padding: 18px 18px 20px;
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 255, 255, 0.24), transparent 22%),
    linear-gradient(135deg, #1fc7a1 0%, #1ea5d8 52%, #2578ea 100%);
  box-shadow: var(--mock-shadow);
}

.bank-panel::before,
.bank-panel::after {
  content: "*";
  position: absolute;
  z-index: -1;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.8rem;
  animation: soft-twinkle 1400ms ease-in-out infinite;
}

.bank-panel::before {
  top: 22px;
  left: 30px;
}

.bank-panel::after {
  right: 28px;
  bottom: 30px;
  animation-delay: 420ms;
}

.bank-kicker {
  padding: 7px 14px;
  border: 2px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.22);
  color: white;
  font-size: 0.76rem;
}

.bank-panel strong {
  margin: 8px 0 0;
  font-size: clamp(5.8rem, 31vw, 8.4rem);
  font-weight: 1000;
  text-shadow: 0 9px 0 rgba(10, 57, 109, 0.13);
}

.bank-panel p {
  min-height: 36px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.98rem;
  font-weight: 750;
}

.players-panel,
.setup-card,
.input-panel {
  border: 3px solid rgba(255, 255, 255, 0.94);
  border-radius: 18px;
  background: rgba(255, 249, 236, 0.96);
  box-shadow: var(--mock-shadow);
}

.players-panel {
  margin-bottom: 14px;
  padding-top: 0;
}

.players-panel .section-heading {
  margin-bottom: 0;
  padding: 13px 14px 10px;
}

.players-panel h2,
.setup-card h2 {
  font-size: 1rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.sort-pill,
.count-pill {
  min-height: 38px;
  border-radius: 999px;
  padding: 8px 13px;
  background: #fff0b7;
  color: var(--mock-ink);
  box-shadow: inset 0 0 0 2px rgba(255, 212, 90, 0.65), 0 5px 0 rgba(211, 151, 29, 0.12);
}

.count-pill {
  background: var(--mock-blue);
  color: white;
}

.player-row {
  grid-template-columns: minmax(0, 1fr) 86px;
  min-height: 72px;
  padding: 12px 14px;
  border-top: 2px solid rgba(240, 219, 184, 0.78);
  background: rgba(255, 255, 255, 0.58);
}

.player-row.current-roller {
  background: white;
  box-shadow:
    inset 0 0 0 3px white,
    inset 0 0 0 6px rgba(255, 212, 90, 0.74),
    0 0 24px rgba(255, 212, 90, 0.54);
}

.player-row.banked-player {
  background: #ece4d7;
  opacity: 0.62;
}

.player-text strong {
  font-size: 1.12rem;
  font-weight: 1000;
}

.player-text span {
  color: #657080;
  font-size: 0.9rem;
  font-weight: 700;
}

.bank-button {
  min-height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #18a96f, #12b9b1);
  color: white;
  font-weight: 1000;
  box-shadow: 0 7px 0 rgba(6, 118, 100, 0.18);
}

.bank-button:disabled {
  background: #cfc7ba;
  color: #fff8ec;
}

.bottom-input {
  border-radius: 18px 18px 0 0;
  padding: 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 241, 189, 0.86)),
    var(--mock-cream);
}

.keypad {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.keypad-button {
  min-height: 56px;
  border-radius: 12px;
  background: white;
  color: var(--mock-ink);
  font-size: 1.04rem;
  font-weight: 1000;
  box-shadow:
    inset 0 0 0 2px #ffe3a3,
    0 7px 0 rgba(92, 57, 25, 0.11);
}

.keypad-button.good-key {
  background: linear-gradient(135deg, #1fb76e, #1cc299);
  color: white;
}

.keypad-button.danger-key {
  background: linear-gradient(135deg, var(--mock-red), #ff7567);
  color: white;
}

.keypad-button.unavailable-key {
  background: #e5ded2;
  color: #a89f91;
  box-shadow: inset 0 0 0 2px #d8cfc0;
}

.keypad-button.wide-key {
  grid-column: span 2;
}

.virtual-dice-stage {
  padding: 8px 8px 0;
}

.dice-pair {
  min-height: 128px;
}

.dice-face {
  width: min(100%, 124px);
  border-radius: 16px;
  background: linear-gradient(145deg, #ffffff, #fff7e6);
  box-shadow: 0 16px 24px rgba(59, 42, 25, 0.2);
}

.roll-button,
.start-button {
  border-radius: 12px;
  min-height: 84px;
}

.floating-effect {
  background: white;
  color: #0c8791;
}

.floating-effect.bank {
  background: linear-gradient(135deg, #7c5cff, #39a8ff);
}

.floating-effect.celebrate {
  background: linear-gradient(135deg, #ffd45a, #ffed9c);
}

.setup-screen {
  padding-bottom: 24px;
}

.hero-strip {
  padding-top: 12px;
}

.setup-card {
  padding: 15px;
}

.segmented-control button,
.secondary-button,
.remove-button {
  border-radius: 12px;
}

.segmented-control button {
  border: 2px solid #ffe3a3;
  box-shadow: 0 6px 0 rgba(92, 57, 25, 0.08);
}

.segmented-control button.selected {
  background: linear-gradient(135deg, var(--mock-coral), var(--mock-blue));
}

@keyframes soft-twinkle {
  0%,
  100% {
    opacity: 0.38;
    transform: scale(0.8) rotate(0deg);
  }

  50% {
    opacity: 1;
    transform: scale(1.15) rotate(20deg);
  }
}

@media (min-width: 640px) {
  .app-shell {
    width: min(100%, 520px);
    padding: 24px;
  }

  .keypad {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .keypad-button {
    min-height: 58px;
  }
}

/* Spec sheet exacting pass */
:root {
  --spec-header: #ff6868;
  --spec-main: #00796b;
  --spec-panel: #fffde7;
  --spec-active: #4caf50;
  --spec-dana: #b0bec5;
  --spec-inactive: #b0bec5;
  --spec-teal: #006064;
  --spec-red: #d32f2f;
  --spec-dark: #212121;
  --spec-glow: #00bcd4;
  --spec-shadow: 0 8px 18px rgba(80, 55, 20, 0.2);
}

html {
  background:
    radial-gradient(circle at 16% 18%, rgba(0, 188, 212, 0.12), transparent 28%),
    linear-gradient(180deg, #e9fbff 0%, #dff7ff 42%, #effcff 100%);
}

body {
  background-image:
    radial-gradient(circle, rgba(0, 96, 100, 0.08) 1px, transparent 1px);
  background-size: 16px 16px;
  color: var(--spec-dark);
}

.app-shell {
  width: min(100%, 430px);
  padding: 0 0 10px;
}

.game-screen {
  position: relative;
  overflow: hidden;
  border-radius: 0 0 18px 18px;
}

.game-header {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr) 70px;
  align-items: center;
  min-height: 122px;
  padding: 8px 14px 10px;
  border-radius: 0 0 0 0;
  background:
    radial-gradient(circle at 22% 68%, rgba(255, 255, 255, 0.12), transparent 20%),
    var(--spec-header);
  box-shadow: none;
}

.game-header > div:first-child {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  align-self: center;
}

.game-header .eyebrow {
  order: 0;
  margin: 0 0 8px;
  color: #6d1f1f;
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  font-size: 0.875rem;
  font-weight: 900;
  text-align: center;
  text-transform: none;
}

.game-header h1 {
  order: 1;
  margin: 0;
  color: #ffffff;
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 2.6rem;
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  -webkit-text-stroke: 3px var(--spec-main);
  text-shadow:
    0 4px 0 #004b43,
    0 6px 9px rgba(0, 0, 0, 0.22);
}

.game-header h1::before,
.game-header h1::after {
  content: "✦";
  display: inline-block;
  margin: 0 8px;
  color: #ffeb3b;
  font-size: 1rem;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.header-actions {
  display: contents;
}

.icon-button {
  position: absolute;
  top: 58px;
  display: grid;
  width: 54px;
  min-height: 54px;
  place-items: center;
  border: 3px solid rgba(0, 121, 107, 0.56);
  border-radius: 10px;
  background: var(--spec-panel);
  color: var(--spec-main);
  box-shadow: var(--spec-shadow);
}

.undo-icon,
.back-icon {
  left: 16px;
}

.menu-icon,
.game-rules-icon {
  right: 16px;
}

.game-rules-icon {
  position: absolute;
  top: 58px;
  border-radius: 10px;
}

.icon-button span {
  display: block;
  height: 22px;
  font-size: 1.55rem;
  font-weight: 1000;
  line-height: 1;
}

.icon-button small {
  color: var(--spec-dark);
  font-size: 0.55rem;
  font-weight: 1000;
  line-height: 1;
  text-transform: uppercase;
}

.bank-panel {
  margin: 22px 18px 16px;
  border: 3px solid #f2d46a;
  border-radius: 16px;
  padding: 34px 16px 18px;
  background:
    radial-gradient(circle at 86% 24%, rgba(255, 235, 59, 0.55), transparent 18%),
    var(--spec-panel);
  color: var(--spec-teal);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    0 6px 0 rgba(196, 146, 33, 0.22),
    var(--spec-shadow);
}

.bank-panel::before,
.bank-panel::after {
  content: "✦";
  z-index: 1;
  color: #fdd835;
  font-size: 1rem;
}

.bank-kicker {
  position: absolute;
  top: -18px;
  left: 50%;
  translate: -50% 0;
  border: 2px solid #00584f;
  border-radius: 999px;
  padding: 10px 20px;
  background: var(--spec-main);
  color: white;
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 0.95rem;
  font-weight: 1000;
  white-space: nowrap;
  box-shadow: 0 4px 0 rgba(0, 58, 51, 0.3);
}

.bank-panel strong {
  margin: 10px 0 4px;
  color: var(--spec-teal);
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: clamp(5rem, 25vw, 6.6rem);
  font-weight: 1000;
  line-height: 0.92;
  text-shadow:
    0 4px 0 #fff7cc,
    0 6px 5px rgba(0, 0, 0, 0.18);
}

.bank-panel p {
  min-height: 24px;
  color: var(--spec-teal);
  font-size: 1rem;
  font-weight: 900;
}

.floating-effect {
  border: 4px solid white;
  background: #00a4cf;
  color: white;
  font-size: 1.55rem;
  box-shadow:
    0 0 0 4px rgba(255, 235, 59, 0.55),
    0 0 24px rgba(255, 235, 59, 0.9),
    var(--spec-shadow);
}

.floating-effect.celebrate {
  background: #00a4cf;
  color: white;
}

.players-panel {
  margin: 0 10px 14px;
  border: 0;
  border-radius: 16px;
  background: var(--spec-panel);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    var(--spec-shadow);
}

.players-panel .section-heading {
  padding: 10px 16px 6px;
}

.players-panel h2 {
  color: var(--spec-teal);
  font-size: 1.75rem;
  font-weight: 1000;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sort-pill {
  min-height: 40px;
  border-radius: 999px;
  padding: 8px 17px 8px 12px;
  background: var(--spec-main);
  color: white;
  font-size: 0.8rem;
  text-transform: uppercase;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.2),
    0 4px 0 rgba(0, 70, 63, 0.28);
}

.sort-pill::before {
  content: "⟳";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 9px;
  font-size: 2.35em;
  line-height: 1;
  transform: translateY(-0.03em);
  vertical-align: middle;
}

.player-row {
  grid-template-columns: minmax(0, 1fr) 76px 84px;
  gap: 12px;
  min-height: 74px;
  margin: 0 10px;
  padding: 8px 8px 8px 14px;
  border: 1px solid rgba(0, 121, 107, 0.12);
  border-bottom: 0;
  background: rgba(255, 253, 231, 0.7);
}

.player-row:first-child {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.player-row:last-child {
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(0, 121, 107, 0.12);
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
}

.player-row.current-roller {
  position: relative;
  z-index: 2;
  background: #fffef7;
  box-shadow:
    0 0 0 3px var(--spec-glow),
    0 0 18px rgba(0, 188, 212, 0.95);
}

.player-row.banked-player {
  background: #eef0e7;
  opacity: 1;
}

.player-row.banked-player .player-text strong,
.player-row.banked-player .player-score {
  color: #90a4ae;
}

.player-name-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.player-text strong {
  color: var(--spec-teal);
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 1.55rem;
  font-weight: 1000;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leader-gap {
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 1000;
  line-height: 1;
}

.leader-gap.score-gap {
  color: #f12a2a;
}

.leader-gap.leader-crown {
  color: #d6a300;
  font-size: 1.5rem;
  line-height: 0.9;
}

.player-score {
  align-self: center;
  color: var(--spec-teal);
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 1.75rem;
  font-weight: 1000;
  text-align: right;
}

.bank-button {
  align-self: center;
  min-height: 48px;
  border-radius: 10px;
  background: linear-gradient(180deg, #66c95f, var(--spec-active));
  color: white;
  font-size: 1rem;
  font-weight: 1000;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.16),
    0 5px 0 #2f8d35;
}

.bank-button:disabled {
  background: linear-gradient(180deg, #c4c9cc, #a6adb2);
  color: white;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.18),
    0 5px 0 #838a8f;
}

.bottom-input {
  margin: 0;
  border: 0;
  border-radius: 16px 16px 0 0;
  padding: 18px 18px 0;
  background: rgba(216, 246, 255, 0.82);
  box-shadow: none;
}

.keypad {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.keypad-button {
  position: relative;
  min-height: 60px;
  border-radius: 10px;
  background: var(--spec-panel);
  color: var(--spec-teal);
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 1.95rem;
  font-weight: 1000;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.8),
    0 6px 0 rgba(60, 60, 60, 0.22);
}

.keypad-button.danger-key {
  background: linear-gradient(180deg, #ff2828, var(--spec-red));
  color: white;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.16),
    0 6px 0 #a31919;
}

.keypad-button.good-key {
  background: linear-gradient(180deg, #68c95a, var(--spec-active));
  color: white;
}

.keypad-button.unavailable-key {
  background: #eeeeea;
  color: #b0b0ae;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.65),
    0 6px 0 rgba(120, 120, 120, 0.18);
}

.keypad-button.wide-key {
  display: grid;
  gap: 2px;
  align-content: center;
  grid-column: span 3;
  font-size: 2rem;
  text-transform: uppercase;
}

.keypad-button.undo-key {
  background: var(--spec-panel);
  color: var(--spec-main);
  font-size: 2rem;
}

.keypad-button.undo-key:disabled {
  background: #eeeeea;
  color: #b0b0ae;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.65),
    0 6px 0 rgba(120, 120, 120, 0.18);
}

.keypad-button.wide-key::before {
  content: "★";
  position: absolute;
  left: 16px;
  top: 50%;
  translate: 0 -50%;
  color: #ffeb3b;
}

.keypad-button.wide-key::after {
  content: "★";
  position: absolute;
  right: 16px;
  top: 50%;
  translate: 0 -50%;
  color: #ffeb3b;
}

.keypad-button.wide-key small {
  display: block;
  font-size: 0.78rem;
  line-height: 1;
}

.rule-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px -18px 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--spec-main);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.74rem;
  font-weight: 900;
  text-align: center;
}

.rule-strip span:not(:last-child) {
  border-right: 1px solid rgba(255, 255, 255, 0.54);
}

@media (min-width: 640px) {
  .app-shell {
    width: min(100%, 430px);
    padding: 0 0 10px;
  }

  .keypad {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

/* Setup screen spec */
.setup-screen {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 10px 24px;
}

.setup-screen .hero-strip {
  display: grid;
  justify-items: center;
  padding: 0 0 10px;
}

.setup-screen .setup-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  width: min(100%, 398px);
  align-items: center;
  gap: 10px;
}

.setup-screen .hero-strip h1 {
  width: 100%;
  min-height: 68px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--spec-header);
  color: #ffffff;
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 2.55rem;
  font-weight: 1000;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  -webkit-text-stroke: 3px var(--spec-main);
  text-shadow:
    0 4px 0 #004b43,
    0 6px 9px rgba(0, 0, 0, 0.22);
  box-shadow: 0 8px 18px rgba(80, 55, 20, 0.18);
}

.setup-screen .hero-strip h1::before,
.setup-screen .hero-strip h1::after {
  content: "✦";
  display: inline-block;
  margin: 0 10px;
  color: #ffeb3b;
  font-size: 0.92rem;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.setup-screen .helper-copy {
  width: min(100%, 398px);
  margin: 8px 0 0;
  color: var(--spec-dark);
  font-size: 0.75rem;
  line-height: 1.25;
  text-align: left;
}

.setup-screen .rules-info-button {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  background: var(--spec-main);
  color: white;
  font-family: "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  font-size: 1.15rem;
  box-shadow: 0 5px 0 rgba(0, 70, 63, 0.26);
}

.setup-screen .setup-card {
  margin-bottom: 10px;
  border: 0;
  border-radius: 16px;
  padding: 13px;
  background: rgba(255, 253, 231, 0.96);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.9),
    var(--spec-shadow);
}

.setup-screen .section-heading {
  margin-bottom: 9px;
}

.setup-screen h2 {
  color: var(--spec-dark);
  font-size: 1rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.setup-screen .count-pill {
  min-height: 30px;
  min-width: 30px;
  padding: 5px 9px;
  background: var(--spec-main);
  color: white;
}

.setup-screen .field-label {
  margin-bottom: 5px;
  color: var(--spec-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

.setup-screen .input-row {
  grid-template-columns: minmax(0, 1fr) 62px;
  gap: 8px;
}

.setup-screen input {
  min-height: 38px;
  border: 2px solid var(--spec-main);
  border-radius: 8px;
  background: var(--spec-panel);
  color: var(--spec-dark);
  font-size: 16px;
}

.setup-screen .secondary-button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: var(--spec-main);
  color: white;
  font-size: 0.86rem;
  box-shadow: 0 4px 0 rgba(0, 70, 63, 0.22);
}

.setup-player-list {
  gap: 7px;
  margin-top: 12px;
}

.setup-player-row {
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  min-height: 38px;
  border-radius: 10px;
  padding: 0 4px 0 0;
  background: white;
  box-shadow:
    inset 0 0 0 1px rgba(0, 121, 107, 0.08),
    0 3px 8px rgba(80, 55, 20, 0.14);
}

.setup-player-row input {
  min-height: 38px;
  border: 0;
  background: transparent;
  font-weight: 800;
}

.setup-player-row .remove-button {
  align-self: center;
  width: 30px;
  min-height: 30px;
  border-radius: 999px;
  background: #b08ec5;
  color: white;
  font-size: 0.9rem;
  box-shadow: none;
}

.setup-screen .segmented-control {
  gap: 8px;
}

.setup-screen .segmented-control button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  background: white;
  color: var(--spec-dark);
  font-size: 0.9rem;
  font-weight: 1000;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.04),
    0 4px 9px rgba(80, 55, 20, 0.13);
}

.advanced-rules-card .section-heading {
  margin-bottom: 0;
}

.advanced-rules-card.rules-open .section-heading {
  margin-bottom: 9px;
}

.advanced-rules-heading h2 {
  width: 100%;
}

.advanced-rules-toggle {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--spec-dark);
  font-size: 1rem;
  font-weight: 1000;
  text-align: left;
  text-transform: uppercase;
}

.advanced-rules-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.advanced-rules-action-text {
  color: var(--spec-main);
  font-size: 0.78rem;
  font-weight: 1000;
}

.advanced-rules-chevron {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  background: var(--spec-main);
  color: white;
  font-size: 1.35rem;
  line-height: 1;
  transition: rotate 160ms ease;
}

.advanced-rules-card.rules-open .advanced-rules-chevron {
  rotate: 180deg;
}

.rule-toggle-list {
  display: grid;
  gap: 8px;
}

.rule-toggle-list[hidden] {
  display: none;
}

.rule-toggle-list button {
  display: grid;
  grid-template-columns: minmax(76px, 0.7fr) minmax(0, 1.2fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 54px;
  border-radius: 10px;
  padding: 9px 10px;
  background: white;
  color: var(--spec-dark);
  text-align: left;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.04),
    0 4px 9px rgba(80, 55, 20, 0.13);
}

.rule-toggle-list button strong {
  color: var(--spec-teal);
  font-size: 0.9rem;
  font-weight: 1000;
  text-transform: uppercase;
}

.rule-toggle-list button .rule-copy {
  color: #455a64;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.2;
}

.rule-state {
  display: grid;
  justify-items: center;
  gap: 3px;
}

.rule-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #cfd8dc;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.rule-switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.24);
  transition: translate 160ms ease;
}

.rule-state-text {
  color: #607d8b;
  font-size: 0.58rem;
  font-weight: 1000;
  letter-spacing: 0;
}

.rule-toggle-list button.selected {
  background: var(--spec-main);
  color: white;
  box-shadow:
    0 0 16px rgba(0, 188, 212, 0.72),
    0 5px 0 rgba(0, 70, 63, 0.26);
}

.rule-toggle-list button.selected strong,
.rule-toggle-list button.selected .rule-copy,
.rule-toggle-list button.selected .rule-state-text {
  color: white;
}

.rule-toggle-list button.selected .rule-switch {
  background: #64d36e;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24);
}

.rule-toggle-list button.selected .rule-switch::after {
  translate: 18px 0;
}

.setup-screen #roundLimitControls button.selected {
  background: var(--spec-main);
  color: white;
  box-shadow:
    0 0 16px rgba(0, 188, 212, 0.72),
    0 5px 0 rgba(0, 70, 63, 0.26);
}

.setup-screen #diceModeControls button.selected[data-dice-mode="physical"] {
  background: var(--spec-red);
  color: white;
  box-shadow: 0 5px 0 #9f2424;
}

.setup-screen #diceModeControls button.selected[data-dice-mode="virtual"] {
  background: var(--spec-main);
  color: white;
  box-shadow: 0 5px 0 rgba(0, 70, 63, 0.26);
}

.setup-screen .start-button {
  min-height: 48px;
  border-radius: 10px;
  background: var(--spec-main);
  color: white;
  font-size: 1.25rem;
  font-weight: 1000;
  box-shadow:
    0 0 12px rgba(0, 188, 212, 0.35),
    0 6px 0 rgba(0, 70, 63, 0.26);
}

/* Responsive frame invariants */
:root {
  --phone-frame: min(100vw, 430px);
}

.app-shell {
  width: var(--phone-frame);
  max-width: 430px;
  padding: 0;
}

.setup-screen,
.game-screen {
  width: 100%;
  max-width: 430px;
  margin-right: auto;
  margin-left: auto;
}

.setup-screen {
  padding-right: 10px;
  padding-left: 10px;
}

.setup-screen .setup-title-row,
.setup-screen .helper-copy {
  width: min(100%, 398px);
}

@media (max-width: 374px) {
  .game-header h1 {
    font-size: 2.35rem;
    -webkit-text-stroke-width: 2px;
  }

  .icon-button {
    width: 48px;
    min-height: 48px;
  }

  .bank-panel {
    margin-right: 12px;
    margin-left: 12px;
  }

  .bank-panel strong {
    font-size: clamp(4.6rem, 24vw, 5.8rem);
  }

  .players-panel {
    margin-right: 8px;
    margin-left: 8px;
  }

  .player-row {
    grid-template-columns: minmax(0, 1fr) 62px 76px;
    gap: 8px;
    margin-right: 8px;
    margin-left: 8px;
    padding-left: 10px;
  }

  .player-text strong {
    font-size: 1.35rem;
  }

  .player-score {
    font-size: 1.45rem;
  }

  .bank-button {
    font-size: 0.86rem;
  }

  .bottom-input {
    padding-right: 12px;
    padding-left: 12px;
  }

  .keypad {
    gap: 8px;
  }

  .keypad-button {
    min-height: 54px;
    font-size: 1.6rem;
  }

  .keypad-button.wide-key {
    font-size: 1.45rem;
  }

  .rule-strip {
    margin-right: -12px;
    margin-left: -12px;
    font-size: 0.68rem;
  }

  .rule-toggle-list button {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 5px 8px;
  }

  .rule-toggle-list button strong,
  .rule-toggle-list button .rule-copy {
    grid-column: 1;
  }

  .rule-toggle-list button .rule-state {
    grid-column: 2;
    grid-row: 1 / span 2;
  }
}

/* Compact one-screen game layout */
.app-shell:has(.game-screen:not(.hidden)) {
  height: 100svh;
  max-height: 100svh;
  padding: 0;
  overflow: visible;
}

.game-screen:not(.hidden) {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  height: 100svh;
  max-height: 100svh;
  min-height: 0;
  overflow: hidden;
}

.game-screen .game-header {
  min-height: 70px;
  padding: max(5px, env(safe-area-inset-top)) 10px 5px;
}

.game-screen .game-header .eyebrow {
  margin-bottom: 2px;
  font-size: 0.68rem;
}

.game-screen .game-header h1 {
  font-size: clamp(1.85rem, 9vw, 2.35rem);
  -webkit-text-stroke-width: 2px;
  text-shadow:
    0 3px 0 #004b43,
    0 4px 6px rgba(0, 0, 0, 0.2);
}

.game-screen .game-header h1::before,
.game-screen .game-header h1::after {
  margin: 0 5px;
  font-size: 0.72rem;
}

.game-screen .icon-button {
  top: max(18px, env(safe-area-inset-top));
  width: 42px;
  min-height: 42px;
  border-width: 2px;
}

.game-screen .icon-button span {
  height: 18px;
  font-size: 1.2rem;
}

.game-screen .icon-button small {
  display: none;
}

.game-screen .undo-icon,
.game-screen .back-icon {
  left: 10px;
}

.game-screen .menu-icon,
.game-screen .game-rules-icon {
  right: 10px;
}

.game-screen .game-rules-icon {
  top: max(18px, env(safe-area-inset-top));
  width: 42px;
  min-width: 42px;
  min-height: 42px;
  border-width: 2px;
  font-size: 1.15rem;
}

.game-screen .bank-panel {
  margin: 12px 12px 8px;
  padding: 18px 12px 8px;
  border-width: 2px;
  border-radius: 12px;
}

.game-screen .bank-kicker {
  top: -12px;
  padding: 6px 14px;
  font-size: 0.74rem;
  box-shadow: 0 3px 0 rgba(0, 58, 51, 0.24);
}

.game-screen .bank-panel strong {
  margin: 2px 0 0;
  font-size: clamp(3.35rem, 17vw, 4.8rem);
  line-height: 0.86;
}

.game-screen .bank-panel p {
  min-height: 18px;
  margin-bottom: 0;
  font-size: 0.78rem;
  line-height: 1.15;
}

.game-screen .players-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
  margin: 0 8px 8px;
  overflow: hidden;
  border-radius: 12px;
}

.game-screen .players-panel .section-heading {
  flex: 0 0 auto;
  margin-bottom: 0;
  padding: 4px 10px 2px;
}

.game-screen .players-panel h2 {
  font-size: 1.05rem;
}

.game-screen .sort-pill {
  min-height: 28px;
  padding: 3px 10px 3px 6px;
  font-size: 0.64rem;
}

.game-screen .sort-pill::before {
  margin-right: 7px;
  font-size: 2.75em;
  transform: translateY(-0.04em);
}

.game-screen .players-list {
  min-height: 0;
  padding-top: 3px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.game-screen .player-row {
  grid-template-columns: minmax(0, 1fr) 96px 99px;
  gap: 6px;
  min-height: 44px;
  margin: 0 6px;
  padding: 5px 6px 5px 9px;
}

.game-screen .player-row:last-child {
  margin-bottom: 6px;
}

.game-screen .player-text strong {
  font-size: 1rem;
  line-height: 1;
}

.game-screen .leader-gap {
  font-size: 0.82rem;
}

.game-screen .leader-gap.score-gap {
  color: #f12a2a;
}

.game-screen .leader-gap.leader-crown {
  font-size: 1.85rem;
}

.game-screen .player-score {
  font-size: 1.12rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.game-screen .bank-button {
  min-height: 32px;
  border-radius: 8px;
  font-size: 0.78rem;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.16),
    0 3px 0 #2f8d35;
}

.game-screen .bank-button:disabled {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.18),
    0 3px 0 #838a8f;
}

.game-screen .bottom-input {
  padding: 8px 10px 0;
  border-radius: 12px 12px 0 0;
}

.game-screen .keypad {
  gap: 6px;
}

.game-screen .keypad-button {
  min-height: 72px;
  border-radius: 8px;
  font-size: 1.28rem;
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.78),
    0 3px 0 rgba(60, 60, 60, 0.2);
}

.game-screen .keypad-button.wide-key {
  gap: 0;
  font-size: 1.14rem;
}

.game-screen .keypad-button.undo-key {
  font-size: 1.5rem;
}

.game-screen .keypad-button.wide-key::before,
.game-screen .keypad-button.wide-key::after {
  display: none;
}

.game-screen .keypad-button.wide-key small {
  font-size: 0.58rem;
}

.game-screen .rule-strip {
  gap: 5px;
  margin: 8px -10px 0;
  padding: 7px 8px calc(22px + env(safe-area-inset-bottom));
  font-size: 0.56rem;
  line-height: 1.15;
}

@media (max-height: 700px) {
  .game-screen .game-header {
    min-height: 58px;
    padding-bottom: 3px;
  }

  .game-screen .game-header h1 {
    font-size: clamp(1.6rem, 8vw, 2rem);
  }

  .game-screen .bank-panel {
    margin-top: 8px;
    margin-bottom: 6px;
    padding-top: 15px;
  }

  .game-screen .bank-panel strong {
    font-size: clamp(2.95rem, 15vw, 4.2rem);
  }

  .game-screen .player-row {
    min-height: 38px;
  }

  .game-screen .bottom-input {
    padding-top: 6px;
  }

  .game-screen .keypad-button {
    min-height: 62px;
    font-size: 1.12rem;
  }

  .game-screen .rule-strip {
    margin-top: 6px;
    padding-top: 5px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }
}
