/* Agent Arena host page: full-bleed canvas + Roman loading screen (CSS only, plus the HUD medallion and Cinzel). */

@font-face {
  font-family: 'Cinzel';
  src: url('fonts/Cinzel.ttf') format('truetype');
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --ink: #f6e8c8;
  --ink-dim: rgba(236, 218, 180, 0.72);
  --gold: #e8ba5c;
  --gold-hi: #ffe296;
  --gold-lo: #784e1e;
  --crimson: #8e1b1b;
  --crimson-hi: #ce3028;
  --night: #0a0604;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: 'Cinzel', 'Trajan Pro', Georgia, serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
}

#stage { position: fixed; inset: 0; }
#unity-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--night);
  outline: none;
}

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

.loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, rgba(120, 46, 20, 0.55) 0%, rgba(40, 14, 8, 0.2) 38%, rgba(0, 0, 0, 0) 62%),
    radial-gradient(ellipse at 50% 120%, rgba(142, 27, 27, 0.35) 0%, rgba(0, 0, 0, 0) 55%),
    linear-gradient(180deg, #0d0806 0%, #140a06 55%, #070403 100%);
  transition: opacity 0.85s ease, visibility 0.85s ease;
}
.loader.done { opacity: 0; visibility: hidden; }

.loader-rays {
  position: absolute;
  inset: -40%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 210, 140, 0.035) 0deg 6deg, rgba(0, 0, 0, 0) 6deg 18deg);
  animation: rays 90s linear infinite;
  mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 55%);
  -webkit-mask-image: radial-gradient(circle at 50% 50%, #000 0%, transparent 55%);
}
@keyframes rays { to { transform: rotate(360deg); } }

.loader-frame {
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(232, 186, 92, 0.28);
  box-shadow: inset 0 0 0 5px rgba(10, 6, 4, 0.6), inset 0 0 0 6px rgba(232, 186, 92, 0.14), inset 0 0 120px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.loader-center {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(760px, 92vw);
  text-align: center;
}

.loader-emblem-wrap { position: relative; width: min(230px, 42vw); aspect-ratio: 856 / 902; }
.loader-glow {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 196, 110, 0.45) 0%, rgba(255, 150, 60, 0) 70%);
  filter: blur(18px);
  animation: glow 3.2s ease-in-out infinite;
}
@keyframes glow { 0%, 100% { opacity: 0.45; transform: scale(0.94); } 50% { opacity: 0.9; transform: scale(1.06); } }
.loader-emblem {
  position: relative;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.8));
  animation: rise 1.1s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }

.loader-title {
  margin: 14px 0 0;
  font-size: clamp(26px, 5vw, 66px);
  font-weight: 700;
  letter-spacing: 0.16em;
  white-space: nowrap;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff3c8 0%, #ffe296 38%, #e8ba5c 62%, #9a6424 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.9));
}
.loader-tagline {
  margin: 6px 0 34px;
  font-size: clamp(10px, 1.4vw, 15px);
  letter-spacing: 0.3em;
  white-space: nowrap;
  text-transform: uppercase;
  color: #e27860;
}

