/*
 * style.css — TiltLink, a tech demo in neon on near-black.
 *
 * The top block is the hub's "a game is not a document" floor (hub §2):
 * no selection, no callout, no double-tap zoom, and the play surfaces take
 * no browser gestures at all. A phone held like a tray is a phone with a
 * thumb resting on it, and Safari would otherwise start selecting words.
 */

html,
body {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
input,
textarea,
[contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

:root {
  --bg: #0b0e1a;
  --panel: rgba(20, 24, 44, 0.82);
  --edge: #2c3360;
  --text: #eef0ff;
  --muted: #9aa0c8;
  --accent: #4fd6ff;
  --hot: #ff5c8a;
  /* This phone's ball colour, written by pad.js once the stage says. */
  --me: var(--accent);
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
}

[hidden] {
  display: none !important;
}

#crash {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  padding: 10px 14px;
  background: #a1172f;
  color: #fff;
  font-size: 14px;
}

/* ---------- shared bits ---------- */

.screen {
  min-height: 100%;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 22px;
  padding: max(24px, env(safe-area-inset-top)) 20px
    max(24px, env(safe-area-inset-bottom));
  text-align: center;
}

.wordmark {
  margin: 0;
  font-size: clamp(44px, 12vw, 88px);
  font-weight: 800;
  letter-spacing: -0.03em;
  text-shadow: 0 0 24px rgba(79, 214, 255, 0.6);
}
.wordmark span {
  color: var(--hot);
  text-shadow: 0 0 24px rgba(255, 92, 138, 0.6);
}
.lede {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
}
.label {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.status {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  white-space: pre-line;
}
.small {
  font-size: 12px;
}

/* Equal doors (hub §2: alternatives get one size). */
.doors {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: min(100%, 420px);
}
.doors > * {
  flex: 1 1 0;
}

.pill {
  min-height: 52px;
  padding: 0 20px;
  border: 2px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: 600 17px var(--body);
  cursor: pointer;
}
.pill.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--me));
  color: #071018;
}
.pill.big {
  min-height: 72px;
  width: min(100%, 320px);
  font-size: 22px;
}
.pill:disabled {
  opacity: 0.45;
  cursor: default;
}
.pill:focus-visible,
.key:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.code-icons {
  margin: 0;
  font-size: 44px;
  letter-spacing: 0.15em;
}
.code-names {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

/* ---------- the stage ---------- */

#stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
#arena {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#join-card {
  position: absolute;
  left: 24px;
  bottom: 24px;
  display: flex;
  gap: 18px;
  align-items: center;
  max-width: calc(100% - 48px);
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: scale 0.3s, translate 0.3s;
  transform-origin: bottom left;
}
#qr {
  width: 232px;
  height: 232px;
  border-radius: 10px;
  image-rendering: pixelated;
  flex: none;
}
.join-text {
  display: grid;
  gap: 8px;
  text-align: left;
  min-width: 0;
}
.join-url {
  margin: 0;
  color: var(--muted);
  font: 12px ui-monospace, Menlo, monospace;
  overflow-wrap: anywhere;
  -webkit-user-select: text;
  user-select: text;
}
/* Once someone is in, the card steps back out of the way, still scannable. */
#join-card.small {
  scale: 0.6;
}

