:root {
  --bg: #fff4e0;
  --card: #fffdf8;
  --text: #5a3825;
  --orange: #ff8a3d;
  --yellow: #ffc947;
  --coral: #ff6b6b;
  --peach: #ffb38a;
  --line: #f3d9b5;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Jua", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  min-height: 100vh;
}

.app { max-width: 520px; margin: 0 auto; padding: 20px 16px 40px; }

.screen { display: none; }
.screen.active { display: block; animation: pop 0.3s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.title {
  text-align: center; font-size: 2.6rem; margin: 24px 0 4px;
  color: var(--orange); letter-spacing: 2px;
  text-shadow: 3px 3px 0 var(--yellow);
}
.subtitle { text-align: center; margin: 0 0 28px; font-size: 1.1rem; }

.menu { display: flex; flex-direction: column; gap: 16px; }
.menu-btn {
  border: none; border-radius: 28px; padding: 26px 20px; cursor: pointer;
  color: #fff; text-align: center; font-family: inherit;
  box-shadow: 0 6px 0 rgba(0,0,0,0.15);
  transition: transform 0.1s, box-shadow 0.1s;
}
.menu-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.menu-name { display: block; font-size: 1.8rem; font-weight: bold; }
.menu-desc { display: block; margin-top: 4px; font-size: 1rem; opacity: 0.95; }
.c1 { background: var(--orange); }
.c2 { background: var(--coral); }
.c3 { background: #f5a623; }

.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.bar h2 { margin: 0; font-size: 1.6rem; color: var(--orange); }
.back {
  border: none; background: var(--yellow); color: var(--text);
  border-radius: 20px; padding: 10px 16px; font-size: 1rem; cursor: pointer;
  font-family: inherit; font-weight: bold;
}

.card {
  background: var(--card); border-radius: 28px; padding: 20px 16px;
  margin-bottom: 16px; box-shadow: 0 4px 0 var(--line);
  border: 2px solid var(--line);
}
.card h3 { margin: 0 0 12px; font-size: 1.2rem; }
.hint { text-align: center; margin: 0 0 10px; }

.big-btn {
  display: block; width: 100%; border: none; border-radius: 24px;
  background: var(--orange); color: #fff; font-size: 1.4rem; font-weight: bold;
  padding: 18px; cursor: pointer; font-family: inherit;
  box-shadow: 0 5px 0 #d96a1f; margin-top: 16px;
  transition: transform 0.1s, box-shadow 0.1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #d96a1f; }
.big-btn:disabled { opacity: 0.6; cursor: default; }
.big-btn.alt { background: var(--coral); box-shadow: 0 5px 0 #c94a4a; }
.big-btn.alt:active { box-shadow: 0 1px 0 #c94a4a; }

.result {
  margin-top: 16px; padding: 16px; text-align: center; font-size: 1.4rem;
  background: #fff1cc; border-radius: 20px; min-height: 60px;
  display: flex; align-items: center; justify-content: center; font-weight: bold;
}

/* 룰렛 */
.wheel-wrap { position: relative; width: 100%; max-width: 340px; margin: 0 auto; }
.wheel-wrap canvas { width: 100%; height: auto; display: block; }
.pointer {
  position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 0; height: 0; z-index: 2;
  border-left: 16px solid transparent; border-right: 16px solid transparent;
  border-top: 32px solid var(--text);
}

/* 항목 편집 */
.edit-row { display: flex; gap: 8px; margin-bottom: 10px; }
.edit-row input {
  flex: 1; min-width: 0; border: 2px solid var(--line); border-radius: 16px;
  padding: 12px 14px; font-size: 1.05rem; font-family: inherit; color: var(--text);
  background: #fff;
}
.edit-row input:focus { outline: none; border-color: var(--orange); }
.del-btn {
  border: none; background: var(--peach); color: #fff; border-radius: 16px;
  width: 48px; font-size: 1.3rem; cursor: pointer; font-family: inherit;
}
.add-btn {
  width: 100%; border: 2px dashed var(--orange); background: transparent;
  color: var(--orange); border-radius: 20px; padding: 14px; font-size: 1.1rem;
  font-weight: bold; cursor: pointer; font-family: inherit;
}
.edit-note { margin: 8px 0 0; font-size: 0.9rem; text-align: center; opacity: 0.8; }

/* 사다리 */
.ladder-row { display: flex; width: 100%; }
.ladder-row > * { flex: 1; min-width: 0; text-align: center; }
.ladder-row.top button {
  margin: 0 3px; border: none; border-radius: 14px; padding: 12px 0;
  font-size: 1.1rem; font-weight: bold; color: #fff; cursor: pointer; font-family: inherit;
}
.ladder-row.bottom .slot {
  margin: 0 3px; padding: 10px 2px; border-radius: 14px; background: #fff1cc;
  font-size: 0.95rem; word-break: break-all; font-weight: bold;
}
.ladder-row.bottom .slot.hit { background: var(--yellow); }
.ladder-row.bottom .slot.win { background: var(--yellow); color: #b3470a; }
.ladder-row.bottom .slot.lose { background: #ffe0d6; color: #a05a48; }
.ladder-row.top button:disabled { opacity: 0.5; cursor: default; }
.ladder-box { position: relative; }
#ladderCanvas { width: 100%; height: 280px; display: block; }
.cover {
  position: absolute; inset: 0; border-radius: 20px; z-index: 3;
  background: repeating-linear-gradient(45deg, #ffd9a8, #ffd9a8 14px, #ffe6c4 14px, #ffe6c4 28px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 24px;
}
.cover p { margin: 0; font-size: 1.2rem; font-weight: bold; }
.cover.hidden { display: none; }

.stepper-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 1.15rem; font-weight: bold; }
.stepper { display: flex; align-items: center; gap: 14px; }
.stepper button {
  width: 52px; height: 52px; border: none; border-radius: 18px; background: var(--orange);
  color: #fff; font-size: 1.8rem; font-weight: bold; cursor: pointer; font-family: inherit;
  box-shadow: 0 4px 0 #d96a1f;
}
.stepper button:active { transform: translateY(3px); box-shadow: 0 1px 0 #d96a1f; }
.stepper button:disabled { opacity: 0.4; }
.stepper b { min-width: 32px; text-align: center; font-size: 1.5rem; }
.btn-row { display: flex; flex-direction: column; }

/* 동전 */
.coin-stage {
  position: relative; height: 320px; perspective: 900px; perspective-origin: 50% 40%;
}
.scene {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transform-origin: 50% 273px; transform: rotateX(-10deg);
}
.coin-pos {
  position: absolute; left: 50%; top: 203px; width: 140px; height: 140px;
  margin-left: -70px; transform-style: preserve-3d;
}
.coin { position: relative; width: 140px; height: 140px; transform-style: preserve-3d; }
.cface, .cside { position: absolute; }
.cface {
  inset: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: bold; color: #8a4b0a; border: 8px solid #e09a1b;
}
.cface.top { background: radial-gradient(circle at 35% 30%, #ffe27a, #ffc947); }
.cface.bottom { background: radial-gradient(circle at 35% 30%, #ffd0a8, #ffa86b); }
.cside { background: #d9921a; }
.cside:nth-child(even) { background: #c8820f; }
.ground {
  position: absolute; left: 6%; right: 6%; top: 296px; height: 8px;
  border-radius: 8px; background: var(--line);
}
.shadow {
  position: absolute; left: 50%; top: 292px; width: 140px; height: 12px; margin-left: -70px;
  border-radius: 50%; background: rgba(90, 56, 37, 0.3); filter: blur(2px);
}

@media (max-width: 380px) {
  .title { font-size: 2.2rem; }
  .menu-name { font-size: 1.5rem; }
}
