:root {
  --bg: #020309;
  --ink: #eef1f8;
  --ink-2: #aab2c5;
  --ink-3: #7c859b;
  --line: rgba(255, 255, 255, 0.12);
  --panel: rgba(12, 14, 26, 0.92);
  --panel-solid: #0c0e1a;
  --glass: rgba(10, 12, 22, 0.62);
  --gold: #ffd8a0;
  --danger: #ff8a8a;
  --ok: #9be3b8;
  --radius: 14px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* WebGL 판(별)은 뒤, #sky(누르기·고른 별·고리)는 앞. 배경 은하 빛은 body */
body {
  background:
    radial-gradient(ellipse 60% 60% at 72% 28%, rgba(46, 58, 120, 0.16), transparent 70%),
    radial-gradient(ellipse 65% 65% at 22% 78%, rgba(70, 40, 110, 0.10), transparent 70%),
    radial-gradient(ellipse 90% 90% at 50% 50%, rgba(20, 30, 60, 0.18), transparent 75%),
    var(--bg);
}
#sky-gl {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  pointer-events: none;
}
#sky {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
}
#sky.on-star { cursor: pointer; }
#sky.dragging { cursor: grabbing; }
#sky:focus-visible { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.35); }

button, .btn, input { font: inherit; }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 14px; font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
button:focus-visible, .btn:focus-visible, input:focus-visible, summary:focus-visible, .brand:focus-visible {
  outline: 2px solid #fff; outline-offset: 2px;
}
button:disabled { opacity: .45; cursor: not-allowed; }

.primary { background: #f4f6fb; color: #070912; border-color: #f4f6fb; }
.primary:hover:not(:disabled) { background: #fff; }
.ghost { background: rgba(255, 255, 255, 0.04); }
.ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
.sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

.tag {
  display: inline-block;
  padding: 2px 7px;
  border: 1px solid rgba(255, 216, 160, 0.4);
  border-radius: 999px;
  color: var(--gold);
  font-size: 11px; font-weight: 600; line-height: 1.4;
  letter-spacing: .02em;
}

/* ---------- 상단 ---------- */

.top {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: max(14px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(2, 3, 9, 0.85), rgba(2, 3, 9, 0));
  pointer-events: none;
  z-index: 2;
}
.top > * { pointer-events: auto; }

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--ink); text-decoration: none;
  border-radius: 8px;
}
.brand-star {
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.7), 0 0 18px 6px rgba(160, 180, 255, 0.25);
}
.brand-name { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }

.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pill { gap: 1px; background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-variant-numeric: tabular-nums; }
.pill b { font-weight: 700; }
.top .ghost { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }

/* ---------- 이벤트 알림 ---------- */

.notice {
  position: fixed; top: 74px; left: 50%; transform: translateX(-50%);
  min-height: 34px; padding: 0 12px 0 10px;
  font-size: 13px; font-weight: 500;
  color: var(--ink-2);
  background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  z-index: 2;
  white-space: nowrap;
}
.notice:hover { color: var(--ink); }
.notice-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px 2px rgba(255, 216, 160, 0.6);
  animation: twinkle 2.4s ease-in-out infinite;
}
.notice.quiet .notice-dot { background: var(--ink-3); box-shadow: none; animation: none; }

@keyframes twinkle { 50% { opacity: .35; } }

/* ---------- 바닥 ---------- */

.hud {
  position: fixed; left: max(20px, env(safe-area-inset-left)); bottom: max(16px, env(safe-area-inset-bottom));
  right: 140px;
  pointer-events: none;
  z-index: 1;
}
.hud p { margin: 0; text-shadow: 0 0 6px #000, 0 0 2px #000; }
.count { font-size: 13px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.disclaimer { margin-top: 4px !important; font-size: 11.5px; color: var(--ink-3); }

.zoom {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
  z-index: 2;
}
.zoom button {
  width: 44px; height: 44px; min-height: 0; padding: 0;
  font-size: 20px; font-weight: 400;
  background: var(--glass);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.zoom button:hover { background: rgba(255, 255, 255, 0.12); }

.empty-hint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, 90px);
  text-align: center; color: var(--ink-3); font-size: 14px;
  pointer-events: none; z-index: 1;
}
.empty-hint p { margin: 4px 0; }
.empty-title { color: var(--ink-2); font-size: 16px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 8px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(244, 246, 251, 0.95); color: #070912;
  font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 대화창 ---------- */

dialog {
  width: min(440px, calc(100% - 32px));
  max-height: calc(100% - 48px);
  overflow: auto;
  padding: 20px 22px 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-solid);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.02);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }

