:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b1f29;
  --panel-2: #242a36;
  --ink: #f7f4ec;
  --muted: #aeb7c7;
  --line: rgba(255, 255, 255, 0.1);
  --gold: #f2b84b;
  --green: #58d68d;
  --red: #ff6b6b;
  --blue: #69a7ff;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.38);
  --visual-viewport-bottom: 0px;
  --app-bottom-clearance: max(18px, env(safe-area-inset-bottom, 0px), calc(var(--visual-viewport-bottom) + 18px));
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overscroll-behavior-y: none;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(242, 184, 75, 0.24), transparent 34%),
    radial-gradient(circle at 92% 8%, rgba(255, 107, 107, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(105, 167, 255, 0.18), transparent 36%),
    var(--bg);
  overscroll-behavior-y: none;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
}

button {
  min-height: 48px;
  color: var(--ink);
  background: var(--panel-2);
  font-weight: 800;
  cursor: pointer;
}

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

button:active {
  transform: translateY(1px);
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.app {
  display: flex;
  flex-direction: column;
  width: min(100%, 560px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top, 0px)) 10px var(--app-bottom-clearance);
  overflow: hidden;
}

.app.is-playing {
  overflow: hidden;
  overscroll-behavior: none;
}

.game-view {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.play-area {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  min-height: 0;
}

.hidden {
  display: none !important;
}

.home-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.home-card {
  display: grid;
  grid-template-rows: auto auto minmax(24px, 1fr) auto auto minmax(24px, 1fr) auto;
  gap: 12px;
  min-height: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.07), transparent 34%),
    radial-gradient(circle at 50% 0%, rgba(242, 184, 75, 0.18), transparent 48%),
    rgba(27, 31, 41, 0.92);
  box-shadow: var(--shadow);
}

.player-summary-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
  justify-items: start;
  align-items: center;
  min-height: 74px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(255, 255, 255, 0.055);
}

.player-summary-label {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.player-summary-button strong {
  grid-column: 1;
  max-width: 100%;
  overflow: hidden;
  color: var(--ink);
  font-size: clamp(1rem, 4.2vw, 1.18rem);
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-player-icon {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(242, 184, 75, 0.32);
  border-radius: 999px;
  color: #f8db91;
  background: rgba(242, 184, 75, 0.1);
}

.edit-player-icon svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

#aboutBtn {
  color: #f7f4ec;
  background: rgba(255, 255, 255, 0.055);
}

#resumeGameBtn {
  grid-row: 4;
  margin-top: 0;
}

#rulesBtn {
  margin-top: 0;
}

.home-actions {
  grid-row: 5;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.info-actions {
  grid-row: 7;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 0;
}

.dice-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
}

.dice-mode-toggle button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
}

.dice-mode-toggle button.active {
  color: #1b1403;
  background: linear-gradient(180deg, #ffe19a, var(--gold));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.22);
}

.about-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}

