:root {
  color-scheme: light;
  --bg: #f8faf7;
  --paper: #fffdf8;
  --surface: #ffffff;
  --surface-strong: #f1f6f4;
  --ink: #14213d;
  --muted: #5c687a;
  --line: #dbe4df;
  --gold: #c99423;
  --gold-soft: #fff2c4;
  --teal: #108d86;
  --teal-soft: #dff5f1;
  --red: #c44848;
  --shadow: 0 18px 50px rgba(20, 33, 61, 0.12);
  --radius: 8px;
  --speed: 180ms;
  font-family:
    Inter, "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui,
    -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.68)),
    radial-gradient(circle at 30% 20%, rgba(255, 242, 196, 0.5), transparent 26rem),
    linear-gradient(135deg, #f8faf7 0%, #eef6f2 50%, #f9fbf7 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.app {
  min-height: 100vh;
  padding: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1280px;
  margin: 0 auto 18px;
  padding: 10px 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(201, 148, 35, 0.45);
  border-radius: var(--radius);
  background: var(--gold-soft);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(201, 148, 35, 0.12);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
}

.brand strong {
  display: block;
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
  font-weight: 820;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.top-actions,
.tool-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.icon-button,
.tool-button,
.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 780;
  letter-spacing: 0;
  text-decoration: none;
  transition:
    transform var(--speed) ease,
    border-color var(--speed) ease,
    background var(--speed) ease,
    box-shadow var(--speed) ease;
}

.icon-button {
  padding: 0 13px;
}

.tool-button,
.primary-action {
  padding: 0 14px;
}

.icon-button:hover,
.tool-button:hover,
.primary-action:hover {
  transform: translateY(-1px);
  border-color: rgba(16, 141, 134, 0.5);
  box-shadow: 0 10px 22px rgba(20, 33, 61, 0.08);
}

.icon-button:focus-visible,
.tool-button:focus-visible,
.primary-action:focus-visible,
.drop-zone:focus-within,
canvas:focus-visible,
input[type="range"]:focus-visible {
  outline: 3px solid rgba(16, 141, 134, 0.25);
  outline-offset: 3px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
  align-items: start;
}

.intro-panel,
.game-panel,
.verse-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 0.9fr);
  min-height: 560px;
  gap: 24px;
  align-items: center;
  padding: clamp(22px, 4vw, 48px);
}

.intro-copy h1 {
  max-width: 650px;
  margin: 0;
  font-size: clamp(2.3rem, 6vw, 5.25rem);
  font-weight: 880;
  line-height: 0.98;
  letter-spacing: 0;
}

.intro-copy p {
  max-width: 640px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.18rem);
  font-weight: 570;
  line-height: 1.72;
}

.drop-zone {
  display: flex;
  min-height: 340px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1.5px dashed rgba(16, 141, 134, 0.5);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(223, 245, 241, 0.82), rgba(255, 253, 248, 0.94)),
    var(--surface);
  color: var(--ink);
  text-align: center;
  transition:
    border-color var(--speed) ease,
    background var(--speed) ease,
    transform var(--speed) ease;
}

.drop-zone.is-dragging {
  transform: translateY(-2px);
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(255, 242, 196, 0.94), rgba(255, 253, 248, 0.96));
}

.drop-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.drop-icon {
  display: grid;
  width: 72px;
  height: 72px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--teal);
  box-shadow: 0 12px 30px rgba(16, 141, 134, 0.15);
}

.drop-icon svg {
  width: 38px;
  height: 38px;
}

.drop-title {
  font-size: 1.22rem;
  font-weight: 850;
}

.drop-note {
  max-width: 260px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 620;
  line-height: 1.45;
}

.game-panel {
  padding: 16px;
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px 16px;
}

.progress-block {
  display: grid;
  gap: 5px;
}

.progress-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 780;
}

.progress-block strong {
  font-size: 1.6rem;
  line-height: 1;
}

.progress-dots {
  display: flex;
  gap: 5px;
}

.progress-dots span {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(20, 33, 61, 0.2);
  border-radius: 50%;
  background: #fff;
}

.progress-dots span.is-found {
  border-color: var(--teal);
  background: var(--teal);
}

