.ladders-page .shell {
  max-width: 1400px;
}
.board-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin: 32px 0;
}
.board-heading h1 {
  font-size: clamp(2.4rem, 5.5vw, 5.1rem);
  line-height: 1.06;
  letter-spacing: -0.055em;
  margin: 14px 0 30px;
}
.board-heading h1 span {
  color: var(--lime);
}
.board-stamp {
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 114px;
  height: 114px;
  display: grid;
  place-content: center;
  text-align: center;
  font-size: 11px;
  letter-spacing: 2px;
  transform: rotate(12deg);
  flex-shrink: 0;
  color: var(--peach);
}
.board-setup {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  overflow: hidden;
}
.setup-intro {
  padding: 40px;
  background: #203e32;
}
.setup-intro h2 {
  font-size: clamp(2rem, 3.4vw, 3.5rem);
  line-height: 1.15;
  letter-spacing: -0.04em;
  margin: 20px 0;
}
.setup-intro p {
  max-width: 350px;
}
.setup-art {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  width: min(290px, 100%);
  margin: 50px auto;
  transform: rotate(-9deg);
}
.setup-art span {
  aspect-ratio: 1;
  display: grid;
  place-content: center;
  border-radius: 10px;
  background: var(--peach);
  color: var(--ink);
  font:
    700 24px "Space Grotesk",
    sans-serif;
  box-shadow: 0 5px 0 #a18b6d;
}
.setup-art span:nth-child(3n + 1) {
  background: var(--lime);
}
.setup-art .art-pawn {
  font-size: 60px;
  background: #a8c9ec;
  transform: translateY(-14px);
  box-shadow: 0 19px 0 #758c9d;
}
.board-setup form {
  padding: 36px;
  min-width: 0;
}
.ladders-page textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  color: var(--text);
  font: inherit;
}
.ladders-page label {
  display: block;
  font-size: 14px;
}
.ladders-page input,
.ladders-page select {
  width: 100%;
  min-width: 0;
  margin-top: 7px;
}
.ladders-page small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}
.ladders-page details {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}
.ladders-page summary {
  cursor: pointer;
  font-weight: 700;
  padding: 6px 0;
}
.board-settings {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 20px;
}
.board-settings label:nth-child(4) {
  grid-column: span 2;
}
.ladders-page .check-label {
  display: flex;
  gap: 10px;
  align-items: center;
  grid-column: 1/-1;
}
.ladders-page input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--lime);
}
.category-editor {
  margin: 16px 0;
}
.category-editor textarea {
  margin-top: 10px;
}
.field-inputs {
  display: grid;
  grid-template-columns: 75px 1fr;
  gap: 12px;
}
.field-inputs button {
  grid-column: 1/-1;
}
.field-editor ul {
  list-style: none;
  padding: 0;
}
.field-editor li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  overflow-wrap: anywhere;
}
.field-editor li button {
  flex-shrink: 0;
}
.start-board {
  width: 100%;
  justify-content: space-between;
  margin-top: 12px;
}
.board-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  gap: 10px;
  margin: 20px 0;
}
.board-topline .status-dot {
  display: inline-block;
  margin-right: 10px;
}
.board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}
.board-table {
  background: radial-gradient(ellipse at 50% 30%, #315946, #18382e 75%);
  border: 1px solid #62764a;
  border-radius: 22px;
  overflow: hidden;
  position: relative;
  box-shadow:
    inset 0 0 0 5px #203a2d,
    0 15px 60px #07181044;
}
.board-table-head,
.board-table-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 24px;
  color: #d4d9b5;
  font-size: 10px;
  letter-spacing: 1.2px;
}
.board-table-foot {
  flex-wrap: wrap;
  letter-spacing: 0;
  font-size: 11px;
}
.board-table-foot b {
  font-weight: 400;
  color: var(--muted);
}
#scene-host {
  width: 100%;
  height: clamp(390px, 48vw, 690px);
}
#scene-host canvas {
  display: block;
  width: 100%;
  height: 100%;
}
#field-info {
  margin: 0 20px 20px;
  padding: 12px;
  background: #102b26dd;
  border-radius: 10px;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.turn-panel {
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.turn-panel h2 {
  font-size: 32px;
  letter-spacing: -0.03em;
  margin: 8px 0;
}
.turn-panel > p {
  margin: 10px 0;
}
.turn-panel .primary {
  width: 100%;
}
.dice-display {
  width: 94px;
  height: 94px;
  display: grid;
  place-content: center;
  font-size: 80px;
  line-height: 1;
  background: #f9efd3;
  color: #173128;
  border-radius: 20px;
  box-shadow:
    0 7px 0 #b1a988,
    0 16px 28px #0003;
  transform: rotate(-8deg);
  margin: 26px auto 30px;
}
.dice-display.rolling {
  animation: dice-toss 0.45s infinite alternate;
}
.task-card {
  border: 1px solid var(--task-color, var(--lime));
  background: #102820;
  padding: 18px;
  border-radius: 14px;
  margin: 20px 0;
  animation: task-arrive 0.35s ease-out;
}
.task-card .eyebrow {
  color: var(--task-color, var(--lime));
  font-size: 10px;
}
.task-card #task-text {
  font-size: 20px;
  line-height: 1.45;
  margin: 12px 0 0;
}
.roll-button {
  margin-top: 16px;
  min-height: 58px;
  font-size: 18px;
  justify-content: space-between;
}
#task-actions .text-button {
  width: 100%;
  font-size: 12px;
  margin-top: 6px;
}
#move-label {
  min-height: 24px;
  font-weight: 600;
  color: var(--peach);
}
.standings-panel {
  margin: 32px 0;
}
.standings-panel h2 {
  font-size: 22px;
}
.standings-panel ol {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  padding: 0;
  list-style: none;
}
.player-position {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  min-width: 0;
}
.player-position.active {
  border-color: var(--player-color);
  background: #294437;
}
.player-position > div {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}
.player-position strong {
  overflow-wrap: anywhere;
}
.player-position .player-number {
  display: inline-grid;
  place-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--player-color);
  color: var(--ink);
  font-weight: bold;
}
.player-position progress {
  width: 100%;
  height: 7px;
  accent-color: var(--player-color);
  margin-top: 12px;
}
.player-position small {
  font-size: 11px;
}
.board-details {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 24px;
}
.board-details details {
  min-width: 0;
}
.board-details ol {
  padding-left: 22px;
  font-size: 13px;
}
.board-details li {
  margin: 10px 0;
}
.board-rules {
  margin-top: 35px;
  max-width: 850px;
}
.board-rules p {
  color: var(--muted);
}
#field-list {
  max-height: 390px;
  overflow: auto;
  display: grid;
  gap: 6px;
}
#field-list button {
  justify-content: flex-start;
  text-align: left;
  padding: 10px;
  font-size: 12px;
  font-weight: 400;
  overflow-wrap: anywhere;
}
#fallback {
  padding: 18px;
}
#flat-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}
#flat-board button {
  padding: 5px;
  min-height: 50px;
  color: var(--ink);
  background: var(--tile-color);
  font-size: 11px;
  display: block;
}
#flat-board .occupied {
  outline: 3px solid white;
  outline-offset: -3px;
}
.turn-panel.winner {
  border-color: var(--lime);
  background: radial-gradient(ellipse at top, #4b6232, #1c352f 65%);
}
.turn-panel.winner .dice-display {
  background: var(--lime);
  font-size: 60px;
}
.ladders-page dialog {
  max-width: min(450px, 90vw);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 26px;
}
.ladders-page dialog::backdrop {
  background: #061b15b8;
}
.ladders-page :focus-visible {
  outline: 3px solid var(--peach);
  outline-offset: 3px;
}
@keyframes dice-toss {
  to {
    transform: rotate(18deg) translateY(-12px);
  }
}
@keyframes task-arrive {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (max-width: 1000px) {
  .board-layout {
    grid-template-columns: minmax(0, 1fr) 290px;
  }
  .board-setup {
    grid-template-columns: 0.7fr 1fr;
  }
  .setup-intro,
  .board-setup form {
    padding: 24px;
  }
  .board-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .board-details {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 760px) {
  .board-layout,
  .board-setup {
    grid-template-columns: 1fr;
  }
  .board-heading {
    margin: 16px 0;
  }
  .board-heading h1 {
    font-size: clamp(2.2rem, 8vw, 3.6rem);
  }
  .board-stamp {
    display: none;
  }
  .setup-intro {
    padding: 25px;
  }
  .setup-intro h2 {
    font-size: 30px;
  }
  .setup-art {
    display: none;
  }
  .setup-intro > p {
    max-width: none;
  }
  .board-setup form {
    padding: 22px;
  }
  .turn-panel {
    padding: 22px;
    position: relative;
  }
  .turn-panel h2 {
    padding-right: 100px;
  }
  .turn-panel .dice-display {
    position: absolute;
    right: 24px;
    top: 12px;
    width: 65px;
    height: 65px;
    font-size: 58px;
    margin: 15px 0;
  }
  .turn-panel.winner .dice-display {
    font-size: 40px;
  }
  #position-label {
    padding-right: 80px;
  }
  #scene-host {
    height: clamp(360px, 100vw, 600px);
  }
  .board-table-head,
  .board-table-foot {
    margin: 16px;
    font-size: 9px;
  }
  .board-topline {
    font-size: 11px;
  }
  .board-topline button {
    font-size: 11px;
    padding: 8px;
  }
  .standings-panel ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .player-position {
    padding: 12px;
  }
  .board-details {
    gap: 0;
  }
  .board-heading .eyebrow {
    font-size: 10px;
  }
  .task-card #task-text {
    font-size: 19px;
  }
  .section-heading {
    gap: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

.add-player-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 18px;
}
.add-player-row input {
  flex: 1;
  min-width: 0;
}
.add-player-row button {
  width: auto;
  flex-shrink: 0;
  padding: 12px;
}
.ladders-page #setup-players {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.roster-player {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  animation: task-arrive 0.2s ease-out;
}
.roster-player strong {
  flex: 1;
  overflow-wrap: anywhere;
}
.roster-badge {
  display: grid;
  place-content: center;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  color: var(--ink);
  font-weight: 700;
  flex-shrink: 0;
}
.roster-player button {
  padding: 8px;
  min-width: 44px;
}
.ladders-page #flat-board small {
  font-size: 9px;
  color: var(--ink);
  line-height: 1.25;
}
#flat-board button {
  min-height: 80px;
}
.dice-display.rolling {
  animation: dice-juggle 0.38s infinite alternate;
}
@keyframes dice-juggle {
  0% {
    transform: translate(-12px, -8px) rotate(-24deg) scale(1.05, 0.95);
  }
  50% {
    transform: translate(8px, -20px) rotate(25deg) scale(0.96, 1.05);
  }
  100% {
    transform: translate(0, 2px) rotate(-8deg) scale(1.12, 0.88);
  }
}

