/* The Gun Show. The stage is the loud part; everything else stays out of its way. */
:root {
  --night: #1B0F2E;
  --night-2: #261640;
  --night-3: #352056;
  --pink: #FF2E88;
  --cyan: #19D3E6;
  --gold: #FFC21A;
  --chalk: #FFF8EA;
  --steel: #585A62;
  --steel-2: #6E717B;
  --ink: #140E1E;
  --hurt: #E8242B;
  --muted: #B9A9D6;

  --arms: #FF7A1A; --legs: #19D3E6; --chest: #FF2E88; --back: #8B3DFF; --core: #B6FF2E; --smg: #FFC21A;
  --p0: #FF2E88; --p1: #19D3E6; --p2: #FFC21A; --p3: #B6FF2E;

  --display: 'Kanit', 'Arial Black', sans-serif;
  --text: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--night); color: var(--chalk);
  font: 500 1.125rem/1.35 var(--text);
}
button, input, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* The display face is the card-title face: slanted, heavy, outlined. */
.display {
  font-family: var(--display); font-style: italic; font-weight: 900; letter-spacing: 0.01em;
  line-height: 0.95; margin: 0; text-transform: uppercase;
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--ink);
}

.btn {
  border: 2px solid var(--ink); border-radius: 8px; background: var(--steel); color: var(--chalk);
  padding: 0.5rem 1rem; font-weight: 800; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
}
.btn:hover:not(:disabled) { background: var(--steel-2); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--pink); color: var(--ink); }
.btn.primary:hover:not(:disabled) { background: #ff5aa1; }
.btn.big { font-size: 1.6rem; padding: 0.6rem 2.2rem; }
.link { background: none; border: 0; color: var(--cyan); text-decoration: underline; cursor: pointer; padding: 0.25rem 0; }
.chip {
  border: 1px solid var(--night-3); background: var(--night-2); border-radius: 999px;
  padding: 0.15rem 0.75rem; font-weight: 600; font-size: 1rem; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--cyan); color: var(--ink); border-color: var(--cyan); }
.chip.warn { background: var(--hurt); border-color: var(--hurt); cursor: default; }

