*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0a0a2e;
  --bg-light: #141452;
  --neon-green: #00ff41;
  --pixel-yellow: #ffd700;
  --pixel-red: #ff4136;
  --pixel-cyan: #00e5ff;
  --text: #e0e0e0;
  --text-dim: #7a7a9e;
  --lane-dark: #2a1a0a;
  --lane-light: #3d2b14;
  --grass: #1a5c1a;
}

@font-face {
  font-family: 'DungGeunMo';
  src: url('https://cdn.jsdelivr.net/gh/projectnoonnu/noonfonts_six@1.2/DungGeunMo.woff') format('woff');
  font-weight: normal;
  font-style: normal;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Press Start 2P', 'DungGeunMo', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

.screen { display: none; flex-direction: column; align-items: center; padding: 20px; min-height: 100vh; }
.screen.active { display: flex; }

/* ============ INPUT SCREEN ============ */
#input-screen {
  justify-content: center;
  gap: 24px;
}

.title {
  font-size: 36px;
  color: var(--pixel-yellow);
  text-shadow: 0 0 20px rgba(255,215,0,0.5), 3px 3px 0 #b8860b;
  text-align: center;
  line-height: 1.6;
}
.title .flag { font-size: 42px; }
.subtitle {
  font-size: 15px;
  color: var(--neon-green);
  text-shadow: 0 0 10px rgba(0,255,65,0.4);
}

.input-box {
  background: var(--bg-light);
  border: 3px solid var(--neon-green);
  border-radius: 4px;
  padding: 20px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 0 20px rgba(0,255,65,0.15), inset 0 0 30px rgba(0,0,0,0.3);
}

.input-box label {
  font-size: 13px;
  color: var(--pixel-yellow);
  display: block;
  margin-bottom: 12px;
}

textarea {
  width: 100%;
  height: 200px;
  background: #050520;
  border: 2px solid #333366;
  color: var(--neon-green);
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  padding: 12px;
  resize: none;
  line-height: 1.8;
  border-radius: 2px;
}
textarea::placeholder { color: var(--text-dim); font-size: 12px; }
textarea:focus { outline: none; border-color: var(--neon-green); box-shadow: 0 0 10px rgba(0,255,65,0.3); }

.input-info {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
}

.btn-row { display: flex; gap: 12px; margin-top: 8px; }

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  padding: 14px 24px;
  border: 3px solid;
  cursor: pointer;
  transition: all 0.1s;
  background: transparent;
  text-transform: uppercase;
  image-rendering: pixelated;
}
.btn:hover { transform: translate(-2px, -2px); }
.btn:active { transform: translate(1px, 1px); }

.btn-primary {
  color: #000;
  background: var(--pixel-yellow);
  border-color: #b8860b;
  box-shadow: 4px 4px 0 #b8860b;
}
.btn-primary:hover { box-shadow: 6px 6px 0 #b8860b; }

.btn-secondary {
  color: var(--neon-green);
  border-color: var(--neon-green);
  box-shadow: 4px 4px 0 #006b1d;
}
.btn-secondary:hover { box-shadow: 6px 6px 0 #006b1d; }

/* ============ ITEM GUIDE ============ */
.item-guide {
  width: 100%;
  max-width: 500px;
  background: var(--bg-light);
  border: 2px solid #333366;
  border-radius: 4px;
  padding: 16px;
}
.item-guide-title {
  font-size: 14px;
  color: var(--pixel-yellow);
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #333366;
}
.item-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  background: rgba(0,0,0,0.25);
  border: 1px solid #222244;
  border-radius: 3px;
}
.item-card:hover {
  border-color: var(--pixel-yellow);
  background: rgba(255,215,0,0.05);
}
.item-icon { font-size: 28px; }
.item-label {
  font-size: 14px;
  color: var(--neon-green);
  font-family: 'DungGeunMo', 'Press Start 2P', monospace;
}
.item-desc {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.4;
  font-family: 'DungGeunMo', 'Press Start 2P', monospace;
}

/* ============ CROSS LINK ============ */
.cross-link {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 16px;
  font-family: 'DungGeunMo', 'Press Start 2P', monospace;
  font-size: 13px;
  color: var(--pixel-cyan);
  text-decoration: none;
  border: 2px solid #333366;
  border-radius: 4px;
  background: rgba(0,0,0,0.2);
  transition: all 0.15s;
}
.cross-link:hover {
  border-color: var(--pixel-cyan);
  background: rgba(0,229,255,0.1);
  text-shadow: 0 0 8px rgba(0,229,255,0.4);
}

/* ============ RACE SCREEN ============ */
#race-screen {
  padding: 10px;
  gap: 8px;
}