.about-page {
  display: grid;
  gap: 10px;
  padding-bottom: 8px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.about-intro {
  padding: 14px;
  border: 1px solid rgba(242, 184, 75, 0.22);
  border-radius: 8px;
  background:
    radial-gradient(circle at 15% 0%, rgba(242, 184, 75, 0.18), transparent 48%),
    rgba(27, 31, 41, 0.9);
  box-shadow: var(--shadow);
}

.about-kicker {
  margin: 0 0 8px;
  color: #f8db91;
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.about-intro h1 {
  margin: 0 0 8px;
  font-size: clamp(2.2rem, 10vw, 3.6rem);
  line-height: 0.95;
}

.about-intro p,
.about-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.about-grid {
  display: grid;
  gap: 10px;
}

.about-panel {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 31, 41, 0.9);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
}

.about-panel h2 {
  margin: 0;
  font-size: 1.25rem;
}

.about-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  color: #1b1403;
  background: linear-gradient(180deg, #ffe19a, var(--gold));
  font-size: 1.1rem;
  font-weight: 950;
}

.support-panel .about-icon {
  color: #092414;
  background: linear-gradient(180deg, #dffce9, #8ce8ae);
}

.about-link {
  display: inline-grid;
  place-items: center;
  justify-self: start;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 8px;
  color: #1b1403;
  background: linear-gradient(180deg, #ffd982, var(--gold));
  font-weight: 900;
  text-decoration: none;
}

.about-link.secondary {
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.055);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.06);
}

.target-field,
.player-editor-heading,
.name-grid,
.setup-card .primary,
.setup-card .secondary-button {
  grid-column: 1 / -1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 4px;
  min-height: 76px;
}

.setup-view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.brand h1,
.game-header h1 {
  margin: 0;
  font-size: clamp(2.15rem, 10vw, 4.4rem);
  line-height: 0.9;
  letter-spacing: 0;
}

.brand p,
.game-header p {
  margin: 8px 0 0;
  color: var(--muted);
}

.dice-mark {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  flex: 0 0 76px;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  padding: 14px;
  background: linear-gradient(145deg, #fff5d6, var(--gold));
  box-shadow: var(--shadow);
  transform: rotate(-5deg);
}

.dice-mark span {
  border-radius: 999px;
  background: #171a21;
}

.setup-card,
.entry-card,
.scoreboard,
.score-hero {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(27, 31, 41, 0.88);
  box-shadow: var(--shadow);
}

.setup-card {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 12px;
  min-height: 0;
  padding: 14px;
}

.player-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-editor-heading > span {
  color: var(--ink);
  font-size: 0.8rem;
  line-height: 1;
  font-weight: 900;
}

.mini-button {
  min-height: 38px;
  padding: 0 12px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.toggle-row input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--gold);
}

.toggle-row span {
  margin: 0;
}

.toggle-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.name-grid {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.player-name-row {
  display: grid;
  grid-template-columns: 1fr 44px 44px;
  align-items: end;
  gap: 8px;
}

.order-controls {
  display: grid;
  gap: 4px;
}

.order-button {
  min-width: 42px;
  min-height: 22px;
  padding: 0;
  font-size: 0.95rem;
}

.order-button:disabled {
  opacity: 0.28;
}

.trash-button {
  min-width: 44px;
  min-height: 48px;
  padding: 0;
  color: #2e0505;
  background: var(--red);
  display: grid;
  place-items: center;
}

.trash-button svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.trash-button:disabled {
  opacity: 0.28;
}

.primary,
.hold-button {
  border-color: rgba(242, 184, 75, 0.65);
  color: #1b1403;
  background: linear-gradient(180deg, #ffd982, var(--gold));
  box-shadow: 0 12px 26px rgba(242, 184, 75, 0.22);
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0;
}

.app-title {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
  color: var(--ink);
  font-size: clamp(0.96rem, 3.7vw, 1.25rem);
  font-weight: 950;
  line-height: 1;
}

.app-title > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-dice-mark {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  gap: 4px;
  border-radius: 8px;
  padding: 7px;
  background: linear-gradient(145deg, #fff5d6, var(--gold));
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
  transform: rotate(-5deg);
}

.mini-dice-mark span {
  border-radius: 999px;
  background: #171a21;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: end;
}

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

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  padding: 0 9px;
}

.text-button,
.icon-button {
  font-size: clamp(0.72rem, 3.1vw, 0.9rem);
  font-weight: 800;
}

.score-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, 1fr) 92px;
  column-gap: 14px;
  row-gap: 8px;
  align-items: stretch;
  margin-bottom: 0;
  padding: 10px;
  border-color: rgba(242, 184, 75, 0.46);
  background:
    linear-gradient(135deg, rgba(242, 184, 75, 0.16), transparent 52%),
    rgba(27, 31, 41, 0.94);
}

.score-hero span {
  color: var(--muted);
  font-weight: 800;
}

.score-hero .projected-total {
  display: grid;
  place-items: center;
  transform: translateX(-10px);
  color: #f8db91;
  font-size: clamp(2.8rem, 13vw, 5rem);
  font-weight: 950;
  line-height: 0.9;
  white-space: nowrap;
}

.score-hero strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(3rem, 17vw, 5.3rem);
  line-height: 0.9;
}

.score-hero h1 {
  margin: 1px 0 2px;
  font-size: clamp(1.4rem, 7vw, 2.4rem);
  line-height: 1;
}

.hold-button {
  min-height: 100%;
  font-size: 1.05rem;
  width: 100%;
}

.entry-card {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr) auto;
  flex: 1;
  gap: clamp(8px, 1.4vh, 10px);
  margin-bottom: 0;
  padding: 10px;
  min-height: 0;
}

.virtual-dice-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 0;
}

.virtual-dice-table {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 5vw, 22px);
  min-height: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(242, 184, 75, 0.14), transparent 42%),
    rgba(255, 255, 255, 0.035);
}

