@import url('https://fonts.googleapis.com/css2?family=Jua&family=Press+Start+2P&family=Noto+Sans+KR:wght@400;500;700;900&display=swap');

:root {
  /* purple~pink pixel palette */
  --ink: #140a2b;
  --ink-deep: #0c0620;
  --card: #1f1142;
  --card-light: #2a1856;
  --purple: #7b2ff7;
  --purple-dark: #4f1aa8;
  --pink: #ff3ea8;
  --pink-dark: #b81d74;
  --cyan: #3de8e0;
  --gold: #ffd23f;
  --ok: #3ddc97;
  --danger: #ff4d6d;
  --paper: #f6eeff;
  --muted: #a797cf;
  --outline: #2a0f4a;
  --radius: 16px;
  --max-w: 480px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ink-deep);
  color: var(--paper);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
  overflow-wrap: break-word;
  overflow-x: hidden;
}

#app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--ink);
  box-shadow: 0 0 60px rgba(0,0,0,0.6);
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}
.screen.hidden { display: none; }
.hidden { display: none !important; }

.pixel-tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  letter-spacing: 1px;
}

/* ---------------- CHUNKY PANEL (rounded candy-pixel card) ---------------- */
.chunky-panel {
  position: relative;
  background: var(--card);
  border: 4px solid var(--pink);
  border-radius: 22px;
  box-shadow:
    inset 0 -6px 0 rgba(0,0,0,0.25),
    5px 5px 0 var(--purple-dark);
}

/* ---------------- BUTTONS (rounded candy-pixel UI) ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  border: 4px solid var(--outline);
  border-radius: 16px;
  padding: 14px 28px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .1s ease, box-shadow .1s ease, filter .1s ease;
  width: 100%;
}
.btn:active { transform: translate(4px, 4px); }

.btn-primary {
  background: var(--pink);
  color: #fff;
  box-shadow:
    inset 0 -5px 0 rgba(0,0,0,0.22),
    4px 4px 0 var(--purple-dark);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active {
  box-shadow: inset 0 -5px 0 rgba(0,0,0,0.22);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 2.5px solid rgba(167,151,207,0.4);
  margin-top: 10px;
  box-shadow: none;
}
.btn-ghost:active { transform: translate(1px, 1px); }
.btn-ghost:hover { border-color: var(--cyan); color: var(--paper); }

/* ---------------- INTRO (pixel arcade, purple~pink) ---------------- */
#screen-intro {
  padding-bottom: 40px;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,62,168,0.35), transparent 45%),
    radial-gradient(circle at 85% 20%, rgba(61,232,224,0.22), transparent 40%),
    linear-gradient(180deg, #1b0e3d 0%, #140a2b 55%, #0c0620 100%);
  position: relative;
  overflow: hidden;
}

.intro-sky {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.sun {
  position: absolute;
  left: 50%;
  bottom: 160px;
  transform: translateX(-50%);
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe17d 0%, #ff8a5c 38%, #ff3ea8 72%, #b81d74 100%);
  box-shadow: 0 0 70px rgba(255,138,92,0.45);
  opacity: 0.8;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.sun::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 9px,
    var(--ink) 9px 15px
  );
  clip-path: inset(52% 0 0 0);
}

.skyline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 160px;
  height: 64px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 6%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.9;
}
.building {
  display: block;
  width: 11%;
  background: #190c35;
  border-top: 2px solid rgba(61,232,224,0.5);
  position: relative;
}
.building::after {
  content: "";
  position: absolute;
  top: 35%;
  left: 35%;
  width: 3px;
  height: 3px;
  background: var(--gold);
  box-shadow:
    9px 5px var(--gold),
    2px 14px var(--cyan),
    11px 15px var(--gold);
  opacity: 0.85;
}
.b1 { height: 32px; }
.b2 { height: 50px; }
.b3 { height: 26px; }
.b4 { height: 58px; }
.b5 { height: 38px; }
.b6 { height: 46px; }
.b7 { height: 30px; }

.pixel-floor {
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -10px;
  height: 220px;
  background-image:
    linear-gradient(rgba(61,232,224,0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,62,168,0.3) 1px, transparent 1px);
  background-size: 30px 30px;
  transform: perspective(260px) rotateX(58deg);
  transform-origin: bottom;
  mask-image: linear-gradient(to top, black 30%, transparent);
  -webkit-mask-image: linear-gradient(to top, black 30%, transparent);
  opacity: 0.8;
}

.floatie {
  position: absolute;
  font-size: 1.6rem;
  opacity: 0.9;
  filter: drop-shadow(0 3px 6px rgba(0,0,0,0.35));
  animation: bob 4.5s ease-in-out infinite;
}
.f1 { top: 6%;  left: 8%;  font-size: 1.9rem; animation-delay: 0s; }
.f2 { top: 13%; left: 80%; animation-delay: 0.6s; }
.f3 { top: 30%; left: 5%;  animation-delay: 1.1s; }
.f4 { top: 5%;  left: 48%; animation-delay: 1.6s; }
.f5 { top: 24%; left: 86%; font-size: 1.7rem; animation-delay: 0.3s; }
.f6 { top: 44%; left: 12%; animation-delay: 2s; }
.f7 { top: 37%; left: 72%; animation-delay: 1.4s; }
.f8 { top: 9%;  left: 28%; animation-delay: 0.9s; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-14px) rotate(6deg); }
}

