* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #2b2530;
  color: #f6efe2;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
#app {
  max-width: 600px;
  min-height: 100%;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
header h1 { font-size: 20px; margin: 0; letter-spacing: 0.04em; }
button {
  font: inherit; font-weight: bold; border: none; border-radius: 14px; cursor: pointer;
  color: #2b2530; background: #f6efe2; padding: 12px 16px; font-size: 16px;
}
button:active { transform: translateY(1px) scale(0.98); }
button.small { font-size: 13px; padding: 6px 12px; border-radius: 10px; background: rgba(255,255,255,0.12); color: #f6efe2; }
button.primary { background: #ff6b4f; color: #fff; }

#stage { display: flex; flex-direction: column; align-items: center; gap: 10px; flex: 1; justify-content: center; }
#viewfinder {
  position: relative; width: 100%; aspect-ratio: 6 / 5; border-radius: 10px; overflow: hidden;
  background: #000; box-shadow: 0 6px 24px rgba(0,0,0,0.4);
  max-width: min(100%, calc((100vh - 260px) * 1.2));
}
#scene { width: 100%; height: 100%; display: block; }
.corner { position: absolute; width: 22px; height: 22px; border: 3px solid rgba(255,255,255,0.85); pointer-events: none; }
.corner.tl { top: 10px; left: 10px; border-right: none; border-bottom: none; }
.corner.tr { top: 10px; right: 10px; border-left: none; border-bottom: none; }
.corner.bl { bottom: 10px; left: 10px; border-right: none; border-top: none; }
.corner.br { bottom: 10px; right: 10px; border-left: none; border-top: none; }

#card {
  position: absolute; inset: 12% 8%; border-radius: 14px; padding: 12px 14px;
  background: rgba(30,24,36,0.82); display: flex; flex-direction: column; justify-content: center; text-align: center;
}
#card h2 { margin: 0 0 4px; font-size: clamp(20px, 6vw, 30px); color: #ffd36b; }
#card .tagline { margin: 0 0 8px; font-size: clamp(12px, 3.4vw, 16px); }
#card ul { list-style: none; margin: 0; padding: 0; font-size: clamp(11px, 3.2vw, 15px); line-height: 1.55; }
#card .controls { margin: 8px 0 0; font-size: clamp(10px, 2.9vw, 13px); opacity: 0.75; }
#card.hide { display: none; }

#ready {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(30,24,36,0.8); padding: 10px 18px; border-radius: 999px; font-size: 20px; font-weight: bold; white-space: nowrap;
}
#flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#flash.on { animation: flash 0.55s ease-out; }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }

#hud { width: 100%; display: flex; align-items: center; gap: 10px; max-width: inherit; }
#timerbar { flex: 1; height: 10px; border-radius: 999px; background: rgba(255,255,255,0.15); overflow: hidden; }
#timerbar i { display: block; height: 100%; width: 100%; background: #7fd99a; border-radius: inherit; transform-origin: left; }
#timerbar.hurry i { background: #ff6b4f; }
#timetext { font-variant-numeric: tabular-nums; font-weight: bold; min-width: 3.2em; text-align: right; }
#prompt { margin: 0; min-height: 1.4em; font-size: 15px; text-align: center; }

#shutter {
  width: 86px; height: 86px; border-radius: 50%; padding: 0; position: relative;
  background: #f6efe2; box-shadow: 0 0 0 6px rgba(255,255,255,0.18), 0 6px 18px rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center; flex-direction: column;
}
#shutter .lens { width: 58px; height: 58px; border-radius: 50%; background: #ff6b4f; position: absolute; }
#shutter span#shutterLabel { position: relative; color: #fff; font-size: 11px; letter-spacing: -0.03em; }
#shutter.start { width: auto; height: auto; border-radius: 999px; padding: 16px 30px; background: #ff6b4f; }
#shutter.start .lens { display: none; }
#shutter.start span#shutterLabel { font-size: 18px; }
#shutter:disabled { opacity: 0.5; }