.virtual-dice-table .large-dice {
  width: clamp(96px, 28vw, 132px);
  height: clamp(96px, 28vw, 132px);
  border-radius: 20px;
  padding: clamp(16px, 4vw, 24px);
}

.virtual-roll-button {
  min-height: 62px;
  font-size: clamp(1.2rem, 5vw, 1.65rem);
}

.roll-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(7px, 1.15vh, 8px);
  min-height: 0;
}

.roll-grid button {
  min-height: 0;
  font-size: clamp(1.3rem, 5.6vw, 2rem);
  font-weight: 950;
}

.roll-grid .disabled-roll {
  color: rgba(247, 244, 236, 0.68);
  background: rgba(255, 255, 255, 0.045);
}

.pair-dice-icon {
  position: relative;
  display: block;
  width: 52px;
  height: 38px;
}

.tiny-die,
.large-dice {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  background: linear-gradient(145deg, #fff6d8, #f2b84b);
  box-shadow:
    inset -4px -5px 8px rgba(71, 43, 6, 0.28),
    inset 3px 3px 6px rgba(255, 255, 255, 0.6),
    0 8px 18px rgba(0, 0, 0, 0.26);
}

.tiny-die {
  position: absolute;
  width: 29px;
  height: 29px;
  border-radius: 7px;
  padding: 5px;
}

.tiny-die:first-child {
  left: 2px;
  top: 6px;
  transform: rotate(-9deg);
}

.tiny-die:last-child {
  right: 2px;
  top: 2px;
  transform: rotate(8deg);
}

.tiny-die::before,
.tiny-die::after,
.tiny-die span,
.large-dice .pip {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #171a21;
}

.tiny-die::before,
.tiny-die::after {
  content: "";
}

.tiny-die.five::before {
  grid-column: 1;
  grid-row: 1;
}

.tiny-die.five::after {
  grid-column: 3;
  grid-row: 3;
}

.tiny-die.five span:nth-child(1) {
  grid-column: 3;
  grid-row: 1;
}

.tiny-die.five span:nth-child(2) {
  grid-column: 2;
  grid-row: 2;
}

.tiny-die.five span:nth-child(3) {
  grid-column: 1;
  grid-row: 3;
}

.tiny-die.three::before {
  grid-column: 1;
  grid-row: 1;
}

.tiny-die.three::after {
  grid-column: 3;
  grid-row: 3;
}

.tiny-die.three span:nth-child(1) {
  grid-column: 2;
  grid-row: 2;
}

.tiny-die.three span:nth-child(2),
.tiny-die.three span:nth-child(3) {
  display: none;
}

.dice-result {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 6px 0 22px;
  perspective: 600px;
}

.large-dice {
  width: 96px;
  height: 96px;
  border-radius: 18px;
  padding: 18px;
  transform-origin: center;
  transition: transform 180ms ease, filter 180ms ease;
}

.is-rolling .large-dice {
  animation: diceTumble 720ms cubic-bezier(.2,.78,.24,1) both;
  filter: blur(.35px);
}

.is-rolling .large-dice:nth-child(2) {
  animation-delay: 45ms;
}

.large-dice .pip {
  display: none;
}

.large-dice .pip-1 {
  grid-column: 1;
  grid-row: 1;
}

.large-dice .pip-2 {
  grid-column: 2;
  grid-row: 1;
}

.large-dice .pip-3 {
  grid-column: 3;
  grid-row: 1;
}

.large-dice .pip-4 {
  grid-column: 1;
  grid-row: 2;
}

.large-dice .pip-5 {
  grid-column: 2;
  grid-row: 2;
}

.large-dice .pip-6 {
  grid-column: 3;
  grid-row: 2;
}

.large-dice .pip-7 {
  grid-column: 1;
  grid-row: 3;
}

.large-dice .pip-8 {
  grid-column: 2;
  grid-row: 3;
}

.large-dice .pip-9 {
  grid-column: 3;
  grid-row: 3;
}

.die-face-1 .pip-5,
.die-face-2 .pip-1,
.die-face-2 .pip-9,
.die-face-3 .pip-1,
.die-face-3 .pip-5,
.die-face-3 .pip-9,
.die-face-4 .pip-1,
.die-face-4 .pip-3,
.die-face-4 .pip-7,
.die-face-4 .pip-9,
.die-face-5 .pip-1,
.die-face-5 .pip-3,
.die-face-5 .pip-5,
.die-face-5 .pip-7,
.die-face-5 .pip-9,
.die-face-6 .pip-1,
.die-face-6 .pip-3,
.die-face-6 .pip-4,
.die-face-6 .pip-6,
.die-face-6 .pip-7,
.die-face-6 .pip-9 {
  display: block;
}

.danger-grid {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.danger-grid button {
  min-height: clamp(50px, 7.2dvh, 70px);
  font-size: clamp(1.05rem, 4.4vw, 1.45rem);
}

.soft-danger {
  color: #2d1200;
  background: #ffb86c;
}

.danger {
  color: #2e0505;
  background: var(--red);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(var(--player-count, 2), minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 0;
  padding: 8px;
  min-height: 84px;
  align-content: start;
  overflow: hidden;
}

.player-row {
  display: grid;
  grid-template-rows: auto auto;
  align-items: center;
  justify-items: center;
  gap: 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  min-width: 0;
  min-height: 68px;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.05);
}

.scoreboard.many-players {
  gap: 5px;
  min-height: 0;
  padding: 7px;
}

.scoreboard.many-players .player-row {
  min-height: clamp(55px, 8.1dvh, 66px);
  padding: 6px 4px;
}

.player-row.active {
  border-color: rgba(155, 255, 188, 0.9);
  color: #0f2819;
  background: linear-gradient(180deg, #dffce9, #a8efc1);
  box-shadow:
    0 0 0 1px rgba(155, 255, 188, 0.28),
    0 10px 24px rgba(88, 214, 141, 0.22);
}

.player-row.active .player-name,
.player-row.active .player-score {
  color: #0f2819;
}

.player-row.winner {
  border-color: rgba(88, 214, 141, 0.7);
  background: rgba(88, 214, 141, 0.13);
}

.player-name {
  display: block;
  width: 100%;
  overflow: hidden;
  font-size: clamp(0.72rem, 3.3vw, 1.2rem);
  line-height: 1;
  font-weight: 900;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  display: none;
}

.player-score {
  max-width: 100%;
  overflow: hidden;
  font-size: clamp(2rem, 11.2vw, 3.8rem);
  line-height: 0.9;
  font-weight: 950;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.scoreboard.many-players .player-name {
  font-size: clamp(0.72rem, 3vw, 0.96rem);
}

.scoreboard.many-players .player-score {
  font-size: clamp(1.85rem, 10vw, 3.1rem);
}

.player-row.large-score .player-score {
  font-size: clamp(1.75rem, 8.8vw, 3rem);
}

.player-row.huge-score .player-score {
  font-size: clamp(1.45rem, 7.2vw, 2.55rem);
}

.scoreboard.many-players .player-row.large-score .player-score {
  font-size: clamp(1.45rem, 7.6vw, 2.35rem);
}

.scoreboard.many-players .player-row.huge-score .player-score {
  font-size: clamp(1.2rem, 6.2vw, 2rem);
}

.winner-banner {
  grid-column: 1 / -1;
  border: 1px solid rgba(88, 214, 141, 0.55);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 12px;
  color: #dffce9;
  background: rgba(88, 214, 141, 0.13);
  font-weight: 900;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
}

.snake-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
}

.snake-vignette {
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at center, transparent 0 28%, rgba(0, 0, 0, 0.66) 54%, rgba(0, 0, 0, 0.92) 100%);
}

.snake-warning-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(193, 29, 43, 0.62), transparent 52%);
  mix-blend-mode: screen;
  opacity: 0;
}

