/* The Lick Man. Dark room, one bright ring, nothing else competing.
   Motion is transform and opacity only, and one --beat drives the whole cast. */

:root {
  --beat: 200ms;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ink: #0a0b0d;
  --ink2: #12141a;
  --line: #23262f;
  --fog: #8b93a3;
  --white: #f4f6fa;
  --hot: #ff3b47;
  --gold: #ffc53d;
  --good: #35d07f;
  --pad: 14px;
  --display: 900 clamp(28px, 4.6vw, 56px)/0.95 ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
  --body: 400 15px/1.5 ui-sans-serif, system-ui, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--white);
  font: var(--body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 620px at 78% 18%, #1b1f2b 0%, transparent 60%),
    radial-gradient(700px 500px at 12% 88%, #171a22 0%, transparent 62%),
    var(--ink);
}

a { color: inherit; }

/* ---------- top bar ---------- */

.bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  white-space: nowrap;
  font-weight: 900;
  letter-spacing: .04em;
  font-size: 15px;
}

.logo .dot {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--hot);
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #fff;
}

.bar nav {
  margin-left: auto;
  display: flex;
  gap: 6px;
  align-items: center;
}

.bar nav a {
  text-decoration: none;
  color: var(--fog);
  padding: 8px 12px;
  border-radius: 9px;
  white-space: nowrap;
  font-weight: 600;
  font-size: 14px;
}

.bar nav a:hover { color: var(--white); background: #ffffff0f; }

/* ---------- screens ---------- */

main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 18px 22px;
}

.screen { display: none; width: 100%; max-width: 1140px; }
.screen.on { display: block; }

/* ---------- home, the split shape ---------- */

/* minmax with a real floor, never bare fr: a long headline sets the first
   column's min content width and silently crushes the second one to zero. */
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(240px, 330px);
  gap: 34px;
  align-items: center;
}

.split > * { min-width: 0; }

h1 {
  font: var(--display);
  margin: 0 0 12px;
  text-wrap: balance;
  letter-spacing: -.02em;
}

h1 .hot { color: var(--hot); }

.lead {
  color: var(--fog);
  margin: 0 0 18px;
  max-width: 42ch;
  text-wrap: pretty;
  font-size: 16px;
}

.lead b { color: var(--white); font-weight: 600; }

.modes { display: grid; gap: 8px; }

.mode {
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 12px;
  align-items: center;
  text-align: left;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff08;
  color: var(--white);
  cursor: pointer;
  font: inherit;
  transition: transform var(--beat) var(--ease), border-color var(--beat) var(--ease);
}

.mode:hover { transform: translateX(3px); border-color: #3b404d; }
.mode .k { font-size: 19px; text-align: center; }
.mode .t { font-weight: 700; white-space: nowrap; }
.mode .s { color: var(--fog); font-size: 13px; }

.center { justify-content: center; }

/* width:100% is load bearing. With an auto width, margin-inline:auto makes a
   grid item shrink wrap and centre itself, which collapsed this to 2px. */
.stage {
  width: 100%;
  max-width: 340px;
  margin-inline: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #05060a;
  overflow: hidden;
  box-shadow: 0 30px 70px #000000aa;
}

/* ---------- the portrait stack ----------
   Every frame is stacked and a pose is an opacity swap, so a turn is instant.
   Poses are data attributes because style-src 'self' blocks a style attribute. */

.port {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 14px;
  overflow: hidden;
  background: #05060a;
  isolation: isolate;
}

.port .fr {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 70ms linear;
  user-select: none;
  -webkit-user-drag: none;
}

.port .vig {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 30%, transparent 40%, #05060acc 100%),
    linear-gradient(to bottom, transparent 62%, #0a0b0d 100%);
}

.port[data-pose="center"] .fr-center,
.port[data-pose="left"] .fr-left,
.port[data-pose="right"] .fr-right,
.port[data-pose="up"] .fr-up,
.port[data-pose="down"] .fr-down,
.port[data-pose="halfleft"] .fr-halfleft,
.port[data-pose="halfright"] .fr-halfright { opacity: 1; }

/* The physical half of the turn. The frames carry the anatomy, this carries the
   weight: the whole stack leans into the sweep and blurs a touch while moving. */
.port { transition: transform 150ms var(--ease); }
.port[data-turning="-1"] { transform: translateX(-7px) scale(1.012); }
.port[data-turning="1"] { transform: translateX(7px) scale(1.012); }
.port[data-turning="-1"] .fr, .port[data-turning="1"] .fr { filter: blur(1.1px); }
.port .fr { transition: opacity 45ms linear, filter 90ms linear; }

/* Mood wins over pose: a reaction is what you want to see at that moment. */
.port[data-mood="smug"] .fr { opacity: 0; }
.port[data-mood="smug"] .fr-smug { opacity: 1; }
.port[data-mood="rattled"] .fr { filter: saturate(1.15) contrast(1.05); }

.face {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  background: #05060a;
}

.face img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- character select ---------- */

.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }

.card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff08;
  padding: 12px;
  cursor: pointer;
  color: var(--white);
  font: inherit;
  text-align: center;
  transition: transform var(--beat) var(--ease), border-color var(--beat) var(--ease);
}

