:root {
  --ink: #12345f;
  --sea: #3fdaea;
  --sand: #f6e2ac;
  --green: #3fb84a;
  --green-d: #2c8f38;
  --rainbow: linear-gradient(90deg, #ff5d8f, #ffb347, #ffe66d, #5be37d, #4db8ff, #b07bff);
  --font: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #27c6df; color: var(--ink); overflow: hidden; touch-action: manipulation; }
body { font-family: var(--font); font-size: 16px; }
body.dim #app { filter: brightness(0.72); }
.hidden { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; }
#app { height: 100dvh; max-width: 520px; margin: 0 auto; position: relative; overflow: hidden; background: var(--sea);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen { position: relative; height: 100%; display: flex; flex-direction: column; z-index: 1; }
.lbl { font-size: 12px; font-weight: 700; opacity: 0.8; display: block; }
.ic { width: 36px; height: 36px; flex: none; }
.ic-s { width: 30px; height: 30px; flex: none; }
.ic-a { width: 22px; height: 22px; flex: none; margin-left: 8px; }

/* 共通ボタン */
.btn { min-height: 48px; border: 0; border-radius: 16px; background: #fff; color: var(--ink); font: inherit; font-weight: 800;
  font-size: 17px; padding: 0 16px; box-shadow: 0 3px 0 rgba(0,40,80,0.2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,40,80,0.2); }
.btn.big { min-height: 56px; font-size: 20px; }
.btn.go { background: linear-gradient(#57d65f, var(--green)); color: #fff; box-shadow: 0 4px 0 var(--green-d); text-shadow: 0 1px 0 rgba(0,70,20,0.35); }
.btn.go:active:not(:disabled) { box-shadow: 0 1px 0 var(--green-d); }
.btn.white { background: #fff; }
.btn:disabled { opacity: 0.45; }
.btn:focus-visible, .up:focus-visible { outline: 3px solid #ff8a3d; outline-offset: 2px; }

/* タイトル風バッジ */
.badge-title { display: inline-flex; align-items: center; gap: 6px; background: #fff; border-radius: 30px; padding: 6px 18px 8px;
  font-weight: 900; font-size: 36px; letter-spacing: 1px; color: var(--ink); box-shadow: 0 4px 0 rgba(0,60,100,0.18); line-height: 1.1; }
.badge-title.sm { font-size: 30px; padding: 6px 14px 8px; align-self: flex-start; }

/* title / end */
#title, #end { align-items: center; justify-content: center; gap: 14px; padding: 20px; text-align: center; }
#end { overflow-y: auto; justify-content: flex-start; }
.lead { margin: 0; color: #fff; font-weight: 800; font-size: 17px; text-shadow: 0 2px 0 rgba(0,60,100,0.45); }
.modes { display: grid; gap: 12px; width: 100%; max-width: 320px; }
.opts { display: grid; background: rgba(255,255,255,0.92); border-radius: 18px; padding: 6px 14px; width: 100%; max-width: 320px; text-align: left; }
.opts label { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 700; }
.opts input { width: 24px; height: 24px; }
.note { margin: 0; font-size: 12px; line-height: 1.5; background: rgba(255,255,255,0.88); border-radius: 14px; padding: 8px 12px; max-width: 320px; }

/* game HUD */
.hud { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 10px 10px 0; }
.pills { display: grid; gap: 6px; width: 142px; flex: none; }
.pill { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 18px; padding: 6px 10px; box-shadow: 0 3px 0 rgba(0,60,100,0.16); min-height: 50px; }
.pill b { display: block; font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.pill small { display: block; font-size: 11px; font-weight: 700; opacity: 0.75; }
.pill .lbl { font-size: 11px; }
.rainbow-text { background: var(--rainbow); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stage { position: relative; flex: 1 1 0; min-height: 100px; }

/* bottom panel */
.bottom { padding: 0 10px 10px; display: grid; gap: 8px; }
.action { min-height: 56px; display: grid; }
.action > * { grid-area: 1 / 1; }
.bar { position: relative; height: 34px; align-self: center; border-radius: 17px; background: rgba(255,255,255,0.85); overflow: hidden; box-shadow: 0 2px 0 rgba(0,60,100,0.14); }
.bar i { position: absolute; inset: 0 auto 0 0; width: 0; background: #8fe3ee; }
.bar span { position: relative; display: block; text-align: center; line-height: 34px; font-size: 14px; font-weight: 800; }
#harvestBtn { width: 100%; animation: ready 1.1s ease-in-out infinite; }
@keyframes ready { 50% { transform: scale(1.03); } }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.card { background: #fff; border-radius: 16px; padding: 6px 4px 6px; text-align: center; display: grid; justify-items: center; gap: 1px; box-shadow: 0 3px 0 rgba(0,60,100,0.16); min-width: 0; }
.card .c-label { font-size: 12px; font-weight: 800; }
.card .ic { width: 30px; height: 30px; }
.card .c-val { font-size: 15px; font-weight: 900; font-variant-numeric: tabular-nums; max-width: 100%; white-space: nowrap; }
.card .c-next { font-size: 10.5px; font-weight: 700; opacity: 0.7; min-height: 14px; max-width: 100%; white-space: nowrap; }
.up { width: 100%; min-height: 44px; border: 0; border-radius: 14px; background: linear-gradient(#57d65f, var(--green)); box-shadow: 0 3px 0 var(--green-d); display: flex; align-items: center; justify-content: center; margin-top: 2px; cursor: pointer; }
.up .arrow { width: 24px; height: 24px; }
.up:disabled { background: #cfd8dc; box-shadow: 0 3px 0 #aab4b9; opacity: 0.8; cursor: default; }
.up:not(:disabled) { animation: ready 1.1s ease-in-out infinite; }
.rare { display: grid; }
.rare-btn { min-height: 48px; border: 3px solid transparent; border-radius: 16px; font: inherit; font-weight: 900; font-size: 15px; color: var(--ink); text-align: left; padding: 4px 14px; cursor: pointer;
  background: linear-gradient(#fffdf2, #fffdf2) padding-box, var(--rainbow) border-box; display: flex; align-items: center; gap: 10px; box-shadow: 0 3px 0 rgba(0,60,100,0.16); }
.rare-btn small { display: block; font-weight: 700; font-size: 12px; opacity: 0.75; }
.rare-btn .ic { width: 30px; height: 30px; }
.rare-btn:disabled { opacity: 0.5; }

/* reveal: 情景を隠しすぎない小さなカード */
.reveal { position: absolute; inset: 0; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 6px; cursor: pointer; }
.reveal-card { width: 94%; background: rgba(255,255,255,0.96); border-radius: 20px; padding: 10px 10px 8px; text-align: center; box-shadow: 0 5px 0 rgba(0,60,100,0.2); }
.reveal-title { font-weight: 900; font-size: 18px; }
.tiles { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px auto; max-width: 300px; }
.tile { aspect-ratio: 1.15; position: relative; visibility: hidden; }
.tile.on { visibility: visible; animation: pop 0.22s ease-out; }
.shell { position: absolute; inset: 0; background: #7d8a8f; border-radius: 48% 52% 46% 54% / 55% 52% 48% 45%; box-shadow: inset 0 -4px 0 rgba(0,0,0,0.18); }
.flesh { position: absolute; inset: 20% 16%; background: #f4ead0; border-radius: 48% 52% 46% 54% / 55% 52% 48% 45%; }
.tile.dopa .shell { background: #5f5a66; }
.tile.dopa .flesh { background: linear-gradient(135deg, #ff5d8f, #ffb347, #ffe66d, #5be37d, #4db8ff, #b07bff, #ff5d8f); background-size: 200% 200%; animation: shimmer 2.4s linear infinite; }
.tile.dopa::after { content: ""; position: absolute; inset: -8%; border-radius: 50%; box-shadow: 0 0 12px 3px rgba(255,230,109,0.8); pointer-events: none; }
.reveal-text { font-size: 16px; font-weight: 800; min-height: 24px; }
.reveal-text .rainbow-text { font-size: 21px; font-weight: 900; }
.reveal-hint { font-size: 12px; opacity: 0.65; margin-top: 2px; }
.reveal.has-dopa .reveal-card { box-shadow: 0 5px 0 rgba(0,60,100,0.2), 0 0 0 4px #ffe66d; }
@keyframes pop { 0% { transform: scale(0.3); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes shimmer { to { background-position: 200% 200%; } }
body.reduce *, body.reduce *::before, body.reduce *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; } }

/* end */
#end h2 { display: none; }
.end-mode { color: #fff; font-weight: 800; text-shadow: 0 2px 0 rgba(0,60,100,0.45); }
.end-card { background: rgba(255,255,255,0.96); border-radius: 22px; padding: 14px; text-align: center; box-shadow: 0 4px 0 rgba(0,60,100,0.18); width: 100%; }
.end-big { font-size: 52px; font-weight: 900; line-height: 1.2; }
.end-mid { font-size: 30px; font-weight: 900; margin-bottom: 6px; }
.buff-list { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.buff-list li { background: #e6f5f3; border-radius: 12px; padding: 4px 10px; font-size: 14px; font-weight: 700; }
.buff-list li.extreme { background: #fff0c2; }
#shareText { width: 100%; border-radius: 14px; border: 0; padding: 8px 10px; font: inherit; font-size: 13px; resize: none; background: rgba(255,255,255,0.92); }
.end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.toast { min-height: 22px; text-align: center; font-weight: 800; font-size: 14px; color: var(--ink); background: rgba(255,255,255,0.7); border-radius: 10px; padding: 0 10px; }
@media (max-height: 700px) { .badge-title { font-size: 30px; } .btn.big { min-height: 52px; } #title { gap: 10px; } }
