/* Kanto Trails web player. Same language as the in-game UI (KantoFrontend.uss): dark translucent rounded
   cards, warm gold accents, chunky bold type; the backdrop is the concept art's warm haze over forest green. */

:root {
  --ink: #10141c;
  --card: rgba(16, 20, 28, 0.84);
  --gold: rgb(245, 197, 66);
  --gold-deep: rgb(240, 160, 60);
  --line: rgba(255, 255, 255, 0.10);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  font-family: "Nunito", "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-weight: 800;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

/* The canvas stays inside the safe area (notches, rounded corners, home indicator) so the HUD never sits
   under them; the strips outside are the page colour. */
#kanto-stage {
  position: fixed;
  left: var(--safe-l);
  right: var(--safe-r);
  top: var(--safe-t);
  bottom: var(--safe-b);
  background: var(--ink);
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
  background: var(--ink);
}

/* ---------------------------------------------------------------- loader */

#kanto-loader, #kanto-error {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 90% at 78% 8%, rgba(255, 224, 150, 0.85) 0%, rgba(245, 197, 66, 0.35) 28%, rgba(0, 0, 0, 0) 60%),
    radial-gradient(90% 70% at 15% 100%, rgba(30, 70, 40, 0.95) 0%, rgba(0, 0, 0, 0) 70%),
    linear-gradient(170deg, #6f8f46 0%, #3d6533 38%, #1d3a2a 72%, #10141c 100%);
  transition: opacity 0.4s ease;
}

#kanto-error { z-index: 40; background: rgba(16, 20, 28, 0.92); }
#kanto-error[hidden] { display: none; }
#kanto-error h2 { margin: 0 0 8px; font-size: 26px; }
#kanto-error p { margin: 0 0 20px; font-weight: 600; opacity: 0.8; max-width: 440px; word-break: break-word; }

#kanto-loader.kanto-loader--gone { opacity: 0; pointer-events: none; }

.kanto-loader__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(60% 50% at 50% 50%, rgba(255, 236, 180, 0.18), rgba(0, 0, 0, 0) 70%);
  animation: kanto-breathe 4s ease-in-out infinite;
  pointer-events: none;
}

.kanto-loader__card {
  position: relative;
  width: min(440px, calc(100vw - 48px));
  box-sizing: border-box;
  padding: 30px 34px 26px;
  border-radius: 26px;
  background: var(--card);
  border: 2px solid var(--line);
  border-top-color: rgba(245, 197, 66, 0.45);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* Loader (owner 2026-10-29): just the Poké Ball, wobbling, inside a gold progress ring. */
.kanto-loadball {
  position: relative;
  width: 132px;
  height: 132px;
  transition: transform 0.6s ease, opacity 0.6s ease;
}
#kanto-loader.kanto-loader--done .kanto-loadball { transform: scale(1.12); }
#kanto-loader.kanto-loader--gone .kanto-loadball { transform: scale(1.35); opacity: 0; }
#kanto-loader { transition: opacity 0.6s ease; }

.kanto-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.kanto-ring__track { fill: none; stroke: rgba(16, 20, 28, 0.42); stroke-width: 7; }
.kanto-ring__fill {
  fill: none;
  stroke: var(--gold);
  stroke-width: 7;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(245, 197, 66, 0.75));
  transition: stroke-dashoffset 0.3s ease;
}