.snake-wrap {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  transform: translateY(160px) scale(0.15);
  transform-origin: 50% 78%;
  filter:
    drop-shadow(0 36px 50px rgba(0, 0, 0, 0.82))
    drop-shadow(0 0 22px rgba(255, 49, 91, 0.12));
}

.snake-art {
  width: min(100vw, 560px);
  height: auto;
  overflow: visible;
}

.snake-body,
.snake-spine,
.snake-scales {
  stroke-dasharray: 940;
  stroke-dashoffset: 940;
}

.snake-hood {
  transform-origin: 260px 235px;
}

.snake-head {
  transform-origin: 260px 235px;
}

.snake-eye-glow {
  filter: drop-shadow(0 0 8px rgba(255, 28, 54, 0.9));
}

.snake-fang {
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.55));
}

.snake-venom {
  opacity: 0;
  transform-origin: center;
}

.snake-overlay.strike {
  animation: snakeOverlayShow 1500ms ease both;
  pointer-events: auto;
}

.snake-overlay.strike .snake-wrap {
  animation: snakeRiseAndStrike 1500ms cubic-bezier(.18,.95,.24,1) both;
}

.snake-overlay.strike .snake-body,
.snake-overlay.strike .snake-spine,
.snake-overlay.strike .snake-scales {
  animation: snakeDrawBody 760ms ease-out 120ms both;
}

