:root {
  --m: 48px;
  --pt: max(var(--m), env(safe-area-inset-top, 0px));
  --pr: max(var(--m), env(safe-area-inset-right, 0px));
  --pb: max(var(--m), env(safe-area-inset-bottom, 0px));
  --pl: max(var(--m), env(safe-area-inset-left, 0px));
  --sb: env(safe-area-inset-bottom, 0px);
  --strip: 100px;   /* collapsed rule strip; keep in step with STRIP in main.js */
  --home-w: 128px;
  --f: 74px;        /* rule sentence, set by layout() */
  --pong: 440px;    /* landing wordmark, set by layout() */
  --track: -0.035em;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

html, body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
  color: #fff;
}

body {
  font: 700 16px/1 "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  cursor: default;
}

/* Tracking is set where the size is set, so the em follows the type. */
#sentence, #actions, #home, #measure { letter-spacing: var(--track); }

button {
  display: block;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 0;
  outline: 0;
  -webkit-appearance: none;
  appearance: none;
  cursor: inherit;
}

canvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ------------------------------------------------------------ landing */

#landing {
  position: fixed;
  inset: 0;
  background: #000;
  padding: var(--pt) var(--pr) var(--pb) var(--pl);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

#pong {
  font-size: var(--pong);
  line-height: 0.73;
  margin-top: var(--pong-lift, 0);   /* its cap line on the top margin */
  letter-spacing: -0.05em;
  text-indent: var(--pong-indent, -0.07em);   /* the stem of the P sits on the margin */
  white-space: nowrap;
}

/* One row along the bottom margin. White blocks are the things to press. */
#cards {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  column-gap: 16px;
}

.card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: clamp(160px, 17vw, 250px);
  padding: 12px 12px 14px;
  background: #fff;
  color: #000;
}

.card .t {
  font-size: clamp(16px, 1.76vw, 26px);
  line-height: 1.02;
  letter-spacing: var(--track);
}

.card.start .t {
  font-size: clamp(24px, 2.8vw, 42px);
  line-height: 0.95;
}

.card .d {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 8;
  overflow: hidden;
  font-size: clamp(10px, 1.03vw, 15px);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

/* ------------------------------------------------------------ strip / rules
   One panel, one block of text. Collapsed it is clipped to a strip along the
   bottom edge; open it is the whole screen. main.js animates between the two. */

#panel {
  position: fixed;
  inset: 0;
  background: #fff;
  color: #000;
}

#sentence {
  position: absolute;
  left: var(--pl);
  right: var(--pr);
}

#panel.strip #sentence {
  right: calc(var(--pr) + var(--home-w) + 32px);
  bottom: calc(var(--sb) + var(--strip) / 2);
  transform: translateY(50%);   /* centred in the strip whatever the line count */
  font-size: min(21px, 1.54vw);
  line-height: 1.22;   /* same as the rules screen, so the words scale between the two exactly */
}

#panel.open #sentence {
  top: var(--pt);
  font-size: var(--f);
  line-height: 1.22;
}

#panel.open .cl {
  display: block;
  white-space: nowrap;
}

.w {
  display: inline-block;
  white-space: pre;
  transform-origin: 0 0;
}

.slot {
  position: relative;
  display: inline-block;
  padding: 0 0.08em 0.12em;
  line-height: 0.98;
  -webkit-clip-path: inset(0);
  clip-path: inset(0);
}

.val {
  display: inline-block;
  text-decoration: underline;
  text-decoration-thickness: 0.09em;
  text-underline-offset: 0.07em;
  text-decoration-skip-ink: none;
  -webkit-text-decoration-skip: none;
}

.val.out {
  position: absolute;
  left: 0.08em;
  top: 0;
}

.slot.on {
  background: #000;
  color: #fff;
}

.cl.inert .w {
  opacity: 0.4;
  text-decoration: line-through;
  text-decoration-thickness: 0.08em;
}

.cl.inert .val {
  text-decoration-line: underline line-through;
}

#actions {
  position: absolute;
  left: var(--pl);
  right: var(--pr);
  bottom: var(--pb);
  display: flex;
  column-gap: 16px;
  font-size: calc(var(--f) * 0.62);
  line-height: 1;
  opacity: 0;
}

#panel.open #actions {
  opacity: 1;
  transition: opacity 120ms linear 140ms;
}

#panel.open.closing #actions {
  opacity: 0;
  transition: opacity 80ms linear;
}

#play, #save {
  height: 1.9em;
  min-height: 64px;
  padding: 0 0.6em;
  border: 4px solid #000;
  background: #000;
  color: #fff;
  letter-spacing: inherit;
  text-align: center;
}

/* Unavailable: an empty outline. Struck when there is nothing to save. */
#save.off {
  background: #fff;
  color: #000;
  text-decoration: line-through;
  text-decoration-thickness: 0.08em;
}

#save.kept { text-decoration: none; }

/* Same block in the strip and on the rules screen; it only shifts to the margin. */
#home {
  position: absolute;
  right: var(--pr);
  bottom: calc(var(--sb) + (var(--strip) - 64px) / 2);
  width: var(--home-w);
  height: 64px;
  background: #000;
  color: #fff;
  font-size: 24px;
  text-align: center;
  transition: bottom 350ms cubic-bezier(.4, 0, 0, 1);
}

#panel.open #home { bottom: var(--pb); }
#panel.open.closing #home { bottom: calc(var(--sb) + (var(--strip) - 64px) / 2); }

/* ------------------------------------------------------------ helpers */

#probe {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

#measure {
  position: fixed;
  left: 0;
  top: 0;
  visibility: hidden;
  pointer-events: none;
  white-space: pre;
  font-size: 100px;
}
