/* ─── 말랑 공방 ─── */
:root {
  --bg: #fdf6ee;
  --bg2: #f7ebde;
  --ink: #3d3229;
  --ink-soft: #8a7a6a;
  --accent: #ff8fab;
  --accent-deep: #f26d92;
  --card: #ffffff;
  --line: #eadfd2;
  --radius: 22px;
  --shadow: 0 10px 30px rgba(120, 90, 60, 0.12);
}

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

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 700px at 85% -10%, #ffe3ec 0%, transparent 55%),
    radial-gradient(900px 600px at -10% 100%, #e3f3ff 0%, transparent 50%),
    var(--bg);
  color: var(--ink);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  overflow-x: hidden;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

.screen { flex: 1; display: flex; flex-direction: column; }

/* ═══ 홈 ═══ */
#screen-home {
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 40px 20px 24px;
  text-align: center;
}

.hero .logo {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  margin: 0 0 6px;
  letter-spacing: -0.02em;
}
.logo-emoji { display: inline-block; animation: wobble 3.2s ease-in-out infinite; }
@keyframes wobble {
  0%, 100% { transform: rotate(-6deg) scale(1); }
  25% { transform: rotate(4deg) scale(1.08, 0.94); }
  50% { transform: rotate(-3deg) scale(0.95, 1.06); }
  75% { transform: rotate(5deg) scale(1.04, 0.97); }
}
.tagline {
  font-size: clamp(1.05rem, 2.6vw, 1.3rem);
  font-weight: 700;
  color: var(--accent-deep);
  margin: 0 0 10px;
}
.sub { color: var(--ink-soft); line-height: 1.65; margin: 0; font-size: 0.95rem; }

.dropzone {
  width: min(560px, 92vw);
  border: 3px dashed #e8b7c8;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
  padding: 40px 24px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  transform: scale(1.02);
  border-color: var(--accent-deep);
  background: #fff;
  outline: none;
}
.dropzone.dragover { transform: scale(1.05); }
.dz-emoji { font-size: 2.6rem; margin-bottom: 8px; }
.dz-title { font-weight: 700; font-size: 1.05rem; }
.dz-hint { color: var(--ink-soft); font-size: 0.85rem; margin-top: 6px; }

.preset-row { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.preset-label { color: var(--ink-soft); font-size: 0.9rem; }
.preset-btns { display: flex; gap: 10px; }
.preset-btn {
  font-size: 2rem;
  width: 62px; height: 62px;
  border: none;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.preset-btn:hover { transform: translateY(-4px) scale(1.1) rotate(-4deg); }
.preset-btn:active { transform: scale(0.9, 1.05); }

.home-footer { font-size: 0.78rem; color: #b7a893; padding-bottom: 8px; }

/* ═══ 플레이 ═══ */
#screen-play { flex-direction: row; height: 100vh; height: 100dvh; }

.stage-wrap { position: relative; flex: 1; min-width: 0; }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#stage.grabbing { cursor: grabbing; }
#stage.pressing { cursor: cell; }

.squish-counter {
  position: absolute; top: 14px; left: 16px;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  user-select: none;
  pointer-events: none;
}
.stage-hint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  color: var(--ink-soft);
  background: rgba(255,255,255,0.7);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.82rem;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 1s ease;
}
.stage-hint.fade { opacity: 0; }

/* 패널 */
.panel {
  width: 300px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(10px);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
  gap: 8px;
}
.panel-title { font-weight: 800; font-size: 0.95rem; }
.ghost-btn {
  border: none; background: none; cursor: pointer;
  color: var(--ink-soft); font-size: 0.85rem; font-weight: 600;
  padding: 6px 8px; border-radius: 10px;
}
.ghost-btn:hover { background: var(--bg2); color: var(--ink); }
.panel-toggle { display: none; }

.panel-body { padding: 16px 16px 24px; display: flex; flex-direction: column; gap: 20px; }

.opt-group { display: flex; flex-direction: column; gap: 8px; }
.opt-label { font-weight: 800; font-size: 0.88rem; }
.opt-val { color: var(--ink-soft); font-weight: 600; }
.chip-row { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.1s ease, background 0.1s ease;
}
.chip:hover { transform: scale(1.05); border-color: var(--accent); }
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(242, 109, 146, 0.35);
}
.opt-desc { color: var(--ink-soft); font-size: 0.8rem; line-height: 1.5; min-height: 2.4em; }
.opt-desc.small { min-height: 0; }

input[type="range"] { width: 100%; accent-color: var(--accent-deep); }

.row-btns { gap: 8px; }
.tool-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink);
  transition: transform 0.1s ease, border-color 0.1s ease;
  text-align: left;
}
.tool-btn:hover { transform: scale(1.02); border-color: var(--accent); }
.tool-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ═══ 오버레이 ═══ */
.overlay[hidden], .screen[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0;
  background: rgba(61, 50, 41, 0.45);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
.overlay-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 34px 44px;
  text-align: center;
  box-shadow: var(--shadow);
  width: min(360px, 86vw);
}
.overlay-emoji { font-size: 2.6rem; animation: wobble 1.6s ease-in-out infinite; }
.overlay-msg { margin: 12px 0 16px; font-weight: 700; }
.overlay-bar { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; }
.overlay-fill {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--accent), #ffb56b);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* ═══ 모바일 ═══ */
@media (max-width: 760px) {
  #screen-play { flex-direction: column; }
  .stage-wrap { flex: 1; }
  .panel {
    width: 100%;
    max-height: 46vh;
    border-left: none;
    border-top: 1px solid var(--line);
    order: 2;
  }
  .panel-toggle { display: block; }
  .panel.collapsed .panel-body { display: none; }
  .panel.collapsed { max-height: none; }
}