.race-header {
  font-size: 16px;
  color: var(--pixel-yellow);
  text-shadow: 0 0 15px rgba(255,215,0,0.4);
  text-align: center;
  width: 100%;
}

.race-body {
  display: flex;
  width: 100%;
  max-width: 1200px;
  gap: 12px;
  align-items: flex-start;
}

.canvas-wrap {
  flex: 1;
  min-width: 0;
  border: 3px solid #333366;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg);
  position: relative;
}

/* CRT Scanline & Glow Effect */
.canvas-wrap::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.15) 0px,
    rgba(0,0,0,0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  pointer-events: none;
  z-index: 5;
  box-shadow:
    inset 0 0 60px rgba(0,255,65,0.05),
    inset 0 0 120px rgba(0,0,0,0.3);
}
.canvas-wrap::before {
  content: '';
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  border-radius: 6px;
  box-shadow:
    0 0 15px rgba(0,255,65,0.15),
    0 0 40px rgba(0,255,65,0.05);
  pointer-events: none;
  z-index: 6;
}

.canvas-scroll { width: 100%; overflow-y: auto; overflow-x: hidden; }
#raceCanvas { display: block; width: 100%; image-rendering: pixelated; image-rendering: crisp-edges; }

.countdown-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10,10,46,0.85);
  z-index: 10;
}
.countdown-overlay.active { display: flex; }
.countdown-text {
  font-size: 72px;
  color: var(--pixel-yellow);
  text-shadow: 0 0 40px rgba(255,215,0,0.8);
  animation: countPulse 0.5s ease-out;
}
@keyframes countPulse {
  0% { transform: scale(2); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.rank-panel {
  background: #050520;
  border: 4px solid #333366;
  padding: 12px;
  flex: 0 0 auto;
  overflow-y: auto;
  box-shadow: inset 0 0 15px rgba(0,0,0,0.8);
}
.rank-panel h3 {
  font-size: 11px;
  color: var(--pixel-cyan);
  margin-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
  border-bottom: 2px solid #333366;
  padding-bottom: 8px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  font-size: 10px;
  border: 1px solid transparent;
}
.rank-item.highlight {
  background: rgba(255,215,0,0.2);
  border-color: rgba(255,215,0,0.4);
  animation: rankFlash 0.5s ease-out;
}
@keyframes rankFlash {
  0% { background: rgba(255,215,0,0.8); transform: scale(1.05); }
  100% { background: rgba(255,215,0,0.2); transform: scale(1); }
}
.rank-item.finished { color: var(--text-dim); }
.rank-num { width: 30px; text-align: center; font-weight: bold; }
.rank-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-medal { font-size: 14px; }

@keyframes blink { 50% { opacity: 0; } }

/* ============ RESULT SCREEN ============ */
#result-screen {
  justify-content: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
}
#confettiCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.podium-area {
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: center;
}
#podiumCanvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  max-width: 420px;
  height: auto;
}

.result-title {
  font-size: 22px;
  color: var(--pixel-yellow);
  text-shadow: 0 0 20px rgba(255,215,0,0.6), 3px 3px 0 #b8860b;
}

