/* REDLCRAFT — voxel daylight
   Palette derives from the server itself: lobby quartz, noon sky, bed red,
   generator gold. Ore colours are reserved for the minigame so the game
   feels like the payoff. */

:root {
  --sky-top: #2F7FC9;
  --sky-mid: #63AEE6;
  --sky-low: #B9E2F7;
  --ink: #14161c;
  --ink-soft: #4a5162;
  --paper: #FBFAF7;
  --quartz: #F4F2ED;
  --stone: #8C919B;
  --red: #E23B32;
  --red-dark: #A72620;
  --gold: #FFB13B;
  --grass: #64BE3C;

  --line: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --s: 34px;              /* voxel edge */
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Rubik, system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: Unbounded, Rubik, sans-serif; margin: 0; line-height: 1.05; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px max(20px, 5vw);
  background: var(--quartz);
  border-bottom: var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }

.brand__cube {
  width: 22px; height: 22px;
  background: var(--red);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
}

.brand__name {
  font-family: Unbounded, sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-size: 18px;
}

.topnav { display: flex; gap: 22px; margin-left: auto; font-weight: 500; }
.topnav a { text-decoration: none; padding: 4px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { border-bottom-color: var(--red); }

.ip-mini {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: 6px 12px;
  background: var(--ink);
  color: var(--quartz);
  border: none;
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.ip-mini:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.ip-mini__addr { font-size: 13px; font-weight: 700; }
.ip-mini__hint { font-size: 10px; opacity: .6; text-transform: uppercase; letter-spacing: .1em; }

/* ------------------------------------------------------------------ hero */

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(48px, 7vw, 96px) max(20px, 5vw) clamp(60px, 8vw, 120px);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 52%, var(--sky-low) 100%);
  border-bottom: var(--line);
}

.hero__grid {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: center;
}

.eyebrow {
  margin: 0 0 14px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--quartz);
  border: 2px solid var(--ink);
  display: inline-block;
  padding: 5px 10px;
}

.hero__title {
  font-size: clamp(40px, 6.4vw, 82px);
  font-weight: 900;
  letter-spacing: -0.035em;
  color: var(--quartz);
  text-shadow: 5px 5px 0 var(--ink);
}

.hero__lead {
  max-width: 46ch;
  margin: 22px 0 28px;
  color: #0d1a2b;
  font-size: clamp(16px, 1.5vw, 18px);
}

.ipcard {
  background: var(--quartz);
  border: var(--line);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  max-width: 460px;
}

.ipcard__label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.ipcard__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 10px; }

.ipcard__addr {
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 700;
  letter-spacing: -0.01em;
}

.ipcard__status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-soft);
  border-top: 2px dashed rgba(20, 22, 28, .18);
  padding-top: 10px;
}

.dot {
  width: 10px; height: 10px;
  background: var(--stone);
  border: 2px solid var(--ink);
  flex: none;
}
.dot.is-on { background: var(--grass); }
.dot.is-off { background: var(--red); }

.hero__actions { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 26px; }

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

.btn {
  display: inline-block;
  font-family: Rubik, sans-serif;
  font-weight: 700;
  font-size: 16px;
  padding: 12px 20px;
  border: var(--line);
  background: var(--quartz);
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease;
}
.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(--red); color: #fff; }
.btn--ghost { background: transparent; }
.btn--sm { font-size: 14px; padding: 9px 14px; }
.btn--copy { font-family: "JetBrains Mono", monospace; }

/* ----------------------------------------------------------------- clouds */

