:root {
  color-scheme: dark;
  font-family: Inter, "Noto Sans JP", "Hiragino Sans", system-ui, sans-serif;
  --gold: #ffd56a;
  --red: #f25743;
  --cyan: #67eaff;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body { margin: 0; overflow: hidden; background: #05070a; color: #fff; }
button { font: inherit; }
[hidden] { display: none !important; }

.ar-view { position: fixed; inset: 0; overflow: hidden; background: #080c11; }

.mindar-container,
.demo-background,
.camera-shade,
.three-layer,
.three-layer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mindar-container { z-index: 0; overflow: hidden; }
.mindar-container > video {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.mindar-container > canvas { display: none !important; }

.demo-background {
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(11, 25, 31, 0.08), rgba(2, 7, 10, 0.24)),
    radial-gradient(ellipse at 50% 42%, rgba(65, 147, 158, 0.34), transparent 34%),
    linear-gradient(150deg, #334d4c 0%, #172729 42%, #101820 42%, #070a0e 100%);
  transition: opacity 0.3s ease;
}

.demo-background::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.22;
  background-image:
    linear-gradient(67deg, transparent 47%, rgba(255,255,255,.08) 48%, transparent 49%),
    linear-gradient(113deg, transparent 47%, rgba(255,255,255,.06) 48%, transparent 49%);
  background-size: 120px 140px;
}

.ar-view[data-camera="active"] .demo-background { opacity: 0; }

.camera-shade {
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 5, 8, 0.6) 0%, transparent 25%, transparent 65%, rgba(3, 5, 8, 0.72) 100%),
    radial-gradient(ellipse at center, transparent 44%, rgba(0, 0, 0, 0.27) 100%);
}

.three-layer { z-index: 2; pointer-events: none; }

.ar-view[data-unlocked="false"] .enemy-hud,
.ar-view[data-unlocked="false"] .battle-controls,
.ar-view[data-unlocked="false"] .three-layer {
  opacity: 0;
  pointer-events: none;
}

.enemy-hud, .battle-controls, .three-layer { transition: opacity .38s ease; }

.enemy-hud {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  z-index: 5;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.enemy-label { color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: 0.18em; }
.enemy-hud h1 { margin: 3px 0 0; font-family: serif; font-size: clamp(25px, 8vw, 42px); letter-spacing: 0.08em; }

.hit-status { width: min(37vw, 170px); padding-top: 2px; text-align: right; }
.hit-status > span { color: rgba(255,255,255,.7); font-size: 8px; font-weight: 800; letter-spacing: .15em; }
.hit-status strong { display: block; margin-top: 2px; font-size: 16px; }
.hit-pips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 7px; }
.hit-pips i { height: 4px; border-radius: 99px; background: rgba(255,255,255,.25); box-shadow: 0 1px 8px rgba(0,0,0,.5); transition: background .2s ease, box-shadow .2s ease; }
.hit-pips i.is-active { background: var(--red); box-shadow: 0 0 10px rgba(242,87,67,.75); }

.model-status {
  position: absolute;
  top: max(91px, calc(env(safe-area-inset-top) + 80px));
  left: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 99px;
  background: rgba(2, 7, 11, .52);
  font-size: 9px;
  transform: translateX(-50%);
  backdrop-filter: blur(8px);
  transition: opacity .35s ease;
}
.model-status[data-state="ready"] { opacity: 0; pointer-events: none; }
.model-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px var(--gold); animation: pulse 1s infinite; }
.model-status[data-state="error"] i { background: var(--red); box-shadow: 0 0 8px var(--red); animation: none; }

.battle-controls {
  position: absolute;
  left: 50%;
  bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
  z-index: 7;
  width: min(88vw, 430px);
  text-align: center;
  transform: translateX(-50%);
}

.battle-controls p {
  display: inline-block;
  min-height: 31px;
  margin: 0 0 10px;
  padding: 7px 12px;
  border-radius: 99px;
  background: rgba(2, 7, 11, .56);
  color: rgba(255,255,255,.9);
  font-size: 10px;
  line-height: 1.6;
  text-shadow: 0 1px 7px #000;
  backdrop-filter: blur(7px);
}

.attack-button, .capture-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  width: 100%;
  min-height: 64px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 15px;
  color: #fff;
  box-shadow: 0 13px 35px rgba(0,0,0,.4);
  transition: opacity .18s ease, transform .12s ease, filter .18s ease;
}
.attack-button { background: linear-gradient(135deg, rgba(121,25,21,.94), rgba(239,79,56,.96)); }
.capture-button { background: linear-gradient(135deg, rgba(9,98,125,.96), rgba(62,215,240,.98)); color: #031216; }
.attack-button:active:not(:disabled), .capture-button:active { transform: scale(.98); }
.attack-button:disabled { opacity: .42; }
.attack-button small, .capture-button small { display: block; margin-bottom: 1px; font-size: 8px; font-weight: 900; letter-spacing: .26em; opacity: .72; }
.attack-button span:last-child, .capture-button span { font-size: 17px; font-weight: 900; }
.slash-mark { font-family: serif; font-size: 34px; font-weight: 200; transform: rotate(-20deg); }

.damage-flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(118deg, transparent 35%, rgba(255,248,205,.94) 47%, rgba(242,66,46,.88) 51%, transparent 64%);
}
.damage-flash.is-active { animation: slash .42s ease-out; }

