:root {
  --bg: #0d0d12;
  --accent: #eda3c4;
  --text-dim: rgba(255, 255, 255, 0.35);
  --error: #ffb3b3;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Godot's virtual-keyboard <input>: iOS Safari won't focus or type into an
   input that inherits user-select: none from body. */
input,
textarea {
  user-select: text;
  -webkit-user-select: text;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}
canvas:focus {
  outline: none;
}

#ident {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg);
  transition:
    opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.8s;
}

#ident.done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

#ident-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transition: opacity 3.7s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  background: #000;
}

#ident-video.ready {
  opacity: 1;
}

#loader-icon {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 210;
  width: 32px;
  height: 32px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    scale 0.5s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.5s;
}

#loader-icon.active {
  opacity: 1;
  visibility: visible;
}

#loader-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  animation:
    loader-pulse 5s ease-in-out infinite,
    loader-wiggle 10s ease-in-out infinite;
}

@keyframes loader-pulse {
  0%,
  100% {
    opacity: 0.3;
    scale: 0.6;
  }
  50% {
    opacity: 0.6;
    scale: 0.85;
  }
}

@keyframes loader-wiggle {
  0%,
  66.6% {
    transform: rotate(0deg);
  }
  68.6% {
    transform: rotate(-5deg);
  }
  70.6% {
    transform: rotate(5deg);
  }
  72.6% {
    transform: rotate(-3deg);
  }
  74.6% {
    transform: rotate(3deg);
  }
  76.6% {
    transform: rotate(-1deg);
  }
  78.6%,
  100% {
    transform: rotate(0deg);
  }
}

#black-hold {
  position: fixed;
  inset: 0;
  z-index: 240;
  background: var(--bg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.6s;
}

#black-hold.active {
  opacity: 1;
  visibility: visible;
}

#black-hold.fade-out {
  opacity: 0;
  visibility: hidden;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

#loading.active {
  display: flex;
}

/* "Loading world": the page rises toward the title's green. --lvl (0..1) is
   set from the load time and progress and eased by the transition; --pulse
   breathes on its own. Both are registered so they animate smoothly. */
@property --lvl {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

@property --pulse {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

#loading {
  overflow: hidden;
  transition: --lvl 0.8s linear;
}

#loading.world {
  background-color: color-mix(
    in oklab,
    var(--bg),
    #548c6c calc(var(--lvl) * 100%)
  );
  animation: world-pulse 4.5s ease-in-out infinite alternate;
}

@keyframes world-pulse {
  from {
    --pulse: 0;
  }
  to {
    --pulse: 1;
  }
}

/* The lighter green on top, breathing a little. */
#loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, #548c6c, #83be9c);
  opacity: 0;
  pointer-events: none;
}

#loading.world::before {
  opacity: calc(var(--lvl) * (0.65 + 0.35 * var(--pulse)));
}

/* The game's own vignette stays over it. */
#loading::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background: radial-gradient(
    ellipse 75% 80% at 50% 50%,
    transparent 30%,
    rgba(8, 10, 20, 0.8) 100%
  );
  opacity: 0;
}

#loading.world::after {
  opacity: 1;
}

#loading-logo {
  display: none;
  position: relative;
  z-index: 1;
  width: 864px; /* set by shell.js: whole multiples of the art's 432px */
  max-width: none;
  image-rendering: pixelated;
  margin-bottom: 8px;
}

#loading.world #loading-logo {
  display: block;
  animation: logo-in 2s ease-out both;
}

@keyframes logo-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

#loading.world #loading-bar-track {
  display: none;
}

#loading.world #loading-text {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.7);
}

#loading-bar-track {
  display: none;
}

#loading.world #loading-text {
  position: relative;
  color: rgba(255, 255, 255, 0.7);
}

#loading-bar-track {
  width: min(280px, 60vw);
  height: 3px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}