.volume-control {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
}

.volume-control label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.volume-control input {
  width: 92px;
  accent-color: var(--teal);
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.image-board {
  min-width: 0;
  margin: 0;
}

.image-board figcaption {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 830;
}

.canvas-frame {
  position: relative;
  display: grid;
  min-height: 260px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(45deg, rgba(219, 228, 223, 0.45) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(219, 228, 223, 0.45) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(219, 228, 223, 0.45) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(219, 228, 223, 0.45) 75%),
    var(--paper);
  background-position:
    0 0,
    0 9px,
    9px -9px,
    -9px 0;
  background-size: 18px 18px;
}

.active-frame {
  cursor: crosshair;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: 62vh;
  object-fit: contain;
  border-radius: calc(var(--radius) - 2px);
}

.image-board--active canvas {
  cursor: crosshair;
}

.status-line {
  min-height: 24px;
  margin: 14px 2px 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 700;
}

.status-line.is-good {
  color: var(--teal);
}

.status-line.is-warn {
  color: var(--red);
}

.hint-ring {
  position: absolute;
  width: 74px;
  height: 74px;
  pointer-events: none;
  border: 3px solid var(--gold);
  border-radius: 50%;
  box-shadow:
    0 0 0 7px rgba(201, 148, 35, 0.18),
    0 0 28px rgba(201, 148, 35, 0.44);
  transform: translate(-50%, -50%);
  animation: hintPulse 1s ease-in-out infinite;
}

.verse-panel {
  position: sticky;
  top: 20px;
  min-height: 560px;
  padding: 18px;
}

.verse-empty,
.verse-card {
  display: flex;
  min-height: 520px;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  border-radius: var(--radius);
}

.verse-empty {
  gap: 12px;
  padding: 24px;
  background: linear-gradient(180deg, rgba(241, 246, 244, 0.96), rgba(255, 253, 248, 0.9));
}

.verse-empty span {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--gold-soft);
  color: var(--ink);
}

.verse-empty svg {
  width: 30px;
  height: 30px;
}

.verse-empty h2,
.verse-card h2 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.2;
}

.verse-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.62;
}

.verse-card {
  position: relative;
  gap: 12px;
  padding: 28px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 242, 196, 0.72), rgba(223, 245, 241, 0.92)),
    var(--paper);
}

.verse-card::before {
  content: "";
  position: absolute;
  inset: 18px;
  border: 1px solid rgba(201, 148, 35, 0.35);
  border-radius: var(--radius);
  pointer-events: none;
}

.complete-mark {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  box-shadow: 0 18px 40px rgba(16, 141, 134, 0.24);
}

.complete-mark svg {
  width: 30px;
  height: 30px;
  stroke-width: 2.5;
}

.complete-label {
  margin: 8px 0 0;
  color: var(--teal);
  font-size: 0.8rem;
  font-weight: 860;
}

.verse-card blockquote {
  position: relative;
  z-index: 1;
  margin: 8px 0 0;
  font-size: clamp(1.5rem, 2.8vw, 2.15rem);
  font-weight: 840;
  line-height: 1.28;
}

.verse-note {
  position: relative;
  z-index: 1;
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 680;
  line-height: 1.65;
}

.primary-action {
  position: relative;
  z-index: 1;
  min-height: 46px;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.is-hidden {
  display: none !important;
}

@keyframes hintPulse {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.92);
    opacity: 0.72;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.06);
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .verse-panel {
    position: static;
    min-height: auto;
  }

  .verse-empty,
  .verse-card {
    min-height: 320px;
  }

  .intro-panel {
    grid-template-columns: 1fr;
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 14px;
  }

  .topbar,
  .game-toolbar,
  .top-actions {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .top-actions,
  .tool-group {
    width: 100%;
  }

  .icon-button,
  .tool-button,
  .file-action,
  .volume-control {
    flex: 1 1 150px;
  }

  .board-grid {
    grid-template-columns: 1fr;
  }

  .game-toolbar {
    flex-direction: column;
  }

  .progress-block {
    width: 100%;
  }

  .drop-zone {
    min-height: 260px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
