:root {
  --bg: #0a0810;
  --surface: rgba(18, 14, 24, 0.84);
  --surface-strong: rgba(24, 20, 30, 0.96);
  --surface-soft: rgba(255, 255, 255, 0.05);
  --text: #f6f1e8;
  --muted: #c2b3af;
  --line: rgba(255, 255, 255, 0.08);
  --gold: #f1c277;
  --gold-strong: #ffe0aa;
  --mint: #88d7a4;
  --danger: #ff9a8f;
  --violet: #7e5cff;
  --ember: #ff7c5e;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Manrope", system-ui, sans-serif;
  background:
    radial-gradient(circle at 20% 10%, rgba(126, 92, 255, 0.22), transparent 26%),
    radial-gradient(circle at 88% 12%, rgba(255, 124, 94, 0.18), transparent 18%),
    linear-gradient(180deg, #110d17 0%, #08070b 100%);
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 94%);
}

.page {
  width: min(100% - 24px, 560px);
  margin: 0 auto;
  padding: 12px 0 calc(120px + env(safe-area-inset-bottom));
}

.hero,
.panel,
.history-shell,
.arsenal__list,
.mobile-dock {
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 80% 20%, rgba(126, 92, 255, 0.16), transparent 24%),
    radial-gradient(circle at 20% 80%, rgba(255, 124, 94, 0.12), transparent 26%),
    linear-gradient(160deg, rgba(19, 15, 24, 0.96) 0%, rgba(11, 9, 14, 0.96) 100%);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.04) 50%, transparent 100%);
  transform: translateX(-65%);
  animation: sheen 8.5s linear infinite;
  pointer-events: none;
}

@keyframes sheen {
  to {
    transform: translateX(135%);
  }
}

.topbar,
.hero__stack,
.section-heading,
.panel,
.history-shell,
.arsenal__list {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.topbar__actions {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.topbar__badge {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.language-picker {
  width: 100%;
}

.language-select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
}

.language-select:focus {
  outline: none;
  border-color: rgba(241, 194, 119, 0.32);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-strong) 100%);
  color: #241810;
  font-family: "Cinzel", serif;
  font-weight: 900;
  font-size: 1.1rem;
}

.brand__name,
.brand__meta {
  margin: 0;
}

.brand__name {
  font-size: 0.95rem;
  font-weight: 800;
}

.brand__meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.hero__stack {
  display: grid;
  gap: 18px;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.68rem;
  color: var(--gold);
}

.eyebrow--soft {
  color: #dbbf94;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Cinzel", Georgia, serif;
  letter-spacing: 0.01em;
}

h1 {
  font-size: clamp(2.55rem, 10vw, 4rem);
  line-height: 0.95;
  max-width: 10ch;
}

h2 {
  font-size: clamp(1.8rem, 7vw, 2.5rem);
}

h3 {
  font-size: 1.2rem;
}

.hero__lead,
.section-copy,
.status-message,
.result-panel,
.history__item,
.history__empty,
.arsenal-item p {
  line-height: 1.65;
}

.hero__lead,
.section-copy,
.status-message {
  color: var(--muted);
  font-size: 0.98rem;
  margin: 0;
}

.hero__visual {
  position: relative;
  min-height: 240px;
  display: grid;
  place-items: center;
}

.sigil,
.hero-glow {
  position: absolute;
  border-radius: 50%;
}

