/* TechVizier Games — screenprint.
   Warm paper, ink rules, flat spot colours. No gradients, no glow, no blur,
   no rounded corners. Depth comes from hard offset shadows, the way a second
   pass of ink sits beside the first. */

:root {
  --paper: #f2ede3;
  --paper-2: #e7e0d2; /* panels and play fields */
  --paper-3: #dbd3c1; /* pressed / inset */
  --ink: #17150f;
  --ink-2: #6b6355;

  --vermilion: #d8452f;
  --mustard: #e3a423;
  --teal: #14706e;
  --olive: #5d7a34;
  --plum: #7a3b58;

  --spot: var(--vermilion); /* re-pointed per game */

  --rule: 2px;
  --drop: 6px; /* offset-shadow distance */

  --display: "Helvetica Neue", Helvetica, Arial, "Liberation Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain. Fine-grained turbulence at low opacity — enough to kill the
   flatness of a solid fill without reading as texture. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}

[hidden] {
  display: none !important;
}

::selection {
  background: var(--spot);
  color: var(--paper);
}

/* ------------------------------------------------------------ typography */

h1,
h2,
h3 {
  margin: 0;
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 0.92;
  text-transform: uppercase;
}

.wordmark {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.wordmark span:last-child {
  color: var(--ink-2);
}

/* ------------------------------------------------------------- structure */

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 22px;
}

.rule-top {
  border-top: var(--rule) solid var(--ink);
}

.masthead {
  padding: 40px 0 46px;
  border-top: 6px solid var(--ink);
  border-bottom: var(--rule) solid var(--ink);
}

.masthead h1 {
  font-size: clamp(64px, 17vw, 156px);
  line-height: 0.82;
  margin-left: -0.06em; /* optical: pull the cap stem to the grid line */
}

.masthead-grid {
  display: grid;
  gap: 26px;
  grid-template-columns: 1fr;
  align-items: end;
}

@media (min-width: 720px) {
  .masthead-grid {
    grid-template-columns: 1.4fr 1fr;
  }
}

.lede {
  margin: 0;
  max-width: 34ch;
  font-size: 17px;
  line-height: 1.45;
  border-left: var(--rule) solid var(--ink);
  padding-left: 14px;
}

.masthead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.section {
  padding: 44px 0;
  border-bottom: var(--rule) solid var(--ink);
}

.section:last-of-type {
  border-bottom: 0;
}

/* "01 / PLAY NOW" — the index number is set in the spot colour and the rule
   runs to the end of the measure. */
.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.section-title::after {
  content: "";
  flex: 1;
  height: var(--rule);
  background: var(--ink);
}

.section-title .num {
  font-family: var(--mono);
  color: var(--vermilion);
}

.section-note {
  margin: 0 0 26px;
  max-width: 58ch;
  color: var(--ink-2);
}

/* ------------------------------------------------------------------ grid */

.grid {
  display: grid;
  gap: 26px var(--drop);
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  margin-top: 22px;
}

/* Column layout so the meta rule sits on a shared baseline across a row,
   however many lines a tagline runs to. */
.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: inherit;
  text-decoration: none;
}

.card-art {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background: var(--spot);
  border: var(--rule) solid var(--ink);
  box-shadow: var(--drop) var(--drop) 0 var(--ink);
  transition: transform 0.09s steps(2), box-shadow 0.09s steps(2);
}

.card-art svg {
  width: 62%;
  height: 62%;
  /* Marks are cut out of the plate in paper, like a knocked-out screenprint. */
  color: var(--paper);
}

a.card:hover .card-art,
a.card:focus-visible .card-art {
  transform: translate(3px, 3px);
  box-shadow: 3px 3px 0 var(--ink);
}

a.card:active .card-art {
  transform: translate(var(--drop), var(--drop));
  box-shadow: 0 0 0 var(--ink);
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 0 0;
}

.card-index {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-2);
}

.card-title {
  font-size: 25px;
  margin: 2px 0 5px;
}

.card-tagline {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto; /* pinned to the bottom, so rules align across the row */
  padding-top: 10px;
  border-top: 1px solid var(--ink);
}

.tags {
  display: flex;
  gap: 6px;
}

.tag,
.pill {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 7px;
  border: 1px solid var(--ink);
}

