/* Game UI. Tokens are scoped to .rr so they cannot leak into the content pages. */
.rr {
  --bg: #0e0e10;
  --surface: #1a1a1e;
  --text: #f2f2f2;
  --text-muted: #9a9aa2;
  --danger: #e0242c;
  --safe: #2fbf71;
  --metal: #8c8f96;
  --tint: #0e0e10;
  --kb: 0px;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--tint);
  color: var(--text);
  transition: background-color 250ms ease;
  -webkit-touch-callout: none;
}

.rr[data-screen="HOME"],
.rr[data-screen="SETUP"],
.rr[data-screen="SETTINGS"],
.rr[data-screen="TURN"],
.rr[data-screen="COUNTDOWN"],
.rr[data-screen="SURVIVED"],
.rr[data-screen="RELOAD"] {
  background: var(--bg);
}

.rr[data-screen="ELIMINATED"] {
  background: #4a070c;
}

.rr[data-screen="COUNTDOWN"] {
  background: #070708;
}

.app {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 30rem;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

.app.enter {
  animation: enter 250ms ease-out;
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(0.5rem + env(safe-area-inset-top, 0px)) 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

/* ---- shared parts */

.bar {
  display: grid;
  grid-template-columns: 3rem 1fr 3rem;
  align-items: center;
  min-height: 3rem;
}

.bar-title {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
}

.bar-end {
  display: flex;
  justify-content: flex-end;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
}

.icon-btn svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

.icon-btn:active {
  background: var(--surface);
}

.icon-btn[aria-pressed="true"] {
  color: var(--text-muted);
}

.btn {
  display: block;
  width: 100%;
  min-height: 3.5rem;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.9rem;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--surface);
  color: var(--text);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.btn:disabled {
  opacity: 0.4;
}

.btn.primary {
  min-height: 4rem;
  background: var(--danger);
  color: #fff;
}

.btn.primary:active:not(:disabled) {
  transform: scale(0.98);
}

.btn.ghost {
  background: transparent;
  border: 1px solid #3a3a42;
  color: var(--text);
  min-height: 3.25rem;
  font-size: 1.25rem;
}

.btn:focus-visible,
.link:focus-visible,
.icon-btn:focus-visible,
.seg button:focus-visible,
.field input:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.dock {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: auto;
  padding-top: 1rem;
}

.links {
  display: flex;
  justify-content: center;
  gap: 0.25rem 1.5rem;
  flex-wrap: wrap;
}

.link {
  min-height: 2.75rem;
  padding: 0 0.25rem;
  border: 0;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  display: inline-flex;
  align-items: center;
}

.eyebrow {
  margin: 0;
  color: var(--text-muted);
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.hint {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

.big-name {
  margin: 0;
  max-width: 100%;
  font-family: var(--display);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-align: center;
  overflow-wrap: anywhere;
  font-size: clamp(2.5rem, min(6rem, calc((100vw - 2.5rem) / (var(--len, 6) * 0.46))), 6rem);
}

.big-name.land {
  animation: land 260ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes land {
  from {
    transform: scale(1.25);
  }
  to {
    transform: none;
  }
}

/* ---- home */

.home .top-right {
  position: absolute;
  top: calc(0.5rem + env(safe-area-inset-top, 0px));
  right: 0.75rem;
}

.logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  flex: 1;
}

.logo-mark {
  width: min(52vw, 13rem);
  height: auto;
}

.logo-mark .body,
.cyl-svg .body {
  fill: #25262b;
  stroke: var(--metal);
  stroke-width: 4;
}

.hole.live circle:first-child,
.logo-mark .hole.live {
  fill: #3a3b42;
  stroke: var(--metal);
  stroke-width: 3;
}

.hole.live circle:last-child {
  fill: #6b6e76;
}

.hole.bullet {
  fill: var(--danger);
  stroke: #ff8a8f;
  stroke-width: 3;
}

.hole.spent {
  fill: #050506;
  stroke: #2a2b30;
  stroke-width: 3;
}

.hub {
  fill: #121214;
  stroke: var(--metal);
  stroke-width: 3;
}

.logo-title {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: clamp(3.5rem, 18vw, 5.5rem);
  font-weight: 800;
  line-height: 0.88;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* ---- setup */

.setup {
  padding-bottom: calc(7rem + env(safe-area-inset-bottom, 0px));
}

.setup .dock.pinned {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--kb);
  z-index: 5;
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
  padding: 0.75rem 1.25rem calc(1rem + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

.stepper {
  display: grid;
  grid-template-columns: 3.5rem 1fr 3.5rem;
  gap: 1rem;
  align-items: center;
  margin: 0.75rem 0 1.25rem;
}

.step {
  width: 3.5rem;
  height: 3.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-family: var(--display);
  font-size: 2.25rem;
  line-height: 1;
}

.step:disabled {
  opacity: 0.3;
}

.count {
  text-align: center;
}

.count strong {
  display: block;
  font-family: var(--display);
  font-size: 4.5rem;
  line-height: 0.9;
}

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

.fields {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.field {
  position: relative;
  display: grid;
  grid-template-columns: 1rem 1fr;
  align-items: center;
  column-gap: 0.85rem;
  min-height: 3.5rem;
  padding: 0 1rem;
  border: 2px solid transparent;
  border-radius: 0.9rem;
  background: var(--surface);
}

.field:focus-within {
  border-color: #3a3a42;
}

.field.bad {
  border-color: var(--danger);
}

.dot {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--c);
}

.field input {
  width: 100%;
  min-height: 3.25rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 1.125rem;
  font-weight: 600;
}

.field input:focus {
  outline: none;
}

.err {
  grid-column: 2;
  margin: 0;
  color: #ff6b71;
  font-size: 0.875rem;
}

.err:empty {
  display: none;
}

.field.bad {
  padding-bottom: 0.5rem;
}

/* ---- settings */

.rows {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.5rem;
  padding: 0.6rem 1rem;
  border-radius: 0.9rem;
  background: var(--surface);
}

.row-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-label {
  font-weight: 600;
}

.row-hint {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.seg {
  display: flex;
  flex-shrink: 0;
  border-radius: 0.7rem;
  background: #0e0e10;
  padding: 0.2rem;
}

.seg button {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0 0.7rem;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
}

.seg button[aria-pressed="true"] {
  background: var(--danger);
  color: #fff;
}

/* ---- turn */

.strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 7rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875rem;
  font-weight: 600;
}

.chip i {
  flex: none;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--c);
}

.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.cur {
  padding: 0.4rem 0.85rem;
  font-size: 1.05rem;
  background: color-mix(in srgb, var(--c) 30%, var(--surface));
  box-shadow: 0 0 0 2px var(--c);
}

.chip.out {
  color: #6d6d75;
  text-decoration: line-through;
}

.chip.out i {
  background: #4a4a52;
}

.stage {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}

.cyl {
  position: relative;
  width: min(66vw, 17rem);
  aspect-ratio: 1;
}

.cyl-arrow {
  position: absolute;
  top: -0.9rem;
  left: 50%;
  z-index: 2;
  width: 0;
  height: 0;
  margin-left: -0.8rem;
  border-left: 0.8rem solid transparent;
  border-right: 0.8rem solid transparent;
  border-top: 1.2rem solid var(--text);
}

.cyl-rot {
  width: 100%;
  height: 100%;
  will-change: transform;
}

.cyl-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
}

.odds {
  min-height: 1em;
  margin: 0;
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.odds.danger {
  color: var(--danger);
}

.spin-slot {
  min-height: 3.25rem;
}

.btn.hold {
  position: relative;
  overflow: visible;
}

.btn.hold span {
  position: relative;
}

.btn.hold .ring {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  pointer-events: none;
}

.btn.hold .ring rect {
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}

.btn.hold.holding {
  transform: scale(0.98);
}

/* ---- overlays */

.vig {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, 0.85) 100%);
}

.vig.turn {
  opacity: 0.35;
}

.vig.count {
  opacity: 0.6;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.95) 100%);
}

.vig.danger {
  background: radial-gradient(ellipse at center, transparent 45%, rgba(224, 36, 44, 0.45) 100%);
  animation: slow-pulse 2.4s ease-in-out infinite;
}

body.rm .vig.danger {
  animation: none;
  opacity: 0.35;
}

@keyframes slow-pulse {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.6;
  }
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  opacity: 0;
}