.intro-content {
  position: relative;
  z-index: 1;
  padding: 26px 22px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.biff-logo {
  height: 20px;
  object-fit: contain;
  margin-bottom: 14px;
  background: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px var(--pink), 3px 3px 0 var(--purple-dark);
}

.badge-wrap {
  margin: 6px 0 18px;
  animation: wiggle 3.5s ease-in-out infinite;
}
.wordmark-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 22px;
}
.wordmark-line1 {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.15rem;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 var(--purple-dark);
}
.wordmark-line2 {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  color: var(--gold);
  letter-spacing: 2px;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-1.5deg); }
  50% { transform: rotate(1.5deg) translateY(-4px); }
}

.game-title {
  font-family: 'Jua', 'Noto Sans KR', sans-serif;
  font-size: 3.2rem;
  margin: 4px 0 0;
  letter-spacing: 1px;
  color: #fff;
  text-shadow:
    0 4px 0 var(--pink-dark),
    0 8px 16px rgba(0,0,0,0.28);
  animation: pop-title 0.6s ease;
}
.game-title .dot { color: var(--gold); }

@keyframes pop-title {
  from { transform: scale(0.8) rotate(-3deg); opacity: 0; }
  to { transform: scale(1) rotate(0); opacity: 1; }
}

.game-sub {
  margin: 14px 0 20px;
  color: var(--paper);
  opacity: 0.9;
  font-size: 0.92rem;
  font-weight: 500;
}

.concept-strip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
}
.concept-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.filmstrip {
  position: relative;
  display: flex;
  gap: 6px;
  background: var(--ink-deep);
  border: 3px solid var(--gold);
  border-radius: 6px;
  padding: 9px 10px;
}
.filmstrip::before,
.filmstrip::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  height: 5px;
  background-image: repeating-linear-gradient(90deg, var(--gold) 0 5px, transparent 5px 11px);
}
.filmstrip::before { top: -4px; }
.filmstrip::after { bottom: -4px; }
.frame {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 2px solid rgba(255,255,255,0.18);
  border-radius: 4px;
  font-size: 1.15rem;
}
.concept-arrow {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.1rem;
  color: var(--cyan);
}
.concept-answer {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--pink);
  border: 3px solid #fff;
  border-radius: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 1.05rem;
  color: #fff;
  box-shadow: 3px 3px 0 var(--purple-dark);
  animation: wiggle 2.4s ease-in-out infinite;
}
.concept-caption {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
}

.card-wrap { width: 100%; }
.rules-card {
  padding: 26px 20px 18px;
  text-align: left;
}
.rules-card h2 {
  margin: 0 0 14px;
  font-size: 1.1rem;
  color: var(--cyan);
  font-weight: 800;
}
.rules-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #ddd0ff;
}
.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  word-break: keep-all;
}
.rules-list li > .rule-text {
  flex: 1;
  min-width: 0;
}
.rule-emoji {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1.5;
}
.rules-card strong { color: var(--gold); }
.rules-note {
  margin: 16px 0 0;
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px dashed rgba(167,151,207,0.3);
  padding-top: 10px;
}

.btn-start {
  margin-top: 24px;
  font-size: 1.02rem;
}

#screen-intro .btn-ghost {
  color: var(--paper);
  border-color: rgba(246,238,255,0.4);
}
#screen-intro .btn-ghost:hover {
  border-color: var(--cyan);
  color: #fff;
  background: rgba(61,232,224,0.1);
}

/* ---------------- GAME ---------------- */
#screen-game {
  background: linear-gradient(180deg, #1b0e3d 0%, #140a2b 100%);
}
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 10px;
}
.header-logo {
  height: 18px;
  object-fit: contain;
  background: #fff;
  padding: 5px 10px;
  border-radius: 999px;
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}
.score-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.55rem;
  color: var(--muted);
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.score-label-icon { font-size: 0.85rem; }
.score-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.2rem;
  font-weight: 400;
  color: var(--gold);
  margin-top: 4px;
}

.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 22px 40px;
  text-align: center;
}

.section-tag {
  display: inline-block;
  background: rgba(255,62,168,0.18);
  color: #ff9fd0;
  border: 2px solid var(--pink);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 26px;
}