.sigil {
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.sigil--outer {
  width: min(72vw, 280px);
  aspect-ratio: 1;
  box-shadow: inset 0 0 0 14px rgba(255, 255, 255, 0.015);
  animation: spin 24s linear infinite;
}

.sigil--inner {
  width: min(52vw, 210px);
  aspect-ratio: 1;
  border-style: dashed;
  animation: spin-reverse 16s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes spin-reverse {
  to {
    transform: rotate(-360deg);
  }
}

.hero-die-shell {
  position: relative;
  width: min(42vw, 180px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.hero-die-shell::before {
  content: "";
  position: absolute;
  inset: -18px;
  border-radius: 30px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.01));
  filter: blur(16px);
}

.hero-die,
.die {
  position: relative;
  display: grid;
  place-items: center;
  font-family: "Cinzel", serif;
  font-weight: 900;
  color: #261a12;
  background: linear-gradient(145deg, #ffedc4 0%, #f1c277 50%, #a86934 100%);
  box-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.3),
    inset 0 -12px 18px rgba(0, 0, 0, 0.18),
    0 16px 34px rgba(0, 0, 0, 0.3);
}

.hero-die {
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 0%, 100% 28%, 100% 72%, 50% 100%, 0% 72%, 0% 28%);
  font-size: clamp(3.3rem, 13vw, 4.6rem);
  animation: hover 4.8s ease-in-out infinite;
}

.hero-die::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  clip-path: inherit;
}

@keyframes hover {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

.hero-glow {
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(242, 194, 119, 0.24), transparent 60%);
}

.hero__actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 52px;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 180ms ease,
    filter 180ms ease,
    background 180ms ease,
    border-color 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.button--primary {
  color: #23170f;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-strong) 100%);
}

