:root {
  --navy: #12142B;
  --navy-2: #1C1F42;
  --navy-3: #262A54;
  --gold: #D4AF37;
  --gold-bright: #F1CE6B;
  --ruby: #9A2F3D;
  --parchment: #EFE6CB;
  --parchment-dim: #D9CCA0;
  --emerald: #2E6B52;
  --ink: #201533;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% -10%, #262a54 0%, #14162e 45%, #0d0e20 100%);
  color: var(--parchment);
  font-family: 'Noto Sans KR', sans-serif;
  overflow-x: hidden;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.site-footer {
  margin-top: auto;
  padding: 18px 16px;
  text-align: center;
  border-top: 1px solid rgba(212, 175, 55, 0.18);
}

.site-footer-credit {
  font-size: 12px;
  color: var(--parchment-dim);
  text-decoration: none;
  letter-spacing: 0.3px;
  transition: color 0.2s ease;
}

.site-footer-credit:hover {
  color: var(--gold-bright);
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

/* ---------- Topbar Nav ---------- */
.topbar-wrap {
  padding: 12px 10px 0;
  display: flex;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 90;
}

/* Desktop: topbar-top-row is inline (flex-row) inside the horizontal topbar */
.topbar-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar {
  width: 100%;
  max-width: 980px;
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 999px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04);
  gap: 8px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}
.logo:hover {
  transform: scale(1.04);
}

.logo-crest {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  animation: logoGlow 3s infinite alternate;
}
@keyframes logoGlow {
  0% { filter: drop-shadow(0 0 2px var(--gold)); }
  100% { filter: drop-shadow(0 0 8px var(--gold-bright)); }
}

.topbar-icon {
  font-size: 11px;
  display: inline-block;
  vertical-align: -1px;
  margin-right: 2px;
}

.logo-text {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding: 2px 4px;
  flex: 1;
  justify-content: center;
}
.topbar-nav::-webkit-scrollbar { height: 4px; }
.topbar-nav::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.4); border-radius: 999px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.nav-tab-btn {
  border: none;
  background: transparent;
  color: var(--parchment-dim);
  font-weight: 600;
  font-size: 12px;
  padding: 5px 9px;
  border-radius: 999px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}
.nav-tab-btn:hover {
  color: var(--parchment);
  background: rgba(239, 230, 202, 0.12);
  transform: translateY(-1px);
}
.nav-tab-btn.active {
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(212,175,55,0.35);
}

.nav-btn, .login-btn, .text-btn, .ghost-btn {
  border: none;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 12px;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.login-btn {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(212,175,55,0.3);
}
.login-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }

.text-btn {
  background: transparent;
  color: var(--parchment-dim);
  padding: 5px 6px;
}
.text-btn:hover { color: var(--gold-bright); }

.user-chip-wrap {
  position: relative;
  display: inline-flex;
}

.user-chip {
  font-size: 12px;
  font-weight: 600;
  color: var(--gold-bright);
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  background: transparent;
  border: none;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.user-chip:hover { color: var(--parchment); background: rgba(212,175,55,0.12); }

.user-chip-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: linear-gradient(180deg, var(--navy-3), var(--navy-2));
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  z-index: 95;
}
.user-chip-dropdown-label {
  font-size: 11px;
  color: var(--parchment-dim);
  margin-bottom: 3px;
}
.user-chip-dropdown-id {
  font-size: 13px;
  font-weight: 700;
  color: var(--parchment);
  word-break: break-all;
}

/* ---------- Stage & Button Empire Animations ---------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 14px 40px;
}

.view {
  display: block;
  width: 100%;
  max-width: 680px;
  animation: viewFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}
/* Ensure hidden views are truly hidden, overriding any display:flex on specific views */
.view[hidden] {
  display: none !important;
  animation: none !important;
}
@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(10px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Landing View */
#landingView {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.hero-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  animation: pulseBadge 2.5s infinite alternate;
}
@keyframes pulseBadge {
  0% { box-shadow: 0 0 4px rgba(212,175,55,0.2); }
  100% { box-shadow: 0 0 14px rgba(241,206,106,0.6); }
}

