: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 {
  --settle: cubic-bezier(.18,.72,.24,1);
  --caption-top: max(58svh, min(37.5vw, 63svh), calc(24svh + 21.9vw));
  --trace-time: 510ms;
  --name-delay: 145ms;
  --detail-delay: 235ms;
  --action-delay: 290ms;
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  overflow: clip;
}
.world[data-pace="quick"] {
  --trace-time: 300ms;
  --name-delay: 70ms;
  --detail-delay: 135ms;
  --action-delay: 175ms;
}
.scenery { position: absolute; z-index: -1; inset: 0; pointer-events: none; }
.scenery {
  background-position: center top;
  background-repeat: no-repeat;
  background-size: cover;
  transition: opacity 270ms var(--settle);
}
.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 {
  --art-height: max(100svh, 62.63vw);
  --art-width: max(100vw, 159.68svh);
  --face-x: 40.9%;
  --face-y: 12.5%;
  --face-width: 16.6%;
  --face-height: 43.7%;
  opacity: 0;
  height: 100svh;
  overflow: clip;
}
.plate-frame {
  position: absolute;
  left: 50%;
  top: calc((100svh - var(--art-height)) * .24);
  width: var(--art-width);
  height: var(--art-height);
  transform: translateX(-50%);
}
.plate-frame picture, .plate-frame img, .ink-veil { position: absolute; inset: 0; width: 100%; height: 100%; }
.plate-frame img { display: block; }
.ink-veil {
  background: radial-gradient(ellipse 27% 45% at 50% calc(var(--face-y) + var(--face-height) / 2),
    #09181c42 0%, #09181c91 50%, #081419d1 100%);
  opacity: 0;
  transition: opacity 340ms var(--settle);
}
:is([data-stage="draw"], [data-stage="result"]) .entry-art { opacity: 0; transition-delay: 75ms; }
:is([data-stage="draw"], [data-stage="result"]) .result-art { opacity: 1; }
[data-stage="draw"] .ink-veil { opacity: 1; transition-duration: 165ms; }
.seal-face {
  position: absolute;
  top: var(--face-y); left: var(--face-x);
  width: var(--face-width); height: var(--face-height);
}
.seal-trace, .seal-sheen { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; }
.seal-trace { overflow: visible; }
.seal-trace path {
  fill: none;
  stroke: #ffe4a7;
  stroke-width: 1.7px;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 22 78;
  filter: drop-shadow(0 0 3px #efb357);
}
[data-stage="draw"] .seal-trace { animation: trace-light var(--trace-time) linear; }
[data-stage="draw"] .seal-trace path { animation: ink-trace var(--trace-time) var(--settle); }
.seal-sheen {
  overflow: clip;
  clip-path: polygon(27% 2%, 79% 2%, 95% 14%, 99% 89%, 90% 99%, 14% 99%, 2% 88%, 15% 12%);
}
.seal-sheen::before {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(163deg, transparent 26%, #fbd09520 41%, #fff0be8c 49%, #eab97130 54%, transparent 67%);
}
[data-reveal] .seal-sheen { animation: glaze-light 455ms var(--settle); }
[data-reveal] .seal-sheen::before { animation: glaze-pass 455ms var(--settle); }
@keyframes trace-light {
  0%, 100% { opacity: 0; }
  16% { opacity: .82; }
  67% { opacity: .55; }
}
@keyframes ink-trace { from { stroke-dashoffset: 22; } to { stroke-dashoffset: -70; } }
@keyframes glaze-light {
  0%, 100% { opacity: 0; }
  24% { opacity: 1; }
}
@keyframes glaze-pass {
  from { transform: translateY(90%); }
  to { transform: translateY(-84%); }
}

.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: transform 155ms var(--settle);
}
.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:active:not(:disabled) { transform: translateY(1px) scale(.985); transition-duration: 75ms; }
@media (hover: hover) and (pointer: fine) {
  .gold-button:hover:not(:disabled) { filter: brightness(1.1) drop-shadow(0 0 15px #f7bb6850); }
}

.drawing {
  text-align: center;
  min-height: 100svh;
  padding: var(--caption-top) var(--gutter) 2rem;
}
.drawing h2 {
  color: var(--gold); font-size: clamp(.9rem, 1.52vw, 1.3rem); font-weight: 400;
  letter-spacing: .16em; text-shadow: 0 2px 15px #070e11; margin: 0;
}

.result {
  position: relative; text-align: center; width: min(100%, 70rem); margin: auto;
  padding: var(--caption-top) var(--gutter) 2rem;
}
[data-reveal] .result-label::before, [data-reveal] .result-label::after {
  animation: letter-rule 270ms var(--settle) backwards;
}
[data-reveal] .result h2 { animation: inscribe-name 345ms var(--settle) var(--name-delay) backwards; }
[data-reveal] .winner-id { animation: settle-detail 230ms var(--settle) var(--detail-delay) backwards; }
[data-reveal] .result-actions { animation: settle-detail 190ms var(--settle) var(--action-delay) backwards; }
@keyframes letter-rule { from { scale: .18 1; opacity: .45; } to { scale: 1; opacity: 1; } }
@keyframes inscribe-name {
  from { clip-path: inset(115% -.3em -.25em); transform: translateY(.14em); }
  to { clip-path: inset(-.3em); transform: none; }
}
@keyframes settle-detail {
  from { opacity: 0; transform: translateY(.2em); }
  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) {
  .world { --caption-top: clamp(15.4rem, 79vw, 31rem); }
  .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 {
    --art-height: 150vw;
    --art-width: 100vw;
    --face-x: 34%;
    --face-y: 10%;
    --face-width: 32%;
    --face-height: 35.3%;
  }
  .plate-frame { top: 0; }
  .result-art::after { background: linear-gradient(180deg, transparent 39%, #0b171b25 68%, var(--ink) min(150vw, 46rem)); }
  .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; }
}

@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; }
  .gold-button:active:not(:disabled) { transform: none; }
}

