/* 焼き芋シミュレーター — 冬の夜、屋台の火のまわり（明るい設定でも夜のまま） */
:root {
  --bg: #140c08;
  --bg2: #22140d;
  --text: #f7ecdd;
  --sub: rgba(247, 236, 221, .62);
  --line: rgba(255, 230, 200, .14);
  --btn: #3a2216;
  --btn-press: #4c2d1d;
  --accent: #ff9a3c;
  --gold: #ffc95c;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic", Meiryo, sans-serif;
}
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { --bg: #140c08; } }
:root[data-theme="dark"] { --bg: #140c08; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font);
  overflow: hidden; overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
body { background: radial-gradient(120% 80% at 50% 70%, #2a160c 0%, var(--bg) 70%) fixed, var(--bg); }
button, a { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app {
  position: fixed; inset: 0; margin: 0 auto; max-width: 560px;
  display: flex; flex-direction: column;
  padding: max(4px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

.top { display: flex; align-items: center; justify-content: space-between; height: 44px; flex: none; gap: 8px; }
.title { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tools { display: flex; gap: 2px; flex: none; }
.iconbtn { width: 44px; height: 44px; border: 0; background: none; padding: 11px; border-radius: 10px; cursor: pointer; }
.iconbtn svg { width: 22px; height: 22px; display: block; fill: var(--text); }
.iconbtn svg .w { fill: none; stroke: var(--text); stroke-width: 2; stroke-linecap: round; }
.iconbtn .off { display: none; }
.iconbtn[aria-pressed="true"] .on { display: none; }
.iconbtn[aria-pressed="true"] .off { display: block; }
.iconbtn:focus-visible, .btn:focus-visible, .closebtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.today { margin: 0 0 2px; font-size: 13px; color: var(--sub); flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.today b { color: var(--text); font-weight: 700; }
.bestchip { margin-left: auto; flex: none; font-size: 12px; font-weight: 700; color: var(--gold); border: 1px solid rgba(255, 201, 92, .35); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.title { min-width: 0; }

.stage { position: relative; flex: 1; min-height: 0; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }

.hint {
  position: absolute; left: 50%; top: 4%; transform: translate(-50%, -100%); margin: 0; z-index: 2;
  max-width: 92%; width: max-content; padding: 8px 14px; border-radius: 999px;
  background: rgba(30, 18, 12, .78); border: 1px solid var(--line); color: var(--text);
  font-size: 14px; line-height: 1.45; text-align: center; pointer-events: none; white-space: pre-line; text-wrap: balance; word-break: auto-phrase;
  opacity: 0; transition: opacity .35s;
}
.hint.on { opacity: 1; }
.hint.side { transform: translate(-50%, -50%); width: max-content; border-radius: 14px; text-align: left; }

.reveal { position: absolute; left: 0; right: 0; bottom: 6%; text-align: center; pointer-events: none; }
.reveal .brix { display: inline-flex; align-items: baseline; gap: 6px; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.reveal .brix small { font-size: 18px; font-weight: 700; color: rgba(255, 226, 180, .9); }
.reveal .brix b { font-size: 64px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1; }
.reveal.bad .brix b { color: #d8cfc6; }
.etitle { margin-top: 6px; font-size: 26px; font-weight: 900; color: #fff3e2; opacity: 0; transform: scale(1.5); text-shadow: 0 2px 12px rgba(0,0,0,.7); }
.etitle.on { opacity: 1; transform: scale(1); transition: opacity .25s, transform .3s cubic-bezier(.2, 1.6, .4, 1); }

.bar { flex: none; height: 64px; display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn {
  min-height: 48px; padding: 0 22px; border: 1px solid var(--line); border-radius: 14px; background: var(--btn);
  font-size: 16px; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  touch-action: manipulation;
}
.btn:active { background: var(--btn-press); }
.btn.main { min-width: 180px; background: linear-gradient(#d9692b, #b84a18); border-color: rgba(255, 200, 150, .3); color: #fff; }
.btn.main:disabled { opacity: .35; cursor: default; filter: saturate(.4); }
.btn.main.ready { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(255, 140, 60, .25); } }
@media (prefers-reduced-motion: reduce) { .btn.main.ready { animation: none; box-shadow: 0 0 0 3px rgba(255, 140, 60, .4); } .etitle.on { transition: none; } }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: rgba(30, 18, 12, .92); border: 1px solid var(--line); padding: 8px 14px; border-radius: 12px; font-size: 14px; z-index: 5; }

/* 結果 */
.result { position: fixed; inset: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #100906; z-index: 8; touch-action: pan-y; }
.rin { max-width: 480px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
/* カードとボタンは1画面に収める（下の図鑑だけスクロール） */
#card { display: block; height: auto; width: auto; max-width: 100%; max-height: calc(100vh - 190px); max-height: calc(100dvh - 190px); margin: 0 auto; border-radius: 14px; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.rside { margin-top: 10px; }
.tip { margin: 10px 2px 4px; font-size: 14px; line-height: 1.6; text-wrap: pretty; word-break: auto-phrase; }
.meta { margin: 14px 2px 8px; font-size: 13px; color: var(--sub); }
.meta .new { color: var(--gold); font-weight: 700; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1.25fr; gap: 8px; }
.actions .btn { padding: 0 10px; font-size: 15px; min-height: 46px; }
.actions .x { background: #000; border-color: #333; color: #fff; }
.actions .x svg { width: 16px; height: 16px; fill: #fff; }
.actions .again { background: linear-gradient(#d9692b, #b84a18); color: #fff; }
.found { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.found li { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 6px 8px; border-radius: 8px; border: 1px dashed var(--line); color: var(--sub); text-align: center; }
.found li.has { border-style: solid; color: var(--text); background: rgba(255, 200, 150, .06); }
.found li.now { border-color: var(--gold); color: var(--gold); }
@media (orientation: landscape) and (max-height: 560px) {
  .rin { max-width: 900px; }
  .found { grid-template-columns: 1fr 1fr; }
  .found li { font-size: 12px; }
  .rmain { display: flex; gap: 16px; align-items: flex-start; }
  #card { max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); margin: 0; }
  .rside { flex: 1; margin-top: 0; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions .again { grid-column: 1 / -1; }
}
.more { text-align: center; margin: 18px 0 0; font-size: 14px; }
.more a { color: var(--sub); }

/* 遊び方 */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; z-index: 10; touch-action: pan-y; }
.sheet { width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: #20140e; border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; padding: 16px 18px max(18px, env(safe-area-inset-bottom)); font-size: 14px; line-height: 1.7; }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet h2 { font-size: 16px; margin: 14px 0 6px; }
.sheet-head h2 { margin: 0; }
.sheet p { margin: 0 0 8px; color: rgba(247, 236, 221, .85); }
.howto { margin: 8px 0; padding-left: 1.3em; }
.howto li { margin-bottom: 4px; }
.keys, .foot { color: var(--sub) !important; font-size: 12px; }
.closebtn { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--btn); cursor: pointer; font-size: 14px; }

@media (max-height: 600px) {
  .top { height: 38px; }
  .bar { height: 52px; }
  .btn { min-height: 44px; }
  .reveal .brix b { font-size: 48px; }
}
.tip .sn { display: inline-block; }