.hero-title {
  font-family: 'Cinzel', 'Noto Serif KR', serif;
  font-size: clamp(32px, 7vw, 52px);
  font-weight: 900;
  margin: 0;
  color: var(--parchment);
  line-height: 1.2;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.3);
}
.hero-title span {
  display: block;
  color: var(--gold-bright);
  font-size: clamp(18px, 4.2vw, 32px);
  white-space: nowrap;
  margin-top: 8px;
}

.hero-subtitle {
  font-size: clamp(14px, 3.2vw, 16px);
  color: var(--parchment-dim);
  max-width: 520px;
  margin: 0;
  line-height: 1.6;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.hero-primary-btn {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  box-shadow: 0 6px 20px rgba(212,175,55,0.4);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), filter 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.hero-primary-btn::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: rotate(30deg) translateY(-100%);
  transition: transform 0.6s ease;
}
.hero-primary-btn:hover::after {
  transform: rotate(30deg) translateY(100%);
}
.hero-primary-btn:hover {
  transform: translateY(-3px) scale(1.02);
  filter: brightness(1.1);
  box-shadow: 0 10px 28px rgba(241,206,106,0.6);
}

.hero-secondary-btn {
  background: rgba(239, 230, 202, 0.08);
  border: 1px solid rgba(212,175,55,0.4);
  color: var(--parchment);
  font-size: 15px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 999px;
  transition: all 0.2s ease;
}
.hero-secondary-btn:hover {
  background: rgba(239, 230, 202, 0.18);
  transform: translateY(-2px);
  border-color: var(--gold-bright);
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  width: 100%;
  margin-top: 16px;
}

.feature-card {
  background: rgba(28, 31, 66, 0.6);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 16px;
  padding: 18px;
  text-align: left;
  backdrop-filter: blur(8px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-bright);
  box-shadow: 0 10px 24px rgba(0,0,0,0.4);
}
.feature-icon {
  font-size: 26px;
  margin-bottom: 6px;
}
.feature-title {
  font-family: 'Noto Serif KR', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--gold-bright);
  margin: 0 0 6px;
}
.feature-desc {
  font-size: 12px;
  color: var(--parchment-dim);
  margin: 0;
  line-height: 1.5;
}

/* Clicker View */
#clickerView {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}

.tier-label {
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--gold-bright);
  text-transform: uppercase;
  margin: 0;
}

.title-tag-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(212, 175, 55, 0.2);
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  margin-bottom: 4px;
}

.click-count {
  font-family: 'Noto Serif KR', serif;
  font-weight: 900;
  font-size: clamp(48px, 14vw, 84px);
  margin: 0 0 4px;
  color: var(--parchment);
  text-shadow: 0 0 24px rgba(212, 175, 55, 0.35);
  line-height: 1;
}

.cps-rate {
  font-size: 14px;
  color: var(--parchment-dim);
  margin-bottom: 12px;
}

