/* Reset, stage, shared plates and buttons, triangles, rotate overlay. Values come from tokens.css. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: repeating-linear-gradient(115deg, var(--speed-lines) 0px, var(--speed-lines) 2px, transparent 2px, transparent 16px), var(--ground);
  color: var(--bone);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; font-weight: inherit; }

/* The 844 x 390 design stage, scaled to fit inside the safe area by main.js. */
#stage {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--stage-w);
  height: var(--stage-h);
  transform-origin: 0 0;
}
.screen { position: absolute; inset: 0; }
.abs { position: absolute; }
.safe-probe {
  position: fixed;
  visibility: hidden;
  pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Background triangles */
.tri-layer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tri { position: absolute; animation: tri-spin var(--tri-spin-dur) linear infinite; }
.tri polygon { animation-name: tri-col; animation-timing-function: ease-in-out; animation-iteration-count: infinite; animation-direction: alternate; }
@keyframes tri-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes tri-col { from { fill: #FFFFFF; } to { fill: var(--gold); } }

/* Type */
.display { font-family: var(--font-display); font-weight: 400; line-height: 1; }
.quote { font-family: var(--font-quote); font-style: italic; }
.label { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }
.muted { color: var(--muted); }

/* Skewed plates: the element leans, its .u child stands upright again. */
.skew { transform: skewX(var(--skew)); }
.u { display: block; transform: skewX(var(--unskew)); }

/* Buttons */
.btn {
  border: 0;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  transform: skewX(var(--skew));
  min-height: 44px;
  white-space: nowrap;
  transition: translate 60ms linear, box-shadow 60ms linear, filter 60ms linear;
}
.btn > * { transform: skewX(var(--unskew)); }
.btn:disabled { cursor: default; filter: saturate(0.2) brightness(0.6); }
.btn-primary {
  background: var(--purple);
  color: var(--on-purple);
  outline: var(--gold-md) solid var(--gold);
  outline-offset: 0;
  box-shadow: 8px 8px 0 var(--bone);
}
.btn-ghost { background: var(--panel); color: var(--bone); border: 2px solid var(--border); }
.btn-bone { background: var(--bone); color: var(--on-purple); box-shadow: 7px 7px 0 var(--black); }
.btn-bone.rim { box-shadow: 8px 8px 0 0 var(--purple), 8px 8px 0 var(--gold-md) var(--gold); }
.btn-outline { background: transparent; color: var(--bone); border: 3px solid var(--bone); }
.btn-quiet { background: transparent; color: var(--muted); border: 2px solid var(--border); }

/* Press: the button sinks into its shadow, the gold border flashes white. */
.btn:not(:disabled):active { translate: 5px 5px; filter: brightness(1.08); }
.btn-primary:not(:disabled):active { box-shadow: 3px 3px 0 var(--bone); outline-color: #FFFFFF; }
.btn-bone:not(:disabled):active { box-shadow: 2px 2px 0 var(--black); }
.btn-bone.rim:not(:disabled):active { box-shadow: 3px 3px 0 0 var(--purple), 3px 3px 0 var(--gold-md) #FFFFFF; }

/* Small purple chip with a gold border, and a bone tag */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--purple);
  color: var(--on-purple);
  padding: 5px 14px;
  outline: var(--gold-sm) solid var(--gold);
  transform: skewX(var(--skew));
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 2px;
}
.chip > * { transform: skewX(var(--unskew)); }
.tag {
  display: inline-block;
  background: var(--bone);
  color: var(--on-purple);
  padding: 3px 12px;
  transform: skewX(var(--skew));
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 3px;
}
.tag > * { display: block; transform: skewX(var(--unskew)); }

/* Rotate overlay: shown whenever the phone is upright. */
.rotate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  background: var(--ground);
  text-align: center;
  padding: 32px;
}
.rotate p { font-family: var(--font-display); font-size: 40px; line-height: 1.05; max-width: 100%; }
.rotate svg { animation: rotate-hint 2.4s var(--ease-out) infinite; }
@keyframes rotate-hint { 0%, 30% { rotate: 0deg; } 60%, 100% { rotate: -90deg; } }
@media (orientation: portrait) {
  .rotate { display: flex; }
  #app { visibility: hidden; }
}

/* Error screen */
.error-box { left: 56px; top: 80px; width: 700px; display: flex; flex-direction: column; gap: 18px; align-items: flex-start; }
.error-box h1 { font-size: 56px; text-shadow: 6px 6px 0 var(--black); }
.error-box p { font-size: 18px; max-width: 620px; }
.error-box code { font-size: 14px; color: var(--muted); white-space: pre-wrap; }