.dlg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.dlg-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.x {
  margin-left: auto;
  width: 36px; height: 36px; min-height: 0; padding: 0;
  border: 0; background: transparent; color: var(--ink-3); font-size: 16px;
}
.x:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }

.lead { margin: 0 0 16px; color: var(--ink-2); font-size: 14px; line-height: 1.6; }
.help { margin: 8px 0 0; color: var(--ink-3); font-size: 12.5px; line-height: 1.55; }
.error { margin: 8px 0 0; color: var(--danger); font-size: 13px; line-height: 1.5; }
.error:empty, .ok-msg:empty { display: none; }
.ok-msg { margin: 10px 0 0; color: var(--ok); font-size: 13px; line-height: 1.5; }

.field-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type="text"] {
  width: 100%; height: 48px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: rgba(255, 255, 255, 0.04); color: var(--ink);
  font-size: 16px;
}
input[type="text"]::placeholder { color: #5b6377; }
input[aria-invalid="true"] { border-color: var(--danger); }

.cost-row {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding: 12px 14px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.04);
  font-size: 14px; color: var(--ink-2);
}
.cost-row b { color: var(--ink); font-size: 16px; }

.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.actions.stack { flex-direction: column; align-items: stretch; margin-top: 14px; }

.facts { margin: 0; display: grid; gap: 10px; }
.facts > div { display: grid; grid-template-columns: 84px 1fr; gap: 10px; font-size: 14px; line-height: 1.55; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; color: var(--ink); min-width: 0; }
.url { overflow-wrap: anywhere; word-break: break-all; }
.cond { margin: 0; padding-left: 18px; }
.cond li + li { margin-top: 2px; }

.domain { margin: 6px 0 4px; font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.small { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.warn {
  margin: 14px 0 0; padding: 12px 14px;
  border-radius: 12px; background: rgba(255, 255, 255, 0.04);
  color: var(--ink-2); font-size: 13px; line-height: 1.6;
}
.mine { margin: 10px 0 0; font-size: 13px; color: var(--gold); }

/* 영상 재생 창 */
dialog.video { width: min(760px, calc(100% - 32px)); }
dialog.video.narrow { width: min(420px, calc(100% - 32px)); }
.player {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 12px; overflow: hidden;
  background: #000;
}
.player.vertical { aspect-ratio: 9 / 16; height: min(68vh, 680px); margin: 0 auto; max-width: 100%; }
.player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
dialog.video .url { margin-top: 10px; }

.ev-title { margin: 0 0 14px; font-size: 20px; font-weight: 700; }

.events-list, .mine-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.event-item, .mine-item {
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}
.event-item p { margin: 6px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.event-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.event-head .state { font-size: 12px; color: var(--gold); }

/* 내 별 — 데스크톱은 오른쪽 옆 판 */
dialog.side {
  margin: 0 0 0 auto; height: 100%; max-height: 100%;
  width: min(420px, 100%);
  border-radius: 0; border-width: 0 0 0 1px;
}
dialog.side[open] { animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.mine-list { margin-top: 14px; }
.mine-item .url { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.meta { margin: 0; display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: 4px 18px; }
.meta div { min-width: 0; }
.meta dt { font-size: 11.5px; color: var(--ink-3); }
.meta dd { margin: 2px 0 0; font-size: 13px; }
.mine-actions { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.mine-empty { margin-top: 30px; text-align: center; color: var(--ink-2); }

.big-points { margin: 4px 0 12px; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; }
.reset { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.reset summary { cursor: pointer; color: var(--ink-3); font-size: 13px; border-radius: 6px; }

/* ---------- 폰 ---------- */

@media (max-width: 560px) {
  .top { padding-left: 16px; padding-right: 16px; gap: 8px; }
  .brand-name { font-size: 17px; }
  .top > .tag { display: none; }
  .top-actions { gap: 6px; }
  .top-actions button { min-height: 36px; padding: 0 12px; font-size: 13px; }
  .notice { top: 64px; }
  .hud { left: 16px; right: 76px; }
  .zoom { right: 16px; }
  .zoom #zoom-in, .zoom #zoom-out { display: none; } /* 폰은 두 손가락으로 확대 */

  dialog:not(.side) {
    width: 100%; max-width: 100%;
    margin: auto 0 0; max-height: 88%;
    border-radius: 20px 20px 0 0; border-width: 1px 0 0;
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }
  dialog:not(.side)[open] { animation: up .2s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } }
  .actions:not(.stack) > * { flex: 1; }
  .facts > div { grid-template-columns: 72px 1fr; }
  dialog.video, dialog.video.narrow { width: 100%; max-height: 94%; }
  .player.vertical { height: min(64vh, 620px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
