/* ===== base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0c14;
  --ink: #e8ecf8;
  --muted: #8892b0;
  --accent: #43e5a0;
  --accent-2: #5b8cff;
  --danger: #ff4d6d;
  --warn: #ffc247;
  --panel: rgba(16, 20, 34, 0.92);
  --line: rgba(255, 255, 255, 0.09);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }

/* ===== fake desktop backdrop ===== */
#stage { position: absolute; inset: 0; overflow: hidden; cursor: crosshair; }

#desktop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 0%, #1b2242 0%, #0a0c14 60%),
    var(--bg);
}

.desktop-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(80% 70% at 50% 40%, #000 30%, transparent 100%);
  mask-image: radial-gradient(80% 70% at 50% 40%, #000 30%, transparent 100%);
}

.desktop-brand {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: .3;
  pointer-events: none;
}
.desktop-brand__logo { font-size: 60px; color: var(--accent-2); }
.desktop-brand__name { font-size: 26px; font-weight: 800; letter-spacing: .04em; margin-top: 6px; }
.desktop-brand__sub { font-size: 13px; color: var(--muted); margin-top: 8px; }

#ads, #floaters { position: absolute; inset: 0; }
#floaters { pointer-events: none; }

/* ===== ad window ===== */
.ad {
  position: absolute;
  top: 0; left: 0;
  width: 200px;
  border-radius: 8px;
  overflow: hidden;
  background: #141a2b;
  border: 1px solid rgba(255,255,255,.14);
  box-shadow: 0 18px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(0,0,0,.4);
  will-change: transform;
  /* 좁은 화면에서 창 전체를 비례 축소한다. 왼쪽 위 기준이라
     translate 좌표가 곧 창의 좌상단이 되어 물리 계산과 어긋나지 않는다. */
  transform-origin: 0 0;
}

.ad--spawning { animation: ad-in .18s cubic-bezier(.2,1.4,.4,1); }
@keyframes ad-in { from { opacity: 0; } }

.ad--dying {
  pointer-events: none;
  opacity: 0;
  filter: brightness(2.4);
  transition: opacity .16s ease-in, filter .16s ease-in;
}

.ad__bar {
  display: flex; align-items: center; gap: 6px;
  height: 24px;
  padding: 0 4px 0 8px;
  background: linear-gradient(180deg, #3b4bd8, #2a2f8f);
  font-size: 11px; font-weight: 700;
  white-space: nowrap; overflow: hidden;
}
.ad__title { flex: 1; overflow: hidden; text-overflow: ellipsis; opacity: .95; }

.ad__close {
  flex: none;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 3px;
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 11px; line-height: 1;
  font-family: inherit;
  cursor: pointer;
}
.ad__close:hover { background: var(--danger); border-color: var(--danger); }

.ad__close--locked {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.5);
  border-style: dashed;
  cursor: not-allowed;
  width: auto; min-width: 18px; padding: 0 5px;
  font-size: 10px; font-variant-numeric: tabular-nums;
}
.ad__close--locked:hover { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.35); }

