:root {
  color-scheme: light;
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  color: #24312b;
  background: #f3efe3;
  font-synthesis: none;
  --app-background: #f6f3e7;
  --surface: #fffdf7;
  --surface-muted: #faf7ee;
  --border: #e5dfce;
  --text-muted: #6f726d;
  --primary: #08733e;
  --primary-dark: #075c34;
  --danger: #ff6b6b;
  --header-height: 4.5rem;
  --content-width: 1240px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 50% 10%, rgb(255 255 255 / 80%), transparent 32rem),
    var(--app-background);
}

.app-header {
  position: relative;
  z-index: 100;
  min-height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: rgb(246 243 231 / 94%);
}

.app-header__inner {
  display: flex;
  width: min(100%, var(--content-width));
  min-height: calc(var(--header-height) - 1px);
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2.5rem);
}

.brand {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
}

.brand__mark {
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand__copy {
  display: grid;
  min-width: 0;
  gap: 0.05rem;
}

.brand__name {
  color: #676766;
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  line-height: 1.05;
}

.brand__tagline {
  overflow: hidden;
  color: #777975;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header__actions {
  display: flex;
  flex: 0 0 auto;
}

.icon-button,
.dialog-close {
  display: grid;
  width: 2.6rem;
  min-height: 2.6rem;
  padding: 0;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  color: #5f695f;
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}

.icon-button svg {
  width: 1.45rem;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.icon-button:focus-visible,
.dialog-close:focus-visible,
.menu-action:focus-visible,
.secondary-button:focus-visible,
.danger-button:focus-visible {
  outline: 3px solid rgb(8 115 62 / 30%);
  outline-offset: 2px;
}

.page-shell {
  width: min(100%, var(--content-width));
  margin-inline: auto;
  padding: clamp(1rem, 4vw, 2.5rem);
}

html[data-app-phase="first-player-roll"] .app-header,
html[data-app-phase="game"] .app-header {
  display: none;
}

.orientation-guard {
  display: none;
}

[hidden] {
  display: none !important;
}

h1,
p {
  margin-top: 0;
}

.flow-screen {
  width: 100%;
}

.setup-screen,
.first-roll-screen {
  display: grid;
  min-height: calc(100vh - var(--header-height) - 5rem);
  place-items: center;
}

.flow-card {
  width: min(100%, 46rem);
  padding: clamp(1.2rem, 4vw, 2rem);
}

.flow-card--compact {
  width: min(100%, 32rem);
  text-align: center;
}

.flow-card h1 {
  margin: 0;
}

.setup-heading {
  margin-bottom: 0.85rem;
}

.setup-heading h1 {
  color: #111;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 900;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.flow-intro {
  margin: 0.55rem 0 1.4rem;
  color: #626b64;
}

.player-count {
  display: grid;
  gap: 0.45rem;
  margin: 0 0 0.9rem;
}

.player-count__label {
  color: #171717;
  font-size: 0.84rem;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.8rem;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
}

.segmented-control span {
  display: grid;
  width: 100%;
  min-height: 3rem;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  color: #111;
  background: var(--surface);
  cursor: pointer;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: 0 1px 2px rgb(45 42 31 / 5%);
}

.segmented-control input:checked + span {
  border-color: var(--primary);
  color: white;
  background: var(--primary);
}

.segmented-control input:focus-visible + span {
  outline: 3px solid rgb(47 113 80 / 35%);
  outline-offset: 2px;
}

.player-settings {
  display: grid;
  gap: 0.7rem;
}

.player-setting {
  display: grid;
  grid-template-columns: 2rem minmax(8rem, 1fr) auto auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(45 42 31 / 5%);
}

.player-setting__number {
  display: grid;
  width: 1.9rem;
  min-height: 1.9rem;
  place-items: center;
  border-radius: 0.35rem;
  color: #747a73;
  background: #f0ede4;
  font-weight: 900;
}

.field-label {
  display: grid;
  gap: 0.25rem;
  color: #687169;
  font-size: 0.72rem;
  font-weight: 700;
}

.field-label input,
.field-label select {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid #c9c1ad;
  border-radius: 0.55rem;
  color: #24312b;
  background: white;
  font: inherit;
  font-size: 0.9rem;
}

.player-setting__name input {
  min-height: 2rem;
  border-color: var(--border);
  border-radius: 0.35rem;
  color: #111;
  font-size: 0.92rem;
  font-weight: 750;
}

.type-options {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  background: #fbfaf4;
}

.type-option input {
  position: absolute;
  opacity: 0;
}

.type-option span {
  display: grid;
  min-height: 1.8rem;
  padding-inline: 0.7rem;
  place-items: center;
  border-radius: 0.45rem;
  color: #8b8a83;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.type-option input:checked + span {
  color: white;
  background: var(--primary);
}

.type-option input:focus-visible + span {
  outline: 3px solid rgb(8 115 62 / 30%);
  outline-offset: 1px;
}

.color-options {
  display: flex;
  min-height: 2.5rem;
  align-items: center;
  gap: 0.45rem;
}

.color-option {
  display: grid;
  cursor: pointer;
  place-items: center;
}

.color-option input {
  position: absolute;
  width: 1px;
  min-height: 0;
  padding: 0;
  border: 0;
  opacity: 0;
}

.color-option__piece {
  width: 1.65rem;
  aspect-ratio: 1;
  border: 2px solid color-mix(in srgb, var(--option-color), #27362e 22%);
  border-radius: 50%;
  background: var(--option-color);
  box-shadow: inset 0 0.28rem 0.35rem rgb(255 255 255 / 28%), 0 0.12rem 0.22rem rgb(36 49 43 / 18%);
  opacity: 0.46;
  transition: opacity 120ms ease, transform 120ms ease;
}

.color-option:hover .color-option__piece,
.color-option input:focus-visible + .color-option__piece {
  opacity: 0.6;
}

.color-option input:checked + .color-option__piece {
  opacity: 1;
  transform: scale(1.08);
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 3px #26332d,
    inset 0 0.28rem 0.35rem rgb(255 255 255 / 28%);
}

.color-option input:focus-visible + .color-option__piece {
  outline: 3px solid rgb(47 113 80 / 35%);
  outline-offset: 2px;
}

.primary-button,
.secondary-button {
  min-height: 2.65rem;
  padding: 0.55rem 1rem;
  border-radius: 0.65rem;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--primary-dark);
  color: white;
  background: var(--primary);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  display: grid;
  place-items: center;
  border: 1px solid #bdb49e;
  color: #34443b;
  background: #fffdf7;
  text-align: center;
  text-decoration: none;
}

.form-error {
  min-height: 1.2em;
  margin: 0.65rem 0 0;
  color: #9b3f36;
  font-size: 0.8rem;
}

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

.game-menu {
  width: min(18.75rem, calc(100% - 2rem));
  max-width: none;
  padding: 0;
  overflow: visible;
  border: 1px solid #b8b09a;
  border-radius: 1.15rem;
  color: #111;
  background: var(--surface);
  box-shadow: 0 1.5rem 4rem rgb(45 42 31 / 24%);
}

.game-menu::backdrop,
.rules-dialog::backdrop,
.victory-overlay::backdrop {
  background: rgb(36 49 43 / 48%);
  backdrop-filter: blur(6px);
}

.game-menu__panel {
  position: relative;
  min-height: 12.25rem;
  padding: 4.1rem 1rem 1.45rem;
}

.dialog-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  width: 2.5rem;
  min-height: 2.5rem;
  color: #111;
  font-size: 1.5rem;
  line-height: 1;
}

.game-menu__actions {
  display: grid;
  gap: 1rem;
}

.menu-action {
  display: flex;
  width: 100%;
  min-height: 2.7rem;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  color: #111;
  background: var(--surface);
  box-shadow: 0 1px 2px rgb(45 42 31 / 5%);
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
}

.menu-action svg {
  width: 1.15rem;
  fill: none;
  stroke: #547487;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.new-game-confirmation {
  display: grid;
  gap: 1.8rem;
}

.new-game-confirmation p {
  margin: 0;
  font-size: 1rem;
  text-align: center;
}

.danger-button {
  min-height: 2.75rem;
  border: 0;
  border-radius: 0.65rem;
  color: #111;
  background: var(--danger);
  font: inherit;
  font-size: 1.2rem;
  cursor: pointer;
}

.rules-dialog {
  width: min(42rem, calc(100% - 2rem));
  height: min(42rem, calc(100dvh - 2rem));
  max-width: none;
  max-height: none;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d7d0bd;
  border-radius: 1.2rem;
  color: #24312b;
  background: #fffdf7;
  box-shadow: 0 1.5rem 4rem rgb(24 34 28 / 28%);
}

.rules-dialog__panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100%;
}