.capture-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  width: min(72vw, 410px);
  aspect-ratio: 1;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: inset 0 0 45px rgba(103,234,255,.5), 0 0 40px rgba(103,234,255,.5);
}
.capture-ring span { position: absolute; inset: 11%; border: 1px solid rgba(103,234,255,.62); border-radius: 50%; }
.capture-ring.is-active { animation: capture 1.35s ease-in forwards; }

.capture-label {
  position: absolute;
  left: 50%;
  top: calc(50% - min(39vw, 220px));
  z-index: 6;
  color: var(--cyan);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .34em;
  opacity: 0;
  transform: translateX(-50%);
  text-shadow: 0 0 12px var(--cyan);
}
.capture-label.is-active { animation: seal-label 1.35s ease forwards; }

.compendium-toast {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 13px;
  width: min(84vw, 360px);
  padding: 16px 18px;
  border: 1px solid rgba(103,234,255,.56);
  border-radius: 16px;
  background: rgba(3, 18, 24, .86);
  box-shadow: 0 15px 45px rgba(0,0,0,.5), 0 0 32px rgba(103,234,255,.12);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -35%) scale(.94);
  backdrop-filter: blur(12px);
  transition: opacity .3s ease, transform .3s ease;
}
.compendium-toast.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.compendium-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border: 1px solid var(--cyan); border-radius: 50%; color: var(--cyan); font-family: serif; font-size: 22px; }
.compendium-toast small { display: block; color: var(--cyan); font-size: 8px; letter-spacing: .13em; }
.compendium-toast strong { display: block; margin-top: 4px; font-size: 14px; }

.marker-gate {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 24px;
  text-align: center;
  background: radial-gradient(circle at center, transparent 15%, rgba(0,0,0,.46) 78%);
}

.marker-frame {
  position: relative;
  width: min(72vw, 330px);
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,.42);
}
.marker-frame img { width: 100%; height: 100%; object-fit: cover; opacity: .3; filter: saturate(.6); }
.marker-frame > span { position: absolute; z-index: 2; width: 34px; height: 34px; border-color: var(--cyan); filter: drop-shadow(0 0 7px var(--cyan)); }
.marker-frame > span:nth-child(1) { top: 0; left: 0; border-top: 3px solid var(--cyan); border-left: 3px solid var(--cyan); }
.marker-frame > span:nth-child(2) { top: 0; right: 0; border-top: 3px solid var(--cyan); border-right: 3px solid var(--cyan); }
.marker-frame > span:nth-child(3) { bottom: 0; left: 0; border-bottom: 3px solid var(--cyan); border-left: 3px solid var(--cyan); }
.marker-frame > span:nth-child(4) { right: 0; bottom: 0; border-right: 3px solid var(--cyan); border-bottom: 3px solid var(--cyan); }
.marker-gate h2 { margin: 22px 0 7px; font-size: 19px; text-shadow: 0 2px 10px #000; }
.marker-gate p { margin: 0; color: rgba(255,255,255,.7); font-size: 11px; text-shadow: 0 2px 8px #000; }

.start-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 34%, #16343d, #080c11 62%);
  transition: opacity .4s ease, visibility .4s ease;
}
.start-screen.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.start-card { width: min(100%, 390px); text-align: center; }
.start-kicker { color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: .26em; }
.start-card h2 { margin: 13px 0 10px; font-family: serif; font-size: 37px; letter-spacing: .1em; }
.start-card p { margin: 0 auto 28px; max-width: 310px; color: rgba(255,255,255,.68); font-size: 13px; line-height: 1.8; }
.start-card button { width: 100%; min-height: 58px; border: 0; border-radius: 14px; background: linear-gradient(135deg, #d5a738, #ffe184); color: #161006; font-weight: 900; }
.start-card .demo-button { min-height: 45px; margin-top: 9px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: rgba(255,255,255,.78); font-size: 11px; }
.start-card > small { display: block; margin-top: 18px; color: rgba(255,255,255,.4); font-size: 9px; line-height: 1.6; }

@keyframes pulse { 50% { opacity: .3; } }
@keyframes slash { 0% { opacity: 0; transform: translateX(-25%) scale(1.1); } 38% { opacity: 1; } 100% { opacity: 0; transform: translateX(25%) scale(1.1); } }
@keyframes capture { 0% { opacity: 0; transform: translate(-50%,-50%) scale(1.22) rotate(0); } 24% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(.06) rotate(160deg); } }
@keyframes seal-label { 0%, 100% { opacity: 0; } 20%, 72% { opacity: 1; } }

@media (orientation: landscape) and (max-height: 600px) {
  .enemy-hud { top: max(10px, env(safe-area-inset-top)); }
  .enemy-hud h1 { font-size: 25px; }
  .model-status { top: 64px; }
  .battle-controls { bottom: max(10px, env(safe-area-inset-bottom)); width: min(45vw, 420px); }
  .battle-controls p { margin-bottom: 5px; }
  .attack-button, .capture-button { min-height: 50px; }
  .capture-ring { width: min(55vh, 330px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
