/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 300;
  background: #0a0a0f;
  color: #ffffff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ===== NAV ===== */
.site-nav {
  width: 100%;
  max-width: 480px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #1e1e2e;
  position: sticky;
  top: 0;
  background: rgba(10, 10, 15, 0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
}

.nav-logo {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 1px;
  color: #fff;
}

.nav-links {
  display: flex;
  gap: 16px;
}

.nav-links a {
  font-size: 13px;
  color: #888;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: #ff1801;
}

/* ===== APP CONTAINER ===== */
#app {
  width: 100%;
  max-width: 480px;
  padding: 16px;
  flex: 1;
}

/* ===== SCREENS ===== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  animation: fadeIn 0.4s ease;
}

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== AD SLOTS ===== */
.ad-slot {
  background: #111118;
  border: 1px dashed #2a2a3a;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333;
  font-size: 11px;
  letter-spacing: 1px;
}

.ad-slot::before { content: 'AD'; }

/* ===== SETUP SCREEN ===== */
.title {
  font-size: 32px;
  font-weight: 500;
  margin-top: 24px;
  letter-spacing: 2px;
}

.subtitle { color: #888; margin-top: 6px; font-size: 14px; }

.setup-panel {
  width: 100%;
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 16px;
  padding: 20px;
  margin-top: 24px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.player-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}

.player-row input {
  flex: 1;
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 9px 12px;
  color: #fff;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.player-row input:focus { border-color: #ff1801; }
.player-row input::placeholder { color: #555; }

.loss-badge {
  font-size: 11px;
  background: rgba(255, 24, 1, 0.15);
  border: 1px solid rgba(255, 24, 1, 0.3);
  color: #ff6060;
  border-radius: 8px;
  padding: 3px 7px;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-remove {
  background: none;
  border: none;
  color: #555;
  font-size: 17px;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

.btn-remove:hover { color: #ff1801; background: rgba(255, 24, 1, 0.1); }

/* ===== BUTTONS ===== */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: #ff1801;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 14px;
  transition: background 0.2s, transform 0.1s;
}

.btn-primary:hover { background: #e01500; }
.btn-primary:active { transform: scale(0.98); }

.btn-kakao { background: #fee500; color: #3c1e1e; }
.btn-kakao:hover { background: #e6ce00; }

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: #888;
  border: 1px dashed #2a2a3a;
  border-radius: 12px;
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
  transition: color 0.2s, border-color 0.2s;
}

.btn-secondary:hover { color: #fff; border-color: #555; }

/* ===== LIGHTS OUT SCREEN ===== */
#screen-lights {
  width: 100%;
  justify-content: center;
  align-items: center;
  min-height: 500px;
  position: relative;
}

.lights-loading {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 20px;
  animation: fadeIn 0.4s ease;
}

.lights-loading-text {
  color: #888;
  font-size: 14px;
  animation: pulse 1.5s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.lights-sequence {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  animation: fadeIn 0.3s ease;
}

.lights-sequence.hidden { display: none; }

#screen-lights canvas {
  width: 100%;
  border-radius: 12px;
  opacity: 0.3;
}

.lights-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  background: linear-gradient(180deg, #2c2c34, #1a1a22);
  border: 2px solid #3a3a48;
  border-radius: 16px;
  padding: 20px 28px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.85), inset 0 1px 0 rgba(255,255,255,0.05);
  z-index: 10;
}

.lights-row { display: flex; gap: 16px; }

.light {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #1a1a1a;
  border: 2px solid #3a3a3a;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.light.on {
  background: #ff1801;
  border-color: #ff4030;
  box-shadow: 0 0 14px rgba(255,24,1,0.9), 0 0 30px rgba(255,24,1,0.5), 0 0 60px rgba(255,24,1,0.2);
}

.light.off {
  background: #111;
  border-color: #2a2a2a;
  box-shadow: none;
}

.lights-text {
  position: absolute;
  bottom: 60px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 44px;
  font-weight: 500;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #00ff55;
  text-shadow:
    0 0 10px rgba(0,255,85,0.9),
    0 0 30px rgba(0,255,85,0.6),
    0 0 60px rgba(0,255,85,0.3);
  white-space: nowrap;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.1s;
}

.lights-text.visible {
  opacity: 1;
  animation: lightsOut 0.4s cubic-bezier(0.2, 0, 0.1, 1);
}

@keyframes lightsOut {
  0%  { transform: translateX(-50%) scale(0.7); opacity: 0; }
  60% { transform: translateX(-50%) scale(1.08); }
  100%{ transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ===== RACE SCREEN ===== */
#screen-race { width: 100%; }

#canvas-race { width: 100%; border-radius: 12px; display: block; }

.race-hud-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  width: 100%;
}

.hud-title { font-size: 13px; font-weight: 500; letter-spacing: 1px; }

.hud-timer {
  background: #ff1801;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 20px;
  min-width: 58px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.hud-timer.final { animation: timerFlash 0.5s ease infinite; }

@keyframes timerFlash {
  0%, 100% { background: #ff1801; }
  50% { background: #ff6030; }
}

/* ===== EVENT BANNER ===== */
.event-banner {
  width: 100%;
  background: #111118;
  border: 1px solid #ffd700;
  border-radius: 12px;
  padding: 10px 16px;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  animation: slideIn 0.3s ease;
}

.event-banner.hidden { display: none; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== RACE LEGEND ===== */
.race-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  width: 100%;
  margin-top: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 12px;
}

.legend-color {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.legend-gap { font-size: 9px; color: #666; flex-shrink: 0; min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

.legend-rank {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 5px;
  border-radius: 6px;
  background: #1e1e2e;
  color: #aaa;
  flex-shrink: 0;
}

.legend-rank.rank-1 { background: rgba(241,196,15,0.2); color: #f1c40f; }
.legend-rank.last   { background: rgba(255,24,1,0.2); color: #ff1801; }

/* ===== RACE STATS ===== */
.race-stats {
  display: flex;
  justify-content: space-around;
  width: 100%;
  margin-top: 10px;
  padding: 8px 0;
  border-top: 1px solid #1e1e2e;
}

.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-label { font-size: 9px; color: #555; letter-spacing: 1px; }
.stat-value { font-size: 14px; font-weight: 500; }

/* ===== INTERSTITIAL ===== */
#screen-interstitial {
  justify-content: center;
  align-items: center;
  min-height: 500px;
}

.interstitial-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  padding: 40px 0;
}

.interstitial-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid #1e1e2e;
  border-top-color: #ff1801;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.interstitial-text { font-size: 16px; color: #888; letter-spacing: 1px; }

/* ===== RESULT SCREEN ===== */
.result-title {
  font-size: 22px;
  font-weight: 500;
  margin-top: 16px;
  margin-bottom: 14px;
}

/* CAPTURE AREA */
#result-capture {
  width: 100%;
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 16px;
  padding: 16px;
  position: relative;
}

.capture-header {
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 1px;
  color: #888;
  margin-bottom: 14px;
}

.capture-watermark {
  text-align: center;
  font-size: 11px;
  color: #333;
  margin-top: 10px;
  letter-spacing: 1px;
}

/* PODIUM */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-bottom: 14px;
}

.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 120px;
}

.podium-name {
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.podium-bar {
  width: 100%;
  text-align: center;
  border-radius: 8px 8px 0 0;
  padding-top: 8px;
  font-size: 16px;
  line-height: 1.5;
  font-weight: 500;
}

.podium-bar.p1 { height: 96px; background: linear-gradient(180deg,#ffd700,#b8960f); color: #1a1400; }
.podium-bar.p2 { height: 72px; background: linear-gradient(180deg,#c0c0c0,#888);    color: #1a1a1a; }
.podium-bar.p3 { height: 52px; background: linear-gradient(180deg,#cd7f32,#8b5a2b); color: #1a1000; }

/* RESULT CARDS */
.result-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0e0e16;
  border: 1px solid #1e1e2e;
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 6px;
  animation: resultSlide 0.4s ease both;
}

.result-card.gold   { background: linear-gradient(135deg,#2a2000,#1a1500); border-color: #ffd700; }
.result-card.silver { background: linear-gradient(135deg,#202028,#181820); border-color: #c0c0c0; }
.result-card.bronze { background: linear-gradient(135deg,#221a10,#1a1208); border-color: #cd7f32; }
.result-card.loser  { background: linear-gradient(135deg,#2a0000,#1a0000); border-color: #ff1801; }

@keyframes resultSlide {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

.result-rank  { font-size: 17px; font-weight: 500; min-width: 28px; text-align: center; }
.result-color { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.15); }
.result-name  { flex: 1; font-size: 14px; }
.result-badge { font-size: 16px; }

.result-loser {
  margin-top: 12px;
  background: linear-gradient(135deg,#2a0500,#1a0300);
  border: 2px solid #ff1801;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  animation: fadeIn 0.6s ease 0.4s both;
}

.result-loser .loser-name { color: #ff1801; font-size: 22px; }

/* RECORDS */
.result-records {
  width: 100%;
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 13px;
  color: #aaa;
  line-height: 1.8;
  animation: fadeIn 0.5s ease 0.6s both;
}

.result-records strong { color: #fff; }
.result-records .record-highlight { color: #ff1801; }

/* COFFEE RECOMMENDATIONS */
.coffee-section {
  width: 100%;
  margin-top: 20px;
  animation: fadeIn 0.5s ease 0.8s both;
}

.coffee-section-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 12px;
}

.coffee-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.coffee-card {
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}

.coffee-card:hover { border-color: #ff1801; transform: translateY(-2px); }

.coffee-emoji { font-size: 28px; display: block; margin-bottom: 6px; }
.coffee-name  { font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.coffee-desc  { font-size: 11px; color: #666; line-height: 1.4; }

/* RESULT ACTIONS */
.result-actions {
  width: 100%;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-actions .btn-primary,
.result-actions .btn-secondary { margin-top: 0; }

/* ===== FOOTER ===== */
.site-footer {
  width: 100%;
  border-top: 1px solid #1e1e2e;
  padding: 20px 16px;
  margin-top: auto;
}

.footer-inner {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  font-size: 12px;
  color: #555;
  transition: color 0.2s;
}

.footer-links a:hover { color: #fff; }

.footer-copy { font-size: 11px; color: #333; }

/* ===== CONTENT PAGES (about, howto, blog, etc.) ===== */
.content-page {
  width: 100%;
  max-width: 480px;
  padding: 24px 16px;
}

.content-page h1 {
  font-size: 26px;
  font-weight: 500;
  margin-bottom: 8px;
  margin-top: 12px;
}

.content-page h2 {
  font-size: 18px;
  font-weight: 500;
  margin-top: 28px;
  margin-bottom: 10px;
  color: #ff1801;
}

.content-page h3 {
  font-size: 15px;
  font-weight: 500;
  margin-top: 18px;
  margin-bottom: 6px;
}

.content-page p {
  font-size: 14px;
  color: #bbb;
  line-height: 1.9;
  margin-top: 8px;
}

.content-page ul, .content-page ol {
  padding-left: 20px;
  margin-top: 8px;
}

.content-page li {
  font-size: 14px;
  color: #bbb;
  line-height: 2;
}

.content-page a { color: #ff1801; }
.content-page a:hover { text-decoration: underline; }

.content-lead {
  font-size: 15px !important;
  color: #ccc !important;
}

.step-card {
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 14px;
  padding: 16px 18px;
  margin-top: 12px;
}

.step-num {
  font-size: 11px;
  color: #ff1801;
  font-weight: 500;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.step-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
}

.step-desc {
  font-size: 13px;
  color: #888;
  line-height: 1.7;
}

.faq-item {
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 10px;
}

.faq-q { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.faq-a { font-size: 13px; color: #888; line-height: 1.7; }

/* Blog */
.blog-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.blog-card {
  background: #111118;
  border: 1px solid #1e1e2e;
  border-radius: 14px;
  padding: 16px;
  transition: border-color 0.2s;
}

.blog-card:hover { border-color: #ff1801; }

.blog-tag {
  font-size: 10px;
  color: #ff1801;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.blog-card h2 {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  margin-top: 0;
  margin-bottom: 8px;
}

.blog-card p { font-size: 13px; color: #777; line-height: 1.6; margin-top: 0; }

.blog-date { font-size: 11px; color: #444; margin-top: 10px; }

.post-back {
  font-size: 13px;
  color: #888;
  display: inline-block;
  margin-bottom: 16px;
}

.post-back:hover { color: #fff; }

.post-meta {
  font-size: 12px;
  color: #555;
  margin-bottom: 20px;
  margin-top: 4px;
}

.post-body p  { font-size: 14px; color: #bbb; line-height: 1.9; margin-top: 12px; }
.post-body h2 { font-size: 17px; font-weight: 500; color: #fff; margin-top: 24px; margin-bottom: 8px; }
.post-body ul { padding-left: 18px; margin-top: 8px; }
.post-body li { font-size: 14px; color: #bbb; line-height: 1.9; }

/* ===== UTILITIES ===== */
canvas { image-rendering: auto; }
