:root {
  --red: #b3261e;
  --red-dark: #7f1a14;
  --gold: #c9a24a;
  --paper: #fffdf6;
  --ink: #2b2118;
  --bg1: #fdf1e3;
  --bg2: #f6d9c4;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html { background: var(--bg2); }
html, body { min-height: 100%; }

body {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.7), transparent 40%),
    linear-gradient(180deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(24px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ヘッダー */
.header { text-align: center; margin-bottom: 16px; }
.date { font-size: 14px; color: #7a5a44; letter-spacing: .1em; }
.title {
  font-size: 44px;
  color: var(--red);
  letter-spacing: .3em;
  margin: 4px 0 6px .3em;
  text-shadow: 0 2px 0 rgba(0,0,0,.08);
}
.subtitle { font-size: 14px; color: #7a5a44; }

/* 筒 */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  width: 100%;
}

.box {
  position: relative;
  width: 140px;
  height: 260px;
  border: none;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
}
.box:focus-visible { outline: 3px solid var(--gold); outline-offset: 8px; border-radius: 12px; }

.box-body {
  position: absolute;
  inset: 40px 0 0 0;
  border-radius: 14px 14px 10px 10px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.18), transparent 25%, transparent 75%, rgba(0,0,0,.22)),
    repeating-linear-gradient(180deg, #8a5a32 0 6px, #94643a 6px 12px);
  box-shadow: 0 14px 24px rgba(80,40,20,.35), inset 0 0 0 4px #6b4224;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.box-body::before {
  /* 上部の口 */
  content: "";
  position: absolute;
  top: -8px; left: 6px; right: 6px;
  height: 16px;
  border-radius: 50%;
  background: #3b2414;
  box-shadow: inset 0 3px 6px rgba(0,0,0,.6);
}
.box-label {
  writing-mode: vertical-rl;
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  background: var(--red);
  padding: 14px 8px;
  border-radius: 4px;
  letter-spacing: .2em;
  box-shadow: 0 0 0 3px var(--gold);
}

.stick {
  position: absolute;
  left: 50%;
  top: 40px;
  width: 16px;
  height: 150px;
  margin-left: -8px;
  border-radius: 3px;
  background: linear-gradient(90deg, #e8d3a8, #f7ead0, #e0c896);
  box-shadow: 0 2px 4px rgba(0,0,0,.25);
  z-index: 1;
  transform: translateY(0);
  transition: transform .5s cubic-bezier(.2,.9,.3,1.2);
  display: flex;
  justify-content: center;
  padding-top: 8px;
}
.stick-num {
  writing-mode: vertical-rl;
  font-size: 12px;
  color: var(--red-dark);
  font-weight: 700;
}
.stick.out { transform: translateY(-110px); }

.box.shaking { animation: shake .9s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  10% { transform: rotate(-14deg) translateY(-4px); }
  20% { transform: rotate(12deg); }
  30% { transform: rotate(-12deg) translateY(-6px); }
  40% { transform: rotate(10deg); }
  50% { transform: rotate(-8deg) translateY(-3px); }
  60% { transform: rotate(8deg); }
  70% { transform: rotate(-5deg); }
  80% { transform: rotate(4deg); }
  90% { transform: rotate(-2deg); }
}
.box.flip { animation: flip .6s ease forwards; }
@keyframes flip {
  to { transform: rotate(180deg) translateY(10px); }
}

.hint { font-size: 15px; color: #7a5a44; min-height: 1.5em; }

.motion-btn {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid #c8a88e;
  background: rgba(255,255,255,.6);
  color: #6b4a34;
}

/* 結果 */
.result {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: fadeUp .6s ease both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

.paper {
  background:
    linear-gradient(var(--paper), var(--paper)) padding-box,
    linear-gradient(135deg, var(--red), var(--gold), var(--red)) border-box;
  border: 4px solid transparent;
  border-radius: 6px;
  padding: 22px 20px 20px;
  box-shadow: 0 10px 30px rgba(80,40,20,.2);
  text-align: center;
  animation: unfold .7s cubic-bezier(.2,.8,.2,1) both;
  transform-origin: top center;
}
@keyframes unfold {
  from { transform: scaleY(.05); opacity: 0; }
  60% { opacity: 1; }
  to { transform: scaleY(1); }
}

.paper-no { font-size: 13px; color: #8c6d55; letter-spacing: .15em; }

.fortune {
  font-size: 72px;
  font-weight: 800;
  line-height: 1.2;
  margin: 6px 0 4px;
  color: var(--red);
  letter-spacing: .1em;
}
.fortune.great {
  background: linear-gradient(180deg, #e0b84a, #b3261e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.fortune.bad { color: #3d4a63; }

.message {
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px dashed #d8c3ad;
}

.details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 12px;
  text-align: left;
  font-size: 14px;
  line-height: 1.6;
}
.details dt {
  color: #fff;
  background: var(--red);
  font-weight: 700;
  padding: 0 8px;
  border-radius: 3px;
  height: fit-content;
  white-space: nowrap;
}
.details dd { margin: 0; }

.lucky {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 16px;
}
.lucky div {
  background: #fbf2e4;
  border-radius: 6px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lucky span { font-size: 11px; color: #8c6d55; }
.lucky strong { font-size: 15px; }

.actions { display: flex; gap: 10px; }
.btn {
  flex: 1;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 14px;
  border-radius: 999px;
  border: 2px solid var(--red);
  background: #fff;
  color: var(--red);
  cursor: pointer;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--red); color: #fff; }

/* 紙吹雪（大吉用） */
.confetti {
  position: fixed;
  top: -20px;
  width: 10px;
  height: 14px;
  pointer-events: none;
  z-index: 50;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(720deg); }
}

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