.card-best {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  background: var(--ink);
  color: var(--paper);
  padding: 3px 7px;
}

/* The number carries the weight; the word just says what it is. */
.card-best-label {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.7;
}

/* ----------------------------------------------------------------- ideas */

.grid-ideas {
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  gap: 0;
  margin-top: 0;
  border-top: 1px solid var(--ink);
}

.card-idea {
  padding: 18px 0 20px;
  border-bottom: 1px solid var(--ink);
}

@media (min-width: 620px) {
  .card-idea {
    padding-right: 26px;
  }
}

.card-idea .card-title {
  font-size: 20px;
}

.card-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink-2);
  font-family: var(--mono);
}

a.card-idea:hover .card-title {
  color: var(--vermilion);
}

.pill-next {
  background: var(--olive);
  color: var(--paper);
  border-color: var(--olive);
}

.pill-exploring {
  background: var(--mustard);
}

.pill-someday {
  background: transparent;
}

/* ----------------------------------------------------------------- notes */

.notes {
  display: grid;
  gap: 0;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin-top: 22px;
  border-top: 1px solid var(--ink);
}

.note {
  padding: 18px 0 4px;
}

@media (min-width: 700px) {
  .note {
    padding-right: 26px;
  }
}

.note h3 {
  font-size: 15px;
  margin-bottom: 7px;
}

.note p {
  margin: 0;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink-2);
}

.footer {
  padding: 22px 0 calc(var(--safe-b) + 34px);
  border-top: var(--rule) solid var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border: var(--rule) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform 0.09s steps(2), box-shadow 0.09s steps(2);
}

.btn:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

.btn:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-primary {
  background: var(--spot);
  color: var(--paper);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: 4px 4px 0 var(--ink);
}

/* ---------------------------------------------------------------- player */

#player {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l);
  background: var(--paper);
}

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 8px;
  border-bottom: var(--rule) solid var(--ink);
  background: var(--spot);
  /* The bar must never widen the page: a 390px phone is the tightest case. */
  max-width: 100%;
  overflow: hidden;
}

.hud-btn {
  flex: 0 0 auto;
  min-width: 40px;
  min-height: 38px;
  padding: 0 8px;
  border: var(--rule) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}

.hud-btn:active {
  background: var(--paper-3);
}

.hud-btn.is-off {
  color: var(--ink-2);
}

.hud-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.hud-scores {
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

/* Stacked, not inline: a six-figure net worth in the sim needs the full width
   of the chip for its digits, and side-by-side truncated it to "2,4…". */
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
  min-width: 0;
  background: var(--paper);
  border: var(--rule) solid var(--ink);
  padding: 2px 7px;
}

.stat-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.status {
  margin: 0;
  padding: 5px 12px 0;
  min-height: 17px;
  text-align: center;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 10px;
}

.game-canvas {
  display: block;
  border: var(--rule) solid var(--ink);
  background: var(--paper-2);
}

/* DOM-surface games (see engine/host.js) get a plain scrollable plate. */
.game-root {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.stage:has(.game-root) {
  padding: 0;
  place-items: stretch;
}

/* -------------------------------------------------------------- touchpad */

.touchpad {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px 12px;
  border-top: var(--rule) solid var(--ink);
}

.pad-btn {
  flex: 1;
  max-width: 92px;
  min-height: 54px;
  border: var(--rule) solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font-size: 19px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.pad-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
  background: var(--spot);
  color: var(--paper);
}

@media (hover: hover) and (pointer: fine) {
  .touchpad {
    display: none;
  }
}

/* --------------------------------------------------------------- overlay */

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 21, 15, 0.55);
  z-index: 10;
}

.overlay-card {
  width: min(410px, 100%);
  padding: 26px 24px;
  background: var(--paper);
  border: var(--rule) solid var(--ink);
  box-shadow: 9px 9px 0 var(--ink);
}

.overlay-card h2 {
  font-size: 34px;
  margin-bottom: 8px;
}

.overlay-card > p {
  margin: 0;
  color: var(--ink-2);
  line-height: 1.45;
}

.controls {
  margin: 20px 0 0;
}

.controls > div {
  padding: 10px 0;
  border-top: 1px solid var(--ink);
}

.controls dt {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.controls dd {
  margin: 4px 0 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-2);
}

.overlay-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