#loading-bar-track::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(237, 163, 196, 0.12),
    transparent
  );
  transform: translateX(-100%);
  animation: track-sweep 2s ease-in-out infinite;
}

#loading-bar {
  width: 0%;
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 10px var(--accent);
  transition: width 0.2s ease-out;
  position: relative;
  overflow: hidden;
}

#loading-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.35),
    transparent
  );
  transform: translateX(-100%);
  animation: bar-shimmer 1.2s ease-in-out infinite;
}

/* The page says nothing while it loads: the notice speaks if there's
   something to say. (shell.js still sets it; it stays for screen readers.) */
#loading-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  margin-top: 14px;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: text-pulse 2.4s ease-in-out infinite;
}

/* ── Play nav: peek & hover-reveal ── */
#play-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 400;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: rgba(13, 13, 18, 0.85);
  backdrop-filter: blur(10px);
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  transform: translateY(-100%);
  visibility: hidden;
  transition:
    transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.35s;
}

#play-nav.visible {
  visibility: visible;
  transform: translateY(calc(-100% + 0.25rem));
}

#play-nav.visible:hover,
#play-nav.visible:focus-within {
  transform: translateY(0);
}

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

.nav-brand:hover {
  color: var(--accent);
}

.nav-brand svg {
  display: block;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.nav-brand-text {
  display: none;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: #fff;
}

@media (min-width: 768px) {
  .nav-brand-text {
    display: inline;
  }
}

.nav-actions button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.6);
  padding: 6px 14px;
  margin-inline-start: 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.nav-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#play-menu {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  background: rgba(13, 13, 18, 0.96);
  backdrop-filter: blur(16px);
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

#play-menu.visible {
  display: flex;
}

.play-menu-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  text-align: center;
  cursor: default;
}

.play-menu-content a,
.play-menu-content button {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 18px;
  font-weight: 300;
  color: #fff;
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  letter-spacing: 0.02em;
}

.play-menu-content a:hover,
.play-menu-content button:hover {
  color: var(--accent);
}

#breakout {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--bg);
}

#breakout.visible {
  display: flex;
}

#breakout-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.35;
  filter: grayscale(0.7);
  pointer-events: none;
  background: #000;
}

.breakout-content {
  position: relative;
  z-index: 2;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  padding: 20px;
}

.breakout-title {
  font-family: system-ui, sans-serif;
  font-size: clamp(1.2rem, 4vw, 1.8rem);
  font-weight: 300;
  color: #fff;
  letter-spacing: 0.04em;
}

.breakout-sub {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.4);
  max-width: 320px;
  line-height: 1.5;
}

.breakout-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.breakout-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-family: system-ui, sans-serif;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: all 0.2s;
}

.breakout-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── The notice: the game's NoticeBubble on the page ──
   A stone pill, ( [avi] words ): @cozysky.quest's character popping out of
   its squircle (its own backdrop colour, rendered from the game's
   SquircleAvatar) at the leading end, telling you how the start is going.
   The pill boops up from small and the avi pops a beat later with a wobble;
   new words punch it; it slides down and fades when the game takes over. */
/* Both cut to exactly the characters the notice's words use (cozysky's
   `just shell-fonts`): Handjet, the game's face, and GNU Unifont, a pixel
   face, for the account's kaomoji. */
@font-face {
  font-family: "Handjet";
  src: url("handjet.woff2") format("woff2");
  font-display: swap;
}
@font-face {
  font-family: "Kaomoji";
  src: url("kaomoji.woff2") format("woff2");
  font-display: swap;
}

#shell-error {
  display: none;
  position: absolute;
  bottom: 8%;
  left: 50%;
  width: min(440px, 92vw);
  transform: translateX(-50%);
  z-index: 300;
  --ink: #2b232e; /* the stone's ink */
  --amber: #d18014;
}

#shell-error.show {
  display: block;
}

