@import url("https://fonts.googleapis.com/css2?family=Gowun+Batang:wght@400;700&family=Noto+Sans+KR:wght@500;700;900&display=swap");

:root {
  --bg: #fff8f0;
  --paper: #fffdf8;
  --ink: #382521;
  --muted: #856761;
  --rose: #df6f7c;
  --deep: #ad3447;
  --carnation: #c94155;
  --leaf: #667d58;
  --gold: #c99b5e;
  --line: rgba(113, 64, 54, 0.16);
  --shadow: 0 22px 56px rgba(115, 55, 46, 0.18);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(255, 255, 255, 0.44) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.38) 1px, transparent 1px),
    linear-gradient(180deg, #fffaf4 0%, #ffe8df 54%, #fff3e8 100%);
  background-size: 26px 26px, 26px 26px, auto;
}

.app {
  position: relative;
  width: min(100%, 430px);
  min-height: 100svh;
  margin: 0 auto;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.84), rgba(255, 242, 232, 0.78)),
    var(--bg);
}

.screen {
  min-height: 100svh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(22px, env(safe-area-inset-bottom));
}

.screen--video {
  position: relative;
  display: grid;
  place-items: center;
  padding: 0;
  background: #1d1210;
}

.intro-video {
  width: 100%;
  height: auto;
  max-height: 100svh;
  object-fit: contain;
  background: #1d1210;
}

.video-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 14px;
  padding: 32px 26px;
  color: var(--ink);
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.94), rgba(255, 231, 222, 0.92)),
    var(--bg);
  animation: fadeIn 760ms ease both;
}

.fallback-flower {
  width: min(52vw, 190px);
  margin: 0 auto 4px;
  filter: drop-shadow(0 18px 22px rgba(173, 52, 71, 0.14));
  animation: riseIn 900ms ease both;
}

.fallback-kicker,
.eyebrow {
  margin: 0;
  color: var(--deep);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

h1 {
  margin: 0;
  font-family: "Gowun Batang", "Noto Sans KR", serif;
  font-size: clamp(28px, 7.5vw, 38px);
  line-height: 1.18;
  letter-spacing: 0;
}

.button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--deep), #7f2535);
  box-shadow: 0 14px 28px rgba(173, 52, 71, 0.24);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
}

.screen--gift {
  display: grid;
  align-items: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 680ms ease, transform 680ms ease;
}

.screen--gift.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gift-content {
  display: grid;
  gap: 12px;
  width: 100%;
  margin: auto 0;
}

.title-block {
  position: relative;
  padding-top: 8px;
  text-align: center;
  animation: riseIn 760ms ease both;
}

.title-flower {
  position: absolute;
  top: -6px;
  right: -18px;
  width: 118px;
  opacity: 0.3;
  pointer-events: none;
}

.eyebrow {
  margin-bottom: 8px;
}

.screen-note {
  max-width: 22em;
  margin: 0 auto;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.58;
  text-align: center;
}

.draw-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
  width: 100%;
  max-width: min(100%, calc(100svh - 250px));
  max-height: calc(100svh - 250px);
  aspect-ratio: 1;
  margin: 0 auto;
  animation: fadeIn 900ms ease 140ms both;
}

.tile {
  appearance: none;
  position: relative;
  display: grid;
  place-items: center;
  gap: 8px;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 246, 238, 0.92)),
    var(--paper);
  box-shadow: 0 10px 24px rgba(115, 55, 46, 0.12);
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.tile__mark {
  display: grid;
  place-items: center;
  width: clamp(40px, 13vw, 56px);
  height: clamp(40px, 13vw, 56px);
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--rose), var(--deep));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
  text-shadow: none;
  font-size: clamp(26px, 8vw, 34px);
  line-height: 1;
}

.tile__label {
  color: var(--muted);
  font-size: 12px;
  line-height: 1;
}

.dialog,
.scratch-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(43, 24, 20, 0.48);
  opacity: 0;
  transition: opacity 260ms ease;
}

.dialog.is-visible {
  opacity: 1;
}

.scratch-modal {
  z-index: 20;
  padding: 18px;
}

.scratch-modal.is-visible {
  opacity: 1;
}

.dialog__panel {
  width: min(100%, 340px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 30px 22px 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 247, 239, 0.98)),
    var(--paper);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateY(8px) scale(0.98);
  transition: transform 320ms ease;
}

.dialog.is-visible .dialog__panel {
  transform: translateY(0) scale(1);
}

.dialog__message {
  margin: 0 0 22px;
  white-space: pre-line;
  font-family: "Gowun Batang", "Noto Sans KR", serif;
  font-size: 23px;
  line-height: 1.6;
  font-weight: 700;
}

.scratch-modal__panel {
  display: grid;
  gap: 18px;
  width: min(100%, 330px);
  justify-items: stretch;
  transform: translateY(14px) scale(0.96);
  transition: transform 300ms ease;
}

.scratch-modal.is-visible .scratch-modal__panel {
  transform: translateY(0) scale(1);
}

.scratch-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 248, 241, 0.98)),
    var(--paper);
  box-shadow: var(--shadow);
}

.scratch-card__result {
  display: grid;
  gap: 10px;
  place-items: center;
  width: 100%;
  height: 100%;
  padding: 28px;
  text-align: center;
}

.scratch-card__image {
  display: block;
  width: min(78%, 220px);
  max-height: 170px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px rgba(57, 39, 35, 0.12));
}

.scratch-card__result span {
  font-family: "Gowun Batang", "Noto Sans KR", serif;
  font-size: clamp(30px, 8vw, 42px);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.scratch-card.has-image .scratch-card__result {
  align-content: center;
  grid-template-rows: auto auto;
  padding: 24px 24px 34px;
}

.scratch-card.has-image .scratch-card__result span {
  font-size: clamp(24px, 6.5vw, 34px);
}

.scratch-card__label {
  position: absolute;
  left: 50%;
  bottom: 13%;
  z-index: 2;
  translate: -50% 0;
  color: var(--muted);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.scratch-card__canvas {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: calc(100% + 20px);
  height: calc(100% + 20px);
  border-radius: inherit;
  cursor: grab;
  touch-action: none;
}

.scratch-card__canvas:active {
  cursor: grabbing;
}

.confetti-burst {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: confettiPop 920ms ease-out forwards;
}

.tile.is-revealed {
  padding: 8px;
  border-color: rgba(173, 52, 71, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 241, 232, 0.98)),
    var(--paper);
}

.tile__prize {
  display: block;
  max-width: 100%;
  color: var(--ink);
  font-family: "Gowun Batang", "Noto Sans KR", serif;
  font-size: clamp(12px, 3.5vw, 16px);
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: pre-line;
  text-align: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes confettiPop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4) rotate(0deg);
  }

  12% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) scale(1) rotate(var(--r));
  }
}

@media (min-width: 431px) {
  body {
    background-color: #2a1a16;
  }

  .app {
    box-shadow: 0 0 70px rgba(87, 42, 32, 0.24);
  }
}

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