:root {
  --bg: #f3e8d0;
  --bg-soft: #ece0bf;
  --card-bg: #fffaf0;
  --accent: #b8460e;
  --accent-strong: #8f370b;
  --text: #3d2b1f;
  --text-dim: #8a7256;
  --border: #d9c9a0;
  --tape: rgba(255, 221, 130, 0.65);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background-color: var(--bg);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse 140% 60% at 50% -10%, rgba(255, 255, 255, 0.5) 0%, transparent 60%),
    radial-gradient(ellipse 140% 60% at 50% 110%, rgba(61, 43, 31, 0.14) 0%, transparent 60%);
  background-size: 180px 180px, cover, cover;
  background-repeat: repeat, no-repeat, no-repeat;
  background-blend-mode: overlay, normal, normal;
  background-attachment: fixed, fixed, fixed;
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  text-align: center;
  padding: 32px 16px 8px;
}

.site-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

.particles {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.particles span {
  position: absolute;
  bottom: -12px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: floatUp 9s linear infinite;
}

.particles span:nth-child(1) { left: 4%; animation-delay: 0s; animation-duration: 8s; }
.particles span:nth-child(2) { left: 14%; animation-delay: 1.2s; animation-duration: 11s; width: 3px; height: 3px; }
.particles span:nth-child(3) { left: 24%; animation-delay: 2.5s; animation-duration: 9s; }
.particles span:nth-child(4) { left: 36%; animation-delay: 0.6s; animation-duration: 12s; width: 5px; height: 5px; }
.particles span:nth-child(5) { left: 48%; animation-delay: 3.4s; animation-duration: 8.5s; }
.particles span:nth-child(6) { left: 58%; animation-delay: 1.8s; animation-duration: 10.5s; width: 3px; height: 3px; }
.particles span:nth-child(7) { left: 68%; animation-delay: 4s; animation-duration: 9.5s; }
.particles span:nth-child(8) { left: 78%; animation-delay: 0.3s; animation-duration: 11.5s; width: 5px; height: 5px; }
.particles span:nth-child(9) { left: 88%; animation-delay: 2.2s; animation-duration: 8.8s; }
.particles span:nth-child(10) { left: 94%; animation-delay: 3.8s; animation-duration: 10s; width: 3px; height: 3px; }

@keyframes floatUp {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 0.7; }
  90% { opacity: 0.2; }
  100% { transform: translateY(-100vh); opacity: 0; }
}

.clock-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.clock-hand {
  transform-origin: 20px 20px;
}

.clock-hand.hour {
  animation: spinHand 6s linear infinite;
}

.clock-hand.minute {
  animation: spinHand 2.4s linear infinite;
}

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

.time-machine {
  position: relative;
  max-width: 640px;
  margin: 24px auto;
  padding: 20px 20px 16px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 20px;
  text-align: center;
}

.time-machine::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 26px;
  background: conic-gradient(from 0deg, transparent, var(--accent-strong) 6%, transparent 18%, transparent 82%, var(--accent-strong) 94%, transparent);
  opacity: 0.7;
  filter: blur(5px);
  animation: rotateRing 6s linear infinite;
  z-index: -1;
}

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

.dial-readout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 14px;
}

.era-label {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  min-width: 160px;
  transition: opacity 0.15s ease;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dial-wheel-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 10px;
}

.dial-wheel {
  position: relative;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, var(--card-bg) 0%, var(--bg-soft) 72%);
  border: 1px solid var(--border);
  box-shadow: inset 0 0 0 6px var(--bg), 0 4px 10px rgba(61, 43, 31, 0.15);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.dial-wheel:active {
  cursor: grabbing;
}

.dial-ticks-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.dial-tick {
  stroke: var(--border);
  stroke-width: 2;
}

.dial-tick-major {
  stroke: var(--accent);
  stroke-width: 3;
}

.dial-tick-label {
  fill: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
}

.dial-pointer-anchor {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
}

.dial-pointer {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 4px;
  height: 76px;
  background: var(--accent);
  border-radius: 4px;
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(0deg);
  pointer-events: none;
}

.dial-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--card-bg);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(61, 43, 31, 0.2);
  pointer-events: none;
}

.now-btn {
  margin-top: 14px;
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}

.now-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.category-section {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-width: 16px;
  border-bottom-color: var(--card-bg);
  border-radius: 4px;
  padding: 18px;
  box-shadow: 3px 4px 10px rgba(61, 43, 31, 0.15);
  animation: photoDevelop 0.7s ease-out;
  transition: transform 0.2s ease;
}

.category-section:nth-child(odd) { transform: rotate(-1deg); }
.category-section:nth-child(even) { transform: rotate(1deg); }

.category-section:hover {
  transform: rotate(0deg) scale(1.02);
  z-index: 2;
}

.category-section::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 56px;
  height: 20px;
  background: var(--tape);
  transform: translateX(-50%) rotate(-3deg);
  box-shadow: 0 1px 2px rgba(61, 43, 31, 0.2);
}

.category-section h2 {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--accent);
}

.item-card {
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

.item-card:first-of-type {
  border-top: none;
  padding-top: 0;
}

.item-card .item-name {
  font-weight: 600;
  font-size: 14px;
}

.item-card .item-desc {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-dim);
}

.empty-note {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 14px;
  padding: 24px 0;
}

.insights {
  max-width: 960px;
  margin: 40px auto 0;
  padding: 24px 4px 0;
  border-top: 1px solid var(--border);
}

.insights-title {
  margin: 8px 0 4px;
  font-size: 20px;
}

.insights-sub {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 13px;
}

.reveal-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 auto 22px;
  padding: 12px 22px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.reveal-btn:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}