/* Voxel clouds live in the open sky on the right, never behind the text. */
.clouds { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.cloud {
  position: absolute;
  width: 30px; height: 26px;
  background: rgba(255, 255, 255, .78);
  box-shadow:
    30px 0 0 rgba(255, 255, 255, .78),
    60px 0 0 rgba(255, 255, 255, .78),
    30px -26px 0 rgba(255, 255, 255, .78),
    60px -26px 0 rgba(255, 255, 255, .6);
}
.cloud--a { top: 14%; right: 30%; }
.cloud--b { top: 30%; right: 6%; transform: scale(1.35); }
.cloud--c { bottom: 20%; right: 20%; transform: scale(.75); opacity: .7; }

/* ------------------------------------------------------------ voxel island */

.island-stage { display: flex; flex-direction: column; align-items: center; gap: 18px; }

.island-bob { animation: bob 7s ease-in-out infinite; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

.iso {
  position: relative;
  width: calc(var(--s) * 9);
  height: calc(var(--s) * 9);
  transform-style: preserve-3d;
  transform: rotateX(58deg) rotateZ(45deg);
}

.vx { position: absolute; width: var(--s); height: var(--s); transform-style: preserve-3d; }

.vx__in {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  animation: drop .55s cubic-bezier(.2, .85, .25, 1) backwards;
  animation-delay: calc(var(--i) * 16ms);
}

@keyframes drop {
  from { transform: translateZ(220px); opacity: 0; }
  to   { transform: translateZ(0); opacity: 1; }
}

.vx i {
  position: absolute;
  inset: 0;
  background: var(--c);
  display: block;
}
/* Scene is tilted by the parent, so the untransformed face reads as the top. */
.vx .t { transform: translateZ(calc(var(--s) / 2)); }
.vx .f { transform: rotateX(-90deg) translateZ(calc(var(--s) / 2)); filter: brightness(.72); }
.vx .r { transform: rotateY(90deg) translateZ(calc(var(--s) / 2)); filter: brightness(.52); }

.vx--lamp .t { box-shadow: 0 0 22px 6px rgba(255, 233, 150, .75); }

.island-caption {
  margin: 0;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: .1em;
  color: #0d1a2b;
  background: rgba(255, 255, 255, .7);
  padding: 4px 10px;
  border: 2px solid var(--ink);
}

/* --------------------------------------------------------------- sections */

.sec-head { max-width: var(--maxw); margin: 0 auto clamp(28px, 4vw, 48px); }
.sec-title { font-size: clamp(28px, 4vw, 46px); font-weight: 700; letter-spacing: -0.03em; }
.sec-title--light { color: var(--quartz); }
.eyebrow--light { background: var(--red); color: #fff; border-color: #fff; }

.modes { padding: clamp(56px, 8vw, 104px) max(20px, 5vw); }

.cards {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 22px;
}

.card {
  background: var(--quartz);
  border: var(--line);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  transition: transform .14s ease, box-shadow .14s ease;
}
.card:hover { transform: translate(-3px, -3px); box-shadow: 9px 9px 0 var(--ink); }

.card__top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }

.chip {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  border: 2px solid var(--ink);
  padding: 3px 8px;
  background: #fff;
}

.card__title { font-size: 23px; letter-spacing: -0.02em; margin-bottom: 8px; }
.card__text { margin: 0 0 16px; font-size: 15px; color: var(--ink-soft); }
.card__text code { font-size: 13px; background: #fff; border: 1px solid var(--ink); padding: 1px 5px; }

.specs { list-style: none; margin: auto 0 0; padding: 0; border-top: 2px solid var(--ink); }
.specs li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(20, 22, 28, .2);
  font-size: 14px;
}
.specs li:last-child { border-bottom: 0; }
.specs span { color: var(--ink-soft); }
.specs b { font-family: "JetBrains Mono", monospace; }

/* small isometric icon cube */
.cube-icon {
  position: relative;
  width: 34px; height: 34px;
  transform-style: preserve-3d;
  transform: rotateX(58deg) rotateZ(45deg);
  flex: none;
  margin: 6px 10px 0 0;
}
.cube-icon i { position: absolute; inset: 0; background: var(--cc); }
.cube-icon i:nth-child(1) { transform: translateZ(17px); }
.cube-icon i:nth-child(2) { transform: rotateX(-90deg) translateZ(17px); filter: brightness(.72); }
.cube-icon i:nth-child(3) { transform: rotateY(90deg) translateZ(17px); filter: brightness(.52); }
.cube-icon--grass  { --cc: var(--grass); }
.cube-icon--quartz { --cc: #E9E6DF; }
.cube-icon--gold   { --cc: var(--gold); }
.cube-icon--bed    { --cc: var(--red); }

/* ------------------------------------------------------------------ steps */

.join {
  padding: clamp(56px, 8vw, 104px) max(20px, 5vw);
  background: var(--quartz);
  border-top: var(--line);
  border-bottom: var(--line);
}

.steps { max-width: var(--maxw); margin: 0 auto; padding: 0; list-style: none; display: grid; gap: 16px; }

.step {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  background: var(--paper);
  border: var(--line);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}

.step__num {
  font-family: Unbounded, sans-serif;
  font-weight: 900;
  font-size: 26px;
  color: var(--red);
  flex: none;
  width: 52px;
}

.step__body h3 { font-size: 19px; margin-bottom: 4px; letter-spacing: -0.02em; }
.step__body p { margin: 0 0 10px; color: var(--ink-soft); font-size: 15px; }

.cmd {
  display: inline-block;
  background: var(--ink);
  color: #9BE86A;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 700;
}

/* ------------------------------------------------------------------- game */

.game {
  padding: clamp(56px, 8vw, 104px) max(20px, 5vw);
  background: var(--ink);
  color: var(--quartz);
}

.game__head { max-width: var(--maxw); margin: 0 auto 32px; }
.game__lead { max-width: 56ch; color: #B9BFCC; margin: 14px 0 0; }

.game__wrap {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.game__panel { display: flex; flex-direction: column; gap: 16px; }

.score { display: flex; gap: 12px; }
.score__box {
  flex: 1;
  background: #1E212A;
  border: 3px solid #2E3340;
  padding: 10px 14px;
}
.score__box span {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #7C8496;
}
.score__box b { font-family: Unbounded, sans-serif; font-size: 26px; }

.chain { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.chain li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #B9BFCC;
  font-family: "JetBrains Mono", monospace;
}
.chain i {
  width: 18px; height: 18px;
  background: var(--cc);
  border: 2px solid #000;
  flex: none;
}

/* width must be explicit: auto width + auto inline margins makes a grid item
   shrink to min-content, which collapses the board. */
.board-shell { position: relative; width: 100%; max-width: 520px; margin-inline: auto; }

.board {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  background: #23262F;
  border: 4px solid #000;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, .55);
  padding: 12px;
  touch-action: none;
}

.board__cells, .board__tiles { position: absolute; inset: 12px; }
.board__cells { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 10px; }
.board__cells div { background: #1B1E25; border: 2px solid #14161c; }

.tile {
  position: absolute;
  width: calc((100% - 30px) / 4);
  height: calc((100% - 30px) / 4);
  background: var(--c);
  color: var(--fg);
  border: 3px solid #000;
  box-shadow: inset -6px -6px 0 rgba(0, 0, 0, .22), inset 6px 6px 0 rgba(255, 255, 255, .18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transform: translate(var(--tx), var(--ty));
  transition: transform .12s ease-out;
  will-change: transform;
}
.tile b {
  font-family: Unbounded, sans-serif;
  font-size: clamp(12px, 1.7vw, 17px);
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.1;
}
.tile span { font-family: "JetBrains Mono", monospace; font-size: 10px; opacity: .65; }
.tile--new { animation: pop .16s ease-out; }
.tile--merged { animation: bump .16s ease-out; }

@keyframes pop  { from { transform: translate(var(--tx), var(--ty)) scale(.2); } }
@keyframes bump { 50% { transform: translate(var(--tx), var(--ty)) scale(1.14); } }

.board__over[hidden] { display: none; }   /* author display: wins over the hidden attribute */

.board__over {
  position: absolute;
  inset: 0;
  background: rgba(20, 22, 28, .88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  border: 4px solid #000;
}
.board__over-title { font-family: Unbounded, sans-serif; font-size: 30px; margin: 0; }
.board__over-sub { margin: 0 0 8px; color: #B9BFCC; }

.game__controls { display: none; }

.pad {
  width: 62px; height: 52px;
  background: #23262F;
  color: var(--quartz);
  border: 3px solid #000;
  box-shadow: 4px 4px 0 #000;
  font-size: 18px;
  cursor: pointer;
}
.pad:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 #000; }
.pad-row { display: flex; gap: 10px; }

/* ----------------------------------------------------------------- footer */

.foot { padding: 40px max(20px, 5vw) 56px; }
.foot__row {
  max-width: var(--maxw);
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.foot__brand { font-family: Unbounded, sans-serif; font-weight: 900; font-size: 20px; }
.foot__note { max-width: var(--maxw); margin: 0 auto; color: var(--ink-soft); font-size: 14px; }

/* ------------------------------------------------------------------ toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: var(--quartz);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow-sm);
  padding: 10px 18px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
  z-index: 90;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------ responsive */

@media (max-width: 900px) {
  .hero__grid { grid-template-columns: 1fr; }
  .clouds { display: none; }
  .island-stage { order: -1; --s: 26px; }
  .topnav { display: none; }
  .game__wrap { grid-template-columns: 1fr; }
  .game__controls { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: 22px; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .island-stage { --s: 21px; }
  .step { flex-direction: column; gap: 8px; }
  .step__num { width: auto; }
  .ip-mini__hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .island-bob { animation: none; }
  .vx__in { animation: none; }
  .tile { transition: none; }
  .tile--new, .tile--merged { animation: none; }
}