#shell-error .notice {
  display: flex;
  align-items: flex-start; /* the avi level with the first line, as in the game */
  gap: 12px;
  padding-block: 4px;
  padding-inline: 2px 12px;
  /* The HUD's stone chip, nine-sliced, its pixels kept. */
  border: 10px solid transparent;
  border-image-source: url("stone-chip.png");
  border-image-slice: 22 24 fill;
  border-image-width: 22px 24px;
  border-image-repeat: stretch;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(8, 10, 20, 0.35));
  color: var(--ink);
  font-family: "Handjet", "Kaomoji", system-ui, sans-serif;
  text-align: start;
  transform-origin: 48px 50%;
}

#shell-error.show .notice {
  animation: notice-in 0.34s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

#shell-error.bump .notice {
  animation: notice-bump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#shell-error.leave .notice {
  animation: notice-out 0.22s ease-in both;
}

#shell-error .notice-avi {
  flex: none;
  width: 90px; /* half the art: 3 screen px to each of the character's */
  height: 90px;
  margin-block: -40px -6px; /* the head pokes up over the pill's edge */
  image-rendering: pixelated;
  pointer-events: none;
}

#shell-error.show .notice-avi {
  animation: avi-in 0.5s 0.08s cubic-bezier(0.34, 1.9, 0.5, 1) both;
}

#shell-error.bump .notice-avi {
  animation: avi-bump 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#shell-error .notice-text {
  flex: 1;
  min-width: 0;
}

#shell-error .shell-error-title {
  font-size: 26px;
  line-height: 1.05;
}

#shell-error .shell-error-body:empty {
  display: none;
}

#shell-error .shell-error-body {
  margin-top: 2px;
  font-size: 19px;
  line-height: 1.15;
  opacity: 0.75;
}

#shell-error .shell-error-bar {
  height: 4px;
  margin-top: 8px;
  border-radius: 2px;
  background: rgba(43, 35, 46, 0.14);
  overflow: hidden;
}

#shell-error .shell-error-bar i {
  display: block;
  width: 35%;
  height: 100%;
  border-radius: 2px;
  background: var(--amber);
  animation: bar-indeterminate 1.6s ease-in-out infinite;
}

@keyframes bar-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(290%);
  }
}

@keyframes notice-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.55);
  }
  40% {
    opacity: 1;
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes notice-bump {
  40% {
    transform: scale(1.05);
  }
}

@keyframes notice-out {
  to {
    opacity: 0;
    transform: translateY(24px) scale(0.92);
  }
}

@keyframes avi-in {
  from {
    transform: scale(0) rotate(-28deg);
  }
  to {
    transform: none;
  }
}

@keyframes avi-bump {
  40% {
    transform: scale(1.18) rotate(10deg);
  }
}

#shell-error .shell-error-actions {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin-top: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  transition:
    max-height 0.6s ease,
    opacity 0.6s ease,
    margin-top 0.6s ease;
}

#shell-error .shell-error-actions.open {
  max-height: 10rem;
  opacity: 1;
  margin-top: 8px;
}

/* Small soft pills, as on the game's cards. */
#shell-error .breakout-btn {
  padding: 3px 12px;
  border: none;
  border-radius: 999px;
  background: rgba(43, 35, 46, 0.12);
  color: var(--ink);
  font-family: "Handjet", "Kaomoji", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: normal;
  text-transform: none;
  text-decoration: none;
  cursor: pointer;
}

#shell-error .breakout-btn:hover {
  background: rgba(43, 35, 46, 0.24);
}

@keyframes bar-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
@keyframes track-sweep {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}
@keyframes text-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 0.8;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── The milestone trail ── */
#trail {
  position: absolute;
  inset-inline-start: 16px;
  bottom: 14px;
  max-width: 70vw;
  pointer-events: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.8);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}
#trail div {
  white-space: nowrap;
  animation: trail-in 0.5s ease-out;
}
@keyframes trail-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  #trail div {
    animation: none;
  }
}