.reveal-btn:active {
  transform: scale(0.97);
}

.reveal-icon {
  display: inline-block;
  font-size: 20px;
  animation: floatIcon 2.2s ease-in-out infinite;
}

.reveal-btn.opened .reveal-icon {
  animation: none;
}

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

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.5s ease;
}

.insights-grid.open {
  max-height: 3000px;
}

.insight-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-width: 16px;
  border-bottom-color: var(--card-bg);
  border-radius: 4px;
  padding: 18px;
  box-shadow: 3px 4px 10px rgba(61, 43, 31, 0.15);
  opacity: 0;
  filter: blur(7px) saturate(0.2) brightness(1.3);
  transform: translateY(24px) rotate(-1deg) scale(0.97);
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.5s ease;
  pointer-events: none;
}

.insight-card:nth-child(even) {
  transform: translateY(24px) rotate(1deg) scale(0.97);
}

.insight-card.revealed {
  opacity: 1;
  filter: blur(0) saturate(1) brightness(1);
  transform: translateY(0) rotate(-1deg) scale(1);
  pointer-events: auto;
}

.insight-card:nth-child(even).revealed {
  transform: translateY(0) rotate(1deg) scale(1);
}

.insight-card:hover {
  transform: rotate(0deg) scale(1.02) !important;
  z-index: 2;
}

.insight-card::before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  width: 56px;
  height: 20px;
  background: var(--tape);
  transform: translateX(-50%) rotate(-3deg);
  box-shadow: 0 1px 2px rgba(61, 43, 31, 0.2);
}

.insight-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--accent);
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.bar-label {
  width: 84px;
  flex-shrink: 0;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spark-caption {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.fact-stack .fact-item {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.fact-stack .fact-item:first-child {
  border-top: none;
  padding-top: 0;
}

.fact-number {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
}

.fact-desc {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.quiz {
  max-width: 640px;
  margin: 40px auto 0;
  padding: 24px 4px 0;
  border-top: 1px solid var(--border);
  text-align: center;
}

.quiz-title {
  margin: 8px 0 4px;
  font-size: 20px;
}

.quiz-sub {
  margin: 0 0 18px;
  color: var(--text-dim);
  font-size: 13px;
}

.quiz-area {
  display: flex;
  justify-content: center;
}

.quiz-card {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom-width: 16px;
  border-bottom-color: var(--card-bg);
  border-radius: 4px;
  padding: 26px 22px;
  box-shadow: 3px 4px 10px rgba(61, 43, 31, 0.15);
  animation: photoDevelop 0.5s ease-out;
}

.quiz-progress {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.quiz-word {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 4px;
}

.quiz-question-label {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  text-align: left;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.quiz-option:hover {
  border-color: var(--accent);
  transform: scale(1.01);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.correct {
  background: #d8e8c8;
  border-color: #5a8a3a;
  color: #2f4a1c;
}

.quiz-option.incorrect {
  background: #f0d3c8;
  border-color: #b8460e;
  color: #7a2c0a;
}

.quiz-result-emoji {
  font-size: 40px;
  margin-bottom: 8px;
}

.quiz-result-label {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 8px;
}

.quiz-result-score {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

.chat-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
}

.chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--card-bg);
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(61, 43, 31, 0.25);
  transition: transform 0.15s ease;
}

.chat-toggle:hover {
  transform: scale(1.08);
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 68px;
  width: 300px;
  max-height: 420px;
  flex-direction: column;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 4px 6px 16px rgba(61, 43, 31, 0.25);
  overflow: hidden;
}

.chat-panel:not([hidden]) {
  display: flex;
}

.chat-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}

.chat-close {
  border: none;
  background: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-dim);
  line-height: 1;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: 10px;
  max-width: 85%;
}

.chat-msg-bot {
  background: var(--bg-soft);
  color: var(--text);
  align-self: flex-start;
}

.chat-msg-user {
  background: var(--accent);
  color: #fffaf0;
  align-self: flex-end;
}

.chat-msg-loading {
  background: var(--bg-soft);
  color: var(--text-dim);
  align-self: flex-start;
  font-style: italic;
}

.chat-input-row {
  display: flex;
  border-top: 1px solid var(--border);
}

.chat-input {
  flex: 1;
  border: none;
  padding: 10px 12px;
  font-size: 13px;
  background: var(--card-bg);
  color: var(--text);
  outline: none;
}

.chat-send {
  border: none;
  background: var(--accent);
  color: #fffaf0;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chat-send:hover {
  background: var(--accent-strong);
}

@media (max-width: 480px) {
  .chat-panel { width: 84vw; }
}

.category-section.chat-highlight {
  animation: chatPulse 1.4s ease;
}

@keyframes chatPulse {
  0%, 100% { box-shadow: 3px 4px 10px rgba(61, 43, 31, 0.15); }
  30% { box-shadow: 0 0 0 4px var(--accent), 3px 4px 10px rgba(61, 43, 31, 0.15); }
}

.site-footer {
  text-align: center;
  padding: 16px;
  color: var(--text-dim);
  font-size: 12px;
}

@keyframes photoDevelop {
  0% { opacity: 0; filter: blur(9px) saturate(0.15) brightness(1.35); transform: translateY(10px) scale(0.96); }
  55% { opacity: 1; filter: blur(2px) saturate(0.6) brightness(1.1); }
  100% { opacity: 1; filter: blur(0) saturate(1) brightness(1); transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  .site-header h1 { font-size: 24px; }
  .time-machine { margin: 16px 12px; padding: 16px; }
  .dial-wheel { width: 180px; height: 180px; }
  .dial-pointer { height: 60px; }
  .dial-tick-label { font-size: 9px; }
}