#roster {
  position: absolute;
  top: 20px;
  right: 20px;
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
#roster li {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  min-width: 180px;
  padding: 8px 14px;
  border-left: 6px solid var(--c);
  border-radius: 10px;
  background: var(--panel);
  font-weight: 600;
}
.path {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.path.relay {
  color: #ffd23f;
}


/* ---------- the keypad ---------- */

.slots {
  display: flex;
  gap: 12px;
}
.slot {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border: 2px dashed var(--edge);
  border-radius: 16px;
  font-size: 36px;
}
.keys {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(100%, 360px);
}
.key {
  aspect-ratio: 1;
  border: 2px solid var(--edge);
  border-radius: 16px;
  background: var(--panel);
  font-size: 34px;
  cursor: pointer;
}

/* ---------- the pad ---------- */

#pad {
  touch-action: none;
}
.pad-face {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: 100%;
}
.tray {
  position: relative;
  display: grid;
  place-items: center;
  width: 84vmin;
  height: 84vmin;
  max-width: 460px;
  max-height: 460px;
  border: 3px solid var(--me);
  border-radius: 28px;
  box-shadow: 0 0 40px color-mix(in srgb, var(--me) 35%, transparent);
  touch-action: none;
}
.tray.drag {
  border-style: dashed;
}
.tray-dot {
  width: 22%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--me);
  box-shadow: 0 0 30px var(--me);
}
.tray.hit {
  animation: hit 0.18s ease-out;
}
@keyframes hit {
  from {
    background: color-mix(in srgb, var(--me) 45%, transparent);
  }
  to {
    background: transparent;
  }
}

/* ---------- the fight ---------- */

/* Lobby and result: one card in the middle, the arena moving behind it. */
.centre-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 16px;
  width: min(440px, calc(100% - 48px));
  padding: 24px;
  border: 1px solid var(--edge);
  border-radius: 24px;
  background: var(--panel);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  text-align: center;
}
.small-mark {
  font-size: 48px;
}
.rules {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.rules b {
  color: var(--text);
}
.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}
.stepper output {
  min-width: 2ch;
  font-size: 28px;
  font-weight: 700;
}
.pill.round {
  width: 52px;
  padding: 0;
  font-size: 26px;
}
.over-title {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
  text-shadow: 0 0 24px currentColor;
}

#roster .who {
  flex: 1;
}
#roster .lives {
  font-variant-numeric: tabular-nums;
}
.mute {
  padding: 4px 10px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: 500 12px var(--body);
  cursor: pointer;
}
.mute[aria-pressed="true"] {
  color: var(--muted);
  text-decoration: line-through;
}

/* ---------- the pad in a fight ---------- */

.pad-name {
  margin: 0;
  color: var(--me);
  font-size: 22px;
  font-weight: 800;
}
.pad-lives {
  margin: 0;
  min-height: 1.2em;
  color: var(--me);
  font-size: 22px;
  letter-spacing: 0.1em;
}
#pad-live .tray {
  width: 64vmin;
  height: 64vmin;
}
/* Pulse is the one button a thumb hunts for mid-fight: big, and it shows
   the stage's cooldown filling back up. */
.pill.pulse {
  position: relative;
  overflow: hidden;
  width: min(100%, 420px);
  min-height: 84px;
  font-size: 26px;
  touch-action: none;
}
.pill.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(11, 14, 26, 0.55);
  transform-origin: left;
  scale: 0 1;
}
.pill.pulse.cooling::after {
  animation: cool var(--cd, 0.8s) linear;
}
@keyframes cool {
  from {
    scale: 1 1;
  }
  to {
    scale: 0 1;
  }
}
.tray.hurt {
  animation: hurt 0.35s ease-out;
}
@keyframes hurt {
  from {
    background: rgba(255, 60, 60, 0.6);
  }
  to {
    background: transparent;
  }
}
.pill.rec {
  touch-action: none;
}
.pill.rec.on {
  background: #ff3c5a;
  color: #fff;
  box-shadow: 0 0 30px #ff3c5a;
}

/* A phone on its side: tray left, everything else stacked right, so
   nothing scrolls (hub §2, maxgear's shape). */
@media (orientation: landscape) and (max-height: 500px) {
  #pad-live {
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 24px;
  }
  #pad-live > * {
    grid-column: 2;
  }
  #pad-live .tray {
    grid-column: 1;
    grid-row: 1 / span 7;
    width: 78vh;
    height: 78vh;
  }
  .pill.pulse {
    min-height: 60px;
  }
  .keys {
    grid-template-columns: repeat(6, 1fr);
    width: min(100%, 520px);
  }
  .screen {
    gap: 10px;
  }
  .centre-panel {
    gap: 10px;
    padding: 16px;
  }
}
