/* Balde Runner web shell: a portrait stage (full screen on phones, a centred 9:16 column elsewhere) and the
   loading screen. Colours follow the game palette: ink #1a1c2c, paper #f4f4f4, balde red #e04f4f,
   water #41a6f6, sky #8ccbf0. No web fonts are downloaded; the display stack falls back to system bold. */

:root {
  --ink: #1a1c2c;
  --ink-2: #2e3150;
  --paper: #f4f4f4;
  --red: #e04f4f;
  --red-d: #b23443;
  --red-l: #f58a8a;
  --water: #41a6f6;
  --water-l: #a8eefc;
  --sky: #8ccbf0;
  --sky-d: #3b7ddb;
  --sun: #ffcd75;
  --display: "Lilita One", "Arial Rounded MT Bold", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --text: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(65, 166, 246, 0.16) 0%, rgba(26, 28, 44, 0) 60%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 22px),
    var(--ink);
  touch-action: manipulation;
  font-family: var(--text);
  color: var(--paper);
}

#balde-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--sky);
  flex: 0 0 auto;
}

body.balde-column #balde-stage {
  box-shadow: 0 0 0 4px var(--ink), 0 0 0 7px rgba(255, 255, 255, 0.06), 0 30px 80px rgba(0, 0, 0, 0.55);
}

#unity-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  background: var(--sky);
}

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

#balde-loader {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 3vh) 28px calc(env(safe-area-inset-bottom, 0px) + 22px);
  background:
    radial-gradient(ellipse at 50% 108%, rgba(65, 166, 246, 0.75) 0%, rgba(65, 166, 246, 0) 55%),
    linear-gradient(180deg, #8ccbf0 0%, #5fa9e6 46%, #3b5dc9 100%);
  overflow: hidden;
  transition: opacity 0.42s ease, visibility 0.42s;
}

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

#balde-loader .rain {
  position: absolute;
  inset: -40px;
  background-image:
    repeating-linear-gradient(103deg, rgba(255, 255, 255, 0.0) 0 14px, rgba(255, 255, 255, 0.28) 14px 15px, rgba(255, 255, 255, 0) 15px 46px),
    repeating-linear-gradient(98deg, rgba(255, 255, 255, 0.0) 0 31px, rgba(255, 255, 255, 0.18) 31px 32px, rgba(255, 255, 255, 0) 32px 73px);
  background-size: 100% 120px, 100% 90px;
  animation: rain 0.55s linear infinite;
  pointer-events: none;
  opacity: 0.75;
}

@keyframes rain {
  from { background-position: 0 0, 0 0; }
  to { background-position: -26px 120px, -12px 90px; }
}

.brand {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 4vh;
  width: 100%;
  max-width: 420px;
}

.bucket {
  width: min(44vw, 30vh, 210px);
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 7px 0 var(--ink));
  animation: bob 2.6s ease-in-out infinite;
}

.bucket .handle { fill: none; stroke: var(--ink); stroke-width: 9; stroke-linecap: round; }
.bucket .body { fill: var(--red); stroke: var(--ink); stroke-width: 8; stroke-linejoin: round; }
.bucket .shade { fill: var(--red-d); opacity: 0.55; }
.bucket .band { fill: var(--red-d); opacity: 0.35; }
.bucket .shine { fill: rgba(255, 255, 255, 0.5); }
.bucket .mouth { fill: #7d2231; }
.bucket .water { fill: var(--water); }
.bucket .water-top { fill: var(--water-l); opacity: 0.85; }
.bucket .rim { fill: none; stroke: var(--ink); stroke-width: 8; }
.bucket .drop path { fill: var(--water-l); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.bucket .drop { animation: drop 1.3s cubic-bezier(0.5, 0, 0.9, 0.6) infinite; }

@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
@keyframes drop {
  0% { transform: translateY(-40px); opacity: 0; }
  20% { opacity: 1; }
  78% { transform: translateY(34px); opacity: 1; }
  100% { transform: translateY(44px); opacity: 0; }
}

.logo {
  margin: 14px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--display);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.logo-a {
  font-size: min(19vw, 11.5vh, 92px);
  color: var(--paper);
  -webkit-text-stroke: 0.09em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0.07em 0 var(--ink);
}

.logo-b {
  margin-top: 0.12em;
  padding: 0.12em 0.55em 0.08em;
  font-size: min(8.4vw, 5.2vh, 40px);
  letter-spacing: 0.16em;
  color: var(--paper);
  background: var(--red);
  border: 4px solid var(--ink);
  border-bottom-width: 8px;
  border-radius: 12px;
  transform: rotate(-3deg);
  -webkit-text-stroke: 0.06em var(--ink);
  paint-order: stroke fill;
}

.tagline {
  margin: 18px 0 0;
  max-width: 300px;
  padding: 8px 14px;
  font-family: var(--display);
  font-weight: 800;
  font-size: min(4.6vw, 2.7vh, 19px);
  line-height: 1.25;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-bottom-width: 6px;
  border-radius: 14px;
  transform: rotate(1.5deg);
}

.progress {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin-top: auto;
  margin-bottom: 18px;
}

.progress[hidden] { display: none; }

.bar {
  height: 30px;
  padding: 3px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-bottom-width: 8px;
  border-radius: 999px;
  overflow: hidden;
}

.fill {
  width: 0;
  height: 100%;
  min-width: 18px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38) 0 34%, rgba(255, 255, 255, 0) 34%),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0) 0 9px, rgba(0, 0, 0, 0.09) 9px 18px),
    var(--red);
  box-shadow: inset 0 -3px 0 var(--red-d);
  transition: width 0.3s ease-out;
}

