@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700;800&family=Noto+Sans+KR:wght@400;500;600;700;800&display=swap');

:root {
  color-scheme: dark;
  --bg: #07121a;
  --bg-input: rgba(6, 17, 26, 0.88);
  --text: #f6efe0;
  --text-muted: #b5c3c8;
  --gold: #d5a654;
  --gold-bright: #ffe6a8;
  --cyan: #57e0ff;
  --violet: #b68bff;
  --amber: #f7c04a;
  --molten: #ff8647;
  --coral: #ff7a85;
  --line: rgba(213, 166, 84, 0.34);
  --line-soft: rgba(181, 195, 200, 0.16);
  --line-strong: rgba(255, 230, 168, 0.56);
  --frame-skin: image-set(
    url('../assets/ui/crafted-panel-512.webp?v=3') 1x,
    url('../assets/ui/crafted-panel-1024.webp?v=3') 2x
  );
  --btn-gold-skin: image-set(
    url('../assets/ui/crafted-btn-gold-360.webp?v=3') 1x,
    url('../assets/ui/crafted-btn-gold-720.webp?v=3') 2x
  );
  --btn-teal-skin: image-set(
    url('../assets/ui/crafted-btn-teal-360.webp?v=3') 1x,
    url('../assets/ui/crafted-btn-teal-720.webp?v=3') 2x
  );
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.58);
  --sans: 'Noto Sans KR', 'Manrope', 'Malgun Gothic', system-ui, -apple-system, sans-serif;
  --display: 'Manrope', 'Noto Sans KR', system-ui, sans-serif;
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #efe7d6;
  --text-outer: #1d2633;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input { font: inherit; color: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: 0.58; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 아트 디렉션 기반 데스크톱·모바일 반응형 배경 */
.observatory-bg {
  position: fixed;
  inset: 0;
  z-index: -3;
  background-color: var(--bg);
  background-image:
    linear-gradient(90deg, rgba(6, 16, 24, 0.72) 0%, rgba(6, 16, 24, 0.36) 56%, rgba(6, 16, 24, 0.48) 100%),
    linear-gradient(180deg, rgba(6, 16, 24, 0.42) 0%, transparent 22%, transparent 78%, rgba(6, 16, 24, 0.76) 100%),
    image-set(
      url('../assets/backgrounds/study-desktop-960.webp?v=3') 1x,
      url('../assets/backgrounds/study-desktop-1440.webp?v=3') 1.5x,
      url('../assets/backgrounds/study-desktop-1920.webp?v=3') 2x
    );
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  transition: filter 0.3s ease;
}
@media (max-width: 768px) and (orientation: portrait) {
  .observatory-bg {
    background-image:
      linear-gradient(180deg, rgba(6, 16, 24, 0.62) 0%, rgba(6, 16, 24, 0.25) 45%, rgba(6, 16, 24, 0.72) 100%),
      image-set(
        url('../assets/backgrounds/study-mobile-480.webp?v=3') 1x,
        url('../assets/backgrounds/study-mobile-828.webp?v=3') 2x,
        url('../assets/backgrounds/study-mobile-1080.webp?v=3') 3x
      );
  }
}
body[data-screen='game'] .observatory-bg {
  filter: brightness(0.62) saturate(0.95);
}
:root[data-theme='light'] .observatory-bg {
  filter: brightness(1.06) sepia(0.18);
  opacity: 0.34;
}
:root[data-theme='light'] .hero-copy,
:root[data-theme='light'] .hero-copy h1,
:root[data-theme='light'] .hero-intro,
:root[data-theme='light'] .hero-stat strong,
:root[data-theme='light'] .site-footer {
  color: #172330;
  text-shadow: none;
  filter: none;
}
:root[data-theme='light'] .hero-subtitle { color: #7a5216; }
:root[data-theme='light'] .hero-stat span,
:root[data-theme='light'] .eyebrow { color: #526170; }
:root[data-theme='light'] .rule-token {
  background: rgba(12, 27, 38, 0.9);
  color: #ffe6a8;
}

.vfx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 35;
}

/* 헤더 */
.site-header {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px clamp(16px, 4vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  color: var(--gold-bright);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.65);
}
.brand img {
  width: 32px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}
.header-controls { display: flex; align-items: center; gap: 8px; }
.languages { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; margin-right: 4px; }
.languages a {
  min-width: 44px;
  min-height: 44px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #c2cfd4;
  border-radius: 10px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}
.languages a[aria-current] {
  color: var(--gold-bright);
  font-weight: 800;
  background: rgba(11, 31, 43, 0.84);
  border: 1px solid var(--line);
}
.languages span { opacity: 0.38; }

.icon-button {
  position: relative;
  isolation: isolate;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--gold-bright);
  font-size: 16px;
  font-weight: 800;
  display: grid;
  place-items: center;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.52));
  transition: filter 0.14s, transform 0.12s;
}
.icon-button::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 9px solid transparent;
  border-image: var(--frame-skin) 11% fill / 9px / 0 stretch;
  pointer-events: none;
}
.icon-button img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.65));
}
.icon-button:hover { filter: brightness(1.14) drop-shadow(0 5px 10px rgba(0, 0, 0, 0.58)); }
.icon-button:active { transform: translateY(2px); }