/* Poké Ball mark, pure CSS */
.kanto-ball {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-radius: 50%;
  background: linear-gradient(to bottom, #e8473c 0 46%, #20242c 46% 54%, #f4f1ea 54% 100%);
  box-shadow: inset -7px -7px 0 rgba(0, 0, 0, 0.18), 0 8px 22px rgba(0, 0, 0, 0.38);
  animation: kanto-wobble 1.6s ease-in-out infinite;
  transform-origin: 50% 85%;
}
.kanto-ball__button {
  position: absolute;
  left: 50%; top: 50%;
  width: 22px; height: 22px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: #f4f1ea;
  border: 4px solid #20242c;
}

.kanto-play {
  display: inline-block;
  min-width: 200px;
  min-height: 60px;
  margin-top: 6px;
  padding: 10px 34px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 22px;
  background: linear-gradient(180deg, #ffd45c, var(--gold-deep));
  color: #2b1a05;
  font: inherit;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(120, 70, 10, 0.6), 0 10px 26px rgba(245, 197, 66, 0.35);
  transition: transform 0.12s ease;
}
.kanto-play[hidden] { display: none; }
.kanto-play:hover { transform: scale(1.03); }
.kanto-play:active { transform: scale(0.97); }
.kanto-play:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

@keyframes kanto-wobble {
  0%, 60%, 100% { transform: rotate(0deg); }
  70% { transform: rotate(-14deg); }
  80% { transform: rotate(12deg); }
  90% { transform: rotate(-6deg); }
}
@keyframes kanto-breathe { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* ---------------------------------------------------------------- fullscreen button (top centre: the HUD owns the corners) */

#kanto-fullscreen {
  position: fixed;
  z-index: 15;
  top: calc(8px + var(--safe-t));
  left: 50%;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(16, 20, 28, 0.55) no-repeat center / 20px 20px
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5'/%3E%3C/svg%3E");
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s ease;
}
#kanto-fullscreen:hover { opacity: 1; }
#kanto-fullscreen[hidden] { display: none; }

/* ---------------------------------------------------------------- rotate prompt (phones in portrait) */

#kanto-rotate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: rgba(16, 20, 28, 0.94);
  text-align: center;
  padding: 24px;
}
.kanto-rotate__text { font-size: 22px; max-width: 260px; }
.kanto-rotate__phone {
  width: 54px;
  height: 92px;
  border: 4px solid var(--gold);
  border-radius: 12px;
  animation: kanto-turn 2.2s ease-in-out infinite;
}
@keyframes kanto-turn {
  0%, 25% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(-90deg); }
}
@media (orientation: portrait) {
  html.kanto-mobile #kanto-rotate { display: flex; }
}

/* ---------------------------------------------------------------- fps overlay (?fps=1) */

#kanto-fps {
  position: fixed;
  z-index: 25;
  left: 50%;
  bottom: calc(4px + var(--safe-b));
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  font: 700 12px ui-monospace, Menlo, monospace;
  pointer-events: none;
  white-space: nowrap;
}
#kanto-fps[hidden] { display: none; }

/* ---------------------------------------------------------------- HTML text entry (KantoWeb.jslib, mobile keyboards) */

#kanto-kb {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: calc(12px + var(--safe-t));
  background: rgba(0, 0, 0, 0.35);
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
}
#kanto-kb.kanto-kb--open { display: flex; }
.kanto-kb__card {
  width: min(560px, calc(100vw - 24px - var(--safe-l) - var(--safe-r)));
  box-sizing: border-box;
  padding: 14px 16px 12px;
  border-radius: 20px;
  background: rgba(16, 20, 28, 0.94);
  border: 2px solid var(--line);
  border-top-color: rgba(245, 197, 66, 0.45);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.5);
}
.kanto-kb__title { font-size: 16px; margin: 0 0 10px 2px; }
.kanto-kb__row { display: flex; gap: 8px; margin: 0; }
.kanto-kb__input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font: 700 18px/1 system-ui, -apple-system, sans-serif; /* >= 16px: iOS doesn't zoom on focus */
  outline: none;
}
.kanto-kb__input:focus { border-color: var(--gold); }
.kanto-kb__ok {
  min-width: 84px;
  height: 52px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffd45c, var(--gold-deep));
  color: #2b1a05;
  font: inherit;
  font-size: 18px;
}
.kanto-kb__cancel {
  margin-top: 8px;
  padding: 6px 4px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.65);
  font: inherit;
  font-size: 15px;
}

/* Loading % and rotating tips under the ball (owner 2026-10-29). */
#kanto-loader { flex-direction: column; gap: 14px; padding: 0 24px; text-align: center; }
.kanto-loader__pct {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  font-variant-numeric: tabular-nums;
}
.kanto-loader__tip {
  /* Fixed-width box and no text-shadow: iOS Safari left stale glyphs of the previous (longer) tip behind when the
     text changed during the fade, because the shadow painted outside the box it repaints. */
  box-sizing: border-box;
  width: min(560px, 88vw);
  min-height: 2.9em;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 14px;
  background: rgba(10, 14, 20, 0.42);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  overflow: hidden;
  will-change: opacity;
  transform: translateZ(0);
  transition: opacity 0.35s ease;
}
.kanto-loader__tip--out { opacity: 0; }
#kanto-loader.kanto-loader--gone .kanto-loader__pct,
#kanto-loader.kanto-loader--gone .kanto-loader__tip { opacity: 0; }
@media (max-height: 420px) {
  .kanto-loader__tip { font-size: 14px; }
  .kanto-loader__pct { font-size: 17px; margin-top: 2px; }
}