.rr::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  box-shadow: inset 0 0 0 0 rgba(47, 191, 113, 0);
}

.rr.glow::after {
  animation: glow 400ms ease-out;
}

body.rm .rr.glow::after {
  animation: glow-fade 400ms ease-out;
}

@keyframes glow {
  0% {
    box-shadow: inset 0 0 5rem 1.5rem rgba(47, 191, 113, 0.75);
  }
  100% {
    box-shadow: inset 0 0 5rem 1.5rem rgba(47, 191, 113, 0);
  }
}

@keyframes glow-fade {
  0% {
    box-shadow: inset 0 0 0 0.5rem rgba(47, 191, 113, 0.5);
  }
  100% {
    box-shadow: inset 0 0 0 0.5rem rgba(47, 191, 113, 0);
  }
}

/* ---- countdown */

.countdown {
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.digit {
  margin: 0;
  min-height: 1em;
  font-family: var(--display);
  font-size: 10rem;
  font-weight: 800;
  line-height: 1;
}

.digit.show {
  animation: beat 380ms ease-out;
}

body.rm .digit.show {
  animation: none;
}

@keyframes beat {
  from {
    transform: scale(1.06);
  }
  to {
    transform: scale(1);
  }
}

/* ---- results */

.result {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.75rem, 14vw, 4.25rem);
  font-weight: 800;
  line-height: 0.95;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.survived .result {
  color: var(--text);
}

.next {
  margin: 0;
  min-height: 1.5em;
  font-size: 1.5rem;
  font-weight: 600;
}

.next.danger {
  color: #ff5a60;
}

.reloading {
  margin: 0;
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.alive {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.alive li {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 600;
}

.alive i {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--c);
}

.eliminated .bar-title,
.eliminated .icon-btn {
  color: rgba(255, 255, 255, 0.85);
}

.eliminated .btn.primary {
  background: #fff;
  color: #4a070c;
}

/* ---- pass / reveal / winner */

.pass,
.reveal,
.winner {
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
}

.pass .dock,
.winner .dock {
  width: 100%;
}

.pass .big-name {
  margin-bottom: auto;
  margin-top: 0;
}

.pass,
.winner {
  justify-content: flex-start;
  padding-top: 20vh;
}

.reveal .hint {
  position: absolute;
  bottom: calc(2rem + env(safe-area-inset-bottom, 0px));
  left: 0;
  right: 0;
}

.winner .big-name.win {
  font-size: clamp(3rem, min(7rem, calc((100vw - 2.5rem) / (var(--len, 6) * 0.46))), 7rem);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  width: 100%;
  margin: 1.25rem 0 0;
}

.stats div {
  padding: 0.75rem 0.25rem;
  border-radius: 0.9rem;
  background: var(--surface);
}

.stats dt {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.stats dd {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 800;
}

#confetti {
  position: fixed;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---- pause */

.pause {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
}

.sheet {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 100%;
  max-width: 30rem;
  padding: 1.5rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
  border-radius: 1.25rem 1.25rem 0 0;
  background: var(--surface);
}

.sheet h2 {
  margin: 0 0 0.5rem;
  text-align: center;
  font-family: var(--display);
  font-size: 2rem;
  text-transform: uppercase;
}

/* ---- toast, live region */

.toast {
  position: fixed;
  left: 50%;
  top: calc(1rem + env(safe-area-inset-top, 0px));
  z-index: 30;
  max-width: 90vw;
  padding: 0.75rem 1.25rem;
  border-radius: 0.75rem;
  background: #f2f2f2;
  color: #0e0e10;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -1rem);
  transition: opacity 200ms, transform 200ms;
}

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

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

/* ---- rotate message: phones in landscape */

.orient-gate {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: #0e0e10;
  text-align: center;
}

.orient-title {
  margin: 0;
  color: #f2f2f2;
  font-family: var(--display);
  font-size: 2.5rem;
  font-weight: 800;
  text-transform: uppercase;
}

.orient-copy {
  margin: 0;
  max-width: 20rem;
  color: #9a9aa2;
}

@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .orient-gate {
    display: flex;
  }
}

/* ---- larger screens: keep the phone-shaped column, centred */

@media (min-width: 640px) {
  .app {
    max-width: 28rem;
  }
}

body.rm .app.enter,
body.rm .big-name.land {
  animation: fade 250ms ease-out;
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-height: 640px) {
  .cyl {
    width: min(50vw, 13rem);
  }

  .odds {
    font-size: 2rem;
  }
}

/* CJK and Arabic: no tracking or forced caps. */
body[class*="font-"] .rr * {
  letter-spacing: 0;
  text-transform: none;
}