.rules-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 1.3rem 1rem;
  border-bottom: 1px solid #e4dece;
}

.rules-dialog__header h2 {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.7rem);
  line-height: 1.15;
}

.rules-dialog__close,
.rules-dialog__arrow {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid #c9c1ad;
  color: #34443b;
  background: #fffdf7;
  font: inherit;
  cursor: pointer;
}

.rules-dialog__content {
  overflow-y: auto;
  padding: 1.2rem 1.3rem;
  font-size: 0.98rem;
  line-height: 1.55;
  overscroll-behavior: contain;
}

.rules-dialog__content h3 {
  margin: 1.35rem 0 0.55rem;
  font-size: 1.05rem;
}

.rules-dialog__content p,
.rules-dialog__content ul,
.rules-dialog__content ol {
  margin: 0 0 0.9rem;
}

.rules-dialog__content ul,
.rules-dialog__content ol {
  padding-left: 1.4rem;
}

.rules-dialog__content li + li {
  margin-top: 0.35rem;
}

.rules-dialog__content code {
  padding: 0.08rem 0.3rem;
  border-radius: 0.3rem;
  color: #5f481f;
  background: #f4eddb;
  font-size: 0.92em;
}

.rules-dialog__footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.3rem 1rem;
  border-top: 1px solid #e4dece;
}