.loader-bar { position: relative; width: min(640px, 100%); height: 22px; }
.loader-bar-track {
  position: absolute;
  inset: 0 14px;
  overflow: hidden;
  border-radius: 2px;
  background: linear-gradient(180deg, #050302 0%, #150c07 100%);
  box-shadow:
    0 0 0 1px #2a1709,
    0 0 0 3px #b8864b,
    0 0 0 4px #4a2c10,
    0 6px 18px rgba(0, 0, 0, 0.75),
    inset 0 2px 6px rgba(0, 0, 0, 0.9);
}
.loader-bar-fill {
  position: relative;
  height: 100%;
  width: 0;
  background: linear-gradient(180deg, #ff6a50 0%, #ce3028 45%, #8e1b1b 100%);
  box-shadow: 0 0 14px rgba(255, 110, 70, 0.55);
  transition: width 0.25s ease-out;
}
.loader-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 236, 200, 0.45) 50%, rgba(255, 255, 255, 0) 70%);
  background-size: 220px 100%;
  animation: sheen 1.6s linear infinite;
}
@keyframes sheen { from { background-position: -220px 0; } to { background-position: 220px 0; } }
.loader-bar-cap {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  transform: rotate(45deg);
  background: linear-gradient(135deg, #ffe296, #b8864b 55%, #4a2c10);
  box-shadow: 0 0 0 1px #2a1709, 0 2px 6px rgba(0, 0, 0, 0.8);
}
.loader-bar-cap.left { left: 2px; }
.loader-bar-cap.right { right: 2px; }

.loader-status {
  display: flex;
  justify-content: space-between;
  width: calc(min(640px, 100%) - 28px);
  margin-top: 14px;
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
}
#loader-pct { color: var(--gold-hi); font-weight: 700; letter-spacing: 0.1em; }

.loader-tip {
  min-height: 3em;
  margin: 26px 0 0;
  max-width: 560px;
  font-size: clamp(12px, 1.5vw, 15px);
  line-height: 1.55;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  animation: fade 6s ease-in-out infinite;
}
@keyframes fade { 0%, 100% { opacity: 0.35; } 12%, 88% { opacity: 1; } }

.loader.failed .loader-center { filter: grayscale(0.7) brightness(0.55); }
.loader-error {
  position: absolute;
  left: 50%;
  bottom: 12vh;
  transform: translateX(-50%);
  width: min(560px, 88vw);
  padding: 22px 28px;
  text-align: center;
  background: rgba(24, 8, 6, 0.95);
  border: 1px solid rgba(255, 140, 120, 0.5);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(232, 186, 92, 0.18);
}
.loader-error[hidden] { display: none; }
.loader-error h2 { margin: 0 0 8px; font-size: 22px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--gold-hi); }
.loader-error p { margin: 0 0 18px; font-family: Georgia, serif; font-size: 15px; line-height: 1.5; color: var(--ink); }
.loader-error button {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  padding: 12px 30px;
  color: #28180a;
  cursor: pointer;
  border: 0;
  border-radius: 3px;
  background: linear-gradient(180deg, #ffe296 0%, #e8ba5c 45%, #b8864b 100%);
  box-shadow: 0 0 0 1px #4a2c10, 0 4px 14px rgba(0, 0, 0, 0.7);
}
.loader-error button:hover { filter: brightness(1.1); }

@media (prefers-reduced-motion: reduce) {
  .loader-rays, .loader-glow, .loader-bar-fill::after, .loader-tip, .loader-emblem { animation: none; }
}

/* Portrait phones: the arena and its screens are landscape; ask to turn the phone (the game keeps running behind). */
#rotate { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate {
    position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; background: #0b0706; color: #f6e8c8; font-family: 'Cinzel', Georgia, serif; text-align: center; padding: 24px;
  }
  #rotate p { margin: 18px 0 0; font-size: 22px; letter-spacing: 3px; text-transform: uppercase; color: #ffd98a; }
  #rotate small { font-size: 15px; color: #c9b48c; letter-spacing: 1px; }
  .rotate-phone {
    width: 56px; height: 96px; border: 4px solid #e8ba5c; border-radius: 12px; animation: aa-rotate 2.4s ease-in-out infinite;
  }
  @keyframes aa-rotate { 0%, 25% { transform: rotate(0deg); } 60%, 100% { transform: rotate(-90deg); } }
}

/* wallet in-app browsers (portrait-locked): continue in the phone's own browser (web/src/handoff.ts) */
@media (orientation: portrait) and (pointer: coarse) {
  #rotate.wallet-browser small { max-width: 320px; line-height: 1.45; }
  #rotate.wallet-browser .err { color: #ffb4a8; min-height: 18px; }
  #rotate.wallet-browser button {
    margin-top: 14px; padding: 14px 22px; border: 1px solid #e8ba5c; border-radius: 4px; background: #6d1a14;
    color: #ffe2a0; font-family: 'Cinzel', Georgia, serif; font-size: 16px; letter-spacing: 2px;
  }
  #rotate.wallet-browser button:disabled { opacity: 0.6; }
  #handoff-out { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 10px; }
  #handoff-out[hidden] { display: none; }
  #handoff-link { width: 300px; padding: 10px; font-size: 13px; background: #160c08; color: #f6e8c8; border: 1px solid #b8864b; }
}