.ad__body {
  position: relative;
  padding: 12px 10px;
  text-align: center;
  background: linear-gradient(160deg, #1c2338, #131829);
}
.ad__head { font-size: 14px; font-weight: 800; line-height: 1.25; }
.ad__sub { font-size: 10px; color: var(--muted); margin-top: 5px; line-height: 1.4; }
.ad__cta {
  margin-top: 9px;
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px; font-weight: 800;
  background: linear-gradient(90deg, var(--warn), #ff8a3d);
  color: #241400;
}

/* per-type accents */
.ad[data-type="runner"] { border-color: rgba(91,140,255,.6); }
.ad[data-type="runner"] .ad__bar { background: linear-gradient(180deg, #1f7ae0, #0f4f9c); }
.ad[data-type="splitter"] .ad__bar { background: linear-gradient(180deg, #b93bd8, #7a1f96); }
.ad[data-type="decoy"] .ad__bar { background: linear-gradient(180deg, #d8b13b, #97701f); color: #2a1d00; }
.ad[data-type="decoy"] .ad__close { border-color: rgba(0,0,0,.4); color: #1a1200; }
.ad[data-type="timer"] .ad__bar { background: linear-gradient(180deg, #d8433b, #93211b); }

/* ── 스폰서 소재 ──────────────────────────────────────────────
   ads.js 의 theme 값이 인라인 CSS 변수로 들어온다. 없으면 기본 색. */
.ad[data-sponsor] .ad__bar  { background: var(--ad-bar, linear-gradient(180deg, #3b4bd8, #2a2f8f)); }
.ad[data-sponsor] .ad__body { background: var(--ad-body, linear-gradient(160deg, #1c2338, #131829)); }
.ad[data-sponsor] .ad__cta  { background: var(--ad-cta, linear-gradient(90deg, var(--warn), #ff8a3d)); }

/* 배너 이미지. aspect-ratio 로 자리를 먼저 잡아두기 때문에
   이미지가 나중에 도착해도 창 높이가 변하지 않는다. */
.ad__media {
  width: 100%;
  margin-bottom: 9px;
  border-radius: 5px;
  overflow: hidden;
  background: rgba(255, 255, 255, .06);
}
.ad__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 로고 높이를 고정해야 이미지 로딩 전후로 창 높이가 흔들리지 않는다
   (스폰 시점에 offsetHeight 로 물리 크기를 재기 때문) */
.ad__logo {
  display: block;
  height: 20px;
  width: auto;
  max-width: 70%;
  margin: 0 auto 8px;
  object-fit: contain;
}

/* decoy close buttons inside the body */
.ad__fakeclose {
  position: absolute;
  width: 16px; height: 16px;
  display: grid; place-items: center;
  border-radius: 3px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.28);
  font-size: 10px;
  cursor: pointer;
}

/* ===== hit text ===== */
.floater {
  position: absolute;
  font-size: 15px; font-weight: 800;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
  animation: float-up .7s ease-out forwards;
  white-space: nowrap;
}
.floater--good { color: var(--accent); }
.floater--bad  { color: var(--danger); }
@keyframes float-up {
  from { transform: translate(-50%, 0); opacity: 1; }
  to   { transform: translate(-50%, -46px); opacity: 0; }
}

/* ===== HUD ===== */
#hud {
  position: absolute;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 10px;
  padding: 9px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: none;
  z-index: 20;
}
#hud[hidden] { display: none; }
.hud__cell { display: flex; flex-direction: column; align-items: center; min-width: 68px; }
.hud__cell--wide { min-width: 130px; justify-content: center; }
.hud__label { font-size: 9px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.hud__value { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.hud__value--danger { color: var(--danger); }

.loadbar {
  width: 100%; height: 8px; margin-top: 7px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  overflow: hidden;
}
.loadbar__fill {
  height: 100%; width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--warn));
  transition: width .12s linear;
}

/* ===== overlays ===== */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(6, 8, 16, .78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  z-index: 30;
  cursor: default;
}
.overlay[hidden] { display: none; }

.panel {
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 30px 32px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
  text-align: center;
  animation: panel-in .22s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

.logo { font-size: 46px; font-weight: 900; letter-spacing: -.02em; }
.logo span { color: var(--accent); }
.tagline { margin-top: 10px; color: var(--muted); font-size: 14px; line-height: 1.6; }

.modes { display: grid; gap: 8px; margin: 22px 0 16px; }
.mode {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  text-align: left;
  color: inherit; font-family: inherit;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.mode:hover { border-color: rgba(255,255,255,.25); }
.mode[aria-checked="true"] { border-color: var(--accent); background: rgba(67,229,160,.09); }
.mode__icon { font-size: 20px; }
.mode__text { display: block; }
.mode__name { display: block; font-size: 14px; font-weight: 700; }
.mode__desc { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }

.btn {
  padding: 12px 26px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.06);
  color: var(--ink);
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.btn:hover { background: rgba(255,255,255,.12); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #04120b; }
.btn--primary:hover:not(:disabled) { background: #5df3b3; }
.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 22px; flex-wrap: wrap; }

.rules {
  margin: 20px auto 0;
  padding: 14px 16px 14px 30px;
  max-width: 420px;
  border-radius: 11px;
  background: rgba(255,255,255,.03);
  text-align: left;
  font-size: 11.5px; color: var(--muted); line-height: 1.7;
}
.rules b { color: var(--ink); }

.best { margin-top: 16px; font-size: 12px; color: var(--muted); }

/* ===== 광고 문의 ===== */
.contact { margin-top: 10px; font-size: 12px; }
.contact a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-decoration: none;
}
.contact a:hover { color: var(--ink); border-color: var(--warn); }
.contact__addr {
  color: var(--warn);
  font-variant-numeric: tabular-nums;
  /* 주소는 길어서 좁은 화면에서 줄바꿈되면 지저분하다 */
  white-space: nowrap;
}

/* ===== 언어 선택 ===== */
.langs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.lang {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}
.lang:hover { color: var(--ink); border-color: rgba(255,255,255,.28); }
.lang[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(67,229,160,.1);
  font-weight: 700;
}

/* ===== result ===== */

/* 등급 배지 — 이 화면의 주인공이라 점수보다 눈에 먼저 들어와야 한다 */
.tier { margin: 4px 0 20px; }

.tier__badge {
  display: inline-block;
  padding: 9px 22px;
  border-radius: 999px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -.01em;
  border: 2px solid currentColor;
  background: color-mix(in srgb, currentColor 12%, transparent);
}
.tier__badge[data-tier="guinness"] { color: #ffd35c; }
.tier__badge[data-tier="pro"]      { color: var(--accent); }
.tier__badge[data-tier="local"]    { color: var(--accent-2); }
.tier__badge[data-tier="normal"]   { color: var(--muted); }
.tier__badge[data-tier="hamster"]  { color: var(--danger); }

/* 기네스급은 살짝 빛나게 — 최고 등급의 보상감 */
.tier__badge[data-tier="guinness"] {
  box-shadow: 0 0 26px rgba(255, 211, 92, .35);
}

.tier__note { margin-top: 9px; font-size: 12px; color: var(--muted); }

.result-title { font-size: 17px; font-weight: 700; }
.score-big {
  font-size: 56px; font-weight: 900;
  font-variant-numeric: tabular-nums;
  margin: 4px 0 18px;
}
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { padding: 11px 6px; border-radius: 10px; background: rgba(255,255,255,.04); }
.stat__label { font-size: 10px; color: var(--muted); }
.stat__value { font-size: 18px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; }

@media (max-width: 560px) {
  .panel { padding: 24px 18px; }
  .logo { font-size: 36px; }
  #hud { top: 8px; gap: 4px; padding: 7px 9px; }
  .hud__cell { min-width: 54px; }
  .hud__value { font-size: 17px; }
  .hud__cell--wide { min-width: 92px; }
}