.button--secondary,
.button--ghost {
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

.hero__facts {
  display: grid;
  gap: 10px;
}

.fact {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.fact__label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.arena,
.chronicle,
.arsenal {
  margin-top: 18px;
}

.site-footer {
  margin-top: 18px;
  padding: 18px 6px 6px;
  color: var(--muted);
}

.site-footer__copy,
.site-footer__meta {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.site-footer__meta {
  margin-top: 4px;
  opacity: 0.9;
}

.section-heading {
  margin-bottom: 14px;
}

.arena__grid {
  display: grid;
  gap: 16px;
}

.panel {
  overflow: hidden;
  padding: 18px;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at top right, rgba(126, 92, 255, 0.08), transparent 24%),
    linear-gradient(180deg, rgba(20, 16, 24, 0.9) 0%, rgba(13, 11, 18, 0.94) 100%);
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-badge {
  flex-shrink: 0;
  padding: 8px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.solo-panel {
  display: grid;
  gap: 18px;
}

.solo-toolbox {
  display: grid;
  gap: 10px;
}

.solo-toolbox__label,
.solo-toolbox__meta,
.duel-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

.solo-toolbox__meta {
  font-weight: 700;
  color: var(--text);
}

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

.dice-chip {
  min-height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    box-shadow 180ms ease;
}

.dice-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(241, 194, 119, 0.24);
}

.dice-chip--active {
  border-color: rgba(241, 194, 119, 0.38);
  background: linear-gradient(135deg, rgba(241, 194, 119, 0.18), rgba(255, 224, 170, 0.08));
  box-shadow: inset 0 0 0 1px rgba(241, 194, 119, 0.12);
}

.is-hidden {
  display: none !important;
}

.die-stage {
  display: grid;
  place-items: center;
}

.die-frame {
  position: relative;
  width: 180px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.die-frame::before,
.die-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.die-frame::before {
  border: 1px solid rgba(255, 255, 255, 0.08);
  animation: spin 20s linear infinite;
}

.die-frame::after {
  inset: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  animation: spin-reverse 14s linear infinite;
}

.die {
  width: 128px;
  height: 128px;
  clip-path: polygon(50% 0%, 100% 28%, 100% 72%, 50% 100%, 0% 72%, 0% 28%);
  font-size: 3rem;
  z-index: 1;
}

.die--rolling {
  animation: toss 760ms cubic-bezier(0.22, 1, 0.36, 1);
}

.die--critical {
  box-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.32),
    inset 0 -12px 22px rgba(0, 0, 0, 0.18),
    0 0 0 10px rgba(136, 215, 164, 0.08),
    0 0 72px rgba(136, 215, 164, 0.26);
}

.die--fumble {
  box-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.22),
    inset 0 -12px 22px rgba(0, 0, 0, 0.24),
    0 0 0 10px rgba(255, 154, 143, 0.08),
    0 0 72px rgba(255, 154, 143, 0.24);
}

@keyframes toss {
  0% {
    transform: rotate(0deg) scale(0.94);
  }
  24% {
    transform: rotate(30deg) scale(1.05);
  }
  48% {
    transform: rotate(-24deg) scale(0.98);
  }
  72% {
    transform: rotate(16deg) scale(1.03);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

.players {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.player-row {
  display: grid;
  gap: 8px;
}

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

input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

input::placeholder {
  color: rgba(194, 179, 175, 0.8);
}

input:hover,
input:focus {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(241, 194, 119, 0.28);
}

input:focus {
  outline: none;
  transform: translateY(-1px);
}

.result-panel {
  min-height: 154px;
  padding: 16px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, rgba(255, 255, 255, 0.02) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.result-panel--flash {
  animation: flash 560ms ease;
}

@keyframes flash {
  0% {
    transform: scale(0.99);
    border-color: rgba(241, 194, 119, 0.36);
  }
  100% {
    transform: scale(1);
    border-color: rgba(255, 255, 255, 0.08);
  }
}

.result-panel__intro,
.result-panel__headline {
  margin: 0;
}

.result-panel__headline {
  margin-bottom: 8px;
  font-size: 1.08rem;
}

.result-panel__headline--coin {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.winner {
  color: var(--mint);
}

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

.result-rolls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.result-roll {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 0.88rem;
}

.history-shell {
  border-radius: var(--radius-lg);
  padding: 14px;
  background:
    radial-gradient(circle at top left, rgba(126, 92, 255, 0.08), transparent 24%),
    linear-gradient(180deg, rgba(17, 14, 20, 0.9) 0%, rgba(13, 11, 16, 0.94) 100%);
}

.history {
  display: grid;
  gap: 10px;
}

.history__item,
.history__empty {
  margin: 0;
  padding: 13px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.history__item {
  border-left: 2px solid rgba(241, 194, 119, 0.34);
}

.history__empty {
  font-style: italic;
}

.arsenal__list {
  overflow: hidden;
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 100% 0%, rgba(255, 124, 94, 0.08), transparent 22%),
    linear-gradient(180deg, rgba(17, 14, 20, 0.9) 0%, rgba(13, 11, 16, 0.94) 100%);
}

.arsenal-item {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.arsenal-item:first-child {
  border-top: 0;
}

.arsenal-item__index {
  color: var(--gold);
  font-family: "Cinzel", serif;
  font-size: 1rem;
}

.arsenal-item p {
  margin: 6px 0 0;
  color: var(--muted);
}

.mobile-dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1.15fr 1fr;
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(18, 14, 24, 0.88);
  z-index: 20;
}

.mobile-dock__button {
  min-height: 50px;
  padding-inline: 12px;
  font-size: 0.94rem;
}

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms ease, transform 700ms ease;
}

.reveal--visible,
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

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

@media (min-width: 700px) {
  .page {
    width: min(100% - 28px, 1080px);
    padding-bottom: 56px;
  }

  .hero {
    padding: 24px;
  }

  .topbar {
    align-items: center;
  }

  .topbar__actions {
    justify-items: end;
  }

  .language-picker {
    width: auto;
  }

  .language-select {
    min-width: 98px;
  }

  .hero__stack {
    grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
    align-items: center;
    column-gap: 24px;
  }

  .hero__copy,
  .hero__actions,
  .hero__facts {
    grid-column: 1;
  }

  .hero__visual {
    grid-column: 2;
    grid-row: 1 / span 3;
    min-height: 360px;
  }

  .hero__actions {
    flex-wrap: nowrap;
  }

  .hero__actions .button,
  .button-row .button {
    width: auto;
    flex: 1 1 0;
  }

  .hero__actions .button--ghost.is-hidden {
    display: none !important;
  }

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

  .arena__grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  }

  .arsenal-item {
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .dice-picker {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  .mobile-dock {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