.emoji-wrap {
  width: 100%;
  animation: pop-in 0.25s ease;
}
.emoji-stage {
  font-size: 3rem;
  line-height: 1.3;
  letter-spacing: 0.08em;
  word-break: keep-all;
  padding: 36px 20px;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.question-sub {
  margin: 20px 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.choice-btn {
  width: 100%;
  background: var(--card-light);
  color: var(--paper);
  border: 3px solid rgba(61,232,224,0.4);
  border-radius: 14px;
  box-shadow: inset 0 -4px 0 rgba(0,0,0,0.2);
  padding: 16px 18px;
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.12s ease;
}
.choice-btn:active { transform: translate(2px, 2px); box-shadow: none; }
.choice-btn.correct {
  background: rgba(61,220,151,0.2);
  border-color: var(--ok);
  color: #baffdf;
}
.choice-btn.wrong {
  background: rgba(255,77,109,0.22);
  border-color: var(--danger);
  color: #ffc4cf;
}
.choice-btn:disabled { cursor: default; }

/* ---------------- GAME OVER ---------------- */
#screen-over {
  justify-content: center;
  background: linear-gradient(180deg, #1b0e3d 0%, #140a2b 100%);
}
.over-content {
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.over-stamp {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1.1rem;
  color: var(--muted);
  margin: 0 0 4px;
}
.over-title {
  font-family: 'Jua', sans-serif;
  font-size: 2.4rem;
  margin: 0 0 14px;
  color: var(--danger);
  text-shadow: 3px 3px 0 var(--purple-dark);
}
.over-answer {
  color: var(--paper);
  font-size: 0.95rem;
  margin: 0 0 24px;
  line-height: 1.5;
}
.over-answer strong { color: var(--gold); }

.final-score-card {
  padding: 20px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.final-score-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 1px;
}
.final-score-value {
  font-family: 'Press Start 2P', monospace;
  font-size: 2.1rem;
  font-weight: 400;
  color: var(--gold);
  margin-top: 10px;
}

.register-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 6px;
}
.register-form input {
  width: 100%;
  background: var(--card-light);
  border: 3px solid rgba(61,232,224,0.4);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--paper);
  font-size: 0.95rem;
  font-family: inherit;
}
.register-form input::placeholder { color: var(--muted); }
.register-form input:focus { outline: none; border-color: var(--cyan); }

.over-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
}
.over-actions .btn { margin-top: 0; }

/* ---------------- LEADERBOARD ---------------- */
#screen-board {
  justify-content: flex-start;
  background: linear-gradient(180deg, #1b0e3d 0%, #140a2b 100%);
}
.board-content {
  padding: 36px 22px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.board-title {
  font-family: 'Jua', sans-serif;
  font-size: 1.9rem;
  margin: 0 0 20px;
  text-shadow: 2px 2px 0 var(--purple-dark);
}
.score-wrap { margin-bottom: 28px; }

.board-list {
  width: 100%;
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 2.5px solid rgba(61,232,224,0.3);
  border-radius: 14px;
  padding: 12px 16px;
}
.board-row.me { border: 2.5px solid var(--gold); }
.board-rank {
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--muted);
  width: 1.8em;
  text-align: center;
  flex-shrink: 0;
}
.board-row:nth-child(-n+3) .board-rank { color: var(--gold); }
.board-info { flex: 1; min-width: 0; }
.board-nick {
  font-weight: 700;
  font-size: 0.92rem;
  display: block;
}
.board-msg {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-score {
  font-family: 'Press Start 2P', monospace;
  font-weight: 400;
  color: var(--gold);
  font-size: 0.95rem;
  flex-shrink: 0;
}

#board-empty-wrap { margin-bottom: 20px; }
.board-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #ddd0ff;
  font-size: 0.88rem;
  line-height: 1.5;
  text-align: center;
  padding: 26px 20px;
}
.board-empty-icon { font-size: 1.8rem; }

.share-box {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 20px;
}

.section-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 16px;
}
.section-divider-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 0.62rem;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 2px 2px 0 var(--purple-dark);
}

.share-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.share-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--card-light);
  border: 3px solid rgba(61,232,224,0.35);
  border-radius: 14px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.2);
  padding: 14px 8px;
  color: var(--paper);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform .1s ease, border-color .15s ease;
}
.share-chip:active { transform: translate(2px, 2px); }
.share-chip-icon {
  font-size: 1.3rem;
  line-height: 1;
}
#share-x:hover { border-color: #fff; }
#share-ig:hover, #share-ig-story:hover { border-color: var(--pink); }
#share-naver:hover { border-color: var(--ok); }

.share-hint {
  min-height: 1em;
  margin: 0;
  text-align: center;
  font-size: 0.74rem;
  color: var(--ink-deep);
}
.share-hint:not(:empty) {
  background: var(--cyan);
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 14px;
  font-weight: 700;
}

.credit {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
  margin: 8px 0 0;
  opacity: 0.6;
}

@media (min-width: 480px) {
  #app { border-radius: 24px; margin: 20px auto; min-height: calc(100vh - 40px); }
}

.board-notice {
  margin: -6px 0 14px;
  font-size: 0.78rem;
  color: var(--cyan);
  text-align: center;
}