#result { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1; justify-content: center; }
#photo {
  display: block; width: 100%; height: auto; border-radius: 8px; box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  max-width: min(100%, calc((100vh - 230px) * 0.8));
  animation: develop 0.9s ease-out;
}
@keyframes develop { 0% { filter: brightness(2.2) saturate(0.2); transform: scale(0.96); } 100% { filter: none; transform: none; } }
.actions { width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 10px; }
.actions .primary { font-size: 18px; padding: 15px; }
.actions .row { display: flex; gap: 10px; }
.actions .row button { flex: 1; background: rgba(255,255,255,0.14); color: #f6efe2; }

#toast {
  position: fixed; left: 50%; top: max(56px, calc(env(safe-area-inset-top) + 46px)); transform: translateX(-50%); z-index: 40; width: max-content;
  background: rgba(0,0,0,0.8); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
[hidden] { display: none !important; }

@media (min-width: 900px) {
  header h1 { font-size: 24px; }
  #prompt { font-size: 17px; }
}

button:focus:not(:focus-visible) { outline: none; }
button:focus-visible { outline: 3px solid #ffd36b; outline-offset: 2px; }

/* 記録・図鑑・演出(2026-11-30) */
.hbtns { display: flex; gap: 6px; }
#trytext { font-size: 13px; font-weight: bold; opacity: 0.8; white-space: nowrap; font-variant-numeric: tabular-nums; }
#photoWrap { position: relative; width: min(100%, calc((100vh - 270px - var(--extraH, 0px)) * 0.8)); }
#newBadge {
  position: absolute; top: -8px; right: -6px;
  background: #ffd36b; color: #2b2530; font-weight: bold; font-size: 14px; padding: 4px 10px; border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35); transform: rotate(8deg); animation: pop 0.5s ease-out;
}
@keyframes pop { 0% { transform: scale(0.2) rotate(8deg); } 70% { transform: scale(1.2) rotate(8deg); } 100% { transform: scale(1) rotate(8deg); } }
#statsLine { margin: 0; font-size: 13px; opacity: 0.85; text-align: center; font-variant-numeric: tabular-nums; }
#photo { max-width: 100%; }
#photo.miracle { box-shadow: 0 0 0 4px #f2cf6b, 0 0 40px 10px rgba(255,211,107,0.55); animation: develop 0.9s ease-out, glow 1.6s ease-in-out 0.9s 3; }
@keyframes glow { 50% { box-shadow: 0 0 0 4px #ffe9a8, 0 0 70px 24px rgba(255,211,107,0.8); } }
#retry { position: relative; overflow: hidden; }
#retry.locked { opacity: 0.75; }
#retry.locked::after {
  content: ""; position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: rgba(255,255,255,0.85);
  transform-origin: left; animation: lockbar var(--lock, 350ms) linear forwards;
}
@keyframes lockbar { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.actions .row button { white-space: nowrap; padding: 12px 8px; }
#ready.miracle {
  top: 80%; font-size: clamp(26px, 8vw, 40px); color: #fff; background: #d6402f; padding: 10px 26px;
  box-shadow: 0 0 0 4px #ffd36b, 0 6px 24px rgba(0,0,0,0.4); animation: banner 0.45s ease-out;
}
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(0.3) rotate(-8deg); } 70% { transform: translate(-50%, -50%) scale(1.15) rotate(2deg); } 100% { transform: translate(-50%, -50%) scale(1); } }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 20; }
#zukan {
  position: fixed; inset: 0; z-index: 30; background: rgba(15,10,20,0.7); display: flex; align-items: center; justify-content: center; padding: 16px;
}
#zukan .sheet {
  background: #352d3b; border-radius: 16px; padding: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
#zukan h2 { margin: 0 0 4px; font-size: 20px; color: #ffd36b; }
#zukan p { margin: 0 0 10px; font-size: 13px; opacity: 0.85; }
#zukan ol { list-style: none; margin: 0 0 12px; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
#zukan li { background: rgba(255,255,255,0.08); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
#zukan li b { font-size: 14px; }
#zukan li span { font-size: 11px; opacity: 0.75; }
#zukan li.unseen b { opacity: 0.5; letter-spacing: 0.2em; }
#zukan .row { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
#zukan .row .primary { flex: 1; max-width: 220px; }

/* 残りの直し(2026-12-01) */
#shutter.wait { opacity: 0.4; filter: grayscale(0.7); }
#ready.nudge { animation: nudge 0.35s ease-in-out; }
@keyframes nudge { 0%, 100% { transform: translate(-50%, -50%); } 25% { transform: translate(-56%, -50%); } 75% { transform: translate(-44%, -50%); } }
#winBig {
  margin: 0; font-size: clamp(26px, 8vw, 38px); font-weight: bold; color: #ffd36b; text-align: center; line-height: 1.1;
  text-shadow: 0 2px 0 #d6402f, 0 4px 14px rgba(0,0,0,0.4); font-variant-numeric: tabular-nums; animation: pop2 0.5s ease-out;
}
@keyframes pop2 { 0% { transform: scale(0.3); } 70% { transform: scale(1.12); } 100% { transform: scale(1); } }
#milestone {
  margin: 0; max-width: 440px; width: 100%; font-size: 14px; line-height: 1.5; text-align: center;
  background: rgba(255,211,107,0.16); border: 1px solid rgba(255,211,107,0.5); border-radius: 10px; padding: 8px 12px;
  animation: pop2 0.5s ease-out;
}
#save.done { background: rgba(127,217,154,0.3); }