.mode-picker {
  border: 0;
  padding: 0;
  margin: 0 0 24px;
  min-width: 0;
}
.mode-picker legend {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 15px;
}
#mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--bg);
  min-width: 0;
}
.mode-card strong {
  font-size: 19px;
}
.mode-card span {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
}
.mode-card small {
  font-size: 11px;
  font-weight: 500;
}
.mode-card.selected {
  border-color: var(--lime);
  box-shadow: inset 0 0 0 1px var(--lime);
  background: #2b4432;
}
.mode-card[data-mode="sexy"].selected {
  border-color: #f2a9c2;
  box-shadow: inset 0 0 0 1px #f2a9c2;
}
#adult-setting {
  margin: 0 0 20px;
  padding: 12px;
  border: 1px solid #925d70;
  border-radius: 10px;
  font-size: 12px;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: -26px;
  background: var(--surface);
  z-index: 1;
}
.dialog-heading h2 {
  font-size: 22px;
}
.dialog-heading button {
  flex-shrink: 0;
  font-size: 24px;
}
#board-info-dialog {
  width: 800px;
  max-width: 94vw;
  max-height: 85dvh;
  overflow: auto;
}
#board-info-dialog .board-details {
  grid-template-columns: 1fr;
  gap: 0;
}
#board-info-dialog .standings-panel {
  margin: 20px 0;
}
#field-dialog {
  max-height: 80dvh;
  overflow: auto;
}
#field-info {
  font-size: 18px;
  line-height: 1.6;
  margin: 12px 0;
  padding: 0;
  background: transparent;
}
#task-title {
  font-size: 22px;
  line-height: 1.1;
  margin: 8px 0;
}
#quick-players {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  align-items: center;
  min-width: 0;
  padding: 5px 0;
  scrollbar-width: thin;
}
.quick-player {
  flex-shrink: 0;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.quick-player.current {
  color: var(--player-color);
  border-color: var(--player-color);
}
body.playing {
  overflow: hidden;
}
.playing .shell {
  padding: 0;
  max-width: none;
}
.playing .site-header,
.playing .board-heading,
.playing .site-footer,
.playing #rules {
  display: none;
}
.playing #game {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 44px minmax(0, 1fr) 48px;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  height: 100dvh;
  background: var(--bg);
}
.playing .board-topline {
  display: flex;
  gap: 18px;
  margin: 0;
  font-size: 12px;
  min-width: 0;
}
.playing .board-topline > div {
  flex: 1;
}
.playing .board-home {
  font-size: 13px;
  font-weight: 700;
}
.playing .board-topline button {
  padding: 8px;
  min-height: 40px;
  font-size: 12px;
  white-space: nowrap;
}
.playing .board-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 0;
  min-height: 0;
  border: 1px solid #62764a;
  border-radius: 20px;
  overflow: hidden;
  background: radial-gradient(ellipse at 40% 40%, #315946, #18382e 75%);
}
.playing .board-table {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}
.playing .board-table-head {
  margin: 12px 20px;
  flex-shrink: 0;
}
.playing .board-table-foot {
  display: none;
}
.playing #scene-host {
  flex: 1;
  width: 100%;
  height: auto;
  min-height: 0;
}
.playing #fallback {
  min-height: 0;
  overflow: auto;
  padding: 10px;
}
.playing #fallback > p {
  font-size: 11px;
  margin: 0 0 8px;
}
.playing .turn-panel {
  align-self: center;
  max-height: 100%;
  margin: 12px;
  min-width: 0;
  overflow: auto;
  padding: 22px;
  background: #142b26f5;
  border-color: #638351;
  box-shadow: 0 10px 30px #0003;
}
.playing .turn-panel h2 {
  font-size: 30px;
  padding-right: 0;
}
.playing .task-card {
  padding: 15px;
  margin: 12px 0;
}
.playing .task-card #task-text {
  font-size: 18px;
  line-height: 1.4;
}
.playing .turn-panel .dice-display {
  position: static;
  margin: 20px auto;
  width: 72px;
  height: 72px;
  font-size: 62px;
}
.playing .turn-panel.has-task .dice-display {
  display: none;
}
.playing #next-player {
  font-size: 11px;
}
.playing #notice:not([hidden]) {
  position: fixed;
  top: 60px;
  left: 20px;
  right: 20px;
  z-index: 10;
  box-shadow: 0 10px 30px #0005;
}
.playing .skip-link:not(:focus) {
  visibility: hidden;
}
.playing .board-topline .status-dot {
  display: none;
}
@media (max-width: 760px) {
  .playing #game {
    grid-template-rows: 38px minmax(0, 1fr) 40px;
    gap: 5px;
    padding: env(safe-area-inset-top, 0px) 8px env(safe-area-inset-bottom, 0px);
  }
  .playing .board-topline {
    gap: 6px;
    font-size: 10px;
  }
  .playing .board-home {
    font-size: 11px;
  }
  .playing .board-topline button {
    font-size: 10px;
    padding: 5px;
    min-height: 36px;
  }
  .playing .board-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    border-radius: 15px;
  }
  .playing .board-table-head {
    margin: 8px 12px;
    font-size: 8px;
  }
  .playing .turn-panel {
    max-height: 50dvh;
    margin: 0 6px 6px;
    padding: 12px 14px;
    border-radius: 15px;
    position: relative;
    overflow: visible;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 8px;
    align-items: center;
  }
  .playing .turn-panel .eyebrow {
    font-size: 9px;
    margin: 0;
  }
  .playing .turn-panel > h2 {
    font-size: 21px;
    line-height: 1.1;
    margin: 4px 0;
    grid-column: 1;
  }
  .playing #phase-label {
    grid-column: 1;
  }
  .playing #position-label {
    font-size: 10px;
    padding: 0;
    margin: 0;
    grid-column: 1;
  }
  .playing .turn-panel .dice-display {
    position: absolute;
    top: 12px;
    right: 15px;
    width: 42px;
    height: 42px;
    font-size: 36px;
    margin: 0;
    box-shadow: 0 4px 0 #b1a988;
  }
  .playing #move-label {
    font-size: 11px;
    min-height: 0;
    margin: 5px 0;
    grid-column: 1/-1;
  }
  .playing .task-card {
    grid-column: 1/-1;
    padding: 9px 11px;
    margin: 5px 0;
    max-height: 24dvh;
    overflow: auto;
  }
  .playing #task-title {
    font-size: 17px;
    margin: 5px 0;
  }
  .playing .task-card #task-text {
    font-size: 16px;
    margin: 5px 0;
    line-height: 1.35;
  }
  .playing .turn-panel .roll-button {
    grid-column: 1/-1;
    margin: 6px 0 0;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 16px;
  }
  .playing #task-actions {
    display: flex;
    grid-column: 1/-1;
    gap: 6px;
    align-items: stretch;
    margin-top: 5px;
  }
  .playing #task-actions .primary {
    flex: 1;
    font-size: 13px;
    min-height: 44px;
    padding: 10px;
  }
  .playing #task-actions .text-button {
    width: auto;
    max-width: 95px;
    min-height: 44px;
    font-size: 10px;
    line-height: 1.3;
    margin: 0;
    padding: 6px;
  }
  .playing #next-player {
    grid-column: 1/-1;
    font-size: 10px;
    line-height: 1.2;
    margin: 6px 0 0;
  }
  .playing #again {
    grid-column: 1/-1;
    min-height: 44px;
    margin-top: 6px;
  }
  .playing .quick-player {
    font-size: 10px;
    padding: 6px 9px;
  }
  .playing #fallback #flat-board {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .playing #flat-board button {
    min-height: 60px;
  }
  .playing .turn-panel.has-task #position-label {
    display: none;
  }
}
@media (max-height: 540px) and (orientation: landscape) {
  .playing #game {
    grid-template-rows: 34px minmax(0, 1fr) 32px;
  }
  .playing .board-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: minmax(0, 1fr);
  }
  .playing .turn-panel {
    margin: 5px;
    max-height: 100%;
    overflow: auto;
    padding: 10px;
  }
  .playing .turn-panel .dice-display {
    display: none;
  }
  .playing .task-card {
    max-height: 26dvh;
  }
  .playing #next-player,
  .playing #position-label {
    display: none;
  }
  .playing .board-table-head {
    display: none;
  }
  .playing #task-title {
    font-size: 15px;
  }
  .playing .task-card #task-text {
    font-size: 14px;
  }
  .playing .turn-panel h2 {
    font-size: 20px;
  }
  .playing #move-label {
    font-size: 10px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .playing * {
    animation: none !important;
  }
}
