/*
 * PB Revive - PBResponsive template styles.
 * Full-window canvas, safe-area aware overlays, no external fonts or images (everything is inline SVG/CSS).
 * Processed by Unity's template preprocessor (.css): no triple braces, no lines starting with hash-if/else/endif.
 */
:root {
  --pb-bg: #0b0f14;
  --pb-fg: #e8edf2;
  --pb-muted: #8b98a5;
  --pb-accent: #f5a524;
  --pb-danger: #e5484d;
  --pb-panel: rgba(12, 17, 23, 0.92);
  --pb-safe-top: env(safe-area-inset-top, 0px);
  --pb-safe-right: env(safe-area-inset-right, 0px);
  --pb-safe-bottom: env(safe-area-inset-bottom, 0px);
  --pb-safe-left: env(safe-area-inset-left, 0px);
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--pb-bg);
  color: var(--pb-fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif;
  /* No pull-to-refresh, rubber banding, text selection or tap highlight anywhere on the page. */
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#pb-root {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  /* dvh follows the visible viewport when mobile browser toolbars collapse/expand. */
  height: 100dvh;
  background: var(--pb-bg);
  overflow: hidden;
}

#unity-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--pb-bg);
  outline: none;
  /* The game owns every touch: no browser panning, pinch zoom or double-tap zoom on the canvas. */
  touch-action: none;
  cursor: default;
}

.pb-hidden { display: none !important; }

.pb-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(24px + var(--pb-safe-top)) calc(24px + var(--pb-safe-right)) calc(24px + var(--pb-safe-bottom)) calc(24px + var(--pb-safe-left));
  box-sizing: border-box;
  text-align: center;
  z-index: 10;
}

/* ---------------------------------------------------------------- loading */

#pb-loading {
  background: radial-gradient(ellipse at 50% 40%, #18222e 0%, var(--pb-bg) 70%);
}

.pb-logo {
  width: min(320px, 70vw);
  height: auto;
}

.pb-progress {
  width: min(420px, 80vw);
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}

.pb-progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #d98a10, var(--pb-accent));
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 0.2s linear;
  will-change: transform;
}

.pb-status {
  min-height: 1.4em;
  font-size: 14px;
  color: var(--pb-muted);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- error */

#pb-error {
  background: var(--pb-panel);
  z-index: 30;
  -webkit-user-select: text;
  user-select: text;
}

#pb-error h1 {
  margin: 0;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 600;
}

#pb-error p {
  margin: 0;
  max-width: 560px;
  line-height: 1.5;
  color: #c3ccd5;
}

.pb-error-icon { width: 64px; height: 64px; }

.pb-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.pb-button {
  appearance: none;
  border: 0;
  border-radius: 6px;
  padding: 11px 22px;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  color: #111;
  background: var(--pb-accent);
  cursor: pointer;
}

.pb-button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.pb-button.pb-secondary { background: rgba(255, 255, 255, 0.12); color: var(--pb-fg); }

#pb-error-details {
  max-width: min(720px, 92vw);
  color: var(--pb-muted);
  font-size: 12px;
}

#pb-error-details pre {
  max-height: 30vh;
  overflow: auto;
  text-align: left;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0, 0, 0, 0.35);
  padding: 10px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- rotate prompt (phones in portrait) */

#pb-rotate {
  background: var(--pb-panel);
  z-index: 20;
  font-size: 18px;
}

#pb-rotate img { animation: pb-rotate-hint 2.4s ease-in-out infinite; }

@keyframes pb-rotate-hint {
  0%, 20% { transform: rotate(0deg); }
  50%, 70% { transform: rotate(-90deg); }
  100% { transform: rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  #pb-rotate img { animation: none; }
  .pb-progress-fill { transition: none; }
}

/* ---------------------------------------------------------------- iPhone "Add to Home Screen" steps */

#pb-homescreen {
  background: rgba(0, 0, 0, 0.55);
  z-index: 22;
}

.pb-homescreen-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 16px 20px;
  box-sizing: border-box;
  border-radius: 10px;
  background: var(--pb-panel);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.pb-homescreen-panel h2 { margin: 0; font-size: 18px; font-weight: 600; }

#pb-homescreen-steps {
  margin: 0;
  padding-left: 1.6em;
  text-align: left;
  font-size: 14px;
  line-height: 1.5;
}

#pb-homescreen-steps li + li { margin-top: 4px; }

/* the Safari share icon drawn inline with the step text */
.pb-share-icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; color: #4ea1ff; }

#pb-homescreen-note { margin: 0; font-size: 12px; color: var(--pb-muted); }

/* ---------------------------------------------------------------- toolbar + banner */

#pb-toolbar {
  position: absolute;
  top: calc(8px + var(--pb-safe-top));
  right: calc(8px + var(--pb-safe-right));
  display: flex;
  gap: 6px;
  z-index: 15;
  pointer-events: none;
}

.pb-icon-button {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 8px;
  color: var(--pb-fg);
  background: rgba(0, 0, 0, 0.35);
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.15s;
}

.pb-icon-button:hover, .pb-icon-button:focus-visible { opacity: 1; }

/* Hide the toolbar in fullscreen: the game owns the screen. Separate rules on purpose - an unknown pseudo-class
   in a selector list would invalidate the whole rule in older engines. */
#pb-root:fullscreen #pb-toolbar { display: none; }
#pb-root:-webkit-full-screen #pb-toolbar { display: none; }

#pb-banner {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--pb-safe-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, 92vw);
  z-index: 25;
  pointer-events: none;
}

.pb-banner-item {
  padding: 10px 14px;
  border-radius: 6px;
  background: rgba(20, 28, 38, 0.94);
  border-left: 3px solid var(--pb-accent);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.pb-banner-warning { border-left-color: #e5b700; }
.pb-banner-error { border-left-color: var(--pb-danger); }

/* Unity diagnostics overlay (development builds, TemplateData/diagnostics.css) sits above the canvas. */
#diagnostics-overlay { z-index: 40; }