/* ---------------------------------------------------------------- home */
.home {
  min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 420px);
  gap: 2rem 3rem; align-items: center; padding: 2rem clamp(1rem, 5vw, 4rem);
  background:
    linear-gradient(transparent 62%, rgba(25, 211, 230, 0.12) 62% 63%, transparent 63%) 0 0 / 100% 56px,
    radial-gradient(ellipse at 30% 110%, rgba(255, 46, 136, 0.45), transparent 60%),
    var(--night);
}
.title { font-size: clamp(3.5rem, 11vw, 8.5rem); color: var(--gold); -webkit-text-stroke-width: 4px; text-shadow: 6px 6px 0 var(--pink); }
.title span { display: block; font-size: 0.4em; color: var(--chalk); text-shadow: 3px 3px 0 var(--pink); }
.tag { font-size: 1.4rem; max-width: 32ch; margin: 1rem 0 0; }
.fan { position: relative; height: clamp(220px, 34vw, 380px); margin-top: 2rem; }
.fan img { position: absolute; width: clamp(150px, 21vw, 250px); bottom: 0; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.fan img:nth-child(1) { left: 0; transform: rotate(-9deg); }
.fan img:nth-child(2) { left: 22%; transform: rotate(-1deg); z-index: 1; bottom: 12px; }
.fan img:nth-child(3) { left: 44%; transform: rotate(8deg); }
.entry { display: grid; align-content: start; gap: 0.75rem; background: var(--night-2); border: 2px solid var(--ink); border-radius: var(--radius); padding: 1.5rem; }
.entry label, .entry legend { font-weight: 800; }
.entry input, .entry select, .lobby select { background: var(--chalk); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 0.45rem 0.6rem; }
.entry fieldset { border: 0; border-top: 1px solid var(--night-3); margin: 0; padding: 0.75rem 0 0; }
.entry .row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.entry .row legend { width: 100%; padding: 0 0 0.4rem; }
.entry .row input { width: 8ch; text-transform: uppercase; }

/* ---------------------------------------------------------------- lobby */
.lobby { max-width: 560px; margin: 0 auto; padding: 3rem 1rem; display: grid; gap: 0.75rem; justify-items: start; }
.lobby h1 { font-size: 3rem; color: var(--gold); }
.invite { display: flex; gap: 0.5rem; width: 100%; margin: 0; }
.invite input { flex: 1; min-width: 0; background: var(--night-2); border: 1px solid var(--night-3); border-radius: 8px; padding: 0.4rem 0.6rem; }
.seats { margin: 0; padding-left: 1.4rem; font-size: 1.3rem; }
.waiting { color: var(--muted); }

/* ---------------------------------------------------------------- game */
.bar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.5rem 1rem;
  background: var(--ink); border-bottom: 3px solid var(--pink);
}
.logo { background: none; border: 0; color: var(--gold); font-size: 1.6rem; cursor: pointer; padding: 0; -webkit-text-stroke-width: 1px; text-shadow: 2px 2px 0 var(--pink); }
.where { display: flex; gap: 1.25rem; margin: 0; flex-wrap: wrap; color: var(--muted); }
.your-turn { color: var(--gold); }
.bar-tools { margin-left: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.table { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: 1rem; padding: 1rem; }
.floor { min-width: 0; }
.side { display: grid; gap: 1rem; align-content: start; }

/* --- gym: steel plates, quiet */
.prompt { margin: 0 0 0.75rem; font-size: 1.3rem; font-weight: 600; }
.stations { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.station {
  display: grid; gap: 0.3rem; align-content: start; text-align: left; min-height: 120px;
  background: var(--steel); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 0.7rem 0.8rem; position: relative; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18);
}
.station::before { content: ''; position: absolute; inset: 0 0 auto; height: 6px; border-radius: var(--radius) var(--radius) 0 0;
  background: repeating-linear-gradient(135deg, var(--hurt) 0 8px, transparent 8px 16px); opacity: 0.8; }
.station:disabled { opacity: 0.6; cursor: default; }
.station.open { cursor: pointer; }
.station.open:hover { background: var(--steel-2); }
.st-name { font-weight: 800; font-size: 1.25rem; }
.st-text { font-size: 1rem; color: #E9E4F2; }
.slots { display: flex; gap: 6px; margin-top: auto; }
.slot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); background: rgba(255, 255, 255, 0.18); }
.slot.p0 { background: var(--p0); } .slot.p1 { background: var(--p1); } .slot.p2 { background: var(--p2); } .slot.p3 { background: var(--p3); }

