:root {
  --se-bg: #0f172a;
  --se-surface: #1e293b;
  --se-surface-2: #0f172a;
  --se-ink: #f8fafc;
  --se-ink-muted: #cbd5e1;
  --se-gold: #fbbf24;
  --se-gold-dark: #d97706;
  --se-border: #334155;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif; color: var(--se-ink); background: radial-gradient(circle at 20% 0%, #1e1b4b 0%, #0f172a 55%, #020617 100%); min-height: 100dvh; overflow-x: hidden; }

.se-app { max-width: 1080px; margin: 0 auto; padding: 12px 16px 28px; display: flex; flex-direction: column; gap: 14px; }

.se-topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: rgba(30,41,59,0.92); border: 1.5px solid #475569; border-radius: 16px; padding: 10px 14px; }
.se-topbar-left, .se-topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.se-brand-title { margin: 0; font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 800; color: #f8fafc; }

.se-btn-ghost, .se-btn-pill, .se-btn-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 13px; border-radius: 999px; font-size: 0.92rem; font-weight: 700; text-decoration: none; cursor: pointer; border: 1.5px solid #64748b; background: #0f172a; color: #f8fafc; transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease; }
.se-btn-ghost:hover, .se-btn-pill:hover, .se-btn-action:hover:not(:disabled) { border-color: var(--se-gold); background: #1e293b; transform: translateY(-1px); }
.se-btn-action:disabled { opacity: 0.45; cursor: not-allowed; }
.se-btn-share { background: #fbbf24; border-color: #fbbf24; color: #0f172a; }
.se-btn-share:hover { background: #f59e0b; border-color: #f59e0b; color: #0f172a; }

.se-lobby-card { background: var(--se-surface); border: 1.5px solid #475569; border-radius: 24px; padding: 20px; box-shadow: 0 16px 40px rgba(2,6,23,0.5); display: flex; flex-direction: column; gap: 20px; }
.se-hero-heading { margin: 0 0 8px; font-size: clamp(1.35rem, 3vw, 1.85rem); font-weight: 900; color: #f8fafc; }

.se-tier-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.se-tier-tab { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 12px 10px; border-radius: 16px; border: 2px solid #475569; background: #0f172a; color: #f8fafc; cursor: pointer; font-weight: 700; }
.se-tier-tab span { font-size: 0.8rem; color: #cbd5e1; }
.se-tier-tab.is-active { background: #fbbf24; border-color: #fde68a; color: #0f172a; }
.se-tier-tab.is-active span { color: #1e293b; font-weight: 800; }

.se-stage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.se-stage-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; border-radius: 16px; border: 2px solid #475569; background: #0f172a; color: #f8fafc; cursor: pointer; text-align: left; }
.se-stage-card:hover { border-color: #fbbf24; }
.se-stage-card.is-selected { border-color: #fbbf24; background: #1e1b4b; box-shadow: 0 0 0 3px rgba(251,191,36,0.28); }
.se-stage-card.is-cleared { border-color: #34d399; }
.se-stage-num { font-size: 0.96rem; font-weight: 800; color: #f8fafc; }
.se-stage-meta { font-size: 0.82rem; color: #cbd5e1; font-weight: 600; }

.se-lobby-footer { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.se-btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 28px; border-radius: 16px; border: none; background: #fbbf24; color: #0f172a; font-size: 1.08rem; font-weight: 900; cursor: pointer; box-shadow: 0 8px 20px rgba(251,191,36,0.28); transition: transform 0.14s ease, background 0.14s ease; }
.se-btn-primary:hover { background: #f59e0b; transform: translateY(-2px); }
.se-btn-secondary { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border-radius: 14px; border: 2px solid #fbbf24; background: #0f172a; color: #fde68a; font-size: 0.98rem; font-weight: 800; cursor: pointer; }
.se-btn-ghost-dark { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 18px; border-radius: 14px; border: 1.5px solid #64748b; background: #1e293b; color: #f8fafc; font-size: 0.95rem; font-weight: 700; cursor: pointer; }
.se-btn-full { width: 100%; }
.se-lobby-tip { margin: 0; font-size: 0.9rem; font-weight: 700; color: #fde68a; }

/* PLAY SCREEN */
.se-hud { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #1e293b; border: 1.5px solid #475569; border-radius: 18px; padding: 12px 16px; }
.se-hud-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.se-hud-badge { padding: 4px 10px; border-radius: 999px; background: #fbbf24; color: #0f172a; font-size: 0.875rem; font-weight: 900; }
.se-stat-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 12px; background: #0f172a; border: 1.5px solid #475569; font-size: 0.9rem; font-weight: 700; }
.se-stat-pill strong { color: #fde68a; font-size: 1.05rem; }
.se-hud-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.se-story-bar { background: #1e293b; border: 1.5px solid #64748b; border-radius: 14px; padding: 10px 16px; text-align: center; font-size: 0.98rem; font-weight: 700; color: #f8fafc; }
.se-story-bar.is-hint { background: #422006; border-color: #fbbf24; color: #fef08a; }
.se-story-bar.is-stuck { background: #450a0a; border-color: #f87171; color: #fecaca; }

.se-sky-wrap { background: radial-gradient(circle at 50% 45%, #1e1b4b 0%, #0f172a 70%, #020617 100%); border: 2px solid #475569; border-radius: 24px; padding: 16px; display: grid; place-items: center; box-shadow: inset 0 0 40px rgba(2,6,23,0.7); touch-action: none; }
.se-board { position: relative; aspect-ratio: 1; user-select: none; }
.se-lines { position: absolute; inset: 0; pointer-events: none; }
.se-edge {
  position: absolute;
  height: 2.4%;
  border-radius: 999px;
  transform: translateY(-50%);
  transform-origin: center left;
}
.se-edge-base { background: repeating-linear-gradient(90deg, #91a3c2ae 0 14px, transparent 14px 20px); }
.se-edge-traced { height: 1.8%; background: #fbd45d; box-shadow: 0 0 8px #eabc42; }
.se-edge-hint { height: 1.9%; background: repeating-linear-gradient(90deg, #53d8ff 0 9px, transparent 9px 14px); }
.se-node-hit {
  position: absolute;
  width: var(--node-size);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: transparent;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.se-node-hit::after {
  content: "";
  width: min(70%, var(--star-core));
  aspect-ratio: 1;
  border-radius: 50%;
  border: clamp(3px, .55vw, 8px) solid #94a3b8;
  background: #e2e8f0;
  pointer-events: none;
}
.se-node-hit.is-current::after { background: #fbbf24; border-color: #fff1b5; box-shadow: 0 0 10px #fbc941; }
.se-node-hit.is-reachable::after { background: #38bdf8; border-color: #c5f4ff; }
.se-node-hit.is-hint::after { background: #f472b6; border-color: #ffe4f3; }

/* MODALS */
.se-modal-card { width: 100%; max-width: 440px; background: #1e293b; border: 1.5px solid #64748b; border-radius: 22px; padding: 24px; box-shadow: 0 20px 50px rgba(2,6,23,0.6); color: #f8fafc; }
.se-modal-card h2 { margin: 0 0 12px; font-size: 1.35rem; font-weight: 900; color: #fde68a; }
.se-result-card, .se-qr-card { text-align: center; }
.se-result-stars { font-size: 2.4rem; margin-bottom: 6px; }
.se-result-sub, .se-qr-desc { margin: 0 0 18px; color: #e2e8f0; font-size: 0.96rem; line-height: 1.5; font-weight: 600; }
.se-result-actions, .se-qr-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.se-help-list { margin: 0 0 18px; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; line-height: 1.55; color: #e2e8f0; }
.se-help-list strong { color: #fde68a; }
.se-qr-img { width: 220px; height: 220px; margin: 0 auto 16px; display: block; border-radius: 14px; border: 2px solid #fbbf24; background: #ffffff; padding: 6px; }

@media (max-width: 780px) {
  .se-hero { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .se-tier-tabs { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.se-body { --scene-focus: #fdf0a0; }
.se-play { display: grid; gap: clamp(12px, 1.15vw, 17px); }
.scene-game .se-topbar { background: transparent; border-color: transparent; padding: 0; }
.se-brand-title { font-size: clamp(17px, 2.2vw, 33px); text-shadow: 0 2px 5px #020632; }
.se-play .se-hud {
  background: #191e56f5;
  border: 2px solid #7191d1;
  border-radius: 28px;
  min-height: clamp(60px, 5.8vw, 82px);
  padding-inline: clamp(12px, 1.7vw, 25px);
}
.se-play .se-hud-title > strong { font-size: clamp(15px, 1.7vw, 25px); }
.se-play .se-stat-pill { font-size: clamp(14px, 1.35vw, 19px); border-radius: 999px; }
.se-play .se-stat-pill strong { font-size: clamp(16px, 1.85vw, 26px); }
.se-play .se-story-bar {
  width: min(100%, 1040px);
  justify-self: center;
  background: #211f57f5;
  padding-block: clamp(10px, 1.05vw, 15px);
  border-color: #464286;
  border-radius: 999px;
  font-size: clamp(15px, 1.7vw, 25px);
}
.se-play .se-story-bar.is-hint { background: #422006; border-color: #fbbf24; }
.se-play .se-story-bar.is-stuck { background: #450a0a; border-color: #f87171; }
.se-play .se-sky-wrap {
  background: none;
  border: 0;
  padding: 0;
  box-shadow: none;
  touch-action: auto;
  --sky-size: min(50vw, 72vh, 720px);
  margin-top: calc(var(--sky-size) * -.17);
}
.se-play .se-board {
  --star-core: clamp(20px, 4vw, 50px);
  width: var(--sky-size);
  max-width: 100%;
  touch-action: none;
  transform: translateX(-1.1vw);
}
@media (max-aspect-ratio: 5/4), (max-width: 768px) {
  .se-play .se-sky-wrap { --sky-size: min(100%, 650px); margin-top: 0; }
  .se-play .se-board { transform: none; }
  .scene-game .se-art { object-position: 20% center; }
}

/* Keep the board stationary while feedback changes during a drag. */
.se-play .se-story-bar { display: grid; align-content: center; min-height: 60px; line-height: 1.35; }
@media (max-width: 600px) {
  .se-play .se-story-bar { min-height: 70px; }
}

.se-node-hit::after {
  border: 0;
  background: #94a3b8 url("../images/star-token.0559c8173140.webp") center / contain no-repeat;
}
.se-node-hit.is-current::after { filter: sepia(1) saturate(4); }
.se-node-hit.is-reachable::after { filter: sepia(1) saturate(3.6) hue-rotate(143deg); }
.se-node-hit.is-hint::after { filter: sepia(1) saturate(4) hue-rotate(260deg); }

.se-edge-base { background: none; display: flex; gap: clamp(2px, .45vw, 6px); }
.se-edge-base span { flex: 1 1 0; border-radius: 999px; background: #91a3c2ae; }
.se-play .se-story-bar:not(.is-hint, .is-stuck) {
  background: linear-gradient(90deg, transparent, #f8cf90af, transparent) center top / 70% 1px no-repeat, #211f57;
}
@media (min-width: 901px) and (min-aspect-ratio: 5/4) {
  .se-play .se-hud-actions button { font-size: 1rem; }
}