/* Seal Button with Dynamic Equipped Aura Effects */
.seal-btn {
  position: relative;
  width: clamp(180px, 50vw, 240px);
  height: clamp(180px, 50vw, 240px);
  border-radius: 50%;
  border: var(--border-w, 0px) solid var(--border-c, transparent);
  background: radial-gradient(circle at 50% 50%, var(--core1, #55504a), var(--core2, #33302b) 65%, #232019 100%);
  box-shadow:
    0 10px 28px rgba(0,0,0,0.5),
    inset 0 0 26px rgba(0,0,0,0.25),
    0 0 calc(var(--glow, 0) * 60px) rgba(241, 206, 106, var(--glow, 0));
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s cubic-bezier(0.16, 1, 0.3, 1), background 0.4s ease, border 0.4s ease, box-shadow 0.4s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: visible;
}
.seal-btn:active { transform: scale(0.92); }

/* Aura Effect Overlays */
.seal-btn.effect-aura-dragon {
  box-shadow: 0 0 35px #f1ce6b, inset 0 0 20px #ff9d00;
  animation: auraPulseDragon 2s infinite alternate;
}
@keyframes auraPulseDragon {
  from { filter: drop-shadow(0 0 10px #f1ce6b); }
  to { filter: drop-shadow(0 0 28px #ff4500); }
}

.seal-btn.effect-aura-lightning {
  box-shadow: 0 0 35px #00d2ff, inset 0 0 20px #0072ff;
  animation: auraPulseLightning 0.3s infinite alternate;
}
@keyframes auraPulseLightning {
  from { filter: drop-shadow(0 0 10px #00d2ff); }
  to { filter: drop-shadow(0 0 30px #ffffff); }
}

.seal-btn.effect-aura-galaxy {
  box-shadow: 0 0 40px #c48ef5, inset 0 0 25px #6b11ff;
  animation: auraPulseGalaxy 3s infinite linear;
}
@keyframes auraPulseGalaxy {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.seal-btn.effect-aura-hellfire {
  box-shadow: 0 0 45px #ff2a00, inset 0 0 30px #800000;
  animation: auraPulseHellfire 1s infinite alternate;
}
@keyframes auraPulseHellfire {
  from { filter: drop-shadow(0 0 15px #ff2a00); }
  to { filter: drop-shadow(0 0 35px #ff8800); }
}

.seal-ring circle { fill: none; stroke: var(--gold-bright); }
.seal-ring .ring-mid { stroke-width: 1.5; }
.seal-ring .ring-in { stroke-width: 1; }

.seal-crest path { fill: none; stroke: var(--gold-bright); stroke-width: 2; }
.seal-crest .crest-diamond-1,
.seal-crest .crest-diamond-2 { fill: var(--gold-bright); stroke: none; }

.seal-crest { transform-origin: 50% 50%; }
@keyframes crestPop {
  0%   { transform: scale(0.2) rotate(-8deg); }
  55%  { transform: scale(1.25) rotate(3deg); }
  75%  { transform: scale(0.92) rotate(-1deg); }
  100% { transform: scale(1) rotate(0deg); }
}
.seal-crest.pop { animation: crestPop 0.55s cubic-bezier(.34,1.56,.64,1); }

.seal-gems { position: absolute; inset: 0; }
.seal-gems .gem {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.4s ease, transform 0.4s ease;
  box-shadow: 0 0 6px currentColor;
}
.seal-gems .gem.g1 { top: 8%; left: 50%; margin-left: -4px; color: #7fd3e8; background: #7fd3e8; }
.seal-gems .gem.g2 { top: 50%; right: 6%; margin-top: -4px; color: #e87f9a; background: #e87f9a; }
.seal-gems .gem.g3 { bottom: 8%; left: 50%; margin-left: -4px; color: #9be87f; background: #9be87f; }
.seal-gems .gem.g4 { top: 50%; left: 6%; margin-top: -4px; color: #d69be8; background: #d69be8; }
.seal-gems .gem.visible { opacity: 1; transform: scale(1); }

.seal-crown {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%) scale(0.5);
  font-size: 26px;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  filter: drop-shadow(0 0 6px rgba(241,206,106,0.7));
}
.seal-crown.visible { opacity: 1; transform: translateX(-50%) scale(1); }

.seal-sparkles { position: absolute; inset: -10%; }
.seal-sparkles.active::before,
.seal-sparkles.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(241,206,106,0.35);
  animation: sparkleSpin 6s linear infinite;
}
.seal-sparkles.active::after {
  animation-duration: 9s;
  animation-direction: reverse;
  inset: 6%;
  border-color: rgba(241,206,106,0.2);
}
@keyframes sparkleSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.seal-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

.hint {
  color: var(--parchment-dim);
  font-size: 13px;
  margin: 10px 0 0;
}

.guest-banner {
  margin-top: 22px;
  background: rgba(239, 230, 202, 0.06);
  border: 1px dashed rgba(212, 175, 55, 0.4);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.guest-banner p { margin: 0; font-size: 13px; color: var(--parchment-dim); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
}
.ghost-btn:hover { background: rgba(212,175,55,0.12); }

/* Emoji Rain Effect */
#emojiRain {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.emoji-drop {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  font-size: 20px;
  opacity: 0.6;
  will-change: transform, opacity;
}

/* Floating Particles */
.particle {
  position: fixed;
  pointer-events: none;
  font-size: 18px;
  color: var(--gold-bright);
  z-index: 50;
  animation: floatUp 0.8s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity: 1; transform: translate(0,0) scale(1); }
  100% { opacity: 0; transform: translate(var(--dx), -70px) scale(0.6); }
}

[hidden] { display: none !important; }

/* Glitch Animation Effects for Infinite / Beyond Max Tier */
@keyframes glitchTextAnim {
  0% { transform: translate(0); text-shadow: -2px 0 #ff0055, 2px 0 #00ffff; }
  20% { transform: translate(-3px, 2px); text-shadow: 2px -2px #ff0055, -2px 2px #00ffff; }
  40% { transform: translate(-1px, -2px); text-shadow: -2px 2px #ff0055, 2px -2px #00ffff; }
  60% { transform: translate(3px, 1px); text-shadow: 2px 0 #ff0055, -2px 0 #00ffff; }
  80% { transform: translate(1px, -1px); text-shadow: -1px -2px #ff0055, 1px 2px #00ffff; }
  100% { transform: translate(0); text-shadow: -2px 0 #ff0055, 2px 0 #00ffff; }
}

@keyframes glitchSealAnim {
  0% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg) contrast(1.5); }
  20% { transform: scale(1.03) rotate(2deg); filter: hue-rotate(90deg) contrast(2); }
  40% { transform: scale(0.97) rotate(-2deg); filter: hue-rotate(180deg) contrast(2.5); }
  60% { transform: scale(1.02) rotate(1deg); filter: hue-rotate(270deg) contrast(2); }
  80% { transform: scale(0.98) rotate(-1deg); filter: hue-rotate(360deg) contrast(1.5); }
  100% { transform: scale(1) rotate(0deg); filter: hue-rotate(0deg) contrast(1.5); }
}

.glitch-text {
  animation: glitchTextAnim 0.3s infinite linear alternate-reverse;
  color: #ff0055 !important;
  font-family: monospace;
}

/* [FIX] 숫자(클릭 카운트)는 지직거림/색분리 애니메이션을 빼서 숫자를 읽기 쉽게 유지.
   숫자 ↔ ∞ 전환 자체(js/app.js renderClickerView)는 그대로 유지된다. */
.glitch-number {
  color: #ff0055 !important;
  font-family: monospace;
}

.glitch-seal {
  animation: glitchSealAnim 0.25s infinite ease-in-out alternate !important;
}

/* ── Responsive Topbar: wrap to two rows on small screens ── */
@media (max-width: 700px) {
  .topbar-wrap { padding: 6px 6px 0; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    border-radius: 20px;
    padding: 8px 10px;
    gap: 6px;
  }

  /* Top row: logo + account chip */
  .topbar > .logo,
  .topbar > .topbar-actions {
    /* These are siblings inside .topbar; wrap them in a row */
  }

  /* We need the logo & actions in one flex row */
  .topbar-top-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  /* Nav buttons row: wrap to multiple lines */
  .topbar-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
    gap: 4px;
    padding: 0;
    width: 100%;
    flex: unset;
  }

  .nav-tab-btn {
    font-size: 11px;
    padding: 5px 9px;
    letter-spacing: -0.2px;
    flex-shrink: 0;
  }

  .logo-text { font-size: 12px; }

  .user-chip, .login-btn {
    font-size: 11px;
    padding: 4px 9px;
  }

  .hero-title span { font-size: 18px; white-space: normal; }
}

@media (max-width: 400px) {
  .topbar { border-radius: 16px; padding: 6px 8px; }
  .nav-tab-btn { font-size: 10px; padding: 4px 7px; }
  .logo-text { display: none; }
}

/* Shooter canvas: responsive height on mobile */
@media (max-width: 600px) {
  #shooterCanvasContainer {
    height: 280px !important;
  }
  #shooterCanvas {
    height: 280px !important;
  }
}