/* --- stage: the loud part */
.stage {
  border: 3px solid var(--ink); border-radius: 16px; padding: 1rem; min-height: 460px;
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 248, 234, 0.28), transparent 55%),
    linear-gradient(transparent 70%, rgba(25, 211, 230, 0.25) 70% 71%, transparent 71%) 0 0 / 100% 40px,
    linear-gradient(180deg, #3a1460 0%, #5b1667 55%, #a11d6e 100%);
  display: grid; gap: 0.75rem; align-content: start;
}
.stage.busted { background: linear-gradient(180deg, #2a0d1a, #5c0f1f 70%, #8a1222); }
.spot { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.performer { font-size: clamp(2rem, 5vw, 3.2rem); color: var(--chalk); text-shadow: 4px 4px 0 var(--pink); }
.meter { display: flex; gap: 6px; }
.hurt { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(0, 0, 0, 0.3); position: relative; }
.hurt.on { background: var(--hurt); }
.hurt.on::before, .hurt.on::after { content: ''; position: absolute; background: var(--chalk); left: 50%; top: 50%; transform: translate(-50%, -50%); }
.hurt.on::before { width: 18px; height: 6px; } .hurt.on::after { width: 6px; height: 18px; }
.bonus { margin: 0; color: var(--gold); font-weight: 800; }
.deckpile { margin-left: auto; position: relative; width: 72px; }
.deckpile img { border-radius: 8px; box-shadow: 3px 3px 0 var(--ink), 6px 6px 0 rgba(0, 0, 0, 0.4); }
.deckpile span { position: absolute; inset: auto 0 -0.4rem; text-align: center; font-weight: 800; font-size: 1.3rem; text-shadow: 0 0 4px var(--ink), 0 0 2px var(--ink); }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 190px; align-items: flex-start; perspective: 900px; }
.row .card { width: min(132px, calc((100% - 0.5rem * (var(--cols, 6) - 1)) / var(--cols, 6))); border-radius: 9px; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45); }
.row .card.slap { animation: slap 380ms cubic-bezier(.2, .9, .3, 1.3); }
@keyframes slap {
  0% { transform: translateY(-40px) rotateY(90deg) scale(1.25); opacity: 0.2; }
  60% { transform: translateY(4px) rotateY(0) scale(1.04); opacity: 1; }
  100% { transform: none; }
}
.empty { color: var(--muted); }
.state { margin: 0; font-size: 1.4rem; font-weight: 800; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

/* --- finale */
.finale { display: grid; gap: 1rem; justify-items: start; padding: 1rem 0; }
.finale h2 { font-size: clamp(2.4rem, 6vw, 4rem); color: var(--gold); text-shadow: 4px 4px 0 var(--pink); }
.standings { list-style: none; padding: 0; margin: 0; font-size: 1.5rem; display: grid; gap: 0.3rem; }
.standings span { font-weight: 800; color: var(--gold); margin-left: 0.5rem; }
.standings small { color: var(--muted); margin-left: 0.5rem; }

/* --- scoresheet: dense, like the paper one */
.sheet table { width: 100%; border-collapse: collapse; background: var(--chalk); color: var(--ink); border-radius: 8px; overflow: hidden; font-size: 1rem; }
.sheet th, .sheet td { padding: 0.2rem 0.4rem; border-bottom: 1px solid #e3d8c6; text-align: center; }
.sheet tbody th { text-align: left; font-weight: 600; white-space: nowrap; }
.sheet thead th { background: var(--ink); color: var(--chalk); font-weight: 800; border-bottom: 4px solid; }
.sheet thead th.p0 { border-color: var(--p0); } .sheet thead th.p1 { border-color: var(--p1); }
.sheet thead th.p2 { border-color: var(--p2); } .sheet thead th.p3 { border-color: var(--p3); }
.sheet thead th.now { background: var(--night-3); }
.sheet .total { font-weight: 800; background: #f1e6d1; }
.sheet .meta { color: #5d5470; }
.log ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.2rem; font-size: 1rem; color: var(--muted); max-height: 300px; overflow: auto; }
.log li:first-child { color: var(--chalk); }

/* --- tray */
.tray { padding: 0 1rem 1.5rem; }
.mydeck { margin: 0 0 0.5rem; }
.perks { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.5rem; }
.perk-btn { display: flex; gap: 0.5rem; align-items: center; width: 100%; text-align: left; background: var(--night-2);
  border: 2px solid var(--night-3); border-radius: var(--radius); padding: 0.35rem; }
button.perk-btn { cursor: pointer; border-color: var(--gold); }
.perk-btn img { width: 44px; border-radius: 5px; flex: none; }
.perk-btn span { display: grid; line-height: 1.15; }
.perk-btn small { color: var(--muted); font-size: 0.9rem; }
.perk.down { opacity: 0.45; }
.perk.down img { filter: grayscale(1); }

/* ---------------------------------------------------------------- panels */
.sheet-panel {
  position: fixed; z-index: 10; left: 50%; bottom: 1rem; transform: translateX(-50%);
  width: min(560px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); overflow: auto;
  background: var(--chalk); color: var(--ink); border: 3px solid var(--ink); border-radius: 14px;
  padding: 1rem 1.25rem; box-shadow: 0 10px 0 var(--ink), 0 20px 60px rgba(0, 0, 0, 0.6);
  display: grid; gap: 0.6rem;
}
.sheet-panel.wide { width: min(900px, calc(100% - 2rem)); }
.sheet-panel h2 { font-size: 2rem; color: var(--pink); -webkit-text-stroke-width: 1.5px; text-shadow: 2px 2px 0 var(--ink); }
.sheet-panel p { margin: 0; }
.sheet-panel .btn:not(.primary) { background: #e6dccb; color: var(--ink); }
.panel-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.25rem; }
.toggle { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; }
.toggle input { width: 1.2rem; height: 1.2rem; accent-color: var(--pink); }
.count { font-weight: 800; }
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.4rem; }
.pick { display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 0.35rem;
  border: 2px solid var(--ink); border-left-width: 10px; border-radius: 8px; padding: 0.2rem 0.4rem; background: #fff; }
.pick button { width: 2rem; height: 2rem; border: 2px solid var(--ink); border-radius: 6px; background: #e6dccb; font-weight: 800; cursor: pointer; }
.pick button:disabled { opacity: 0.35; cursor: default; }
.pick b { min-width: 1.2ch; text-align: center; font-size: 1.2rem; }
.m-arms { border-left-color: var(--arms); } .m-legs { border-left-color: var(--legs); } .m-chest { border-left-color: var(--chest); }
.m-back { border-left-color: var(--back); } .m-core { border-left-color: var(--core); } .m-smg { border-left-color: var(--smg); }
.choose { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.supps { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.supps .chip { background: #fff; color: var(--ink); border: 2px solid var(--ink); border-left-width: 8px; }
.supps .chip[aria-pressed="true"] { background: var(--gold); }
.poses { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.pose { width: 100%; display: flex; justify-content: space-between; align-items: center; background: #fff; border: 2px solid var(--ink);
  border-radius: 8px; padding: 0.35rem 0.75rem; cursor: pointer; font-weight: 600; }
.pose b { font-size: 1.3rem; }
.pose.best b { color: #a0005a; }
.pose.chosen { background: var(--gold); }
.mirror { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 0.5rem; }
.mirror-card { position: relative; padding: 0; border: 3px solid transparent; border-radius: 10px; background: none; cursor: pointer; }
.mirror-card:disabled { opacity: 0.5; cursor: default; }
.mirror-card .card { border-radius: 7px; }
.mirror-card.top, .mirror-card.bottom { border-color: var(--pink); }
.mirror-card span { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: var(--pink); color: var(--ink);
  font-weight: 800; padding: 0 0.5rem; border-radius: 6px; border: 2px solid var(--ink); }

/* ---------------------------------------------------------------- rules */
dialog#rules {
  width: min(760px, calc(100% - 2rem)); max-height: calc(100vh - 2rem); border: 3px solid var(--ink); border-radius: 14px;
  background: var(--chalk); color: var(--ink); padding: 1.25rem 1.5rem; line-height: 1.45;
}
dialog#rules::backdrop { background: rgba(27, 15, 46, 0.75); }
dialog#rules h1 { font-size: 2.4rem; color: var(--pink); -webkit-text-stroke-width: 1.5px; text-shadow: 2px 2px 0 var(--ink); }
dialog#rules h2 { font-size: 1.4rem; margin: 1.2rem 0 0.3rem; }
dialog#rules p, dialog#rules li { max-width: 70ch; }
.dialog-close { float: right; }
.dialog-close button { background: #e6dccb; border: 2px solid var(--ink); border-radius: 8px; padding: 0.2rem 0.7rem; cursor: pointer; }
.version { color: #5d5470; margin: 0.25rem 0 0; }
.rules-poses td { padding: 0.1rem 1rem 0.1rem 0; }

#toast {
  position: fixed; z-index: 20; left: 50%; top: 1rem; transform: translate(-50%, -150%); transition: transform 200ms;
  background: var(--gold); color: var(--ink); border: 2px solid var(--ink); border-radius: 8px; padding: 0.4rem 1rem; font-weight: 800;
  max-width: calc(100% - 2rem);
}
#toast:not(.show) { visibility: hidden; transition: transform 200ms, visibility 0s 200ms; }
#toast.show { transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 860px) {
  .home { grid-template-columns: 1fr; padding-top: 1.5rem; }
  .fan { height: 200px; }
  .table { grid-template-columns: 1fr; padding: 0.75rem; }
  .stations { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .perks { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage { min-height: 0; }
  .row { --cols: 4 !important; }
  .bar { gap: 0.5rem; }
  .where { gap: 0.75rem; font-size: 1rem; }
  .btn.big { flex: 1; }
  .sheet-panel { bottom: 0; border-radius: 14px 14px 0 0; width: 100%; max-height: 85vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.fine { margin: 0; font-size: 0.95rem; color: var(--muted); }
