/* AllBlobs — one stylesheet, no build step.
 *
 * The dice are CSS, not images or a canvas. Three reasons: they have to be on
 * screen before anything else has loaded (a die drawn by a script that has not
 * downloaded yet is not a loading indicator), they have to keep tumbling while
 * the main thread is busy building a Construct 2 runtime, and a canvas
 * animation running behind an idle page costs battery on exactly the phones
 * this game is played on. A compositor-only transform costs close to nothing.
 */

:root {
  --ink: #0d0a16;
  --ink-soft: #171130;
  --paper: #f4f1ff;
  --muted: #a79fc8;
  --line: #2b2350;
  --blob: #7cf29b;
  --blob-deep: #34c56d;
  --hot: #ff5fa2;
  --gold: #ffd166;
  --die-size: 72px;
  --radius: 18px;
  --shell: min(1100px, 100% - 2.5rem);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink);
  color: var(--paper);
  font: 16px/1.6 "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

body { min-height: 100vh; overflow-x: hidden; }

a { color: var(--blob); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5em; }
h1 { font-size: clamp(2.4rem, 7vw, 4rem); letter-spacing: -.02em; }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }

.shell { width: var(--shell); margin-inline: auto; }

/* ---------------------------------------------------------------- dice --- */

/* A die is a real cube: six faces, translated out from a shared centre. A
 * sprite sheet or a flipbook would be cheaper still, but a cube tumbles
 * convincingly from any angle, and "any angle" is what makes a background of
 * forty of them not look like forty copies of one animation. */
.die {
  position: relative;
  width: var(--die-size);
  height: var(--die-size);
  transform-style: preserve-3d;
  /* Perspective belongs on each die, not on the container. A shared vanishing
   * point means only the die in the middle of a row faces the viewer squarely
   * and the ones at the ends are read at an angle — which on a row of five
   * dice that spell out a seed makes the numbers genuinely hard to count. */
  perspective: 520px;
  animation: tumble 3.6s infinite cubic-bezier(.6, .05, .4, .95);
  will-change: transform;
}

.die--slow { animation-duration: 9s; animation-timing-function: linear; }
.die--rolling { animation-duration: 1.1s; animation-timing-function: linear; }
.die--still { animation: none; transform: rotateX(-24deg) rotateY(32deg); }