.winner-banner {
  width: 100%;
  max-width: 500px;
  background: linear-gradient(90deg, transparent, rgba(255,215,0,0.15) 20%, rgba(255,215,0,0.25) 50%, rgba(255,215,0,0.15) 80%, transparent);
  border-top: 2px solid #ffd700;
  border-bottom: 2px solid #ffd700;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}
.winner-banner-icon {
  font-size: 20px;
}
.winner-banner-name {
  font-size: 18px;
  color: #ffd700;
  font-family: "DungGeunMo", "Press Start 2P", monospace;
  text-shadow: 0 0 10px rgba(255,215,0,0.6), 2px 2px 0 #b8860b;
  letter-spacing: 2px;
  animation: bannerGlow 1.5s ease-in-out infinite alternate;
}
@keyframes bannerGlow {
  from { text-shadow: 0 0 10px rgba(255,215,0,0.6), 2px 2px 0 #b8860b; }
  to { text-shadow: 0 0 20px rgba(255,215,0,0.9), 0 0 40px rgba(255,215,0,0.4), 2px 2px 0 #b8860b; }
}

.result-list {
  background: var(--bg-light);
  border: 3px solid #333366;
  border-radius: 4px;
  padding: 12px 20px;
  width: 100%;
  max-width: 500px;
  max-height: 30vh;
  overflow-y: auto;
}
.result-list:empty { display: none; }

.result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-bottom: 1px solid #222255;
  font-size: 11px;
}
.result-item:last-child { border-bottom: none; }
.result-item-top { color: #ffd700; text-shadow: 0 0 8px rgba(255,215,0,0.3); }
.result-rank { width: 36px; text-align: center; font-size: 13px; }
.result-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-info { flex: 1; min-width: 0; }
.result-main { display: flex; align-items: center; gap: 6px; }
.result-sub { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.result-spd { font-size: 9px; color: #88aacc; font-family: 'Press Start 2P', monospace; }
.result-badges { font-size: 9px; color: #aaaacc; }
.result-time { font-size: 10px; color: #8888bb; text-align: right; min-width: 60px; }
.rank-speed { font-size: 8px; color: #88aacc; font-family: 'Press Start 2P', monospace; }

/* ============ STATS SECTION ============ */
.stats-section {
  width: 100%;
  max-width: 500px;
  background: var(--bg-light);
  border: 3px solid #333366;
  border-radius: 4px;
  padding: 12px 16px;
}
.stats-section:empty { display: none; }
.stats-title {
  font-size: 13px;
  color: var(--pixel-cyan);
  text-align: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 2px solid #333366;
}
.stats-awards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.stat-award {
  flex: 1 1 45%;
  background: rgba(0,0,0,0.3);
  border: 1px solid #222244;
  border-radius: 3px;
  padding: 6px 8px;
  font-size: 10px;
  font-family: 'DungGeunMo', monospace;
  color: var(--text);
}
.stat-award strong { color: var(--pixel-yellow); }
.stat-icon { margin-right: 2px; }
.stats-runners { display: flex; flex-direction: column; gap: 3px; }
.stat-runner {
  background: rgba(0,0,0,0.2);
  border: 1px solid #222244;
  border-radius: 3px;
  padding: 6px 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.stat-runner:hover { background: rgba(0,0,0,0.35); }
.stat-runner-hd {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-family: 'DungGeunMo', monospace;
  color: var(--pixel-yellow);
}
.stat-summary { font-size: 10px; color: #aaaacc; }
.stat-runner-detail {
  display: none;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid #333366;
}
.stat-runner.expanded .stat-runner-detail { display: block; }
.stat-line {
  font-size: 10px;
  font-family: 'DungGeunMo', monospace;
  color: #aabbcc;
  line-height: 1.6;
  word-break: break-all;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .title { font-size: 18px; }
  #race-screen { padding: 2px; gap: 2px; }
  .race-header { font-size: 10px; padding: 4px; }
  .race-body { flex-direction: column; gap: 0; width: 100%; }
  .canvas-wrap { border-width: 2px; width: 100%; }
  .canvas-scroll { width: 100%; }
  .sidebar {
    width: 100%;
    flex-direction: column;
    height: auto !important;
    overflow: visible;
    gap: 0;
  }
  .rank-panel { display: none; }
  /* 모바일 사이드바엔 순위판(숨김)뿐이라 통째로 숨긴다 — 비어 있는 칸이 화면을 차지하지 않게 */
  .sidebar { display: none; }
  .btn { font-size: 10px; padding: 10px 16px; }
  .item-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .item-guide { padding: 12px; }
  .item-guide-title { font-size: 12px; }
  .item-icon { font-size: 16px; }
  .item-label { font-size: 9px; }
  .item-desc { font-size: 7px; }
  .countdown-text { font-size: 36px; }
  .result-title { font-size: 16px; }
  #podiumCanvas { max-width: 320px; }
  .winner-banner-name { font-size: 14px; }
  .winner-banner { padding: 8px 12px; }
  .result-list { max-height: 25vh; padding: 8px 12px; }
  .result-item { font-size: 9px; padding: 6px 4px; gap: 6px; }
  .result-time { font-size: 8px; min-width: 50px; }
  .result-spd { font-size: 7px; }
  .result-badges { font-size: 8px; }
  .stats-section { padding: 8px 10px; }
  .stat-award { font-size: 9px; flex: 1 1 100%; }
  .stat-runner-hd { font-size: 10px; }
  .stat-line { font-size: 9px; }
}

@media (max-width: 400px) {
  #race-screen { padding: 0; }
  .race-header { font-size: 9px; padding: 3px; }
}

/* ============================================================
   ADVANCED UI — 클래스 가이드 / 무대 / 중계 티커 / 타임라인 / 전적
   ============================================================ */

.guide-note {
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
  line-height: 1.6;
}

/* ---- 캐릭터 클래스 카드 ---- */
.class-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}
.class-card {
  display: flex;
  gap: 10px;
  background: #050520;
  border: 2px solid #333366;
  padding: 10px;
  align-items: flex-start;
}
.class-card:hover { border-color: var(--neon-green); }
.class-sprite {
  width: 48px; height: 48px;
  flex-shrink: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.class-body { flex: 1; min-width: 0; }
.class-name {
  font-family: 'DungGeunMo', monospace;
  font-size: 15px;
  display: flex; align-items: baseline; gap: 6px;
  margin-bottom: 3px;
}
.class-tag {
  font-size: 10px;
  color: var(--text-dim);
  background: rgba(255,255,255,0.06);
  padding: 1px 5px;
}
.class-desc {
  font-family: 'DungGeunMo', monospace;
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.45;
  margin-bottom: 6px;
}
.stat-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; }
.stat-bar { display: flex; align-items: center; gap: 4px; }
.sb-label {
  font-family: 'DungGeunMo', monospace;
  font-size: 10px;
  color: var(--text-dim);
  width: 26px; flex-shrink: 0;
}
.sb-track { flex: 1; height: 5px; background: #1a1a3a; display: block; }
.sb-fill { display: block; height: 100%; }

/* ---- 무대 가이드 ---- */
.stage-grid { display: flex; flex-direction: column; gap: 8px; }
.stage-row { display: flex; align-items: center; gap: 10px; }
.stage-label {
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  color: var(--pixel-yellow);
  width: 36px; flex-shrink: 0;
}
.stage-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-card {
  display: flex; align-items: center; gap: 5px;
  background: #050520;
  border: 1px solid #333366;
  padding: 4px 8px;
}
.stage-icon { font-size: 14px; }
.stage-name { font-family: 'DungGeunMo', monospace; font-size: 11px; color: var(--text); }

/* ---- 중계 티커 ---- */
.commentary-ticker {
  position: absolute;
  left: 50%;
  /* 캔버스 하단의 미니맵+관중석 위에 오도록 race.js:resizeCanvas 가 설정한다 */
  bottom: var(--ticker-bottom, 10px);
  transform: translateX(-50%) translateY(6px);
  max-width: 90%;
  padding: 7px 16px;
  background: rgba(5,5,25,0.88);
  border: 2px solid var(--pixel-yellow);
  color: #fff;
  font-family: 'DungGeunMo', monospace;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 7;
  box-shadow: 0 0 16px rgba(255,215,0,0.25);
}
.commentary-ticker.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.commentary-ticker.pop { animation: tickerPop 0.3s ease-out; }
@keyframes tickerPop {
  0%   { transform: translateX(-50%) scale(0.94); }
  60%  { transform: translateX(-50%) scale(1.03); }
  100% { transform: translateX(-50%) scale(1); }
}

/* ---- 순위판 상태 아이콘 ---- */
.rank-state { font-size: 11px; width: 16px; text-align: center; flex-shrink: 0; }
.rank-fin { color: var(--neon-green); font-size: 7px; }

/* ---- 결과: 무대 정보 ---- */
.stage-info { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 4px; }
.stage-chip {
  background: var(--bg-light);
  border: 2px solid #333366;
  padding: 5px 10px;
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  color: var(--text);
}
.result-class { font-family: 'DungGeunMo', monospace; font-size: 11px; }
.result-gap { color: var(--text-dim); font-size: 9px; margin-left: 6px; }

/* ---- 타임라인 ---- */
.timeline-bar {
  position: relative;
  height: 10px;
  background: #050520;
  border: 1px solid #333366;
  margin-bottom: 10px;
}
.tl-dot {
  position: absolute;
  top: 2px;
  width: 3px; height: 4px;
  background: #ff4136;
}
.tl-dot.tl-zone   { background: #00e5ff; }
.tl-dot.tl-lead   { background: var(--pixel-yellow); height: 6px; top: 1px; }
.tl-dot.tl-photo  { background: #ffffff; height: 8px; top: 0; width: 2px; }
.tl-dot.tl-finish { background: var(--neon-green); height: 8px; top: 0; }
.timeline-list { max-height: 240px; overflow-y: auto; }
.tl-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px;
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.tl-time { color: var(--text-dim); font-size: 10px; width: 62px; flex-shrink: 0; }
.tl-icon { width: 16px; flex-shrink: 0; }
.tl-text { color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-text b { color: var(--pixel-yellow); font-weight: normal; }
.tl-item { color: var(--pixel-cyan); }

/* ---- 통산 전적 ---- */
.hof-total { color: var(--text-dim); font-size: 10px; }
.hof-table { display: flex; flex-direction: column; }
.hof-row {
  display: grid;
  grid-template-columns: 1.6fr 0.6fr 0.6fr 0.6fr 0.9fr 1.2fr;
  gap: 6px;
  padding: 5px 6px;
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.hof-row span:not(.hof-name) { text-align: right; }
.hof-head { color: var(--text-dim); font-size: 10px; }
.hof-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hof-win { color: var(--pixel-yellow); }
.hof-best { color: var(--neon-green); }
.hof-empty { font-family: 'DungGeunMo', monospace; font-size: 12px; color: var(--text-dim); padding: 8px 0; }
.btn-ghost {
  margin-top: 10px;
  background: transparent;
  border: 2px solid #333366;
  color: var(--text-dim);
  font-size: 10px;
  padding: 6px 12px;
  box-shadow: none;
}
.btn-ghost:hover { border-color: var(--pixel-red); color: var(--pixel-red); box-shadow: none; }

/* ---- 토스트 ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(12px);
  background: #050520;
  border: 2px solid var(--neon-green);
  color: var(--text);
  font-family: 'DungGeunMo', monospace;
  font-size: 13px;
  padding: 10px 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
  .class-grid { grid-template-columns: 1fr; }
  .stat-bars { grid-template-columns: 1fr 1fr; }
  .commentary-ticker { font-size: 11px; padding: 5px 10px; bottom: 6px; max-width: 96%; }
  .hof-row { grid-template-columns: 1.4fr 0.5fr 0.5fr 0.5fr 0.8fr 1.1fr; font-size: 10px; }
  .tl-row { font-size: 11px; }
  .tl-time { width: 52px; font-size: 9px; }
}

.result-gap { display: inline-block; min-width: 72px; text-align: right; }
.timeline-meta {
  font-family: 'DungGeunMo', monospace;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

/* 아이템 가이드 도트 아이콘 — 레이스 화면과 동일한 그림 */
.item-icon-canvas {
  width: 40px; height: 40px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* 오른쪽 위 조작 줄(2D/3D 전환 · BGM) — 모든 화면에 고정. 레이스 헤더 띠 안에 들어가게 작게 —
   캔버스 오른쪽 위의 "소리 켜기"와 겹치지 않게 */
.top-controls {
  position: fixed;
  top: 6px;
  right: 8px;
  z-index: 60;
  display: flex;
  gap: 6px;
  align-items: center;
}
.top-btn {
  background: rgba(5,5,25,0.85);
  border: 2px solid var(--pixel-yellow);
  color: var(--pixel-yellow);
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  text-decoration: none;
}
.top-btn[hidden] { display: none; }
.renderer-switch { border-color: var(--pixel-cyan); color: var(--pixel-cyan); }
/* BGM 꺼짐(기본)은 흐리게, 켜짐은 또렷하게 */
.bgm-toggle { opacity: 0.55; }
.bgm-toggle.on { opacity: 1; box-shadow: 0 0 10px rgba(255,215,0,0.35); }
.top-btn:hover, .top-btn:focus-visible { opacity: 1; }
@media (max-width: 600px) {
  .top-controls { top: 3px; right: 4px; gap: 4px; }
  .top-btn { font-size: 10px; padding: 3px 6px; }
}

/* 자동 시작 시 브라우저가 재생을 막았을 때만 뜬다 */
.sound-unlock {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 8;
  background: rgba(5,5,25,0.9);
  border: 2px solid var(--pixel-yellow);
  color: var(--pixel-yellow);
  font-family: 'DungGeunMo', monospace;
  font-size: 13px;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255,215,0,0.25);
}
.sound-unlock:hover { background: var(--pixel-yellow); color: #050520; }

/* 자동 복사가 막혔을 때만 보인다. 사용자의 명단 입력칸은 절대 건드리지 않는다. */
.link-out {
  width: 100%;
  margin-top: 10px;
  background: #050520;
  border: 2px solid var(--pixel-yellow);
  color: var(--pixel-yellow);
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  padding: 8px;
}

/* ============ API 사용법 패널 ============ */
/* 버튼이 5개가 되면서 좁은 화면에서 넘친다. 줄바꿈은 기존 4개 상황도 같이 낫게 한다. */
.btn-row { flex-wrap: wrap; }

.api-code {
  background: #050520;
  border: 2px solid #333366;
  color: var(--neon-green);
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  padding: 10px;
  margin-bottom: 12px;
  /* 디코딩된 URL 이라 사람이 읽는 문자열이다. 가로 스크롤보다 줄바꿈이 낫다. */
  white-space: pre-wrap;
  word-break: break-all;
}
.api-table { width: 100%; border-collapse: collapse; }
.api-table th,
.api-table td {
  font-family: 'DungGeunMo', monospace;
  font-size: 12px;
  text-align: left;
  vertical-align: top;
  padding: 5px 6px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.api-table th { color: var(--pixel-yellow); white-space: nowrap; width: 84px; font-weight: normal; }
.api-table td { color: var(--text); line-height: 1.5; }
.api-table code {
  background: rgba(0,0,0,0.4);
  color: var(--pixel-cyan);
  padding: 1px 4px;
}
.api-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.api-actions .btn { font-size: 10px; padding: 10px 14px; text-decoration: none; }
