:root {
  --bg: #FFF4E0;
  --ink: #5A3A22;
  --orange: #FF8A3D;
  --yellow: #FFC93C;
  --coral: #FF6B6B;
  --peach: #FFB38A;
  --card: #FFFFFF;
  --line: #F2D9B5;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 18px;
  line-height: 1.4;
}

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

.view { animation: pop 0.25s ease-out; }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* 첫 화면 */
.title {
  text-align: center;
  font-size: 48px;
  margin: 28px 0 4px;
  color: var(--orange);
  text-shadow: 3px 3px 0 var(--yellow);
}
.subtitle { text-align: center; margin: 0 0 28px; }

.menu { display: grid; gap: 16px; }
.menu-btn {
  border: 0;
  border-radius: 28px;
  padding: 26px 20px;
  color: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.1s, box-shadow 0.1s;
}
.menu-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15); }
.menu-name { display: block; font-size: 30px; }
.menu-desc { display: block; font-size: 16px; opacity: 0.95; }

.c-orange { background: var(--orange); }
.c-yellow { background: #F5A800; }
.c-coral { background: var(--coral); }
.c-peach { background: #E58A5C; }

/* 공통 */
.bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar h2 { margin: 0; font-size: 28px; color: var(--orange); }
.back-btn {
  border: 0;
  background: var(--card);
  color: var(--ink);
  font-family: inherit;
  font-size: 16px;
  padding: 10px 16px;
  border-radius: 20px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--line);
}

.big-btn {
  display: block;
  width: 100%;
  min-height: 64px;
  border: 0;
  border-radius: 32px;
  color: #fff;
  font-family: inherit;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.1s, box-shadow 0.1s;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); }
.big-btn:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-row { display: flex; gap: 12px; }
.btn-row .big-btn { font-size: 20px; }

.result {
  text-align: center;
  font-size: 28px;
  min-height: 64px;
  margin: 12px 0;
  padding: 12px;
  background: var(--card);
  border: 3px dashed var(--peach);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: keep-all;
}
.hint { text-align: center; margin: 4px 0 12px; font-size: 16px; }

.card {
  margin-top: 24px;
  background: var(--card);
  border-radius: 28px;
  padding: 18px;
  box-shadow: 0 4px 0 var(--line);
}
.card h3 { margin: 0 0 12px; font-size: 20px; }

.items { display: grid; gap: 10px; }
.item-row { display: flex; gap: 8px; }
.item-row input {
  flex: 1;
  min-width: 0;
  height: 52px;
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 18px;
  color: var(--ink);
  background: #FFFBF3;
}
.item-row input:focus { outline: none; border-color: var(--orange); }
.del-btn {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 20px;
  background: var(--peach);
  color: #fff;
  font-family: inherit;
  font-size: 26px;
  cursor: pointer;
}
.add-btn {
  width: 100%;
  height: 52px;
  margin-top: 12px;
  border: 3px dashed var(--orange);
  border-radius: 20px;
  background: transparent;
  color: var(--orange);
  font-family: inherit;
  font-size: 18px;
  cursor: pointer;
}
.add-btn:disabled { opacity: 0.4; cursor: default; }

/* 룰렛 */
.wheel-wrap { position: relative; width: fit-content; margin: 20px auto 0; }
#wheel { display: block; }
.pointer {
  position: absolute;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 16px solid transparent;
  border-right: 16px solid transparent;
  border-top: 30px solid var(--coral);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.2));
  z-index: 2;
}

/* 사다리 */
.ladder-box {
  background: var(--card);
  border-radius: 28px;
  padding: 14px 10px;
  box-shadow: 0 4px 0 var(--line);
}
.ladder-row { display: flex; }
.ladder-row > * {
  flex: 1 1 0;
  min-width: 0;
  margin: 0 3px;
  text-align: center;
}
.start-btn {
  border: 0;
  border-radius: 16px;
  min-height: 44px;
  color: #fff;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}
.start-btn { opacity: 0.5; }
.start-btn.picked { opacity: 1; }
.start-btn:disabled { cursor: default; }
.start-btn .check { display: none; width: 6px; height: 12px; margin-left: 6px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg) translateY(-3px); }
.start-btn.picked .check { display: inline-block; }
.ladder-canvas-wrap { position: relative; }
#ladder { display: block; width: 100%; height: 300px; }
.ladder-cover {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  font-size: 22px;
  color: #fff;
  border-radius: 20px;
  background: repeating-linear-gradient(45deg, #FFB38A 0 16px, #FF9F6B 16px 32px);
  transition: opacity 0.5s;
}
.ladder-cover.gone { opacity: 0; pointer-events: none; }
.end-cell {
  background: #FFF0D6;
  border-radius: 16px;
  padding: 10px 2px;
  font-size: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-height: 42px;
}
.end-cell.win { background: var(--yellow); color: var(--ink); }
.end-cell.lose { background: #E9DCCB; color: #8A6F55; }

.stepper-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stepper-row + .stepper-row { margin-top: 12px; }
.stepper-label { font-size: 20px; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 20px;
  background: var(--orange);
  color: #fff;
  font-family: inherit;
  font-size: 28px;
  cursor: pointer;
}
.stepper span { min-width: 36px; text-align: center; font-size: 26px; }

/* 동전 (옆에서 본 모습) */
.coin-stage {
  position: relative;
  height: 400px;
  margin-top: 8px;
  perspective: 1200px;
  perspective-origin: 50% 40%;
  overflow: hidden;
}
.coin-ground {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 70px;
  height: 14px;
  border-radius: 7px;
  background: var(--peach);
}
.coin-shadow {
  position: absolute;
  left: 50%;
  bottom: 72px;
  width: 130px;
  height: 10px;
  margin-left: -65px;
  border-radius: 50%;
  background: rgba(90, 58, 34, 0.35);
}
.coin-shadow.throw { animation: shadow-throw 2s linear; }
.coin-hop {
  position: absolute;
  left: 50%;
  bottom: 21px;
  width: 140px;
  height: 140px;
  margin-left: -70px;
  transform-style: preserve-3d;
}
.coin-hop.throw { animation: coin-throw 2s linear; }
.coin {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 1.25s cubic-bezier(0.25, 0.45, 0.55, 1);
}
.face, .edge {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}
.edge { background: #D9920A; }
.face {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: #fff;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border: 8px solid #F5A800;
}
.face-front { background: var(--yellow); transform: translateZ(7px); }
.face-back { background: var(--orange); transform: rotateY(180deg) translateZ(7px); }

@keyframes coin-throw {
  0%   { transform: translateY(0);      animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
  38%  { transform: translateY(var(--throw, -190px)); animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  62%  { transform: translateY(0);      animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
  72%  { transform: translateY(-22px);  animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  80%  { transform: translateY(0);      animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
  86%  { transform: translateY(-6px);   animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  92%, 100% { transform: translateY(0); }
}
@keyframes shadow-throw {
  0%   { transform: scale(1);    opacity: 1;    animation-timing-function: cubic-bezier(0.2, 0.6, 0.4, 1); }
  38%  { transform: scale(0.45); opacity: 0.35; animation-timing-function: cubic-bezier(0.6, 0, 0.8, 0.4); }
  62%  { transform: scale(1);    opacity: 1; }
  72%  { transform: scale(0.9);  opacity: 0.85; }
  80%, 100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 380px) {
  .title { font-size: 40px; }
  .btn-row { flex-direction: column; }
}
