/* Base styles for SB_Star_MatchTest */
:root {
  --bg: #0b0f1a;
  --fg: #f2f5f9;
  --muted: #9aa6b2;
  --accent: #7aa2ff;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Pretendard", system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, Arial, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* Quiz pages background */
body.quiz-mode {
  background: var(--bg);
}

#app {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.container {
  width: min(420px, 94vw);
}

.hidden { display: none; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--accent);
  color: #0b0f1a;
  font-weight: 700;
  border: none;
  cursor: pointer;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Start screen layout */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px 0;
  width: 100%;
}

.topbar .left,
.topbar .center,
.topbar .right { display: flex; align-items: center; }
.topbar .left { justify-content: flex-start; }
.topbar .center { justify-content: center; }
.topbar .right { justify-content: flex-end; gap: 8px; }

.logo {
  height: 30px;
  object-fit: contain;
}
.logo.product { height: 36px; }

.start-screen {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 90px);
  overflow: hidden;
  border-radius: 16px;
}

.start-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/bg.jpg') center / cover no-repeat;
  filter: none;
  transform: none;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: block;
  /* No gradient - removed for cleaner look */
  background: none;
  pointer-events: none;
}

/* Quiz screen background inside container */
.quiz-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/bg-quiz.jpg') center / cover no-repeat;
  z-index: 0;
}

/* Use different background on results */
.quiz-complete .quiz-bg {
  background-image: url('../assets/bg-result1.jpg');
}

/* Game screen styles */
.game-screen {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  overflow: hidden;
}

.game-bg {
  position: absolute;
  inset: 0;
  background: url('../assets/bg-quiz.jpg') center / cover no-repeat;
  z-index: 0;
}

.game-screen > *:not(.game-bg):not(.game-ready-overlay) {
  position: relative;
  z-index: 1;
}

.game-canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 15, 26, 0.7);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

#gameCanvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
  background: #0b0f1a;
  image-rendering: auto;
  image-rendering: -webkit-optimize-contrast;
}

.game-ready-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 1000;
  transition: opacity 0.5s ease-out;
}

/* Game info below canvas */
.game-info {
  margin-top: 16px;
  text-align: center;
  max-width: 800px;
  width: 100%;
}

.game-info-control {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
  white-space: pre-line; /* Enable \n line breaks */
}

.game-info-goal {
  font-size: 0.95rem;
  color: var(--fg);
  line-height: 1.5;
  white-space: pre-line; /* Enable \n line breaks */
}

/* Countdown number */
.countdown-number {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 9.6rem; /* 80% of 12rem */
  font-weight: 900;
  color: #FFD700;
  text-shadow: 
    0 0 30px rgba(255, 215, 0, 0.8),
    0 0 60px rgba(255, 215, 0, 0.5),
    0 5px 10px rgba(0, 0, 0, 0.5);
  z-index: 100;
}

/* Game over screen */
.game-over-screen {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start; /* allow content to grow downward */
  padding: 32px 16px 64px; /* extra bottom padding for small screens */
  border-radius: 16px;
  overflow: visible; /* allow scrolling/visible overflow instead of clipping */
}

.game-over-screen > *:not(.quiz-bg):not(.confetti-container) {
  position: relative;
  z-index: 1;
}