.card:hover { transform: translateY(-4px); border-color: #3b404d; }
.card[disabled] { opacity: .38; cursor: not-allowed; }

.card .nm { font-weight: 800; white-space: nowrap; font-size: 14px; margin-top: 6px; }
.card .tr { color: var(--gold); font-size: 12px; font-weight: 700; }
.card .bl { color: var(--fog); font-size: 12px; margin-top: 4px; text-wrap: pretty; }

/* ---------- arena ---------- */

.arena { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.arena > * { min-width: 0; }

.who { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.who .nm { font-weight: 900; font-size: 20px; white-space: nowrap; }
.who .tr { color: var(--gold); font-size: 12px; font-weight: 700; }

.say {
  min-height: 44px;
  border-left: 3px solid var(--hot);
  padding: 6px 0 6px 12px;
  color: var(--white);
  font-size: 15px;
  text-wrap: pretty;
}

.pips { display: flex; gap: 8px; align-items: center; margin: 10px 0; }
.pip { width: 26px; height: 8px; border-radius: 4px; background: #2a2e39; }
.pip.on { background: var(--hot); }
.pips .lbl { color: var(--fog); font-size: 12px; margin-left: 6px; white-space: nowrap; }

.chain { display: flex; gap: 6px; align-items: center; min-height: 30px; color: var(--fog); font-size: 13px; }
.chain .step {
  width: 26px; height: 26px; border-radius: 8px; background: #ffffff10;
  display: grid; place-items: center; font-size: 14px;
}
.chain .step.now { background: var(--gold); color: #1a1200; }

.count {
  font: 900 clamp(40px, 8vw, 92px)/1 ui-sans-serif, system-ui, sans-serif;
  text-align: center;
  min-height: 1em;
  letter-spacing: -.03em;
}

.count.go { color: var(--good); }

.window {
  height: 6px;
  border-radius: 3px;
  background: #2a2e39;
  overflow: hidden;
  margin: 10px 0 14px;
}

.window i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--good);
  transform-origin: left center;
  transform: scaleX(0);
}

/* Two fixed durations rather than a variable one, because setting the duration
   from JS would be an inline style and the CSP blocks it. */
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.window.live i { animation: drain 800ms linear forwards; }
.window.live.fast i { animation: drain 440ms linear forwards; }

.pads { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.pads button {
  aspect-ratio: 1.7 / 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff0d;
  color: var(--white);
  font-size: 26px;
  cursor: pointer;
  transition: transform 90ms var(--ease), background var(--beat) var(--ease);
}

.pads button:hover { background: #ffffff1a; }
.pads button:active { transform: scale(.94); }
.pads button.hit { background: var(--good); color: #04160c; }
.pads .sp { visibility: hidden; }

.seal {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #ffffff06;
  font-size: 12px;
  color: var(--fog);
}

.seal .h { color: var(--white); font-weight: 700; margin-bottom: 4px; font-size: 12px; }
.seal code { font-family: ui-monospace, Menlo, monospace; word-break: break-all; color: var(--gold); font-size: 11px; }
.seal .ok { color: var(--good); font-weight: 700; }
.seal .bad { color: var(--hot); font-weight: 700; }

/* ---------- split screen local play ---------- */

.duo { display: grid; grid-template-rows: 1fr auto 1fr; gap: 12px; height: min(76vh, 620px); }
.half { display: grid; gap: 8px; align-content: center; border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
.half.p2 { transform: rotate(180deg); }
.half .role { color: var(--fog); font-size: 12px; font-weight: 700; text-align: center; white-space: nowrap; }
.half .role b { color: var(--gold); }
.mid { display: flex; align-items: center; justify-content: center; gap: 16px; }

/* ---------- buttons ---------- */

.btn {
  display: inline-block;
  border: 0;
  border-radius: 12px;
  background: var(--hot);
  color: #fff;
  font: 800 15px/1 ui-sans-serif, system-ui, sans-serif;
  padding: 14px 22px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--beat) var(--ease), filter var(--beat) var(--ease);
}

.btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.btn.ghost { background: #ffffff12; color: var(--white); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 16px; }

/* ---------- result ---------- */

.result { text-align: center; }
.result h2 { font: var(--display); margin: 0 0 8px; }
.result .verdict { color: var(--hot); }
.result .verdict.win { color: var(--good); }
.result p { color: var(--fog); margin: 0 auto 8px; max-width: 52ch; text-wrap: pretty; }

/* ---------- board ---------- */

.board { width: 100%; border-collapse: collapse; font-size: 14px; }
.board th, .board td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.board th { color: var(--fog); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.note { color: var(--fog); font-size: 12px; margin-top: 8px; }

/* ---------- phone ---------- */

@media (max-width: 900px) {
  html, body { overflow: auto; }
  .split, .arena { grid-template-columns: 1fr; gap: 18px; }
  .stage { order: -1; }
  .stage { max-width: 210px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  main { padding: 14px; }
}

/* Reduced motion keeps the game fully playable: the head still changes frame so
   you can read the direction, it just does not sweep or blur. */
@media (prefers-reduced-motion: reduce) {
  .port, .port .fr { transition: none; }
  .port[data-turning="-1"], .port[data-turning="1"] { transform: none; }
  .port[data-turning="-1"] .fr, .port[data-turning="1"] .fr { filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  :root { --beat: 1ms; }
  #head, #eyes, #brow, #sweat, .mode, .card, .btn, .pads button { transition: none; }
  .window.live i { transition: none; transform: scaleX(1); }
}

/* ---------- document pages ----------
   The game locks scrolling to hold one screen. A rules page is the opposite:
   it has one job and is allowed the room to do it. */

body.doc { overflow: auto; display: block; }
body.doc .bar { position: sticky; top: 0; background: #0a0b0deb; backdrop-filter: blur(8px); z-index: 5; }

.page { display: block; padding: 34px 22px 64px; }

.prose { max-width: 72ch; margin: 0 auto; }
.prose h1 { font: 900 clamp(30px, 4.4vw, 52px)/1 ui-sans-serif, system-ui, sans-serif; letter-spacing: -.02em; margin: 0 0 14px; text-wrap: balance; }
.prose h2 { font-size: 20px; font-weight: 800; margin: 34px 0 10px; letter-spacing: -.01em; text-wrap: balance; }
.prose p, .prose li { color: #c3c9d6; text-wrap: pretty; }
.prose p { margin: 0 0 12px; }
.prose b { color: var(--white); font-weight: 700; }
.prose a { color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin-bottom: 8px; }
.prose .lead { color: var(--fog); font-size: 17px; max-width: 62ch; }

.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps li {
  position: relative;
  padding: 10px 12px 10px 46px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff06;
  margin-bottom: 8px;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 12px; top: 10px;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--hot);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  display: grid;
  place-items: center;
}

.diagram {
  margin: 16px 0 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #ffffff06;
  overflow-x: auto;
}
.diagram svg { width: 100%; min-width: 560px; height: auto; display: block; }
.diagram .dbox { fill: #ffffff12; stroke: var(--line); }
.diagram .dbox.on { fill: var(--gold); }
.diagram .dsym { fill: var(--white); font-size: 22px; text-anchor: middle; }
.diagram .dbox.on + .dsym { fill: #1a1200; }
.diagram .dlbl { fill: var(--white); font: 700 13px ui-sans-serif, system-ui, sans-serif; }
.diagram .dnote { fill: var(--fog); font: 400 13px ui-sans-serif, system-ui, sans-serif; }
.diagram figcaption { color: var(--fog); font-size: 13px; margin-top: 10px; }

.history li { margin-bottom: 12px; }

.credit {
  border-left: 3px solid var(--gold);
  padding: 10px 0 10px 14px;
  margin: 24px 0;
  color: var(--white) !important;
}

.src li { font-size: 14px; }

.center-text { text-align: center; }

/* ---------- post a score ---------- */

.post { margin-top: 18px; }
.post label { display: block; color: var(--fog); font-size: 13px; margin-bottom: 6px; }
.postrow { display: flex; gap: 8px; justify-content: center; align-items: center; }
.postrow input {
  background: #ffffff0d;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--white);
  font: inherit;
  padding: 12px 14px;
  width: 190px;
}
.postrow input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }

.foot {
  flex: 0 0 auto;
  display: flex;
  gap: 18px;
  justify-content: center;
  padding: 12px 22px 16px;
  border-top: 1px solid var(--line);
}
.foot a { color: var(--fog); font-size: 13px; text-decoration: none; white-space: nowrap; }
.foot a:hover { color: var(--white); }

/* ---------- online ---------- */

.pads.narrow { max-width: 340px; margin: 12px auto 0; }
#o-link { width: 260px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