.rules-dialog__arrow {
  width: 2.75rem;
  aspect-ratio: 1;
  border-radius: 0.7rem;
  font-size: 1.25rem;
  font-weight: 800;
}

.rules-dialog__close:hover,
.rules-dialog__arrow:hover:not(:disabled) {
  background: #f5f1e8;
}

.rules-dialog__close:focus-visible,
.rules-dialog__arrow:focus-visible,
.rules-dialog__content:focus-visible {
  outline: 3px solid rgb(47 113 80 / 35%);
  outline-offset: -3px;
}

.rules-dialog__arrow:disabled {
  cursor: default;
  opacity: 0.35;
}

.rules-dialog__progress {
  color: #687169;
  font-size: 0.82rem;
  font-weight: 750;
  text-align: center;
}

.first-roll-die {
  margin: 0 auto 1rem;
}

.roll-results {
  display: grid;
  gap: 0.45rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
}

.roll-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 2.6rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid #ded7c5;
  border-radius: 0.65rem;
  background: #faf7ee;
}

.roll-result--current {
  border-color: var(--player-color);
  box-shadow: inset 4px 0 var(--player-color);
}

.physical-die.roll-result__die {
  width: 1.9rem;
  flex: 0 0 auto;
  padding: 0.28rem;
  border-width: 2px;
  border-radius: 0.45rem;
}

.roll-result__die .physical-die__pip {
  width: 0.32rem;
  box-shadow: none;
}

.roll-result__die .physical-die__placeholder {
  font-size: 1rem;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 13rem;
  align-items: start;
  gap: 1rem;
}

@media (min-width: 981px) {
  .game-layout {
    width: min(100%, calc(100dvh + 9rem));
    margin-inline: auto;
  }
}

.dice-panel.dice-panel--top {
  display: none;
}

.board-shell {
  position: relative;
  grid-column: 1;
  width: min(100%, calc(100dvh - 5rem));
  justify-self: center;
  padding: clamp(0.35rem, 1.4vw, 0.75rem);
  border: 1px solid #d7d0bd;
  border-radius: clamp(0.8rem, 3vw, 1.4rem);
  background: #fffdf7;
  box-shadow: 0 1.2rem 3rem rgb(53 48 34 / 12%);
}

.board-stage {
  position: relative;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  width: 100%;
  aspect-ratio: 1;
}

.board-menu-button {
  position: absolute;
  z-index: 20;
  top: 0;
  right: 0.5rem;
  display: grid;
  width: clamp(2.25rem, 6.6667%, 3rem);
  aspect-ratio: 1;
  padding: 0.3rem;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}

.board-menu-button img {
  display: block;
  width: 90%;
  height: 90%;
  object-fit: contain;
  transform: rotate(45deg);
}

.board-menu-button:focus-visible {
  outline: 3px solid rgb(8 115 62 / 30%);
  outline-offset: 1px;
}

@media (min-width: 981px) {
  .board-menu-button {
    top: 0.75rem;
    right: 0.75rem;
  }
}