.die__face {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template: repeat(3, 1fr) / repeat(3, 1fr);
  padding: 12%;
  border-radius: 22%;
  background: linear-gradient(150deg, #fffdf6, #e6dfff);
  border: 1px solid rgba(13, 10, 22, .18);
  box-shadow: inset 0 0 12px rgba(90, 70, 160, .25);
  backface-visibility: hidden;
}

.die__pip {
  align-self: center;
  justify-self: center;
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #4a3d7a, #17102e 70%);
}

/* The six faces of a d6. Half the size as the translation distance puts each
 * face flush with the cube surface for any --die-size. */
.die__face--1 { transform: rotateY(0deg) translateZ(calc(var(--die-size) / 2)); }
.die__face--6 { transform: rotateY(180deg) translateZ(calc(var(--die-size) / 2)); }
.die__face--2 { transform: rotateY(90deg) translateZ(calc(var(--die-size) / 2)); }
.die__face--5 { transform: rotateY(-90deg) translateZ(calc(var(--die-size) / 2)); }
.die__face--3 { transform: rotateX(90deg) translateZ(calc(var(--die-size) / 2)); }
.die__face--4 { transform: rotateX(-90deg) translateZ(calc(var(--die-size) / 2)); }

@keyframes tumble {
  0%   { transform: rotateX(0deg)   rotateY(0deg)   rotateZ(0deg); }
  100% { transform: rotateX(360deg) rotateY(720deg) rotateZ(360deg); }
}

/* A die that has stopped on a face. The rotations are the inverse of each
 * face's own transform, so face N ends up pointing at the viewer. */
.die[data-show="1"] { animation: none; transform: rotateX(-8deg); }
.die[data-show="2"] { animation: none; transform: rotateX(-8deg) rotateY(-90deg); }
/* Face 3 sits on the top of the cube (rotateX(90deg) puts it there), so the
 * cube turns the other way to bring it forward. Getting these two backwards
 * shows the wrong number, which on a site where the dice *are* the seed is a
 * lie rather than a cosmetic bug. */
.die[data-show="3"] { animation: none; transform: rotateX(-90deg) rotateZ(8deg); }
.die[data-show="4"] { animation: none; transform: rotateX(90deg) rotateZ(-8deg); }
.die[data-show="5"] { animation: none; transform: rotateX(-8deg) rotateY(90deg); }
.die[data-show="6"] { animation: none; transform: rotateX(-8deg) rotateY(180deg); }

.dice-row { display: flex; gap: .9rem; flex-wrap: wrap; }
.dice-row .die { --die-size: 46px; transition: transform .45s ease; }

/* ------------------------------------------------------- background field */

#dice-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  perspective: 900px;
  background:
    radial-gradient(1100px 700px at 78% -10%, #241a4d 0%, transparent 60%),
    radial-gradient(900px 600px at 8% 100%, #10314a 0%, transparent 55%),
    var(--ink);
}

.field-die {
  position: absolute;
  opacity: .13;
  animation: drift linear infinite;
  will-change: transform;
}

@keyframes drift {
  from { transform: translate3d(0, 12vh, 0); }
  to   { transform: translate3d(0, -112vh, 0); }
}

/* Motion here is decoration with no informational content, so it goes away
 * entirely rather than being slowed down. The dice stay — they are the site's
 * furniture — they just stop moving. */
@media (prefers-reduced-motion: reduce) {
  .die, .field-die { animation: none !important; }
  .die { transform: rotateX(-24deg) rotateY(32deg); }
  .field-die { opacity: .09; }
}

/* --------------------------------------------------------------- layout --- */

.page { position: relative; z-index: 1; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1rem 0;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: .02em;
  text-decoration: none;
  color: var(--paper);
  display: flex;
  align-items: center;
  gap: .55rem;
}

.brand .die { --die-size: 26px; }
.brand__perspective { perspective: 300px; display: flex; }

.topbar nav { margin-left: auto; display: flex; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; font-weight: 600; }
.topbar nav a:hover, .topbar nav a[aria-current="page"] { color: var(--paper); }

.hero { padding: 3rem 0 1rem; display: grid; gap: 1.4rem; }
.hero p.lede { font-size: clamp(1.05rem, 2.4vw, 1.3rem); color: var(--muted); max-width: 56ch; margin: 0; }

.card {
  background: color-mix(in srgb, var(--ink-soft) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  backdrop-filter: blur(6px);
}

.grid-2 { display: grid; gap: 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1.05fr .95fr; } }

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

.btn {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: .85rem 1.6rem;
  cursor: pointer;
  background: linear-gradient(160deg, var(--blob), var(--blob-deep));
  color: #06210f;
  box-shadow: 0 8px 0 -2px rgba(0, 0, 0, .35);
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--ghost { background: transparent; color: var(--paper); border: 1px solid var(--line); box-shadow: none; }
.btn--hot { background: linear-gradient(160deg, var(--hot), #c62d70); color: #2a0013; }

.btn-row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }

input[type="text"] {
  font: inherit;
  width: 100%;
  padding: .75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #0b0818;
  color: var(--paper);
}
input[type="text"]:focus { outline: 2px solid var(--blob); outline-offset: 1px; }

label { display: block; font-weight: 700; margin-bottom: .4rem; }
.hint { color: var(--muted); font-size: .9rem; }

/* ----------------------------------------------------------------- forge --- */

.forge__stage {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 1px dashed var(--line);
  background: repeating-conic-gradient(#120e24 0% 25%, #171130 0% 50%) 50% / 26px 26px;
  perspective: 700px;
  overflow: hidden;
}

.forge__stage img { width: 100%; height: 100%; object-fit: contain; display: block; }

.forge__status { min-height: 1.6em; color: var(--muted); }
.forge__status[data-state="error"] { color: var(--hot); }
.forge__status[data-state="done"] { color: var(--blob); }

.traits { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .35rem; }
.traits li { display: flex; gap: .6rem; align-items: baseline; }
.traits b { color: var(--muted); font-weight: 700; min-width: 5.5rem; text-transform: uppercase; font-size: .72rem; letter-spacing: .08em; }

.seed-tag {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  background: #0b0818;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .1rem .5rem;
}

/* ------------------------------------------------------------ collection --- */

.collection {
  list-style: none;
  padding: 0;
  margin: 1.2rem 0 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}

.collection li {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: .7rem;
  background: #100c22;
  text-align: center;
}
.collection img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.collection .name { font-weight: 700; font-size: .9rem; }
.collection .seed-tag { font-size: .75rem; }
.collection li[data-equipped="true"] { border-color: var(--blob); box-shadow: 0 0 0 1px var(--blob); }

/* ------------------------------------------------------------------ boot --- */

/* The first thing painted, and it is painted by CSS alone so it is on screen
 * before any script has parsed. It hides itself once the page says so; if a
 * script never runs, the noscript rule below still gets the player out. */
#boot {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  gap: 1.4rem;
  align-content: center;
  background: var(--ink);
  perspective: 800px;
  transition: opacity .5s ease, visibility .5s ease;
}
#boot .die { --die-size: 96px; }
#boot p { color: var(--muted); letter-spacing: .3em; text-transform: uppercase; font-size: .8rem; margin: 0; }
#boot[hidden] { display: none; }
body[data-booted="true"] #boot { opacity: 0; visibility: hidden; pointer-events: none; }

/* --------------------------------------------------------------- gamepage --- */

body.playing { overflow: hidden; background: #000; }
body.playing #dice-field { opacity: .55; }

#c2canvasdiv { position: relative; z-index: 1; }
#c2canvas { touch-action: none; -ms-touch-action: none; display: block; margin: 0 auto; }

/* Site chrome over the canvas. The canvas is sized by the Construct runtime
 * against the window, so the chrome floats above it instead of sharing a flow
 * with it — a layout that reserved space would fight cr_sizeCanvas on every
 * resize and lose. */
.game-chrome {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .5rem .8rem;
  background: linear-gradient(#0d0a16e6, #0d0a1600);
  pointer-events: none;
}
.game-chrome > * { pointer-events: auto; }
.game-chrome .btn { padding: .45rem 1rem; font-size: .85rem; }

.hud-blob {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--blob);
  background: #100c22;
  object-fit: contain;
  padding: 2px;
}

/* The ad's close button renders top-right on both interstitial and rewarded
 * formats. Nothing the player taps deliberately may live there — an accidental
 * click on an ad is the single most common reason a game site loses its
 * AdSense account. This is the reservation, in CSS, so it survives a later
 * layout change. */
.ad-safe-zone {
  position: fixed;
  top: 0; right: 0;
  width: 120px; height: 120px;
  z-index: 9;
  pointer-events: none;
}

footer.site {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  padding: 2rem 0 3rem;
  color: var(--muted);
  font-size: .9rem;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