/* 입체 골드·틸 버튼 스킨 */
.primary-btn,
.secondary-btn,
.ghost-btn {
  position: relative;
  isolation: isolate;
  border: 0;
  background: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: filter 0.14s, transform 0.12s;
}
.primary-btn {
  min-height: 54px;
  padding: 12px 28px;
  color: #1c1204;
  font-weight: 800;
  font-size: 16.5px;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 0 rgba(255, 245, 206, 0.55);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55));
}
.primary-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 13px solid transparent;
  border-image: var(--btn-gold-skin) 24% 11% fill / 13px 18px / 0 stretch;
  pointer-events: none;
}
.primary-btn:hover { filter: brightness(1.09) drop-shadow(0 8px 18px rgba(213, 166, 84, 0.38)); }
.primary-btn:active { transform: translateY(2px); }

.secondary-btn {
  min-height: 52px;
  padding: 11px 22px;
  color: #ffeec2;
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.72);
  filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.5));
}
.secondary-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 13px solid transparent;
  border-image: var(--btn-teal-skin) 24% 11% fill / 13px 18px / 0 stretch;
  pointer-events: none;
}
.secondary-btn:hover { filter: brightness(1.16) drop-shadow(0 6px 14px rgba(0, 0, 0, 0.55)); }
.secondary-btn:active { transform: translateY(2px); }

.ghost-btn {
  min-height: 44px;
  padding: 8px 16px;
  color: #e4e9df;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.45));
}
.ghost-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 11px solid transparent;
  border-image: var(--btn-teal-skin) 24% 11% fill / 11px 15px / 0 stretch;
  pointer-events: none;
}
.ghost-btn:hover { color: var(--gold-bright); filter: brightness(1.16) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.52)); }
.ghost-btn:active { transform: translateY(1px); }

main { flex: 1; display: flex; flex-direction: column; width: 100%; }

