:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  background: #080709;
  color: #f6f0f3;
  --muted: #bcb2bf;
  --edge: #38313d;
  --pink: #f9a5d6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
}
button { font: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--pink); outline-offset: 4px; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

.landing {
  width: min(100%, 49rem);
  min-height: min(100dvh, 68rem);
  padding-block: max(clamp(.6rem, 1.7dvh, 1.25rem), env(safe-area-inset-top)) max(clamp(.4rem, 1.2dvh, .85rem), env(safe-area-inset-bottom));
  padding-inline: max(clamp(.65rem, 3vw, 1.45rem), env(safe-area-inset-left)) max(clamp(.65rem, 3vw, 1.45rem), env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  row-gap: clamp(.2rem, .85dvh, .55rem);
  text-align: center;
}

.club-mark {
  display: block;
  width: clamp(4.35rem, min(42vw, 25dvh), 13rem);
  height: auto;
  margin: 0 auto clamp(.15rem, .55dvh, .4rem);
  mix-blend-mode: screen;
}

.club-name {
  margin: 0;
  color: var(--pink);
  font: 700 clamp(1.3rem, min(7vw, 4.9dvh), 2.6rem)/1.04 "Courier New", monospace;
  letter-spacing: -.06em;
}

.intro h1 {
  margin: .18rem 0 .32rem;
  font: 700 clamp(1.6rem, min(8vw, 6.4dvh), 3.8rem)/1 Georgia, serif;
  letter-spacing: -.06em;
  text-wrap: balance;
}

.intro h1 span { white-space: nowrap; }

.members {
  margin: 0;
  color: var(--muted);
  font: 700 .875rem/1.25 "Courier New", monospace;
}

.game {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(clamp(5.25rem, 22dvh, 8rem), 1fr);
  grid-auto-rows: auto;
}

.stage-space {
  container-type: size;
  display: grid;
  place-items: center;
}

.stage {
  position: relative;
  width: min(100cqw, 128cqh, 40rem);
  aspect-ratio: 1419 / 1109;
}

.stage-visuals {
  position: absolute;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background: #000;
  mask-image: linear-gradient(to bottom, transparent, #000 3% 94%, transparent),
    linear-gradient(to right, transparent, #000 4% 95%, transparent);
  mask-composite: intersect;
}

.triangle {
  position: absolute;
  inset: 0;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  clip-path: polygon(32.5% 38.5%, 37% 39.3%, 75.3% 51.2%, 76.2% 55.7%, 74.5% 58.9%, 46.5% 92%, 44.4% 92%, 42.9% 87.9%);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.triangle[aria-disabled="true"] { cursor: progress; }
.triangle:focus-visible { outline: 0; background: #fff2fb32; }

.stage:has(.triangle:focus-visible) {
  outline: 2px solid var(--pink);
  outline-offset: .2rem;
  border-radius: .9rem;
}

@media (hover: hover) {
  .triangle:hover:not([aria-disabled="true"]) { background: #fbdfff24; }
}

.ball, .die, .die canvas, .liquid {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.ball { display: block; object-fit: fill; }
.die canvas { display: block; }
.die {
  clip-path: polygon(31% 38%, 34% 36%, 55% 41%, 75% 49%, 77% 54%, 74% 60%, 49% 91%, 45% 94%, 41% 90%, 35% 67%, 31% 47%);
  transform-origin: 53% 63%;
}

.liquid {
  background:
    radial-gradient(ellipse 16% 27% at 54% 64%, #100662 0%, #080337 54%, transparent 100%),
    radial-gradient(ellipse 34% 38% at 50% 64%, #04021a 0%, #020114 68%, #030109 81%, #0000 98%);
  opacity: 0;
}

.stage.is-dipping .liquid { animation: ink-in .595s both; }
.stage.is-dipping .die { animation: dive .595s both; }
.stage.is-rising .liquid { animation: ink-out .645s both; }
.stage.is-rising .die { animation: surface .645s both; }

@keyframes ink-in {
  from { opacity: 0; }
  28%, to { opacity: 1; }
}

@keyframes ink-out {
  from, 78% { opacity: 1; }
  to { opacity: 0; }
}

@keyframes dive {
  from { transform: none; filter: none; opacity: 1; }
  29% { transform: translate(-.5%, 1%) rotate(-2deg) scale(.96); }
  to { transform: translate(-1.8%, 8%) rotate(-14deg) scale(.49); filter: blur(10px) brightness(.35) saturate(1.8); opacity: 0; }
}

@keyframes surface {
  from { transform: translate(1.5%, 6%) rotate(12deg) scale(.55); filter: blur(8px) brightness(.35) saturate(1.7); opacity: 0; }
  64% { transform: translate(.6%, -1.4%) rotate(2deg) scale(1.01); filter: blur(.25px) brightness(.96); opacity: 1; }
  to { transform: none; filter: none; opacity: 1; }
}

.utilities {
  display: grid;
  justify-items: center;
}

.share, .history-link {
  padding: .3rem .65rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: .875rem;
}

.share {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #f6f0f3;
}

.share svg {
  width: 25px;
  height: 25px;
}

.share:disabled { opacity: .42; }
.share:hover:enabled, .history-link:hover { color: var(--pink); }

.history-link {
  min-height: 34px;
  text-decoration: underline;
  text-underline-offset: .22em;
}

.prompt-hint, .readout, .notice {
  max-width: 34rem;
  margin: .22rem auto 0;
  line-height: 1.25;
  text-wrap: pretty;
}

.prompt-hint { color: var(--muted); font-size: .875rem; }
.game:has(.readout:not([hidden])) .prompt-hint { display: none; }
.readout { font-size: 1rem; }
.notice { color: var(--pink); font-size: .875rem; }
.notice:empty { margin: 0; }

.history {
  width: min(calc(100% - 2rem), 33rem);
  max-height: 80dvh;
  padding: 1.1rem 1.25rem;
  background: #141016;
  color: inherit;
  border: 1px solid #5e4763;
  border-radius: 10px;
}

.history::backdrop { background: #080609c9; }
.dialog-header, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.dialog-header h2 { margin: 0; font: 700 1.65rem/1.1 Georgia, serif; }
.close { min-width: 44px; min-height: 44px; color: inherit; border: none; background: transparent; font-size: 1.6rem; }
.history-list { list-style: none; margin: 0; padding: 0; overflow: auto; max-height: 48dvh; }
.history-list li { border-top: 1px solid var(--edge); }
.history-list button { width: 100%; text-align: left; padding: .85rem .2rem; border: 0; background: transparent; color: inherit; line-height: 1.4; }
.history-list button:hover { color: var(--pink); }
#history-empty, #history-count { color: var(--muted); font-size: .875rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-height: 28rem) {
  .club-mark { width: clamp(4.1rem, 20dvh, 5.6rem); }
  .intro h1 { font-size: clamp(1.45rem, min(8vw, 6.4dvh), 2rem); }
  .history-link { min-height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .stage:is(.is-dipping, .is-rising) :is(.die, .liquid) { animation: none; }
}

.entrance {
  --phosphor: #bafc9b;
  --dim-green: #93ae8a;
  width: min(100%, 40rem);
  padding: clamp(.8rem, 3vw, 1.6rem);
  color: var(--phosphor);
  font-family: "Courier New", monospace;
}

.terminal {
  overflow: hidden;
  border: 1px solid #4c6844;
  border-radius: .55rem;
  background:
    repeating-linear-gradient(transparent 0 3px, #aaff9420 4px, transparent 5px),
    radial-gradient(ellipse at 50% 35%, #162414, #0a100b 75%);
  box-shadow: 0 0 3rem #61c94a1b;
}

.terminal-bar {
  display: flex;
  gap: .6rem;
  align-items: center;
  padding: .75rem 1rem;
  border-bottom: 1px solid #3a5033;
  background: #141d13;
  font-size: .9rem;
  font-weight: bold;
}

.terminal-light {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 .65rem currentColor;
}

.terminal-path {
  margin-left: auto;
  color: var(--dim-green);
  font-weight: normal;
}

.terminal-body {
  padding: clamp(1rem, 5vw, 2.75rem);
  text-align: center;
}

.terminal-stickers {
  display: block;
  width: clamp(5rem, min(35vw, 24dvh), 10rem);
  height: auto;
  margin: 0 auto .7rem;
  mix-blend-mode: screen;
}

.terminal h1 {
  margin: 0;
  font-size: clamp(1.35rem, 5.4vw, 2.65rem);
  line-height: 1.04;
  letter-spacing: -.07em;
  text-wrap: balance;
}

.terminal-members {
  margin: .6rem 0 1.45rem;
  color: var(--dim-green);
  font-size: .875rem;
}

.terminal-login {
  display: grid;
  gap: .55rem;
  text-align: left;
  max-width: 25rem;
  margin: auto;
}

.terminal-input {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding-inline: .75rem;
  border: 1px solid #577b4c;
  border-radius: .25rem;
  background: #080f08;
}

.terminal-input:focus-within {
  outline: 2px solid var(--phosphor);
  outline-offset: 2px;
}

.terminal-input input {
  width: 100%;
  min-height: 44px;
  padding: .35rem 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.terminal-enter {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  padding: .45rem 1.45rem;
  border: 1px solid var(--phosphor);
  border-radius: .25rem;
  background: var(--phosphor);
  color: #10180e;
  text-decoration: none;
  font: bold 1rem "Courier New", monospace;
}

.terminal-enter:hover { background: #d6ffc8; }
.terminal-enter:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.terminal-login .terminal-enter { margin-top: .25rem; }
.terminal-error { margin: 0; color: #ffd3df; font-size: .875rem; }
.lock-form { position: absolute; top: max(.35rem, env(safe-area-inset-top)); right: max(.4rem, env(safe-area-inset-right)); }
.lock-link { min-height: 34px; padding: .35rem .55rem; border: 0; background: none; color: var(--muted); font-size: .875rem; }
.lock-link:hover { color: var(--pink); }