.game-over-title {
  font-size: clamp(2.2rem, 6vw, 3.5rem);
  font-weight: 900;
  color: #FFD700;
  margin-bottom: 32px;
  text-align: center;
  text-shadow: 
    0 0 20px rgba(255, 215, 0, 0.8),
    0 0 40px rgba(255, 215, 0, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.1em;
  animation: celebrateTitle 0.6s ease-out;
}

@keyframes celebrateTitle {
  0% {
    transform: scale(0.5) rotate(-5deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.1) rotate(2deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

.game-score-display {
  position: relative;
  background: url('../assets/img_result.jpg') center/cover no-repeat;
  border: none;
  width: 100%;
  max-width: 480px;
  min-height: 160px;
  padding: 32px 40px;
  border-radius: 20px;
  margin: 0 auto 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  animation: scoreAppear 0.5s ease-out 0.3s both;
}

.game-score-display > * {
  position: relative;
  z-index: 1;
}

@keyframes scoreAppear {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.score-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: #FFD700;
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.score-value {
  font-size: clamp(2.6rem, 8vw, 4rem);
  font-weight: 900;
  color: #FFD700;
  line-height: 1;
  margin: 0;
  text-shadow: 
    0 0 10px rgba(255, 215, 0, 0.5),
    0 2px 4px rgba(0, 0, 0, 0.5);
}

.name-input-section {
  width: 90%;
  max-width: 480px;
  text-align: center;
  margin-bottom: 24px;
  animation: inputAppear 0.5s ease-out 0.5s both;
}

@keyframes inputAppear {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.name-input-section label {
  display: block;
  margin-bottom: 12px;
  color: var(--fg);
  font-weight: 600;
  font-size: 1.05rem;
}

.name-input-section input {
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: 2px solid rgba(122, 162, 255, 0.3);
  background: rgba(24, 32, 48, 0.8);
  color: var(--fg);
  font-size: 1.1rem;
  margin-bottom: 16px;
  transition: all 0.3s ease;
  box-sizing: border-box; /* prevent border from causing overflow */
}

.name-input-section input:focus {
  outline: none;
  border-color: #FFD700;
  background: rgba(24, 32, 48, 0.95);
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.name-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap; /* allow wrapping on small screens */
}

.btn {
  padding: 14px 32px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #7aa2ff, #5a82df);
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(122, 162, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(122, 162, 255, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: linear-gradient(135deg, #3a4458, #2a3347);
  color: var(--fg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-secondary:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.submit-status {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--muted);
  min-height: 20px;
}

/* Game result screen */
.game-result-screen {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px;
  border-radius: 16px;
  overflow: hidden;
}

.game-result-screen > *:not(.quiz-bg) {
  position: relative;
  z-index: 1;
}

.result-title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 24px;
  text-align: center;
}

.result-score-box {
  position: relative;
  background: url('../assets/img_result.jpg') center/cover no-repeat;
  padding: 24px 32px;
  border-radius: 12px;
  margin-bottom: 24px;
  text-align: center;
  min-width: 280px;
  overflow: hidden;
  border: none;
  box-shadow: none;
}

.result-score-box > * {
  position: relative;
  z-index: 1;
}

.rank-text {
  margin-top: 12px;
  font-size: 1.2rem;
  color: var(--fg);
}

/* Rankings list */
.rankings-box {
  width: 100%;
  max-width: 500px;
  background: rgba(42, 51, 71, 0.6);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
}

.rankings-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg);
  margin-bottom: 16px;
  text-align: center;
}

.rankings-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ranking-item {
  display: grid;
  grid-template-columns: 50px 1fr 80px;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(26, 35, 50, 0.5);
  border-radius: 8px;
  margin-bottom: 8px;
  transition: background 0.2s;
}

.ranking-item:hover {
  background: rgba(26, 35, 50, 0.8);
}

.ranking-item.highlight {
  background: rgba(122, 162, 255, 0.2);
  border: 1px solid var(--accent);
}

.rank-num {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.rank-name {
  font-size: 1rem;
  color: var(--fg);
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-score {
  font-size: 1rem;
  font-weight: 600;
  color: var(--fg);
  text-align: right;
}

/* Ensure quiz content sits above background */
.quiz-screen > *:not(.quiz-bg),
.quiz-complete > *:not(.quiz-bg) {
  position: relative;
  z-index: 1;
}

.hero {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 16px 48px;
  min-height: min(720px, 72vh);
}

.hero img.hero-img {
  position: absolute;
  top: 70%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(900px, 100vw);
  height: auto;
  z-index: 0;
  pointer-events: none;
  user-select: none;
  image-rendering: -webkit-optimize-contrast;
}

.hero h2,
.hero .cta {
  position: relative;
  z-index: 1;
  text-align: center;
}

.hero .cta {
  margin-top: 16px;
  width: 100%;
  display: flex;
  justify-content: center;
}

.hero h2 {
  margin-top: 260px;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9), 0 0 32px rgba(0,0,0,0.8);
}

/* Start button emphasis */
#startBtn {
  background: #ffea00;
  color: #0b0f1a;
  font-size: 18px;
  padding: 16px 28px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  width: 82%;
}

#startBtn:hover {
  filter: brightness(0.97);
}

/* Results: style restart button like start button */
.quiz-complete #restartBtn {
  background: #ffea00;
  color: #0b0f1a;
  font-size: 18px;
  padding: 16px 28px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  width: 100%;
  white-space: nowrap;
}
.quiz-complete #restartBtn:hover { filter: brightness(0.97); }

/* Results: preorder button (KR only) same width/centered below restart */
.quiz-complete .preorder-btn,
.game-result-screen .preorder-btn,
.game-over-screen .preorder-btn {
  background: #ffea00;
  border: none;
  color: #0b0f1a;
  font-size: 18px;
  font-weight: 700;
  padding: 16px 28px;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  width: 100%;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
  transition: filter 0.2s ease;
}
.quiz-complete .cta .btn + .preorder-btn,
.quiz-complete .preorder-btn + .btn,
.game-result-screen .cta .btn + .preorder-btn,
.game-result-screen .preorder-btn + .btn,
.game-over-screen .cta .btn + .preorder-btn,
.game-over-screen .preorder-btn + .btn {
  margin-top: 12px;
}
.quiz-complete .preorder-btn:hover,
.game-result-screen .preorder-btn:hover,
.game-over-screen .preorder-btn:hover { 
  filter: brightness(0.95); 
}

.home-meta { margin-top: 0px; display: grid; gap: 8px; justify-items: center; position: relative; z-index: 1; }
.home-meta .participants {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(11, 15, 26, 0.6);
  border: 1px solid #2a3347;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}
.home-meta .participants strong { color: var(--fg); }
#loadStatus:empty { margin-top: 0 !important; }
.home-meta .participants { margin-top: 4px; }
.home-share {
  color: #ffffff;
  background: rgba(11, 15, 26, 0.15);
  border: 1px solid #2a3347;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  padding: 6px 10px;
  margin-top: 12px;
}
.home-share .btn.share { background: transparent; color: var(--fg); padding: 0; border: 0; box-shadow: none; border-radius: 0; text-decoration: underline; }
.home-share .btn[disabled] { opacity: 0.6; cursor: default; text-decoration: none; }

@media (max-width: 640px) {
  .logo { height: 24px; }
  .logo.product { height: 28px; }
  .start-screen { border-radius: 10px; }
  .hero img.hero-img { top: 58%; left: 52%; }
  .quiz-screen, .quiz-complete { border-radius: 10px; }
}

/* Mobile-first refinements */
@media (max-width: 480px) {
  .topbar { grid-template-columns: auto 1fr auto; margin: 12px 0 6px 0; }
  .container { width: 94vw; }
  .hero { padding: 24px 8px 40px; min-height: min(640px, 74vh); }
  .hero h2 { margin-top: 260px; font-size: 20px; }
  #startBtn { width: 82%; padding: 14px 18px; font-size: 16px; }
  .home-meta { gap: 6px; }
  .home-share { gap: 8px; }
  .quiz-screen, .quiz-complete { padding: 16px 6px 40px; }
  .quiz-question { font-size: 18px; }
  .quiz-scenario { font-size: 14px; }
  .quiz-options { gap: 8px; width: 96%; }
  .quiz-options .btn { padding: 14px 12px; font-size: 15px; }
  .share-row { gap: 8px; }
  .share-buttons .btn.share, .home-share .btn.share { width: 40px; height: 40px; }
  .site-footer { bottom: calc(10px + env(safe-area-inset-bottom)); }
}

/* Quiz UI */
.quiz-screen, .quiz-complete {
  position: relative;
  width: 100%;
  min-height: calc(100vh - 90px);
  padding: 24px 8px 48px;
  overflow: hidden;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.quiz-progress {
  color: var(--muted);
  margin-bottom: 12px;
}
.quiz-question {
  margin: 8px 0 16px;
  text-align: center;
  color: #ffffff;
}
.quiz-scenario {
  margin: 0 0 16px;
  color: #ffffff;
  white-space: pre-line;
  text-align: center;
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: 96%;
  margin: 0 auto;
}
.quiz-options .btn {
  background: #1f2a44;
  color: var(--fg);
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.card {
  background: #111827;
  border: 1px solid #2a3347;
  border-radius: 12px;
  overflow: hidden;
}
.card-img { width: 100%; height: auto; display: block; }
.card-body { padding: 12px; }
.card-title { margin: 0 0 6px 0; }
.card-text { margin: 0; color: var(--muted); }

.share-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  color: #ffffff;
  background: rgba(11, 15, 26, 0.15);
  border: 1px solid #2a3347;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  padding: 6px 10px;
}
.share-buttons { display: flex; gap: 8px; }
.btn.share { background: #293957; color: var(--fg); }

/* Image-like circular share buttons (home + results) */
.home-share .btn.share,
.share-buttons .btn.share {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  border: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  vertical-align: middle;
  line-height: 0; /* prevent baseline wobble */
}

/* Hide textual label while keeping accessible name from data-i18n */
.home-share .btn.share { color: transparent; font-size: 0; }
.share-buttons .btn.share { color: transparent; font-size: 0; }

/* center pseudo icons precisely */
.home-share .btn.share::after,
.share-buttons .btn.share::after { content: none; }

/* Image icons inside buttons (home buttons use inline <img>) */
.btn.share .share-icon {
  width: 31px;
  height: 31px;
  display: block;
  object-fit: contain;
}

/* Kakao */
#shareKakao { background: #FEE500; }
.share-buttons .btn.share[data-share="kakao"] {
  background: #FEE500 url('../assets/logo_kakaotalk.jpg') center / 31px 31px no-repeat;
}

/* X (Twitter) */
#shareTwitter { background: #000; }
.share-buttons .btn.share[data-share="twitter"] {
  background: #000 url('../assets/logo_x.jpg') center / 31px 31px no-repeat;
}

/* LINE */
#shareLine { background: #06C755; }
.share-buttons .btn.share[data-share="line"] {
  background: #06C755 url('../assets/logo_line.jpeg') center / 31px 31px no-repeat;
}

/* Link */
#shareLink { background: #80838a; }
#shareLink::after {
  content: '';
  width: 18px;
  height: 18px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 0 0 7.07 0l2.83-2.83a5 5 0 0 0-7.07-7.07L10 5'/><path d='M14 11a5 5 0 0 0-7.07 0L4.1 13.83a5 5 0 0 0 7.07 7.07L14 19'/></svg>") no-repeat center / contain;
}
#shareLink.copied { background: #2e7d32; }
#shareLink.copied::after { content: '✓'; color: #fff; font-size: 18px; }

/* ensure container aligns buttons evenly */
.home-share { display: flex; align-items: center; gap: 10px; }

/* Footer */
.site-footer {
  position: static;
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.footer-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  backdrop-filter: none;
  padding: 0;
  border-radius: 0;
  pointer-events: auto;
}
.footer-logo { height: 18px; }
.footer-text, .footer-copy { color: var(--muted); font-size: 12px; }
.footer-link { color: #9ac7ff; font-size: 12px; text-decoration: underline; }
.footer-link:hover { text-decoration: underline; }
.sep { color: #2f3b52; }

/* Confetti Animation */
.confetti-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 300vh;
  pointer-events: none;
  z-index: 9999 !important;
  border-radius: 16px; /* Match parent border-radius */
}

.confetti {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  opacity: 0;
  animation: confetti-fall linear forwards;
  --fall-distance: 140vh;
  --sway-distance: 0px;
  --spin-angle: 720deg;
}

@keyframes confetti-fall {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(0deg);
  }
  60% {
    opacity: 1;
    transform: translate3d(calc(var(--sway-distance) * 0.5), calc(var(--fall-distance) * 0.6), 0) rotate(calc(var(--spin-angle) * 0.6));
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--sway-distance), var(--fall-distance), 0) rotate(var(--spin-angle));
  }
}