.snake-overlay.strike .snake-hood {
  animation: snakeFlareHood 900ms ease-out 260ms both;
}

.snake-overlay.strike .snake-head {
  animation: snakeHeadSnap 640ms cubic-bezier(.19,1,.22,1) 760ms both;
}

.snake-overlay.strike .snake-warning-flash {
  animation: snakeFlash 1500ms ease both;
}

.snake-overlay.strike .snake-venom {
  animation: snakeSpit 420ms ease-out 980ms both;
}

.win-overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 24%, rgba(242, 184, 75, .26), transparent 15rem),
    linear-gradient(180deg, rgba(12, 15, 20, .93), rgba(9, 11, 16, .98));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.close-win {
  justify-self: end;
  width: 38px;
  height: 38px;
  min-height: 38px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: white;
  background: rgba(255,255,255,.07);
  font-size: 26px;
  line-height: 1;
}

.win-content {
  position: relative;
  z-index: 2;
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.win-kicker {
  margin: 0;
  color: rgba(255,255,255,.72);
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.win-title {
  margin: 0;
  color: #fff5d2;
  font-size: clamp(2.9rem, 12vw, 4.9rem);
  line-height: .94;
  font-weight: 950;
  letter-spacing: 0;
  text-shadow:
    0 0 20px rgba(242, 184, 75, .42),
    0 9px 22px rgba(0, 0, 0, .7);
  animation: winnerPop 950ms cubic-bezier(.2,1.3,.24,1) both;
}

.win-score {
  margin: 0;
  color: rgba(255,255,255,.82);
  font-size: 1.1rem;
  font-weight: 900;
}

.play-again {
  position: relative;
  z-index: 2;
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  color: #211404;
  background: linear-gradient(180deg, #ffe698, var(--gold));
  font-size: 1.1rem;
  font-weight: 950;
  box-shadow: 0 18px 38px rgba(0,0,0,.45);
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  left: var(--x);
  top: -26px;
  width: 9px;
  height: 17px;
  border-radius: 3px;
  background: var(--c);
  transform: rotate(var(--r));
  animation: confettiFall var(--d) linear var(--delay) infinite;
}

.firework {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 7px;
  height: 7px;
  border-radius: 999px;
  color: var(--c);
  background: currentColor;
  box-shadow:
    0 -38px 0 currentColor,
    27px -27px 0 currentColor,
    38px 0 0 currentColor,
    27px 27px 0 currentColor,
    0 38px 0 currentColor,
    -27px 27px 0 currentColor,
    -38px 0 0 currentColor,
    -27px -27px 0 currentColor;
  opacity: 0;
  animation: fireworkBurst 1300ms ease-out var(--delay) infinite;
}

@keyframes snakeOverlayShow {
  0%, 8% { opacity: 0; }
  24%, 82% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes snakeRiseAndStrike {
  0% { transform: translateY(180px) scale(0.12); }
  42% { transform: translateY(18px) scale(0.76); }
  70% { transform: translateY(-8px) scale(0.9); }
  78% { transform: translateY(-84px) scale(1.34); }
  100% { transform: translateY(-30px) scale(1.04); }
}

@keyframes snakeDrawBody {
  to { stroke-dashoffset: 0; }
}

@keyframes snakeFlareHood {
  0% { transform: scaleX(0.36) scaleY(0.86); opacity: 0; }
  45% { transform: scaleX(1.18) scaleY(1.03); opacity: 1; }
  100% { transform: scaleX(1) scaleY(1); opacity: 1; }
}

@keyframes snakeHeadSnap {
  0%, 45% { transform: translateY(0) scale(1); }
  68% { transform: translateY(38px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes snakeFlash {
  0%, 62%, 100% { opacity: 0; }
  74% { opacity: 1; }
  82% { opacity: 0.15; }
}

@keyframes snakeSpit {
  0% { opacity: 0; transform: translateY(0) scale(0.35); }
  35% { opacity: 1; }
  100% { opacity: 0; transform: translateY(62px) scale(1.8); }
}

@keyframes winnerPop {
  0% { opacity: 0; transform: translateY(22px) scale(.82); }
  62% { opacity: 1; transform: translateY(-4px) scale(1.06); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes confettiFall {
  0% { transform: translateY(-30px) rotate(var(--r)); opacity: 0; }
  8% { opacity: 1; }
  100% { transform: translateY(620px) rotate(calc(var(--r) + 720deg)); opacity: .9; }
}

@keyframes fireworkBurst {
  0% { transform: scale(.08); opacity: 0; filter: blur(0); }
  16% { opacity: 1; }
  72% { opacity: .86; }
  100% { transform: scale(1.42); opacity: 0; filter: blur(1px); }
}

.confirm-card {
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.confirm-card h2 {
  margin: 0 0 8px;
}

.confirm-card p {
  margin: 0 0 16px;
  color: var(--muted);
}

.rules-card ul {
  display: grid;
  gap: 9px;
  margin: 0 0 18px;
  padding-left: 20px;
  color: var(--muted);
}

.rules-card li {
  line-height: 1.35;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal-actions.single-action {
  grid-template-columns: 1fr;
}

.dice-card {
  text-align: center;
}

.dice-card .modal-actions {
  margin-top: 4px;
}

@keyframes diceTumble {
  0% { transform: translateY(0) rotateX(0deg) rotateZ(0deg) scale(1); }
  18% { transform: translateY(-20px) rotateX(118deg) rotateZ(-18deg) scale(1.04); }
  38% { transform: translateY(8px) rotateX(224deg) rotateZ(22deg) scale(.98); }
  58% { transform: translateY(-12px) rotateX(314deg) rotateZ(-14deg) scale(1.03); }
  78% { transform: translateY(4px) rotateX(386deg) rotateZ(8deg) scale(.99); }
  100% { transform: translateY(0) rotateX(360deg) rotateZ(0deg) scale(1); }
}

@media (max-height: 720px) {
  .brand {
    margin-top: 4px;
    min-height: 68px;
  }

  button,
  input,
  select {
    min-height: 40px;
  }

  label span {
    margin-bottom: 4px;
  }

  .setup-card,
  .entry-card,
  .score-hero,
  .scoreboard {
    padding: 8px;
  }

  .score-hero strong {
    font-size: clamp(2.6rem, 15vw, 4.4rem);
  }

  .player-row {
    min-height: 58px;
  }

  .player-score {
    font-size: clamp(1.7rem, 9.2vw, 2.85rem);
  }

  .player-row.large-score .player-score {
    font-size: clamp(1.45rem, 7.4vw, 2.25rem);
  }

  .player-row.huge-score .player-score {
    font-size: clamp(1.18rem, 6vw, 1.85rem);
  }

  .game-header {
    gap: 6px;
  }

  .game-view {
    gap: 8px;
  }

  .entry-card {
    gap: 8px;
    padding: 8px;
  }

  .score-hero {
    grid-template-columns: minmax(0, 1fr) minmax(88px, 0.85fr) 84px;
    column-gap: 10px;
  }

  .score-hero .projected-total {
    transform: translateX(-4px);
    font-size: clamp(2.25rem, 11vw, 4rem);
  }

  .danger-grid button {
    min-height: 50px;
  }

  .roll-grid button {
    font-size: clamp(1.2rem, 5vw, 1.8rem);
  }
}

@media (max-width: 390px) {
  .app {
    padding-inline: 8px;
  }

  .mini-dice-mark {
    flex-basis: 30px;
    width: 30px;
    height: 30px;
    padding: 6px;
  }

  .header-actions {
    gap: 5px;
  }

  .text-button {
    padding: 0 7px;
  }

  .icon-button {
    min-width: 44px;
  }
}

@media (max-width: 700px) {
  .app.is-playing {
    --app-bottom-clearance: max(22px, env(safe-area-inset-bottom, 0px), calc(var(--visual-viewport-bottom) + 22px));
  }

  .game-view {
    padding-bottom: 0;
  }
}

@media (min-width: 520px) {
  .setup-card {
    grid-template-columns: 1fr;
  }

  .target-field,
  .toggle-row,
  .name-grid,
  .player-editor-heading,
  .primary,
  .secondary-button {
    grid-column: 1 / -1;
  }
}
