/* --------------------------------------------------------------------
   WebCraft - page chrome.

   The game draws its own interface inside the canvas, so this file only
   styles the page shell: the canvas fill, the loading screen and the
   fatal-error panel.
   ------------------------------------------------------------------ */

:root {
  --ink: #e8e8e8;
  --dim: #9aa0a6;
  --accent: #7ec850;
  --panel: rgba(12, 14, 18, 0.92);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0a0d12;
  color: var(--ink);
  font-family: ui-monospace, "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  /* The canvas handles all interaction; stop the page from fighting it. */
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  /* Nearest-neighbour upscaling keeps the pixel art crisp. */
  image-rendering: pixelated;
  cursor: default;
  outline: none;
}

/* F11 fullscreens the document element; make sure the canvas really fills
   the screen even if a browser gives the fullscreen root its own sizing. */
:fullscreen #game,
:-webkit-full-screen #game {
  width: 100vw;
  height: 100vh;
}

:fullscreen,
:-webkit-full-screen {
  background: #0a0d12;
}

/* ---------------- loading screen ---------------- */

#loading {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1200px 700px at 50% 12%, #1d2a3a 0%, #0a0d12 70%),
    #0a0d12;
  z-index: 20;
  transition: opacity 0.32s ease;
}

#loading.done { opacity: 0; pointer-events: none; }

#loading .panel {
  width: min(560px, 88vw);
  padding: 30px 28px 24px;
  text-align: center;
  background: var(--panel);
  border: 1px solid #2a3140;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

#loading h1 {
  margin: 0;
  font-size: 40px;
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 3px 0 #2f5220;
}

#loading .sub {
  margin: 4px 0 22px;
  color: var(--dim);
  font-size: 13px;
}

.bar-track {
  height: 10px;
  background: #1b2130;
  border: 1px solid #2c3446;
  border-radius: 5px;
  overflow: hidden;
}

#loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4f9e2f, var(--accent));
  transition: width 0.2s ease;
}

#loading-label {
  margin: 10px 0 18px;
  font-size: 12px;
  color: var(--dim);
  min-height: 1em;
}

#loading .tip {
  margin: 0;
  font-size: 11px;
  line-height: 1.9;
  color: #8b93a1;
}

#loading .tip b { color: #cfd6e0; }

/* ---------------- error panel ---------------- */

#error {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  padding: 8vh 6vw;
  background: #14090b;
  overflow: auto;
}

#error h1 {
  margin: 0 0 12px;
  font-size: 26px;
  color: #ff8a7a;
}

#error .msg { font-size: 15px; color: #ffd9d3; }
#error .hint { font-size: 13px; color: var(--dim); }

#error .stack {
  margin-top: 16px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: #c9b7b4;
  background: #1e0d10;
  border: 1px solid #3a1c20;
  border-radius: 6px;
  white-space: pre-wrap;
}

.noscript {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  background: #0a0d12;
  color: var(--ink);
  z-index: 40;
}
