/* Dusted Blocks WebGL shell. Mobile-first, full viewport, no scrollbars. */
:root {
  --bg: #FFFFFF;
  --ink: #17120E;
  --ink-2: #6B625A;
  --line: #ECE7E1;
  --accent: #E8481F;
  --accent-ink: #FFFFFF;
  --radius: 18px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: var(--font); -webkit-font-smoothing: antialiased;
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

/* The stage keeps game UI clear of the notch and home indicator. */
#stage {
  position: fixed;
  top: var(--safe-t); right: var(--safe-r); bottom: var(--safe-b); left: var(--safe-l);
  height: calc(100vh - var(--safe-t) - var(--safe-b));
  height: calc(100dvh - var(--safe-t) - var(--safe-b));
}
#unity-canvas {
  display: block; width: 100%; height: 100%;
  background: var(--bg); outline: none;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}

/* Loading screen */
#loader {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 24px calc(24px + var(--safe-b));
  background: var(--bg);
  transition: opacity .45s ease, visibility 0s linear .45s;
}
#loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: -6vh; }
.brand img {
  width: 76px; height: 76px; image-rendering: pixelated; image-rendering: crisp-edges;
  animation: bob 2.4s ease-in-out infinite;
}
.wordmark {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .22em; line-height: 1;
  padding-left: .22em; /* optically re-centre tracked caps */
}
.wordmark span { color: var(--accent); }
.progress { width: min(220px, 60vw); margin-top: 34px; }
.bar { height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.bar-fill {
  height: 100%; width: 0; border-radius: 4px; background: var(--accent);
  transition: width .25s ease-out;
}
.progress-meta {
  display: flex; justify-content: space-between; margin-top: 10px;
  font-size: 12px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.tip {
  position: absolute; left: 24px; right: 24px; bottom: calc(40px + var(--safe-b));
  margin: 0; text-align: center; font-size: 14px; font-weight: 500; color: var(--ink-2);
  transition: opacity .35s ease;
}
.tip b { color: var(--ink); font-weight: 700; }
.tip.out { opacity: 0; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) {
  .brand img { animation: none; }
  #loader, .tip, .bar-fill { transition: none; }
}

/* Error panel (replaces the loader content) */
.error { display: none; max-width: 340px; text-align: center; }
#loader.failed .brand img { animation: none; }
#loader.failed .progress, #loader.failed .tip { display: none; }
#loader.failed .error { display: block; margin-top: 28px; }
.error h2 { margin: 0 0 8px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.error p { margin: 0 0 20px; font-size: 15px; line-height: 1.5; color: var(--ink-2); }
.error code { font-size: 12px; color: var(--ink-2); word-break: break-word; }

/* Buttons shared by the error panel and overlays */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit;
  min-height: 48px; padding: 0 22px; border-radius: 999px;
  font-size: 16px; font-weight: 700; letter-spacing: .01em;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .08s ease, background-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible { outline: 3px solid rgba(232, 72, 31, .35); outline-offset: 2px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #D63E17; }
.btn-ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn-ghost:hover { background: #F7F4F0; }

/* HTML overlays for text input, paste, copy and share fallbacks */
.dw-overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; justify-content: center; align-items: flex-start;
  padding: calc(max(14vh, 24px) + var(--safe-t)) 16px calc(16px + var(--safe-b));
  background: rgba(23, 18, 14, .36);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  animation: dw-fade .16s ease-out;
}
.dw-card {
  width: 100%; max-width: 380px; background: #FFFFFF; border-radius: 22px;
  padding: 22px 20px 20px; box-shadow: 0 24px 60px rgba(23, 18, 14, .22), 0 2px 6px rgba(23, 18, 14, .08);
  animation: dw-rise .2s cubic-bezier(.2, .9, .3, 1.2);
}
.dw-card label, .dw-title { display: block; margin: 0 0 12px; font-size: 16px; font-weight: 700; color: var(--ink); }
.dw-note { margin: -4px 0 14px; font-size: 14px; line-height: 1.45; color: var(--ink-2); }
.dw-field { position: relative; }
.dw-input {
  width: 100%; height: 52px; padding: 0 14px; border-radius: 14px;
  border: 1.5px solid var(--line); background: #FFFFFF; color: var(--ink);
  font: inherit; font-size: 17px; font-weight: 500; /* >=16px stops iOS zoom */
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.dw-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(232, 72, 31, .14); }
.dw-input.code { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.dw-input[readonly] { background: #FAF8F6; font-size: 15px; }
.dw-count { margin-top: 6px; text-align: right; font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.dw-actions { display: flex; gap: 10px; margin-top: 16px; }
.dw-actions .btn { flex: 1; }
@keyframes dw-fade { from { opacity: 0; } }
@keyframes dw-rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .dw-overlay, .dw-card { animation: none; } }

/* Small toast for "Copied" confirmations */
.dw-toast {
  position: fixed; left: 50%; bottom: calc(28px + var(--safe-b)); z-index: 55;
  transform: translate(-50%, 8px); opacity: 0;
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #FFFFFF;
  font-size: 14px; font-weight: 600; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.dw-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .brand img { width: 88px; height: 88px; }
  .wordmark { font-size: 22px; }
}