.status {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  white-space: nowrap;
  margin-top: 10px;
  padding: 0 6px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.04em;
  color: var(--paper);
  text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink);
}

.error {
  position: relative;
  width: 100%;
  max-width: 340px;
  margin-top: auto;
  margin-bottom: 14px;
  padding: 16px 18px 18px;
  text-align: center;
  color: var(--ink);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-bottom-width: 9px;
  border-radius: 20px;
}

.error[hidden] { display: none; }
.error-title { margin: 0 0 6px; font-family: var(--display); font-weight: 900; font-size: 24px; color: var(--red-d); }
.error-text { margin: 0 0 14px; font-size: 15px; line-height: 1.4; }

.retry {
  font-family: var(--display);
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: var(--paper);
  background: var(--red);
  border: 4px solid var(--ink);
  border-bottom-width: 8px;
  border-radius: 16px;
  padding: 10px 26px 8px;
  cursor: pointer;
}

.retry:active { transform: translateY(3px); border-bottom-width: 5px; }
.retry:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; }

.notice {
  position: relative;
  margin: 0;
  max-width: 330px;
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  color: rgba(244, 244, 244, 0.86);
  text-shadow: 0 1px 0 rgba(26, 28, 44, 0.6);
}

#balde-loader.failed .bucket { animation: none; }
#balde-loader.failed .bucket .drop { animation: none; opacity: 0; }

.status span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

#diagnostics-icon { position: absolute; right: 8px; bottom: 8px; z-index: 20; cursor: pointer; }

@media (max-height: 560px) {
  .tagline { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #balde-loader .rain,
  .bucket { animation: none; }
  .bucket .drop { animation: none; opacity: 0; }
  .fill, #balde-loader { transition: none; }
}

.notice a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.notice a:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; border-radius: 2px; }

/* ---- text pages (privacy.html): same palette, normal scrolling page ---------------------------------- */

html.doc, html.doc body { height: auto; min-height: 100%; overflow: auto; overscroll-behavior: auto; }

html.doc body {
  display: block;
  padding: calc(env(safe-area-inset-top, 0px) + 20px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px);
  background: linear-gradient(180deg, #8ccbf0 0%, #5fa9e6 46%, #3b5dc9 100%) fixed;
  color: var(--ink);
}

.doc-card {
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 22px 26px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-bottom-width: 9px;
  border-radius: 20px;
  line-height: 1.55;
  font-size: 16px;
}

.doc-card h1 { margin: 0 0 4px; font-family: var(--display); font-weight: 900; font-size: 34px; line-height: 1.05; color: var(--red-d); }
.doc-card h2 { margin: 26px 0 6px; font-family: var(--display); font-weight: 800; font-size: 21px; line-height: 1.2; }
.doc-card p, .doc-card ul { margin: 8px 0; }
.doc-card ul { padding-left: 22px; }
.doc-card li { margin: 4px 0; }
.doc-card .meta { margin: 0 0 14px; font-size: 14px; opacity: 0.7; }
.doc-card a { color: var(--sky-d); text-underline-offset: 2px; }
.doc-card a:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; border-radius: 2px; }
.doc-card .back { display: inline-block; margin-bottom: 14px; font-family: var(--display); font-weight: 800; }
.doc-card table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 15px; }
.doc-card th, .doc-card td { padding: 7px 8px; text-align: left; vertical-align: top; border-bottom: 2px solid rgba(26, 28, 44, 0.14); }
.doc-card th { font-family: var(--display); font-weight: 800; font-size: 14px; letter-spacing: 0.03em; }
.doc-card code { font-size: 0.92em; padding: 1px 4px; background: rgba(26, 28, 44, 0.08); border-radius: 4px; }
.doc-card .parody { margin-top: 24px; padding: 12px 14px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; font-size: 14px; }

@media (max-width: 520px) {
  .doc-card { padding: 18px 16px 22px; font-size: 15.5px; }
  .doc-card h1 { font-size: 29px; }
  .doc-card table, .doc-card tbody, .doc-card tr, .doc-card td, .doc-card th { display: block; width: 100%; }
  .doc-card thead { display: none; }
  .doc-card td { border-bottom: 0; padding: 2px 0; }
  .doc-card tr { padding: 8px 0; border-bottom: 2px solid rgba(26, 28, 44, 0.14); }
  .doc-card td:first-child { font-weight: 700; }
}