/* 타이틀 / 로비 화면 (상용 퍼즐 게임 구성) */
.title-screen {
  flex: 1;
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: clamp(12px, 3vh, 42px) clamp(16px, 4vw, 40px) 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  align-items: center;
  gap: clamp(24px, 4.5vw, 56px);
}
.hero-copy { max-width: 540px; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #e4c98b;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}
.eyebrow i {
  width: 22px;
  height: 1px;
  background: var(--gold);
  opacity: 0.75;
}
h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(50px, 6.2vw, 80px);
  line-height: 1.05;
  letter-spacing: -0.04em;
  margin: 12px 0 10px;
  background: linear-gradient(180deg, #fff9dd 15%, #efd08d 52%, #b88435 94%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 0 #3f2809) drop-shadow(0 14px 28px rgba(0, 0, 0, 0.6));
}
.hero-subtitle {
  font-size: clamp(16px, 1.45vw, 19px);
  font-weight: 800;
  color: var(--gold-bright);
  margin: 0 0 10px;
  word-break: keep-all;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.hero-intro {
  font-size: 15px;
  line-height: 1.7;
  color: #dce6e8;
  margin: 0 0 18px;
  word-break: keep-all;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
}

.rule-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.rule-token {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 6px;
  background: rgba(8, 22, 32, 0.78);
  border: 1px solid rgba(213, 166, 84, 0.36);
  color: #f4dfac;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.hero-actions #start { min-height: 62px; padding: 12px 34px; font-size: 18px; }
.btn-arrow { font-size: 12px; opacity: 0.85; }
.resume-timer {
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(87, 224, 255, 0.14);
  border: 1px solid rgba(87, 224, 255, 0.42);
  color: var(--cyan);
}

/* 주얼리아 스타일 오픈 디바이더 스탯 스트립 */
.hero-records {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 24px;
}
.hero-stat {
  border-left: 1px solid rgba(213, 166, 84, 0.48);
  padding: 2px 0 2px 14px;
}
.hero-stat span { display: block; font-size: 11px; font-weight: 600; color: #b5c6cb; text-shadow: 0 1px 4px rgba(0,0,0,0.7); }
.hero-stat strong {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 800;
  color: #fff2cc;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}
.hero-stat.accent strong { color: var(--gold-bright); }

/* 3D 나침반 메달리온 + 9슬라이스 예시 보드 */
.hero-art {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.compass-showcase {
  position: relative;
  width: 148px;
  height: 152px;
  margin-bottom: -24px;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.showcase-burst {
  position: absolute;
  width: 230px;
  height: 230px;
  opacity: 0.55;
  animation: emblem-pulse 5s ease-in-out infinite alternate;
}
.showcase-compass {
  position: relative;
  width: 124px;
  height: auto;
  filter: drop-shadow(0 14px 20px rgba(0, 0, 0, 0.72));
  animation: compass-float 4.6s ease-in-out infinite alternate;
}

.crafted-frame {
  position: relative;
  isolation: isolate;
  border: 16px solid transparent;
  border-image: var(--frame-skin) 11% fill / 16px / 0 stretch;
  filter: drop-shadow(0 18px 34px rgba(0, 0, 0, 0.58));
}
.example-card {
  width: 100%;
  padding: 24px 16px 14px;
}
.example-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.example-badge {
  font-size: 11.5px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(213, 166, 84, 0.16);
  color: var(--gold-bright);
  border: 1px solid rgba(213, 166, 84, 0.42);
}
.example-target {
  font-size: 15px;
  font-weight: 800;
  color: #f7eed8;
}
.example-rows { display: flex; flex-direction: column; gap: 7px; }
.ex-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) 64px 1fr;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  background: rgba(12, 33, 46, 0.72);
  border: 1px solid rgba(181, 195, 200, 0.14);
}
.ex-row.warm { border-color: rgba(182, 139, 255, 0.34); }
.ex-row.hot { border-color: rgba(255, 134, 71, 0.48); }
.ex-row.exact {
  background: linear-gradient(135deg, #f3d285 0%, #c88e35 100%);
  border-color: #fff0c0;
  color: #191105;
}
.ex-word { font-size: 14px; font-weight: 800; }
.ex-score { font-family: var(--display); font-size: 14px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.ex-row.cool .ex-score { color: var(--cyan); }
.ex-row.warm .ex-score { color: var(--violet); }
.ex-row.hot .ex-score { color: var(--molten); }
.ex-row.exact .ex-score { color: #191105; }
.ex-rank-col { display: flex; flex-direction: column; gap: 4px; }
.ex-rank { font-size: 11px; font-weight: 700; text-align: right; color: var(--text-muted); }
.ex-row.hot .ex-rank { color: var(--molten); }
.ex-row.warm .ex-rank { color: var(--violet); }
.ex-row.exact .ex-rank { color: #191105; font-weight: 800; }
.ex-row.cool .sim-meter i { background: var(--cyan); }
.ex-row.warm .sim-meter i { background: var(--violet); }
.ex-row.hot .sim-meter i { background: linear-gradient(90deg, var(--amber), var(--molten)); }
.ex-row.exact .sim-meter { background: rgba(25, 17, 5, 0.2); }
.ex-row.exact .sim-meter i { background: #191105; }
.example-note {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  word-break: keep-all;
}

/* 게임 플레이 화면 */
.game-screen {
  width: 100%;
  max-width: 840px;
  margin: 0 auto;
  padding: 2px clamp(14px, 3vw, 24px) max(18px, env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.case-label {
  font-family: var(--display);
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(9, 25, 36, 0.88);
  border: 1px solid var(--line);
}

/* 통합 크로노미터 계기판 콘솔 */
.chronometer-console {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hud-primary {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr 1fr;
  gap: 8px;
}
.hud-card {
  position: relative;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(11, 31, 44, 0.78);
  border: 1px solid rgba(213, 166, 84, 0.28);
  text-align: center;
}
.hud-card span {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.timer-emblem { width: 16px; height: 20px; object-fit: contain; }
.hud-card strong {
  display: block;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #fff6dc;
}
.hud-card.timer-card {
  border-color: rgba(87, 224, 255, 0.42);
  background: rgba(8, 30, 46, 0.88);
}
.hud-card.timer-card strong {
  color: var(--cyan);
  text-shadow: 0 0 12px rgba(87, 224, 255, 0.35);
}
.hud-card.accent strong { color: var(--gold-bright); }

.benchmark-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(6, 17, 26, 0.65);
  border: 1px solid rgba(181, 195, 200, 0.14);
  font-size: 12px;
  color: var(--text-muted);
  word-break: keep-all;
}
.bench-prefix { font-weight: 700; color: var(--text); }
.bench-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(181, 195, 200, 0.1);
  font-size: 11.5px;
}
.bench-chip strong { font-family: var(--display); font-weight: 800; font-variant-numeric: tabular-nums; }
.bench-chip.hot strong { color: var(--molten); }
.bench-chip.warm strong { color: var(--violet); }
.bench-chip.cool strong { color: var(--cyan); }

.resonance-strip { padding: 2px 4px; }
.resonance-meta { font-size: 12px; color: #d0dfe3; margin-bottom: 5px; }
.resonance-track {
  height: 8px;
  padding: 1px;
  border-radius: 999px;
  border: 1px solid rgba(213, 166, 84, 0.32);
  background: rgba(5, 13, 20, 0.82);
  overflow: hidden;
}
.resonance-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), var(--violet), var(--amber), var(--gold-bright));
  transition: width 0.3s ease;
}
.resonance-fill[data-tier='molten'] { box-shadow: 0 0 14px rgba(255, 134, 71, 0.65); }
.resonance-fill[data-tier='exact'] {
  background: linear-gradient(90deg, var(--gold), #fff5d0);
  box-shadow: 0 0 16px rgba(255, 230, 168, 0.8);
}

/* 결과 배너 + 승리 폭발 이펙트 */
.result-wrap { position: relative; }
.vfx-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 420px;
  height: 420px;
  transform: translate(-50%, -50%) scale(0.35);
  opacity: 0;
  pointer-events: none;
  z-index: 0;
}
.vfx-burst img { width: 100%; height: 100%; object-fit: contain; }
.vfx-burst.is-active { animation: solve-shockwave 1.5s cubic-bezier(0.18, 0.85, 0.32, 1) forwards; }

.result-banner {
  position: relative;
  z-index: 1;
  padding: 12px;
  text-align: center;
}
.result-banner.is-won {
  animation: victory-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.record-badge {
  display: inline-block;
  margin: 0 0 6px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: #191105;
  background: linear-gradient(135deg, #fff1c0, #dfb059);
}
.unranked-note {
  margin: 0 auto 8px;
  max-width: 520px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  color: var(--amber);
  background: rgba(247, 192, 74, 0.14);
  border: 1px solid rgba(247, 192, 74, 0.38);
  word-break: keep-all;
}
.result-banner h2 {
  margin: 0 0 4px;
  font-size: clamp(20px, 3vw, 25px);
  font-weight: 800;
  color: var(--gold-bright);
}
.result-answer-line {
  margin: 4px 0 12px;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.result-answer-line span { font-size: 12px; color: var(--text-muted); }
.result-answer-line strong {
  font-size: clamp(28px, 4.8vw, 38px);
  font-weight: 900;
  background: linear-gradient(180deg, #fff9dd 15%, #efd08d 65%, #c58e39 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.result-stats > div {
  padding: 8px;
  border-radius: 8px;
  background: rgba(11, 31, 44, 0.72);
  border: 1px solid rgba(181, 195, 200, 0.15);
}
.result-stats span { display: block; font-size: 11px; color: var(--text-muted); }
.result-stats strong { font-family: var(--display); font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.result-actions > button { min-height: 46px; padding: 10px 24px; font-size: 13.5px; }
.explore-banner-note { margin: 10px 0 0; font-size: 12px; color: var(--text-muted); }

/* 입력창 */
.composer-wrap { display: flex; flex-direction: column; gap: 4px; }
.composer {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.composer input {
  flex: 1;
  min-width: 0;
  min-height: 50px;
  padding: 10px 15px;
  border-radius: 10px;
  border: 1px solid rgba(213, 166, 84, 0.44);
  background: var(--bg-input);
  color: var(--text);
  font-size: 16px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}
.composer input:focus { border-color: var(--gold-bright); }
.composer input::placeholder { color: #8da1a8; font-size: 14px; }
.composer .primary-btn {
  min-height: 50px;
  min-width: 112px;
  padding: 10px 20px;
  font-size: 15px;
}
.composer-status-slot {
  position: relative;
  height: 52px;
  display: flex;
  align-items: center;
  overflow: visible;
}
.input-hint {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: #bac8cc;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  word-break: keep-all;
  transition: opacity 0.14s ease;
}
:root[data-theme='light'] .input-hint {
  color: #364554;
  text-shadow: none;
}
.composer-status-slot.is-loading .input-hint {
  opacity: 0;
  visibility: hidden;
}
.guess-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.14s ease;
  z-index: 6;
}
.guess-loading[hidden] { display: none; }
.guess-loading:not([hidden]) { opacity: 1; }
.guess-loading-emblem {
  width: 22px;
  height: 27px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 8px rgba(87, 224, 255, 0.45));
}
.guess-loading[data-phase='loading'] .guess-loading-emblem {
  animation: loading-emblem-spin 1.8s linear infinite;
}
.guess-loading-gauge {
  position: relative;
  width: clamp(114px, 31vw, 132px);
  aspect-ratio: 640 / 338;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.65));
}
.guess-loading-frame {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.guess-loading-track {
  position: absolute;
  z-index: 1;
  left: 3.3%;
  width: 93.4%;
  top: 45.2%;
  height: 17.8%;
  overflow: hidden;
  border-radius: 999px;
  clip-path: inset(0 84% 0 0);
}
.guess-loading[data-phase='loading'] .guess-loading-track {
  animation: gauge-sweep 0.55s cubic-bezier(0.22, 0.72, 0.3, 1) forwards;
}
.guess-loading[data-phase='done'] .guess-loading-track {
  animation: none;
  clip-path: inset(0 0% 0 0);
  transition: clip-path 0.14s cubic-bezier(0.2, 0.85, 0.3, 1), filter 0.14s ease;
  filter: brightness(1.18) drop-shadow(0 0 6px rgba(87, 224, 255, 0.75));
}
.guess-loading-fill {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}
.guess-loading-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
}
.turn-feedback {
  margin: 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  background: rgba(11, 31, 44, 0.9);
  border: 1px solid rgba(87, 224, 255, 0.42);
  color: var(--text);
}
.turn-feedback[data-kind='error'] {
  background: rgba(58, 16, 24, 0.92);
  border-color: rgba(255, 122, 133, 0.55);
  color: #ffb8bf;
}
.turn-feedback[data-kind='warm'] {
  background: rgba(34, 29, 12, 0.92);
  border-color: var(--line-strong);
  color: var(--gold-bright);
}

/* 고정 높이 추측 기록 보드 (9슬라이스 스킨) */
.ledger-panel {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  height: clamp(220px, 36dvh, 400px);
  overflow: hidden;
}
.ledger-panel.is-shake { animation: subtle-hit 0.2s ease-out; }
.ledger-scroll {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.guesses-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 14px;
}
.guesses-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #0b1c28;
  border-bottom: 1px solid var(--line);
  padding: 0;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.guesses-table th:nth-child(1) { width: 46px; text-align: center; }
.guesses-table th:nth-child(2) { width: auto; }
.guesses-table th:nth-child(3) { width: 72px; text-align: right; }
.guesses-table th:nth-child(4) { width: 170px; padding: 0 12px; }
.sort-btn {
  width: 100%;
  min-width: 44px;
  min-height: 44px;
  padding: 8px 6px;
  border: 0;
  background: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: inherit;
  white-space: nowrap;
}
.guesses-table th:nth-child(1) .sort-btn { justify-content: center; padding: 8px 4px; }
.guesses-table th:nth-child(3) .sort-btn { justify-content: flex-end; }
.sort-btn.is-sorted { color: var(--gold-bright); }
.sort-btn.is-sorted::after { content: attr(data-dir); font-size: 10px; }
.sort-btn.is-sorted[data-dir='desc']::after { content: '▼'; }
.sort-btn.is-sorted[data-dir='asc']::after { content: '▲'; }

.guesses-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.guesses-table td.col-no {
  text-align: center;
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 13px;
}
.guesses-table td.col-word { font-weight: 600; overflow-wrap: anywhere; }
.latest-pill {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  color: #191105;
  background: var(--gold-bright);
  vertical-align: middle;
}
.guesses-table td.col-sim {
  text-align: right;
  font-family: var(--display);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.guesses-table td.col-rank { padding: 8px 12px; }

.guesses-table tr.latest-guess { background: rgba(213, 166, 84, 0.14); }
.guesses-table tr.latest-guess .word-text { color: var(--gold-bright); font-weight: 800; }
.guesses-table tr.delimiter td {
  padding: 0;
  height: 3px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.guesses-table tr.is-new {
  animation: row-flash 0.65s ease-out;
}

.rank-meter-wrap { display: flex; flex-direction: column; gap: 4px; }
.rank-badge { display: inline-block; font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-badge.is-exact {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--gold-bright);
  color: #191105;
}
.rank-outside { font-size: 11.5px; color: var(--text-muted); }

.tier-exact .col-sim { color: var(--gold-bright); }
.tier-molten .rank-badge, .tier-molten .col-sim { color: var(--molten); }
.tier-hot .rank-badge, .tier-hot .col-sim { color: var(--amber); }
.tier-warm .rank-badge, .tier-warm .col-sim { color: var(--violet); }
.tier-cool .col-sim { color: var(--cyan); }
.tier-cold .col-sim { color: var(--text-muted); }

.sim-meter {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: rgba(181, 195, 200, 0.16);
  overflow: hidden;
}
.sim-meter i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet), var(--amber), var(--gold-bright));
}

.empty-history {
  padding: 18px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.empty-history h2 { margin: 0 0 6px; font-size: 18px; font-weight: 800; color: var(--gold-bright); }
.empty-history p { margin: 0 0 14px; font-size: 13px; color: var(--text-muted); word-break: keep-all; }
.starter-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.starter-chip {
  position: relative;
  isolation: isolate;
  min-height: 44px;
  padding: 8px 18px;
  border: 0;
  background: none;
  color: var(--gold-bright);
  font-size: 14px;
  font-weight: 800;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.45));
  transition: filter 0.15s, transform 0.12s;
}
.starter-chip::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 10px solid transparent;
  border-image: var(--btn-teal-skin) 24% 11% fill / 10px 14px / 0 stretch;
  pointer-events: none;
}
.starter-chip:hover { filter: brightness(1.18); transform: translateY(-1px); }

.site-footer {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px clamp(16px, 4vw, 40px) 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #b5c5ca;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

.notice {
  position: fixed;
  z-index: 40;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 28px));
  padding: 12px 20px;
  border-radius: 10px;
  background: #0a1b26;
  border: 1px solid var(--gold);
  color: var(--text);
  font-size: 13px;
  box-shadow: var(--shadow);
  text-align: center;
}

/* 게임 다이얼로그 */
.game-dialog {
  width: min(580px, calc(100vw - 24px));
  max-height: calc(100dvh - 36px);
  overflow: auto;
  padding: 18px 14px;
  background: transparent;
  color: var(--text);
}
.game-dialog::backdrop { background: rgba(3, 8, 14, 0.78); backdrop-filter: blur(6px); }
.dialog-close { position: absolute; right: 10px; top: 10px; }
.game-dialog h2 { margin: 0 46px 8px 0; font-size: 22px; font-weight: 800; color: var(--gold-bright); }
.dialog-intro { margin: 0 0 14px; font-size: 13px; color: var(--text-muted); word-break: keep-all; }

.name-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.name-form input {
  flex: 1;
  min-width: 150px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-input);
}
.name-form button { min-height: 44px; min-width: 78px; padding: 8px 18px; font-size: 14px; }
.name-help { width: 100%; margin: 0; font-size: 11.5px; color: var(--text-muted); }
.name-status { width: 100%; margin: 0; font-size: 12px; color: var(--gold-bright); }

.leaderboard table, .nearest-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.leaderboard th, .nearest-table th {
  padding: 8px 6px;
  text-align: left;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--line);
}
.leaderboard td, .nearest-table td { padding: 10px 6px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.leaderboard tr.own { background: rgba(213, 166, 84, 0.16); color: var(--gold-bright); font-weight: 700; }
.own-rank { margin: 12px 0 0; font-size: 13px; color: var(--gold-bright); font-weight: 700; }

.nearest-filter {
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-input);
}
.nearest-scroll { max-height: 52dvh; overflow-y: auto; }
.nearest-table th:nth-child(1), .nearest-table td:nth-child(1) { width: 50px; }
.nearest-table th:nth-child(3), .nearest-table td:nth-child(3) { width: 72px; text-align: right; }
.nearest-table th:nth-child(4), .nearest-table td:nth-child(4) { width: 110px; padding-left: 10px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stats-grid > div {
  padding: 10px;
  border-radius: 8px;
  background: rgba(11, 31, 44, 0.72);
  border: 1px solid rgba(181, 195, 200, 0.15);
  text-align: center;
}
.stats-grid span { display: block; font-size: 11px; color: var(--text-muted); }
.stats-grid strong { font-family: var(--display); font-size: 18px; font-weight: 800; color: var(--gold-bright); font-variant-numeric: tabular-nums; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  padding: 11px 14px;
  border-radius: 8px;
  background: rgba(11, 31, 44, 0.72);
  border: 1px solid rgba(181, 195, 200, 0.15);
}
.faq-item h3 { margin: 0 0 4px; font-size: 14px; font-weight: 800; color: var(--gold-bright); }
.faq-item p { margin: 0; font-size: 13px; color: var(--text-muted); word-break: keep-all; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  margin: 8px 0;
  font-size: 14px;
}
.setting-row input[type='checkbox'] { width: 22px; height: 22px; accent-color: var(--gold); }
#sound-volume { width: 100%; height: 44px; accent-color: var(--gold); }
.confirm-dialog { width: min(420px, calc(100vw - 24px)); text-align: center; }
.confirm-dialog h2 { margin-right: 0; }
.confirm-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 16px; }
.confirm-actions > button { min-height: 46px; min-width: 140px; }

/* 애니메이션 및 이펙트 */
@keyframes compass-float {
  from { transform: translateY(0px); }
  to { transform: translateY(-7px); }
}
@keyframes emblem-pulse {
  from { opacity: 0.4; transform: scale(0.92) rotate(0deg); }
  to { opacity: 0.75; transform: scale(1.06) rotate(12deg); }
}
@keyframes row-flash {
  0% { background-color: rgba(255, 230, 168, 0.32); transform: translateY(-4px); }
  100% { transform: translateY(0); }
}
@keyframes subtle-hit {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}
@keyframes victory-pop {
  0% { opacity: 0.2; transform: scale(0.94); }
  65% { transform: scale(1.02); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes solve-shockwave {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.25) rotate(-18deg); }
  25% { opacity: 0.96; transform: translate(-50%, -50%) scale(1.06) rotate(4deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.68) rotate(22deg); }
}
@keyframes loading-emblem-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
@keyframes gauge-sweep {
  0% { clip-path: inset(0 84% 0 0); }
  65% { clip-path: inset(0 26% 0 0); }
  100% { clip-path: inset(0 12% 0 0); }
}

@media (max-width: 820px) {
  .title-screen { grid-template-columns: 1fr; text-align: left; gap: 24px; }
  .compass-showcase { width: 120px; height: 124px; margin-bottom: -20px; }
  .showcase-compass { width: 100px; }
  .showcase-burst { width: 190px; height: 190px; }
}

@media (max-width: 600px) {
  .site-header { padding: 10px 12px; gap: 6px; }
  .brand { width: 44px; min-width: 44px; justify-content: center; }
  .brand > span { display: none; }
  .header-controls { gap: 4px; }
  .languages { font-size: 11px; gap: 2px; margin-right: 0; }
  .languages span { display: none; }
  .languages a { padding: 0 4px; }
  .hero-stat strong { font-size: 20px; }
  .example-card { padding: 18px 10px 10px; }
  .ex-row { grid-template-columns: minmax(0, 1fr) 54px 1fr; padding: 8px 10px; }
  .hud-card { padding: 6px 5px; }
  .hud-card strong { font-size: 17px; }
  .guesses-table th:nth-child(4) { width: 122px; padding: 0 8px; }
  .guesses-table td.col-rank { padding: 8px; }
  .guesses-table th:nth-child(3) { width: 64px; }
  .rank-badge, .rank-outside { font-size: 11px; }
  .ledger-panel { height: clamp(210px, 34dvh, 330px); }
  .result-stats { grid-template-columns: repeat(2, 1fr); }
  .keyboard-open .site-header,
  .keyboard-open .site-footer,
  .keyboard-open .chronometer-console,
  .keyboard-open .composer-status-slot .input-hint { display: none; }
  .keyboard-open .composer-status-slot { height: 34px; }
  .keyboard-open .ledger-panel { height: clamp(130px, 24dvh, 200px); }
  .keyboard-open .empty-history { padding: 10px; }
  .keyboard-open .empty-history p { display: none; }
  .keyboard-open .notice { top: calc(env(safe-area-inset-top, 0px) + 12px); bottom: auto; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .title-screen { grid-template-columns: 1.1fr 0.9fr; padding-top: 8px; }
  .ledger-panel { height: clamp(150px, 36dvh, 220px); }
  .keyboard-open .site-header,
  .keyboard-open .site-footer,
  .keyboard-open .chronometer-console,
  .keyboard-open .composer-status-slot .input-hint { display: none; }
  .keyboard-open .composer-status-slot { height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .vfx-canvas, .vfx-burst { display: none !important; }
}
