:root {
  color-scheme: dark;
  --ink: #0b171b;
  --ivory: #f6ead4;
  --muted: #d2c8b7;
  --gold: #edc68b;
  --line: #d8b78375;
  --serif: "Palatino Linotype", Palatino, "Times New Roman", serif;
  --ui: system-ui, sans-serif;
  --gutter: clamp(1.25rem, 2.5vw, 3rem);
  font-family: var(--serif);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--ink); color: var(--ivory); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid #ffdfa2; outline-offset: 3px; }
h2[tabindex]:focus { outline: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

.world {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  overflow: clip;
}
.scenery, .reveal-light { position: absolute; z-index: -1; inset: 0; pointer-events: none; }
.scenery {
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  transition: opacity .65s ease, filter .85s ease, transform .85s ease;
}
.scenery::after { content: ""; position: absolute; inset: 0; }
.entry-art { background-image: url("/assets/river-desktop.webp"); background-position: 32% top; }
.entry-art::after {
  background: linear-gradient(90deg, #06111654, #09151938 39%, transparent 65%),
    linear-gradient(0deg, #07131756, transparent 27%);
}
.result-art {
  display: none;
  background-image: url("/assets/reveal-desktop.webp");
  background-position: 50% 24%;
}
[data-stage="draw"] .entry-art, [data-stage="result"] .entry-art { opacity: 0; }
[data-stage="draw"] .result-art { display: block; filter: brightness(.57) saturate(.76) blur(1.5px); transform: scale(1.025); }
[data-stage="result"] .result-art { display: block; }
[data-stage="result"] .reveal-light {
  z-index: 0;
  background: radial-gradient(ellipse 30% 38% at 50% 32%, #ffe0a66c, #ffc66e1f 46%, transparent 75%);
  animation: flash .95s ease-out both;
}
@keyframes flash { from { opacity: .85; } to { opacity: 0; } }

.masthead {
  display: flex; align-items: center; gap: .9rem;
  margin-inline: var(--gutter); padding-block: .55rem;
  color: #f3dfba; font-size: clamp(1.05rem, 1.85vw, 1.6rem);
  border-bottom: 1px solid var(--line);
  text-shadow: 0 1px 8px #091418;
}
.masthead img { display: block; width: 2.3rem; height: auto; }
[data-stage="draw"] .masthead, [data-stage="result"] .masthead { display: none; }

.entry {
  position: relative;
  width: min(42rem, 50%);
  margin: clamp(2.2rem, 11.5vh, 7.6rem) 0 0 clamp(2rem, 8.05vw, 11rem);
  padding-bottom: clamp(2.5rem, 8vh, 6rem);
}
.eyebrow, .result-label {
  margin: 0;
  font-size: clamp(.74rem, 1.22vw, 1.15rem);
  font-weight: 700; letter-spacing: .23em;
  text-transform: uppercase;
  color: #f4e4c6;
}
.eyebrow::after {
  content: ""; display: block; width: 4.25rem; height: 2px; margin-top: .7rem;
  background: linear-gradient(90deg, #f3d098 47%, #a48457 47%, #a4845724);
}
h1, h2, p { margin-block-start: 0; }
h1 {
  margin: .65rem 0 .48rem;
  font-size: clamp(3.9rem, 6.8vw, 7.7rem);
  font-weight: 700; line-height: .93; letter-spacing: -.052em;
  text-shadow: 0 3px 14px #051114b0, 0 1px 1px #120c07;
}
.title-tail { display: flex; align-items: center; gap: .15em; }
h1 em {
  color: #efbd6b; font-style: normal;
  background: linear-gradient(#ffe3a7 3%, #f5c471 48%, #bd7d3d 100%);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 2px 1px #0a0d0c);
}
.title-seal {
  display: inline-block; transform: translateY(.12em);
  padding: .17em .18em .14em; border: 1px solid #e06547;
  color: #ec7758; background: #41191044;
  box-shadow: inset 0 0 0 1px #e065473b;
  font: 400 clamp(.58rem, 1.11vw, 1.05rem)/1.06 KaiTi, "Microsoft YaHei", serif;
  letter-spacing: 0; text-align: center; text-shadow: none;
}
.intro {
  margin: .65rem 0 1.65rem;
  color: var(--ivory); font-size: clamp(1.06rem, 1.45vw, 1.46rem); line-height: 1.4;
  text-shadow: 0 2px 7px #061012;
}

.roster { width: min(100%, 29.4rem); }
.roster-header {
  display: flex; align-items: center; justify-content: space-between; gap: .55rem;
  border-bottom: 1px solid var(--line); margin-bottom: .72rem;
}
.roster-header h2 { margin: 0; font-size: clamp(1.05rem, 1.6vw, 1.5rem); line-height: 1.16; }
#roster-count { margin-left: .25rem; font-family: var(--ui); color: var(--gold); font-size: .67em; font-weight: 500; }
.text-button {
  min-height: 2.75rem; padding: .25rem .15rem; border: 0; background: transparent;
  color: var(--gold); font-size: clamp(.93rem, 1.1vw, 1.08rem); text-underline-offset: .2em;
}
.text-button:hover { color: #ffe4b6; text-decoration: underline; }
#paste-open { flex: none; }

.player-form {
  display: grid; grid-template-columns: 1.15fr 1fr 2.75rem; gap: .5rem;
}
input, textarea, .add-button {
  border: 1px solid #caa977a8; border-radius: 2px;
  background: #0c1a1ee8; color: var(--ivory);
}
input, textarea { font-size: 1rem; }
input { min-height: 2.75rem; min-width: 0; padding: .4rem .65rem; }
input::placeholder, textarea::placeholder { color: #cbc3b2; opacity: 1; }
input[aria-invalid], textarea[aria-invalid] { border-color: #f29277; }
#player-id, .player-list .player-id { font-variant-numeric: lining-nums tabular-nums; }
.add-button { font-size: 1.65rem; color: var(--gold); line-height: 1; }
.add-button:hover { border-color: #ffe0a5; background: #253330; }
.empty, .feedback {
  margin: .65rem 0 0; color: var(--muted); font: .81rem/1.4 var(--ui);
}
.feedback { color: #ffc6b1; }
.player-list { padding: 0; margin: .5rem 0 0; list-style: none; max-height: 8.15rem; overflow: auto; scrollbar-color: #a48962 #0a171b; }
.player-list li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 2.75rem; align-items: center; gap: .45rem;
  min-height: 2.65rem; padding-left: .55rem; border-bottom: 1px solid #d8b78351;
  background: #0b171b6b; font-size: 1.05rem;
}
.player-list .player-name { overflow-wrap: anywhere; }
.player-list .player-id { font-size: .93rem; color: var(--muted); }
.player-list .chosen { color: var(--gold); font: .67rem var(--ui); white-space: nowrap; margin-left: .4em; }
.remove-player { min-height: 2.65rem; border: 0; color: var(--muted); background: none; font: 1.25rem var(--ui); }
.remove-player:hover { color: #ffd2bc; background: #43272177; }
.entry-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem 1.1rem; margin-top: 1.35rem; }
#draw-button { min-width: min(100%, 18.5rem); }

.gold-button {
  --shape: polygon(0 13%, 3% 13%, 3% 0, 97% 0, 97% 13%, 100% 13%, 100% 87%, 97% 87%, 97% 100%, 3% 100%, 3% 87%, 0 87%);
  position: relative; isolation: isolate;
  min-height: 3.55rem; min-width: min(100%, 15.6rem); padding: .75rem 1.45rem;
  border: 0; background: transparent; color: #26180b;
  font-weight: 700; font-size: clamp(1.15rem, 1.85vw, 1.85rem); line-height: 1.05;
  filter: drop-shadow(0 6px 12px #050b0ba0); transition: filter .18s ease;
}
.gold-button::before, .gold-button::after {
  content: ""; position: absolute; pointer-events: none; z-index: -1; clip-path: var(--shape);
}
.gold-button::before { inset: 0; background: linear-gradient(145deg, #fae1a7, #996039 56%, #f0c684); }
.gold-button::after {
  inset: 4px; border: 1px solid #553517;
  box-shadow: inset 0 0 0 2px #edc17e, inset 0 0 12px #a16838a3;
  background: url("/assets/foil.svg") center/100% 100%, linear-gradient(140deg, #efd093, #f3d8a1 45%, #cd9b64);
}
.gold-button:hover:not(:disabled) { filter: brightness(1.12) drop-shadow(0 0 15px #f7bb6865); }

.drawing {
  display: grid; place-items: center; align-content: end;
  min-height: 100svh; padding: 2rem var(--gutter) max(13vh, 3rem);
}
.drawing h2 {
  font-size: clamp(1.35rem, 2.9vw, 2.7rem); font-weight: 400;
  letter-spacing: .11em; text-shadow: 0 2px 15px #070e11; margin: 0;
}
.orbit {
  position: absolute; top: 33%; left: 50%; width: min(39vw, 43vh); aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(-22deg) scaleY(.81);
}
.orbit::before, .orbit::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 10deg, transparent 8%, #ffdd946e 28%, #fff1c4 36%, transparent 45%, transparent 62%, #e0a84d90 76%, transparent 91%);
  mask: radial-gradient(farthest-side, transparent calc(100% - 2px), #000 calc(100% - 1px));
  animation: orbit .94s linear infinite;
}
.orbit::after { inset: 11%; animation-direction: reverse; animation-duration: 1.45s; opacity: .7; }
.orbit i {
  --angle: 0deg;
  position: absolute; top: 50%; left: 50%; width: 4px; height: 4px;
  border-radius: 50%; background: #fff2c2; box-shadow: 0 0 12px 4px #f7b85b;
  animation: sparks 1.35s ease-out infinite; animation-delay: calc(var(--n, 0) * -0.21s);
}
.orbit i:nth-child(2) { --n: 1; --angle: 55deg; }
.orbit i:nth-child(3) { --n: 2; --angle: 110deg; }
.orbit i:nth-child(4) { --n: 3; --angle: 164deg; }
.orbit i:nth-child(5) { --n: 4; --angle: 222deg; }
.orbit i:nth-child(6) { --n: 5; --angle: 280deg; }
@keyframes orbit { to { transform: rotate(1turn); } }
@keyframes sparks {
  from { opacity: 0; transform: rotate(var(--angle)) translateX(4vw); }
  38% { opacity: 1; }
  to { opacity: 0; transform: rotate(calc(var(--angle) + 44deg)) translateX(16vw); }
}

.result {
  position: relative; text-align: center; width: min(100%, 70rem); margin: auto;
  padding: max(58svh, min(37.5vw, 63svh)) var(--gutter) 2rem;
  animation: reveal .75s cubic-bezier(.17,.73,.23,1) both;
}
@keyframes reveal {
  from { opacity: 0; transform: translateY(.9rem); }
  25% { opacity: .32; }
  to { opacity: 1; transform: none; }
}
.result-label {
  display: flex; justify-content: center; align-items: center; gap: clamp(.55rem, 2vw, 1.8rem);
  color: #f1ca91; letter-spacing: .31em; font-weight: 600;
  text-shadow: 0 2px 10px #071013;
}
.result-label::before, .result-label::after {
  content: ""; width: clamp(1rem, 4vw, 4.4rem); height: 1px; flex: none;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.result-label::after { transform: rotate(180deg); }
.result h2 {
  margin: .5rem auto .25rem;
  font-size: clamp(3.25rem, 6.35vw, 7.5rem);
  font-weight: 700; letter-spacing: -.042em; line-height: 1.05;
  text-wrap: balance; overflow-wrap: anywhere;
  text-shadow: 0 2px 12px #071013;
}
.result h2[data-long] { font-size: clamp(2.35rem, 4.65vw, 5.3rem); }
.winner-id {
  margin: 0; font-size: clamp(1.12rem, 2vw, 1.8rem); font-style: italic;
  color: #f2d9ae; letter-spacing: .075em; font-variant-numeric: lining-nums tabular-nums;
  text-shadow: 0 2px 9px #071013;
}
.result-actions { display: grid; justify-items: center; gap: .2rem; margin-top: clamp(.8rem, 2.7vh, 1.8rem); }
.result-button {
  --shape: polygon(6% 0, 94% 0, 100% 30%, 100% 70%, 94% 100%, 6% 100%, 0 70%, 0 30%);
  min-width: min(100%, 18rem);
}

dialog {
  width: min(35rem, calc(100% - 2rem)); max-height: calc(100% - 2rem); padding: clamp(1.2rem, 4vw, 2rem);
  border: 1px solid var(--line); border-radius: 2px;
  color: var(--ivory); background: #102024; box-shadow: 0 1.2rem 5rem #000a;
}
dialog::backdrop { background: #071014d9; }
dialog h2 { margin-bottom: .6rem; font-size: 1.8rem; }
dialog p:not(.feedback) { color: var(--muted); font: .92rem/1.5 var(--ui); }
textarea { display: block; width: 100%; resize: vertical; min-height: 7rem; padding: .75rem; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .55rem 1rem; margin-top: 1rem; }
.dialog-actions .gold-button { min-width: 0; font-size: 1.15rem; min-height: 2.75rem; }

@media (max-width: 900px) and (min-width: 701px) {
  .entry { width: 49%; margin-left: 5vw; }
  h1 { font-size: clamp(3.2rem, 7.25vw, 4.3rem); }
  .entry-art::after { background: linear-gradient(90deg, #0712178c, #09151955 45%, transparent 70%); }
}
@media (max-width: 700px) {
  .masthead { min-height: 3.45rem; gap: .55rem; }
  .masthead img { width: 1.85rem; }
  .entry-art, .result-art { background-size: 100% auto; background-position: center top; }
  .entry-art { background-image: url("/assets/river-mobile.webp"); }
  .entry-art::after {
    background: linear-gradient(180deg, #0b171b36, transparent min(48vw, 17rem),
      #0b171b38 min(63vw, 22rem), #0b171bbd min(94vw, 32rem), var(--ink) min(143vw, 45rem));
  }
  .entry {
    width: auto; margin: clamp(12.6rem, 65vw, 22rem) var(--gutter) 0;
    padding-bottom: 2.1rem;
  }
  .eyebrow { font-size: .69rem; letter-spacing: .18em; }
  .eyebrow::after { margin-top: .45rem; width: 2.7rem; }
  h1 { font-size: clamp(2.65rem, 10.5vw, 4.3rem); margin-top: .55rem; }
  .title-tail { display: inline-flex; gap: .11em; }
  .title-seal { font-size: .53rem; transform: translateY(.08em); }
  .intro { font-size: 1.03rem; margin-bottom: 1.15rem; }
  .roster { width: 100%; }
  .entry-actions > .gold-button { flex: 1 1 100%; }
  .player-form { grid-template-columns: minmax(0, 1fr) minmax(0, .95fr) 2.75rem; gap: .38rem; }
  input { padding-inline: .48rem; }
  .player-list li { font-size: .98rem; }
  .player-list .player-id { font-size: .85rem; }
  .result-art { background-image: url("/assets/reveal-mobile.webp"); }
  .result-art::after { background: linear-gradient(180deg, transparent 39%, #0b171b25 68%, var(--ink) min(150vw, 46rem)); }
  .result { padding-top: clamp(15.4rem, 79vw, 31rem); }
  .result h2 { font-size: clamp(2.7rem, 10.8vw, 4.25rem); }
  .result h2[data-long] { font-size: clamp(1.95rem, 8vw, 3rem); }
  .result-label { font-size: .72rem; letter-spacing: .23em; }
  .result-button { min-height: 3.15rem; }
  .orbit { top: min(40vw, 19rem); width: 65vw; }
  .drawing { padding-bottom: 22vh; }
  [data-stage="result"] .reveal-light { background: radial-gradient(ellipse 60% 25% at 50% 27%, #ffe0a66c, transparent 75%); }
}

@media (max-width: 700px) and (max-height: 660px) {
  .entry { margin-top: clamp(10rem, 54vw, 14rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal-light { opacity: 0; }
}