.board {
  position: relative;
  display: grid;
  grid-column: 2 / span 13;
  grid-row: 2 / span 13;
  grid-template-columns: repeat(13, 1fr);
  grid-template-rows: repeat(13, 1fr);
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 0.5rem;
  background:
    linear-gradient(#dce3d9 1px, transparent 1px),
    linear-gradient(90deg, #dce3d9 1px, transparent 1px),
    #edf1e8;
  background-size: calc(100% / 13) calc(100% / 13);
}

.board__connections {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.rainbow-link,
.rainbow-link__hit-area {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

.rainbow-link {
  outline: none;
  touch-action: manipulation;
}

.rainbow-link__highlight {
  opacity: 0;
}

.rainbow-link--valid-destination .rainbow-link__hit-area {
  pointer-events: stroke;
  cursor: pointer;
  touch-action: manipulation;
}

.rainbow-link--valid-destination .rainbow-link__highlight {
  opacity: 0.46;
}

.rainbow-link--valid-destination:focus-visible .rainbow-link__highlight {
  stroke: #fff36a;
  opacity: 0.5;
}

.board__sun {
  z-index: 1;
  display: grid;
  grid-column: 6 / span 3;
  grid-row: 6 / span 3;
  place-items: center;
  margin: 8%;
  border: clamp(2px, 0.45vw, 5px) solid #efac31;
  border-radius: 50%;
  color: #865919;
  background: repeating-conic-gradient(#ffd75b 0 12deg, #ffc43a 12deg 24deg);
  box-shadow: 0 0 0 0.35rem rgb(255 216 91 / 22%);
  font-size: clamp(0.48rem, 1.7vw, 0.88rem);
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.board__pieces {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.board__badges {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  grid-template-rows: repeat(15, 1fr);
  overflow: visible;
  pointer-events: none;
}

.cell-action-badge-anchor {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.player-name {
  position: absolute;
  z-index: 2;
  width: 25%;
  translate: -50% -50%;
  rotate: var(--player-name-rotation);
  color: #26332d;
  font-size: clamp(0.5rem, 1.55vw, 0.95rem);
  font-weight: 400;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.player-name--active {
  font-weight: 900;
}

.player-name__content {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 0.45em;
}

.player-name__roll {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 1.75em;
  aspect-ratio: 1;
  padding: 0.22em;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--player-color), #26332d 24%);
  border-radius: 0.4em;
  color: color-mix(in srgb, var(--player-color), #26332d 34%);
  background: #fffdf7;
  box-shadow: 0 1px 2px rgb(38 51 45 / 14%);
  font-size: 0.95em;
  font-weight: 900;
}

.player-name__roll-pip {
  width: 0.3em;
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background: currentcolor;
}

.player-name__roll-placeholder {
  grid-area: 1 / 1 / 4 / 4;
  place-self: center;
}

.player-name--first-roll-inactive {
  opacity: 0.48;
}

.player-name--first-roll-winner .player-name__roll {
  color: white;
  background: var(--player-color);
}

.player-auto {
  position: absolute;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  translate: -50% -50%;
  rotate: var(--player-auto-rotation);
  color: #26332d;
  font-size: clamp(0.5rem, 1.27vw, 0.78rem);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  pointer-events: auto;
  cursor: pointer;
}

.player-auto__input {
  position: relative;
  width: 1.65em;
  height: 0.9em;
  margin: 0;
  appearance: none;
  border: 1px solid rgb(38 51 45 / 42%);
  border-radius: 999px;
  background: rgb(38 51 45 / 16%);
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.player-auto__input::before {
  position: absolute;
  width: 0.62em;
  height: 0.62em;
  inset: 50% auto auto 0.1em;
  translate: 0 -50%;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 24%);
  content: "";
  transition: translate 140ms ease;
}

.player-auto__input:checked {
  border-color: color-mix(in srgb, var(--player-color), #26332d 18%);
  background: var(--player-color);
}

.player-auto__input:checked::before {
  translate: 0.72em -50%;
}

.player-auto__input:focus-visible {
  outline: 2px solid #26332d;
  outline-offset: 2px;
}

.player-name__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-name__status {
  position: absolute;
  right: calc(100% + 0.35em);
}

.piece-slot {
  position: absolute;
  width: var(--piece-size);
  aspect-ratio: 1;
  translate: -50% -50%;
  border: clamp(1px, 0.2vw, 2px) dashed color-mix(in srgb, var(--slot-color), #48534d 24%);
  border-radius: 50%;
  background: color-mix(in srgb, var(--slot-color) 10%, transparent);
}

.piece {
  position: absolute;
  display: grid;
  width: var(--piece-size);
  aspect-ratio: 1;
  translate: -50% -50%;
  place-items: center;
  border: clamp(1px, 0.25vw, 3px) solid rgb(255 255 255 / 92%);
  border-radius: 50%;
  color: white;
  background: var(--piece-color);
  box-shadow:
    0 0.12rem 0.24rem rgb(22 27 24 / 35%),
    inset 0 -0.18rem 0 rgb(0 0 0 / 16%);
  font-size: clamp(0.4rem, 1.45vw, 0.78rem);
  font-weight: 850;
  line-height: 1;
}

.piece--outside {
  opacity: 0.72;
}

.piece--sun {
  width: var(--sun-piece-size);
}

.piece--finished {
  box-shadow:
    0 0 0 clamp(1px, 0.18vw, 2px) #fff2a8,
    0 0.12rem 0.24rem rgb(22 27 24 / 35%);
}

.piece--valid-action {
  pointer-events: auto;
  cursor: pointer;
  outline: clamp(3px, 0.5vw, 5px) solid #fff36a;
  outline-offset: clamp(1px, 0.2vw, 3px);
  box-shadow:
    0 0 0 clamp(5px, 0.8vw, 8px) rgb(235 182 20 / 55%),
    0 0.12rem 0.24rem rgb(22 27 24 / 35%);
}

.piece--valid-action:hover,
.piece--valid-action:focus-visible {
  filter: brightness(1.08);
}

.piece--selected,
.piece--moving {
  z-index: 5;
}

.piece--selected {
  outline: clamp(3px, 0.5vw, 5px) solid #fff;
  outline-offset: clamp(1px, 0.2vw, 3px);
  box-shadow:
    0 0 0 clamp(6px, 0.9vw, 9px) rgb(43 105 190 / 70%),
    0 0.12rem 0.24rem rgb(22 27 24 / 35%);
}

.piece--swamp-shifting {
  z-index: 4;
}

.piece--being-captured,
.piece--being-released {
  z-index: 6;
}

.piece--teleporting {
  z-index: 5;
  outline: none;
  box-shadow: none;
}

.cell {
  position: relative;
  z-index: 2;
  display: grid;
  place-items: center;
  min-width: 0;
  margin: clamp(1px, 0.22vw, 3px);
  border: 1px solid rgb(35 51 43 / 30%);
  border-radius: clamp(3px, 0.65vw, 8px);
  color: #26332d;
  background: #fffdf8;
  box-shadow: inset 0 -2px 0 rgb(0 0 0 / 7%);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(0.34rem, 1.35vw, 0.72rem);
  font-weight: 750;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
}

.cell--player-hint {
  font-family: inherit;
  font-size: clamp(0.58rem, 2vw, 1rem);
  font-weight: 900;
}

.cell--side-oriented-label .cell__label {
  display: inline-block;
  transform: rotate(var(--cell-label-rotation));
}

.cell--side-a {
  --side-color: var(--side-a-color, #a6aea9);
  --cell-label-rotation: 180deg;
}

.cell--side-b {
  --side-color: var(--side-b-color, #a6aea9);
  --cell-label-rotation: -90deg;
}

.cell--side-c {
  --side-color: var(--side-c-color, #a6aea9);
  --cell-label-rotation: 0deg;
}

.cell--side-d {
  --side-color: var(--side-d-color, #a6aea9);
  --cell-label-rotation: 90deg;
}

.cell--main {
  border-color: color-mix(in srgb, var(--side-color), #27362e 24%);
  background: color-mix(in srgb, var(--side-color) 25%, white);
}

.cell--start {
  outline: clamp(1px, 0.3vw, 3px) solid var(--side-color);
  outline-offset: -3px;
  background: color-mix(in srgb, var(--side-color) 48%, white);
}

.cell--home {
  border-radius: 50%;
  border-color: color-mix(in srgb, var(--side-color), #27362e 20%);
  color: #fff;
  background: color-mix(in srgb, var(--side-color) 58%, white);
  font-family: inherit;
  font-size: clamp(0.58rem, 2vw, 1rem);
  font-weight: 900;
}

.cell--swamp,
.cell--swamp-endpoint {
  border-color: #8a6542;
  color: #3f3024;
  background: #c8a46b;
}

.cell--rainbow {
  background: linear-gradient(135deg, #ef6e77 0 25%, #f4ca52 25% 50%, #73bd83 50% 75%, #6d91d0 75%);
  text-shadow: 0 1px 0 rgb(255 255 255 / 80%);
}

.cell--valid-destination {
  cursor: pointer;
  outline: clamp(3px, 0.5vw, 5px) solid #fff36a;
  outline-offset: clamp(1px, 0.18vw, 2px);
  box-shadow:
    0 0 0 clamp(5px, 0.75vw, 7px) rgb(235 182 20 / 50%),
    inset 0 -2px 0 rgb(0 0 0 / 7%);
}

.cell--valid-destination:hover,
.cell--valid-destination:focus-visible {
  filter: brightness(1.08);
}

.cell-action-badge {
  position: absolute;
  z-index: 4;
  top: 0;
  right: 0;
  display: flex;
  min-height: clamp(0.9rem, 2.4vw, 1.25rem);
  padding: clamp(1px, 0.18vw, 2px);
  translate: 0 calc(-100% - 2px);
  gap: clamp(1px, 0.15vw, 2px);
  place-items: center;
  border: 1px solid rgb(255 255 255 / 92%);
  border-radius: 999px;
  color: #473b10;
  background: #fff36a;
  box-shadow: 0 0.08rem 0.2rem rgb(22 27 24 / 35%);
  pointer-events: none;
}

.cell-action-badge--multiplier {
  display: grid;
  min-width: clamp(0.9rem, 2.4vw, 1.25rem);
  padding-inline: 0.18em;
  font-size: clamp(0.48rem, 1.25vw, 0.68rem);
  font-weight: 900;
  line-height: 1;
}

.cell-action-badge__die {
  display: grid;
  width: clamp(0.7rem, 1.7vw, 0.95rem);
  aspect-ratio: 1;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: clamp(1px, 0.12vw, 2px);
  border-radius: clamp(2px, 0.25vw, 4px);
  background: #fffdf8;
}

.cell-action-badge__pip {
  width: clamp(1.5px, 0.22vw, 3px);
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background: #473b10;
}

.cell--valid-destination[data-action-count="2"] {
  outline-color: #fff69a;
  box-shadow:
    0 0 0 clamp(5px, 0.75vw, 7px) rgb(235 190 50 / 42%),
    inset 0 -2px 0 rgb(0 0 0 / 7%);
}

.cell--valid-destination[data-action-count="3"] {
  outline-color: #fff9bc;
  box-shadow:
    0 0 0 clamp(5px, 0.75vw, 7px) rgb(235 202 91 / 34%),
    inset 0 -2px 0 rgb(0 0 0 / 7%);
}

.cell--valid-destination[data-action-count="4"] {
  outline-color: #fffcdc;
  box-shadow:
    0 0 0 clamp(5px, 0.75vw, 7px) rgb(235 216 142 / 28%),
    inset 0 -2px 0 rgb(0 0 0 / 7%);
}

.dice-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.dice-panel *,
.physical-dice * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.dice-panel--bottom {
  grid-column: 2;
}

.dice-panel--first-roll-inactive .physical-dice,
.dice-panel--first-roll-inactive .turn-status {
  visibility: hidden;
}

.dice-panel--first-roll .physical-die {
  border-color: color-mix(in srgb, var(--dice-owner-color), #26332d 18%);
  color: color-mix(in srgb, var(--dice-owner-color), #26332d 22%);
}

.physical-dice {
  display: flex;
  justify-content: center;
  gap: 0.7rem;
  padding: 0.25rem;
  border: 0;
  border-radius: 0.8rem;
  color: inherit;
  background: transparent;
  font: inherit;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.physical-dice:hover:not(:disabled) .physical-die {
  transform: translateY(-2px);
}

.physical-dice:focus-visible {
  outline: 3px solid rgb(47 113 80 / 45%);
  outline-offset: 3px;
}

.physical-dice:disabled {
  cursor: default;
}

.physical-dice--double {
  display: grid;
  grid-template-columns: repeat(2, 3.2rem);
  gap: 0.4rem;
}

.physical-dice--double .physical-die {
  width: 3.2rem;
}

.physical-die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 3.8rem;
  aspect-ratio: 1;
  padding: 0.55rem;
  border: 3px solid #b9ae91;
  border-radius: 0.8rem;
  color: #29362f;
  background: white;
  box-shadow: inset 0 -0.2rem 0 rgb(0 0 0 / 8%);
  pointer-events: none;
}

.physical-die__pip {
  width: 0.62rem;
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background: currentcolor;
  box-shadow: inset 0 -0.08rem 0 rgb(0 0 0 / 22%);
}

.physical-die__placeholder {
  grid-area: 1 / 1 / 4 / 4;
  place-self: center;
  font-size: 1.8rem;
  font-weight: 900;
}

.physical-die--not-rolled {
  color: #aaa394;
  background: #f5f1e8;
}

.physical-die--active {
  border-color: #d9a514;
  background: #fff36a;
  box-shadow: 0 0 0 4px rgb(217 165 20 / 24%), inset 0 -0.2rem 0 rgb(0 0 0 / 8%);
}

.physical-die--used {
  opacity: 0.42;
}

.physical-die--burned {
  border-style: dashed;
  color: #8b554d;
  background: #eadbd5;
  opacity: 0.72;
}

.physical-die--rolling {
  animation: dice-roll-wobble 420ms ease-in-out infinite;
  border-color: #8e9e93;
  background: #fff;
}

.physical-die--rolling:nth-child(even) {
  animation-direction: reverse;
}

.dice-panel--current .physical-die {
  border-color: color-mix(in srgb, var(--dice-owner-color), #26332d 18%);
  color: color-mix(in srgb, var(--dice-owner-color), #26332d 22%);
}

@keyframes dice-roll-wobble {
  0%, 100% {
    transform: rotate(0deg) scale(1);
  }

  25% {
    transform: rotate(9deg) scale(0.94);
  }

  58% {
    transform: rotate(-10deg) scale(1.04);
  }

  82% {
    transform: rotate(5deg) scale(0.97);
  }
}

.turn-status {
  margin: 0;
  text-align: center;
}

.turn-status {
  min-height: 2.5em;
  color: #626b64;
  font-size: 0.78rem;
}

.victory-overlay {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  inset: 0;
  padding: 8%;
  overflow: auto;
  border: 0;
  color: #203329;
  background: transparent;
}

.victory-overlay__panel {
  position: relative;
  display: grid;
  width: min(100%, 26rem);
  place-items: center;
  gap: 0.75rem;
  padding: clamp(1rem, 5vw, 2rem);
  border-radius: 1rem;
  color: #203329;
  background: rgb(255 253 247 / 94%);
  box-shadow: 0 1rem 3rem rgb(24 34 28 / 25%);
  font-size: clamp(1.15rem, 4vw, 2rem);
  font-weight: 900;
  text-align: center;
}

.victory-overlay__close {
  top: 0.55rem;
  right: 0.55rem;
  border-color: transparent;
  background: transparent;
}

.victory-overlay[open] {
  display: grid;
  place-items: center;
}

.victory-overlay__trophy {
  font-size: clamp(5rem, 20vw, 9rem);
  line-height: 1;
}

.victory-overlay__message {
  margin: 0;
}

.victory-overlay__actions {
  display: grid;
  width: min(100%, 18rem);
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.victory-overlay__actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.victory-overlay__actions svg {
  width: 1.15rem;
  fill: none;
  stroke: currentcolor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.victory-overlay__actions .primary-button {
  margin-top: 0;
}

.rule-debug {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px dashed #b9ae91;
  border-radius: 0.7rem;
  color: #556159;
  background: rgb(255 253 247 / 72%);
  font-size: 0.8rem;
}

.rule-debug summary {
  cursor: pointer;
  font-weight: 700;
}

.rule-debug__controls {
  display: grid;
  grid-template-columns: max-content minmax(10rem, 1fr);
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.rule-debug__controls select,
.rule-debug__controls button {
  min-height: 2rem;
  font: inherit;
}

.dice-inputs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.dice-inputs select {
  width: 3rem;
}

.rule-debug output {
  grid-column: 1 / -1;
  overflow-wrap: anywhere;
}

@media (max-width: 980px) {
  .game-layout {
    position: relative;
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto auto auto minmax(0, 1fr);
    min-height: calc(100dvh - 2 * clamp(1rem, 4vw, 2.5rem));
    gap: 0.35rem;
  }

  .dice-panel {
    position: static;
    width: 100%;
    block-size: 7.5rem;
    padding: 0.35rem 1rem;
    opacity: 0.46;
  }

  .dice-panel .physical-dice {
    position: relative;
    z-index: 1;
    inline-size: 100%;
    block-size: 4.3rem;
    align-items: center;
  }

  .dice-panel.dice-panel--top {
    display: grid;
    grid-row: 2;
  }

  .dice-panel--top .turn-status {
    grid-row: 1;
  }

  .dice-panel--top .physical-dice {
    grid-row: 2;
  }

  .board-shell {
    grid-row: 3;
    width: min(
      100%,
      44rem,
      calc(100dvh - 2 * clamp(1rem, 4vw, 2.5rem) - 16.5rem)
    );
    margin-inline: auto;
  }

  .dice-panel--bottom {
    grid-column: 1;
    grid-row: 4;
  }

  .dice-panel--current {
    opacity: 1;
  }

  .turn-status--hidden {
    visibility: hidden;
  }

  .dice-panel--caption-inverted .turn-status {
    transform: rotate(180deg);
  }

  .physical-dice--double {
    grid-template-columns: repeat(4, minmax(2.7rem, 3.2rem));
    align-content: center;
  }
}

@media (max-width: 760px) {
  .setup-screen {
    min-height: 0;
    place-items: start center;
  }

  #game-screen[data-player-count="2"] .board-shell {
    width: calc(100% + 0.6rem);
    max-width: none;
    overflow: hidden;
    margin-inline: -0.3rem;
    padding-inline: 0.15rem;
  }

  #game-screen[data-player-count="2"] .board-stage {
    width: 110%;
    margin-inline: -5%;
  }

  .player-setting {
    grid-template-columns: 2rem minmax(0, 1fr);
    align-items: start;
  }

  .player-setting__number {
    grid-column: 1;
    grid-row: 1;
  }

  .player-setting__name {
    grid-column: 2;
    grid-row: 1;
  }

  .player-setting__name input {
    font-size: 1rem;
  }

  .type-options {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .player-setting__colors {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .dice-panel {
    grid-template-columns: 1fr;
    align-items: center;
  }

  .turn-status,
  .physical-dice {
    grid-column: 1;
  }

  .physical-die {
    width: clamp(3rem, 14vw, 3.8rem);
  }

  .physical-die.roll-result__die {
    width: clamp(1.5rem, 7vw, 1.9rem);
  }

  .turn-status {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .page-shell {
    padding-inline: 0.55rem;
  }

  .app-header__inner {
    padding-inline: 1.75rem;
  }

  .brand__tagline {
    max-width: 13rem;
  }

  .flow-card {
    padding: 0.95rem 1.3rem 1.5rem;
  }

  .board-shell {
    border-radius: 0.7rem;
  }

  .player-setting {
    padding: 0.65rem;
    gap: 0.55rem;
  }

  .color-options {
    gap: 0.38rem;
  }

  .color-option__piece {
    width: 1.55rem;
  }

  .cell {
    letter-spacing: -0.05em;
  }

  .rule-debug__controls {
    grid-template-columns: 1fr minmax(0, 1.6fr);
  }

  .rule-debug output {
    grid-column: 1 / -1;
  }
}

@media (orientation: landscape) and (max-width: 980px) and (max-height: 600px) {
  body {
    overflow: hidden;
  }

  .page-shell {
    visibility: hidden;
  }

  .orientation-guard {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    padding:
      max(1.5rem, env(safe-area-inset-top))
      max(1.5rem, env(safe-area-inset-right))
      max(1.5rem, env(safe-area-inset-bottom))
      max(1.5rem, env(safe-area-inset-left));
    place-content: center;
    place-items: center;
    color: #24312b;
    background:
      radial-gradient(circle at 50% 35%, rgb(255 255 255 / 82%), transparent 18rem),
      #f3efe3;
    text-align: center;
  }

  .orientation-guard__icon {
    margin-bottom: 0.75rem;
    color: #2f7150;
    font-size: clamp(4rem, 16vh, 7rem);
    font-weight: 800;
    line-height: 1;
  }

  .orientation-guard h1 {
    margin: 0;
    font-size: clamp(1.4rem, 6vh, 2rem);
  }

  .orientation-guard p {
    margin: 0.55rem 0 0;
    color: #626b64;
    font-size: clamp(0.95rem, 3.5vh, 1.1rem);
  }
}
