:root {
  --bg: #07090c;
  --line: #1c2733;
  --text: #d7e0ea;
  --muted: #7f8fa3;
  --live: #2ee59d;
  --warn: #f0b429;
  --bad: #ff5c5c;
  --glow: rgba(46, 229, 157, 0.35);
  --pad: max(12px, env(safe-area-inset-left));
  --pad-r: max(12px, env(safe-area-inset-right));
  --pad-t: max(12px, env(safe-area-inset-top));
  --pad-b: max(12px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% 0%, #243552 0%, transparent 58%),
    radial-gradient(ellipse 70% 55% at 85% 100%, #1a2838 0%, transparent 55%),
    radial-gradient(ellipse 70% 55% at 15% 100%, #15202c 0%, transparent 55%),
    radial-gradient(circle at 50% 55%, rgba(46, 229, 157, 0.06) 0%, transparent 42%);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
  background-attachment: fixed;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  font-family: "Segoe UI", "IBM Plex Sans", "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: auto;
  height: auto;
  margin: 0;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  min-height: 44px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.title {
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tag {
  flex-shrink: 0;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 999px;
  line-height: 1;
  user-select: none;
  -webkit-user-select: none;
}
.tag.live { color: var(--live); border-color: rgba(46,229,157,.35); }
.tag.stale { color: var(--warn); border-color: rgba(240,180,41,.4); }
.tag.down { color: var(--bad); border-color: rgba(255,92,92,.4); }

.fs-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 19, 25, 0.9);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.fs-btn svg { width: 22px; height: 22px; display: block; }
.fs-btn .ico-exit { display: none; }
.fs-btn:active { transform: scale(0.96); }
body.is-fs .fs-btn .ico-enter { display: none; }
body.is-fs .fs-btn .ico-exit { display: block; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--muted);
}
.dot.live {
  background: var(--live);
  box-shadow: 0 0 0 4px var(--glow);
  animation: pulse 1.6s ease-out infinite;
}
.dot.stale { background: var(--warn); }
.dot.down { background: var(--bad); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--glow); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  touch-action: manipulation;
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center center;
  opacity: 0;
  transition: opacity .35s ease;
}
canvas.on { opacity: 1; }

.veil {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,.55) 100%);
}
.scan {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,.03) 0,
    rgba(255,255,255,.03) 1px,
    transparent 2px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
  opacity: .35;
}

.placeholder {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  transition: opacity .3s ease;
}
.placeholder.hide { opacity: 0; pointer-events: none; }

.link-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  z-index: 4;
  padding: 12px 16px;
  text-align: center;
  color: #ffe8e8;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  line-height: 1.35;
  background: rgba(40, 8, 10, 0.82);
  border: 1px solid rgba(255, 92, 92, 0.45);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.link-banner[hidden] { display: none; }

body.is-fs .stage { padding: 0; gap: 0; }
body.is-fs .top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 10px max(12px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(0,0,0,.72), transparent);
}
body.is-fs .viewport {
  border: 0;
  border-radius: 0;
}
body.is-fs .rotate-tip { display: none; }

.rotate-tip {
  display: none;
  position: absolute;
  left: 12px;
  right: 12px;
  top: 50%;
  z-index: 6;
  transform: translateY(-50%);
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  text-align: center;
  color: #e8f0fa;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.4;
  background: rgba(6, 10, 16, 0.88);
  border: 1px solid rgba(125, 170, 230, 0.4);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 1;
  transition: opacity 2s ease;
}
.rotate-tip.is-hiding { opacity: 0; }
.rotate-tip.is-gone { display: none !important; }
.rotate-ico {
  width: 52px;
  height: 52px;
  color: #9ec5ff;
  animation: tip-tilt 1.8s ease-in-out infinite;
}
@keyframes tip-tilt {
  0%, 100% { transform: rotate(0deg); }
  40% { transform: rotate(70deg); }
  60% { transform: rotate(70deg); }
}

@media (max-width: 767px) {
  .title { font-size: 1.35rem; }
  .dot { width: 14px; height: 14px; }
  .tag {
    font-size: 0.92rem;
    padding: 12px 16px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    letter-spacing: 0.08em;
  }
  .fs-btn {
    width: 52px;
    height: 52px;
    border-radius: 14px;
  }
  .fs-btn svg { width: 26px; height: 26px; }
  .placeholder { font-size: 1.1rem; }
  .link-banner {
    font-size: 0.95rem;
    padding: 14px 16px;
    bottom: 16px;
  }
  .viewport {
    flex: 1 1 auto;
    width: 100%;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    border-radius: 12px;
    box-shadow: none;
  }
  canvas {
    object-fit: contain;
    object-position: center center;
  }
}

@media (max-width: 767px) and (orientation: portrait) {
  .rotate-tip:not(.is-gone) { display: flex; }
}

@media (min-width: 768px) {
  .stage {
    padding: 72px 32px 32px;
    gap: 0;
    align-items: center;
    justify-content: center;
  }
  .top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    min-height: 56px;
    padding: 16px 28px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
  }
  .title { font-size: 1.25rem; }
  .fs-btn { width: 42px; height: 42px; }
  .viewport {
    position: relative;
    flex: 0 0 auto;
    width: min(1120px, calc(100% - 64px), calc((100% - 120px) * 960 / 576));
    aspect-ratio: 960 / 576;
    height: auto;
    max-height: calc(100% - 120px);
    margin: 0 auto;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #000;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  }
  canvas {
    object-fit: fill;
  }
  .rotate-tip { display: none; }
  .link-banner {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(640px, calc(100% - 32px));
    bottom: 20px;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .stage {
    padding: 0;
    gap: 0;
    align-items: stretch;
    justify-content: stretch;
  }
  .top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    min-height: 40px;
    padding: max(8px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left));
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
  }
  .title { font-size: 1.05rem; }
  .tag {
    font-size: 0.8rem;
    padding: 8px 12px;
    min-height: 36px;
  }
  .fs-btn { width: 44px; height: 44px; border-radius: 12px; }
  .fs-btn svg { width: 22px; height: 22px; }
  .viewport {
    position: absolute;
    inset: 0;
    flex: none;
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #000;
  }
  canvas {
    object-fit: contain;
    object-position: center center;
  }
  .rotate-tip { display: none !important; }
}
