:root {
  --ink: #26414f; --soft: #6a7f88; --accent: #e07a3f; --accent-dark: #c4632c; --gold: #e8b23a;
  --panel: #f8fbfcee; --line: #d6e3e8;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  color: var(--ink); background: #e4eef2;
}
* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; touch-action: none; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button { font: inherit; cursor: pointer; border: 0; color: inherit; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
[hidden] { display: none !important; }
#scene, #scene canvas, #flash { position: absolute; inset: 0; width: 100%; height: 100%; }
#flash { pointer-events: none; background: #e55454; opacity: 0; z-index: 8; transition: opacity .25s; }

header { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 20px; right: 16px; display: flex;
  justify-content: space-between; align-items: center; z-index: 10; pointer-events: none; }
.brand { font-weight: 900; font-size: 19px; letter-spacing: 2px; }
.brand span { color: var(--accent); }
.tools { display: flex; gap: 8px; pointer-events: auto; }
.tools button { background: #ffffffc8; border: 1px solid #fff; border-radius: 50px; height: 38px; min-width: 44px;
  padding: 0 14px; font-size: 12px; font-weight: bold; box-shadow: 0 2px 8px #26414f14; }

.overlay { position: absolute; inset: 0; z-index: 5; }
#title { background: linear-gradient(90deg, #eef5f8f2 0%, #eef5f8d8 30%, #eef5f800 62%); pointer-events: none; }
.intro { position: absolute; left: 7%; top: 50%; transform: translateY(-50%); max-width: 470px; pointer-events: auto; }
.eyebrow { font-size: 11px; letter-spacing: 2px; font-weight: bold; color: #7a919a; }
h1 { font-size: 64px; line-height: 1.1; letter-spacing: 4px; margin: 14px 0 8px; font-weight: 900; }
h1 span { color: var(--accent); }
.subtitle { font-size: 13px; letter-spacing: 3px; margin: 0 0 18px; }
.rules { font-size: 13px; line-height: 1.7; margin: 0 0 20px; }
.rules p { margin: 4px 0; }
.rules b { color: var(--accent-dark); }
.primary { background: var(--accent); color: #fff; min-width: 240px; padding: 16px 24px; border-radius: 10px; font-weight: bold;
  font-size: 17px; letter-spacing: 4px; box-shadow: 0 6px 18px #c4632c40; }
.primary:hover { background: var(--accent-dark); }
.primary:active { transform: translateY(1px); box-shadow: none; }
.instructions { font-size: 11px; line-height: 1.7; margin-top: 16px; color: var(--soft); }
.instructions p { margin: 3px 0; }
.instructions b { margin-right: 6px; color: var(--ink); }
.best { font-size: 11px; letter-spacing: 2px; margin-top: 12px; font-weight: bold; }
.back { display: inline-block; margin-top: 10px; padding-block: .35rem; font-size: 12px; color: var(--soft); }

.shade { background: #e6eff3b8; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex;
  align-items: center; justify-content: center; overflow-y: auto; padding: 16px; z-index: 7; }
.panel { text-align: center; background: var(--panel); border: 1px solid #fff; padding: 28px; border-radius: 18px;
  max-width: 460px; width: 100%; box-shadow: 0 20px 70px #26414f22; margin: auto; }
.panel.wide { max-width: 820px; }
h2 { font-size: 24px; letter-spacing: 2px; margin: 10px 0 6px; }
.panel .primary { margin-top: 18px; width: 100%; }
.text-button { background: transparent; font-size: 12px; margin-top: 10px; padding: 8px 12px; color: var(--soft); }

#cards { display: flex; gap: 12px; margin-top: 20px; }
#cards button { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--line); border-left: 4px solid #b8d2e1;
  border-radius: 12px; padding: 20px 12px; transition: transform .12s, border-color .12s, background .12s; touch-action: pan-y; }
#cards button:hover { transform: translateY(-3px); border-color: var(--accent); background: #fff8f2; }
#cards .card-icon { font-size: 30px; display: block; margin-bottom: 10px; }
#cards b { display: block; font-size: 15px; }
#cards p { font-size: 12px; line-height: 1.7; color: var(--soft); margin: 8px 0 0; }
#cards .lv { display: block; font-size: 10px; color: var(--accent-dark); margin-top: 6px; letter-spacing: 1px; }

.hud-top { position: absolute; left: 20px; right: 20px; top: calc(max(16px, env(safe-area-inset-top)) + 48px);
  display: flex; justify-content: space-between; pointer-events: none; z-index: 3; }
.hud-top small { display: block; font-size: 10px; letter-spacing: 2px; color: var(--soft); }
.hud-top { text-shadow: 0 0 6px #fff, 0 0 2px #fff; }
.hud-top strong { display: block; font-size: 34px; font-weight: 700; line-height: 1.1; }
.hud-right { text-align: right; }
#life { color: #d0574c; letter-spacing: 4px; font-size: 22px; }
.hud-right small { margin-top: 4px; font-size: 13px; letter-spacing: 1px; }
#toast { position: absolute; top: 26%; width: 100%; text-align: center; font-size: 28px; font-weight: 900; letter-spacing: 3px;
  color: var(--accent-dark); pointer-events: none; z-index: 3; text-shadow: 0 2px 0 #fff, 0 0 18px #fff; opacity: 0; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast small { display: block; font-size: 14px; letter-spacing: 2px; color: var(--ink); }
.charge { position: absolute; left: 50%; bottom: calc(max(22px, env(safe-area-inset-bottom)) + 26px); transform: translateX(-50%);
  width: min(320px, 70vw); pointer-events: none; z-index: 3; text-align: center; }
.charge span { font-size: 11px; letter-spacing: 3px; font-weight: bold; color: var(--soft); }
.charge .track { position: relative; height: 10px; background: #ffffffaa; border: 1px solid #fff; border-radius: 6px; margin-top: 4px; overflow: hidden; }
.charge .track i { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #8fc4dc, var(--accent)); }
.charge .track i.just { background: var(--gold); }
.charge .track i.over { background: #d0574c; }
.charge .just-mark { position: absolute; top: 0; bottom: 0; left: 90%; width: 2px; background: #26414f55; }
.tip { position: absolute; left: 0; right: 0; bottom: max(14px, env(safe-area-inset-bottom)); text-align: center; font-size: 11px;
  color: var(--soft); pointer-events: none; z-index: 3; transition: opacity .6s; }

#result-score { font-size: 56px; line-height: 1.2; letter-spacing: 2px; font-weight: 700; }
.score-label { display: block; margin-top: 16px; font-size: 10px; letter-spacing: 3px; color: var(--soft); }
#result-best { margin: 4px 0 0; font-size: 13px; }
.stats { display: flex; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 14px 0; margin: 16px 0;
  gap: 28px; justify-content: center; }
.stats small, .stats b { display: block; }
.stats small { font-size: 11px; margin-bottom: 4px; color: var(--soft); }
.stats b { font-size: 20px; }
.picked-label { margin: 0 0 4px; font-size: 12px; font-weight: bold; }
#picked { font-size: 12px; line-height: 1.8; color: var(--soft); }

#joystick { position: absolute; width: 90px; height: 90px; margin: -45px 0 0 -45px; border: 1px solid #fff9; background: #ffffff38;
  border-radius: 50%; pointer-events: none; z-index: 4; }
#joystick i { position: absolute; width: 34px; height: 34px; left: 27px; top: 27px; border-radius: 50%; background: #26414f55; }

@media (max-width: 640px) {
  .brand { font-size: 16px; }
  #title { background: linear-gradient(180deg, #eef5f8e8 0%, #eef5f8c0 45%, #eef5f8ee 100%); }
  .intro { left: 18px; right: 18px; top: auto; bottom: max(18px, env(safe-area-inset-bottom)); transform: none; text-align: center; max-width: none; }
  h1 { font-size: 46px; letter-spacing: 2px; margin: 8px 0 4px; }
  .subtitle { font-size: 11px; margin-bottom: 12px; }
  .rules { font-size: 12px; margin-bottom: 14px; }
  .primary { width: 100%; min-width: 0; }
  .instructions { font-size: 10.5px; margin-top: 10px; }
  #cards { flex-direction: column; gap: 8px; }
  #cards button { padding: 12px; text-align: left; display: grid; grid-template-columns: 2.4rem 1fr; column-gap: 12px; align-items: center; }
  #cards .card-icon { grid-row: span 3; margin: 0; font-size: 26px; text-align: center; }
  #cards p { margin-top: 2px; }
  .hud-top strong { font-size: 28px; }
}
/* 背の低い横画面（横向きスマホ）：パネルを詰め、結果は2列に */
@media (orientation: landscape) and (max-height: 500px) {
  .intro { top: calc(50% + 20px); transform: translateY(-50%); bottom: auto; left: 5%; text-align: left; max-width: 520px; }
  .intro .eyebrow { display: none; } /* 左上の札と重なる小見出しは、背の低い横画面では出さない */
  h1 { font-size: 40px; margin: 4px 0; }
  .rules { font-size: 11px; margin-bottom: 10px; }
  .instructions { display: none; }
  .primary { padding: 10px 20px; width: auto; min-width: 200px; }
  .panel { padding: 16px 20px; }
  h2 { font-size: 18px; margin: 4px 0; }
  #result .panel { max-width: 640px; display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; align-items: center; text-align: center; }
  #result .panel > * { grid-column: 1; }
  #result .stats, #result .picked-label, #result #picked, #result #retry, #result #home { grid-column: 2; }
  #result .stats { grid-row: 1 / span 2; margin: 0; }
  #result-score { font-size: 40px; }
  #cards { flex-direction: row; margin-top: 10px; }
  #cards button { padding: 10px; display: block; text-align: center; }
  #cards .card-icon { font-size: 22px; margin-bottom: 4px; }
  .hud-top { top: 54px; }
}

/* 木の上でも読めるように、得点・時間・ためるゲージ・ヒントは白い札に乗せる（スマホ縦で背景の針葉樹に文字が沈んでいた） */
.hud-top > div { background: #ffffffd9; border: 1px solid #fff; border-radius: 14px; padding: 6px 12px; box-shadow: 0 2px 10px #26414f1a; }
.hud-top small { color: var(--ink); opacity: .7; }
.hud-right small { color: var(--ink); opacity: 1; font-weight: bold; }
.charge { background: #ffffffd9; border: 1px solid #fff; border-radius: 14px; padding: 6px 14px 10px; box-shadow: 0 2px 10px #26414f1a; }
.charge span { color: var(--ink); opacity: .75; }
.charge .track { background: #e3ecf1; border-color: #d3e0e8; }
.tip span, .tip { text-shadow: none; }
.tip { left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: 92vw; background: #ffffffd0; border-radius: 99px; padding: 3px 12px; color: var(--ink); }
.brand { background: #ffffffc8; border-radius: 99px; padding: 2px 12px; }
