:root {
  --bg1: #04121f;
  --bg2: #0a2a44;
  --panel: rgba(14, 46, 72, 0.78);
  --panel2: rgba(22, 66, 98, 0.85);
  --line: rgba(120, 220, 215, 0.22);
  --text: #e6f6f8;
  --muted: #a9cfd8;
  --teal: #3fd6c8;
  --teal-d: #1a9b92;
  --gold: #f2c14e;
  --gold-d: #b98a1c;
  --bad: #ff8a7a;
  --radius: 14px;
}
* { box-sizing: border-box; }
html {
  min-height: 100%;
  background: radial-gradient(1200px 700px at 70% -10%, #11456b 0%, transparent 60%) no-repeat, linear-gradient(180deg, var(--bg2), var(--bg1) 70%) no-repeat, var(--bg1);
  background-attachment: scroll;
}
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: transparent;
}
.sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
a { color: var(--teal); }
a:hover { color: #8ff3ea; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 0; background: var(--gold); color: #000; padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; top: 8px; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; max-width: 1000px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.3rem; letter-spacing: 0.5px; color: var(--text); text-decoration: none; }
main { max-width: 1000px; margin: 0 auto; padding: 8px 16px 48px; position: relative; z-index: 1; }
main:focus, [data-k="endh"]:focus, [data-k="rvh"]:focus { outline: none; }
h1 { font-size: 2rem; margin: 8px 0; }
h2 { font-size: 1.15rem; margin: 0 0 10px; color: var(--teal); }
.muted { color: var(--muted); }
.center { text-align: center; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 14px 0; backdrop-filter: blur(4px); }
.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.sb { justify-content: space-between; }
label { display: block; font-size: 0.85rem; color: var(--muted); margin: 8px 0 3px; }
input, select {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #07203a; color: var(--text); font: inherit;
}
input.code { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; text-align: center; }
button, .btn {
  font: inherit; font-weight: 700; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--teal-d);
  background: var(--panel2); color: var(--text); cursor: pointer; text-decoration: none; display: inline-block; min-height: 44px;
  transition: transform 0.12s, background 0.2s, box-shadow 0.2s;
}
button:hover:not(:disabled), .btn:hover { background: #1d5d86; transform: translateY(-1px); color: var(--text); }
button:disabled { opacity: 0.6; cursor: not-allowed; }
button.primary, .btn.primary { background: linear-gradient(180deg, var(--teal), var(--teal-d)); color: #02161c; border-color: #8ff3ea; }
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #6df0e3, var(--teal)); color: #02161c; }
button.gold { background: linear-gradient(180deg, var(--gold), var(--gold-d)); color: #1d1300; border-color: #ffe7a0; }
button.gold:hover:not(:disabled) { background: linear-gradient(180deg, #ffd978, var(--gold)); color: #1d1300; }
.big { font-size: 1.15rem; padding: 14px 26px; }
.hero { text-align: center; padding: 18px 0 4px; }
.hero p { max-width: 640px; margin: 8px auto; color: #cde9ee; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.codebox { font-size: 2.6rem; font-weight: 800; letter-spacing: 8px; color: var(--gold); text-align: center; text-shadow: 0 0 18px rgba(242, 193, 78, 0.35); }
.pill { font-size: 0.75rem; padding: 2px 8px; border-radius: 99px; background: rgba(63, 214, 200, 0.16); border: 1px solid var(--line); color: var(--teal); }
.pill.bot { color: var(--muted); }
.pill.you { color: var(--gold); border-color: rgba(242, 193, 78, 0.5); background: rgba(242, 193, 78, 0.12); }

.hud { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hud b { font-size: 1.3rem; }
.event { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--teal); color: var(--bg1); font-weight: 700; font-size: .85rem; vertical-align: middle; }
h2 .event { margin-left: 8px; }
.events { margin: 10px 0 2px; display: grid; gap: 4px; }
.events p { margin: 0; }
.final { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--gold); color: var(--bg1); font-weight: 700; font-size: .85rem; }
.timer { height: 8px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.timer i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--teal), var(--gold)); transition: width 0.25s linear; }
.timer.low i { background: var(--bad); animation: pulse 1s ease-in-out infinite; }
#tleft.low { color: var(--bad); font-weight: 700; animation: pulse 1s ease-in-out infinite; }
.players { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.pl { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; position: relative; }
.pl.me { border-color: rgba(242, 193, 78, 0.6); }
.pl.win { box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(242, 193, 78, 0.4); }
.pl .nm { font-weight: 700; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pl .stat { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.pearls { color: var(--gold); font-weight: 800; display: inline-flex; align-items: center; gap: 4px; }
.bub { display: inline-flex; gap: 3px; flex-wrap: wrap; max-width: 130px; }
.bub i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--teal); background: rgba(63, 214, 200, 0.7); }
.bub i.off { background: transparent; opacity: 0.35; }
.sub { font-size: 0.875rem; color: var(--muted); }
.sub.ok { color: var(--teal); }
.sub.away { color: var(--bad); }
.act button.on { box-shadow: 0 0 0 3px var(--teal), 0 0 18px rgba(63, 214, 200, 0.35); }
.awaynote { margin: 0 0 10px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--bad); color: var(--bad); }
.wrecks { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.wreck {
  position: relative;
  text-align: left; background: linear-gradient(180deg, rgba(20, 70, 104, 0.9), rgba(9, 36, 58, 0.9));
  border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; font-weight: 400; min-height: 120px;
}
.fresh .wreck { animation: rise 0.5s ease both; }
.wreck[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 22px rgba(242, 193, 78, 0.35); }
.wreck .pv { font-size: 1.9rem; font-weight: 800; color: var(--gold); display: flex; align-items: center; gap: 6px; }
.badge { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin: 4px 4px 0 0; }
.badge.air { background: rgba(63, 214, 200, 0.2); color: var(--teal); border: 1px solid var(--teal-d); }
.badge.grew { background: rgba(242, 193, 78, 0.16); color: var(--gold); border: 1px solid rgba(242, 193, 78, 0.4); }
.act { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper button { width: 44px; padding: 0; font-size: 1.3rem; }
.stepper output { min-width: 3ch; text-align: center; font-size: 1.5rem; font-weight: 800; }
.locked { color: var(--teal); font-weight: 700; }
.reveal { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.rw { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: rgba(5, 22, 38, 0.6); }
.fresh .rw { animation: rise 0.6s ease both; }
.rw.won { border-color: var(--gold); box-shadow: 0 0 20px rgba(242, 193, 78, 0.35); }
.fresh .rw.won { animation: rise 0.6s ease both, glow 1.6s ease 0.4s 2; }
.rw.silt { border-style: dashed; border-color: var(--bad); background: repeating-linear-gradient(135deg, rgba(120, 100, 80, 0.14) 0 8px, transparent 8px 16px); }
.rw .dv { display: flex; justify-content: space-between; font-size: 0.92rem; padding: 2px 0; }
.rw .dv.top { color: var(--gold); font-weight: 700; }
.why { margin-top: 2px; font-size: 0.875rem; color: var(--muted); }
.mine-note { margin-top: 4px; font-size: 0.875rem; color: var(--gold); font-weight: 600; }
.keys { margin: 8px 0 0; }
.recon { margin: 8px 0 0; color: var(--bad); }
@media (hover: none) { .keys { display: none; } }
.verdict { margin-top: 6px; font-weight: 700; font-size: 0.9rem; }
.rests { font-size: 0.85rem; color: var(--muted); margin-top: 8px; }
.log { max-height: 220px; overflow: auto; font-size: 0.88rem; padding-left: 18px; margin: 0; }
.log li { margin: 2px 0; color: #cde9ee; }
.stand { width: 100%; border-collapse: collapse; }
.stand td, .stand th { padding: 8px 6px; text-align: left; border-top: 1px solid var(--line); }
.stand th { font-weight: 700; }
.stand tr.w td, .stand tr.w th { color: var(--gold); font-weight: 800; }
.err { color: var(--bad); font-weight: 600; min-height: 1.4em; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%) translateY(30px); background: #0b3555; border: 1px solid var(--teal); padding: 10px 18px; border-radius: 12px; opacity: 0; transition: 0.3s; z-index: 60; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.bubbles { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.bubbles i { position: absolute; bottom: -20px; border-radius: 50%; border: 1px solid rgba(143, 243, 234, 0.35); animation: float linear infinite; }
.docs { line-height: 1.6; }
.docs pre { background: #041626; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow: auto; font-size: 0.85rem; }
.docs code { background: rgba(255, 255, 255, 0.07); padding: 1px 5px; border-radius: 5px; overflow-wrap: anywhere; }
.docs pre code { background: none; padding: 0; }
.docs .note { border-left: 4px solid var(--teal); background: rgba(255, 255, 255, 0.05); padding: 10px 14px; border-radius: 0 10px 10px 0; }
.docs h1, .docs h2, .docs h3 { color: var(--teal); margin-top: 1.4em; }
.docs h1 { color: var(--text); }
.docs img { display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--radius); margin: 12px 0; }
.docs .tablewrap { overflow-x: auto; margin: 12px 0; }
.docs table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.docs th, .docs td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.docs th { background: var(--panel2); }
.top nav { display: flex; gap: 16px; align-items: center; flex-wrap: nowrap; }
@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes glow { 50% { box-shadow: 0 0 34px rgba(242, 193, 78, 0.7); } }
@keyframes float { from { transform: translateY(0); opacity: 0.7; } to { transform: translateY(-110vh); opacity: 0; } }
@media (max-width: 480px) {
  h1 { font-size: 1.6rem; }
  .codebox { font-size: 2rem; letter-spacing: 5px; }
  main { padding: 4px 12px 40px; }
  .big { padding: 14px 18px; }
  .players { grid-template-columns: repeat(2, 1fr); }
  .bub i { width: 7px; height: 7px; }
  .bub { max-width: 100%; }
  .top .devlink { display: none; }
}
.qbtn { min-width: 44px; padding: 0; border-radius: 50%; font-weight: 800; }
.linkbtn { background: none; border: 0; min-height: 0; padding: 2px 4px; color: var(--teal); text-decoration: underline; font: inherit; cursor: pointer; }
.linkbtn:hover:not(:disabled) { background: none; transform: none; color: #8ff3ea; }
dialog.help { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: 18px; border: 1px solid var(--teal-d); border-radius: var(--radius); background: #0a2a44; color: var(--text); }
dialog.help::backdrop { background: rgba(2, 10, 18, 0.75); }
dialog.help h2 { margin: 0 36px 10px 0; font-size: 1.3rem; }
dialog.help h3 { margin: 16px 0 6px; font-size: 1rem; color: var(--gold); }
dialog.help .x { position: absolute; top: 8px; right: 8px; min-width: 44px; padding: 0; font-size: 1.4rem; line-height: 1; }
.hsteps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hstep { display: flex; gap: 12px; align-items: center; background: rgba(5, 22, 38, 0.6); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.hart { flex: 0 0 88px; }
.hart svg { width: 88px; height: 56px; display: block; }
.hkeys { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; align-items: center; }
.hkeys dt { white-space: nowrap; }
.hkeys dd { margin: 0; color: var(--muted); }
kbd { font: 0.8rem/1 ui-monospace, monospace; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--teal-d); background: #07203a; color: var(--text); margin-right: 3px; }
.stats { margin-top: 18px; text-align: left; }
.stats h2 { font-size: 1.1rem; margin: 0 0 6px; }
.hl { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 4px; }
.hl li { background: rgba(242, 193, 78, 0.1); border: 1px solid rgba(242, 193, 78, 0.35); border-radius: 10px; padding: 6px 10px; font-size: 0.9rem; }
.tw { overflow-x: auto; }
.st2 { font-size: 0.85rem; }
.st2 th, .st2 td { padding: 5px 6px; white-space: nowrap; }
.rlink { width: 100%; max-width: 420px; margin-top: 10px; }
.hstep p { margin: 2px 0 0; }
.hstep b { display: block; }
@media (max-width: 480px) { .hart { flex-basis: 96px; } .hart svg { width: 96px; height: 51px; } .st2 { font-size: 0.78rem; } .st2 th, .st2 td { padding: 5px 3px; } dialog.help { padding: 14px; } }
.reactions { padding: 10px 16px; }
.emotebar { gap: 6px; }
.emo[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.emo { min-width: 44px; min-height: 44px; padding: 4px 8px; font-size: 1.3rem; line-height: 1; }
.emotes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; min-height: 30px; align-items: center; }
.emote { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg2); font-size: .9rem; }
.emote.me { border-color: var(--gold); }
.emote.pop { animation: rise .35s ease-out; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .bubbles { display: none; }
}

.hlline { margin: 0 0 12px; color: var(--gold); font-weight: 700; }
.mine { display: inline-block; margin-top: 8px; padding: 2px 8px; border: 1px dashed var(--gold); border-radius: 999px; color: var(--gold); font-size: 0.8rem; font-weight: 700; }
.wreck .mine { display: block; width: fit-content; }
h2 .mine { margin: 0 0 0 10px; font-size: 0.75rem; vertical-align: middle; color: var(--teal); border-color: var(--teal); }
.rw { position: relative; }
.rw .plus { position: absolute; right: 12px; top: 4px; font-weight: 800; font-size: 1.3rem; color: var(--gold); opacity: 0; pointer-events: none; }
.fresh .rw .plus { animation: plusup 1.6s ease-out 0.5s both; }
.rw.empty { opacity: 0.75; }
.rw.empty .verdict { color: var(--muted); font-weight: 400; }
.fresh .rw.silt { animation: rise 0.6s ease both, shake 0.5s ease 0.5s 1; }
.stand .tw, .tw .stand { margin: 0 auto; }
@keyframes plusup { 0% { opacity: 0; transform: translateY(8px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(-34px); } }
@keyframes shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.snd svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.snd .on { display: none; }
.snd[aria-pressed="true"] .on { display: inline; }
.snd[aria-pressed="true"] .off { display: none; }
.snd[aria-pressed="true"] { color: var(--gold); }
.codebox span { display: inline-block; min-width: 1.1em; }
.invite-row { margin-top: 12px; }
.invite-row input.invite { width: 100%; max-width: 440px; text-align: center; font-size: 0.9rem; }
.copied { min-height: 1.4em; margin-top: 6px; color: var(--teal); font-weight: 700; }
.scrub { margin: 10px 0 4px; }
.scrub input[type="range"] { width: 100%; padding: 0; accent-color: var(--gold); }
.bidcheck { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin-top: 6px; }
.bidcheck input { width: auto; min-height: 0; }
/* Phones: two reveal cards per row so the tide result doesn't push the move panel a screen down. */
@media (max-width: 480px) {
  .reveal { grid-template-columns: 1fr 1fr; gap: 8px; }
  .rw { padding: 8px 9px; }
  .rw .dv { gap: 6px; font-size: 0.85rem; }
  .rw .dv span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .rw .verdict { font-size: 0.84rem; }
  .rw .why { font-size: 0.8rem; }
}

.foot { padding: 8px 16px 28px; font-size: .9rem; }
.docintro { margin: 8px 0 18px; }
.docintro p { margin: 0 0 12px; }
.pl .form { font-size: .8rem; color: var(--muted); margin-top: 2px; }

/* Phones: keep the move controls on screen while scrolling the wrecks. */
@media (max-width: 720px) {
  .movecard { position: sticky; bottom: 0; z-index: 5; padding-top: 10px; padding-bottom: 10px; box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.45); }
  .movecard h2 { font-size: 1rem; margin-bottom: 6px; }
  .movecard.still { position: static; box-shadow: none; }
}
@media (hover: none) { .movecard .keys { display: none; } }

/* live staggered reveal: rows appear smallest bid first; --d is set per element (negative = resume after a re-render) */
.stag .rw .dv, .stag .rw .verdict, .stag .rw .why { animation: dvin .3s ease both; animation-delay: var(--d, 0s); }
.stag .rw.won .dv.top { animation: dvin .3s ease both, topflash 1s ease both; animation-delay: var(--d, 0s), calc(var(--d, 0s) + .1s); }
.stag .rw .plus { animation: plusup 1.2s ease-out both; animation-delay: var(--d, 0s); }
.stag .rw.won .verdict { animation: dvin .3s ease both, winflash 1s ease both; animation-delay: var(--d, 0s), var(--d, 0s); }
.stag .rw.silt { animation: shake .5s ease both; animation-delay: var(--d, 0s); }
.stag .rw.silt { background: rgba(220, 80, 80, 0.08); }
.callout { margin-top: 6px; font-weight: 700; font-size: .85rem; color: var(--gold, #f2c14e); animation: dvin .3s ease both; animation-delay: var(--d, 0s); }
.callout.silt { color: var(--bad, #ff8080); border: 1px dashed var(--bad, #ff8080); border-radius: 6px; padding: 2px 6px; display: inline-block; }
@keyframes dvin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes topflash { 0%, 100% { filter: none; } 40% { filter: brightness(1.6) drop-shadow(0 0 6px #f2c14e); } }
@keyframes winflash { 0%, 100% { color: inherit; } 40% { color: #f2c14e; text-shadow: 0 0 8px #f2c14e; } }
.coach { margin: 10px 0 0; font-size: .9rem; color: var(--muted); }
.whylist { list-style: none; padding: 0; margin: 6px 0 10px; font-size: .92rem; color: var(--muted); }
.series { font-weight: 700; margin: 4px 0 8px; }
@media (max-width: 600px) {
  .players { grid-template-columns: 1fr !important; gap: 4px; }
  .pl { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 6px 10px; }
  .pl .stat { margin-top: 0; gap: 8px; }
  .pl .form, .pl .sub { margin: 0; font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) { .stag .rw *, .callout, .stag .rw { animation: none !important; opacity: 1 !important; } }
@media (prefers-reduced-motion: reduce) {
  .rw .plus { opacity: 1; animation: none; }
}
