/* 色はここで一括管理する。Canvas 側の色は js/config.js の colors */
:root {
  --bg: #0f1220;
  --panel: rgba(15, 18, 32, 0.92);
  --text: #f2f4ff;
  --muted: #b8bdd9;
  --accent: #ffd166;
  --accent-text: #1a1a1a;
  --focus: #6ee7ff;
  /* 絵本風のボタン（荷物の絵と同じ濃紺のふち取り） */
  --ink: #1d2433;
  --paper: #fff8e8;
  --paper-press: #f1e6cc;
  --orange: #ffb13b;
  --orange-press: #f39b1c;
  --game-w: 450px;
  --game-h: 800px;
  --ui-scale: 1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
  /* viewport-fit=cover に対応した安全領域の余白 */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid;
  place-items: center;
}

#game, #ui {
  grid-area: 1 / 1;
  width: var(--game-w);
  height: var(--game-h);
}

#game {
  display: block;
  touch-action: none;
  background: #000;
}

#ui {
  position: relative;
  pointer-events: none;
  /* スマホでも16px以上を保つ */
  font-size: clamp(16px, calc(20px * var(--ui-scale)), 26px);
}

#ui .layer { position: absolute; inset: 0; }
#ui .layer > * { pointer-events: auto; }

/* パネル（タイトル・遊び方・一時停止・ゲームオーバー・設定） */
.panel {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 1.5em;
  text-align: center;
  background: var(--panel);
}
.panel.transparent { background: rgba(15, 18, 32, 0.55); }
.panel h1 { margin: 0 0 0.3em; font-size: 2em; line-height: 1.2; color: var(--accent); }
.panel h2 { margin: 0 0 0.3em; font-size: 1.5em; }
.panel p { margin: 0; line-height: 1.6; color: var(--text); }
.panel .muted { color: var(--muted); }
.panel .big { font-size: 1.6em; font-weight: bold; }
.panel .notice { color: var(--accent); font-weight: bold; }
.panel ul { margin: 0; padding: 0; list-style: none; line-height: 1.8; }

.buttons { display: flex; flex-direction: column; gap: 0.6em; margin-top: 0.8em; width: min(16em, 100%); }

.btn {
  position: relative;
  min-height: 44px;
  padding: 0.5em 1em;
  font: inherit;
  font-weight: bold;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 14px;
  /* 下に厚みを付けて、押すと沈む */
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform 0.06s, box-shadow 0.06s;
}
.btn.primary { color: var(--ink); background: var(--orange); }
.buttons .btn.primary { font-size: 1.15em; }
.btn:hover { filter: brightness(1.04); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); background: var(--paper-press); }
.btn.primary:active:not(:disabled) { background: var(--orange-press); }
.btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

/* 製作者の案内と「Xで共有」（必須。core/social.js） */
.share-row { display: flex; flex-direction: column; align-items: center; gap: 0.6em; margin-top: 0.4em; }
a.btn.share { display: inline-flex; align-items: center; justify-content: center; min-width: 10em; text-decoration: none; }
a.creator {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 0.5em;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}
a.creator:hover { color: var(--text); }
a.creator:focus-visible, a.btn.share:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 1em; width: min(16em, 100%); }

/* プレイ中の表示（スコア・一時停止ボタン） */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4em 0.6em;
  font-weight: bold;
  pointer-events: none;
  text-shadow: 0 2px 0 #000;
}
.hud .btn { pointer-events: auto; min-width: 44px; padding: 0.3em 0.7em; }

/* ---- このゲームで足したもの ---- */
/* HUD の帯が Canvas のタップやドラッグを横取りしないように（ボタンだけ押せる） */
#ui .layer > .hud { pointer-events: none; }
/* 画面の下の操作ボタン（振る・振り直し・ターン終了）。親指の届く位置 */
#ui .layer > .actions {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: flex;
  gap: 0.5em;
  padding: 0.5em 0.6em 0.6em;
  pointer-events: none;
}
.actions .btn { flex: 1; pointer-events: auto; min-height: 48px; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }

/* 遊び方：ゲームの絵とページ送り */
.panel { overflow-y: auto; justify-content: safe center; }
.howto { display: flex; flex-direction: column; align-items: center; gap: 0.6em; width: min(20em, 100%); }
.howto-body { display: flex; flex-direction: column; align-items: center; gap: 0.5em; }
.howto-art { width: 100%; height: auto; border-radius: 12px; border: 2px solid rgba(255, 255, 255, 0.35); }
.howto-body p { text-align: left; }
.howto-nav { display: flex; align-items: center; justify-content: space-between; gap: 0.5em; width: 100%; }
.howto-nav .btn { flex: 1; }
.howto-nav span { flex: none; }
.howto-skip { margin-top: 0.2em; }

/* タイトル・結果の画面：後ろのゲームの絵（トラックと荷物）が下に見えるパネル。
   文字とボタンのある上の方は暗くして読みやすさを保ち、下へいくほど透かす */
.panel.scenic { background: transparent; }

/* 遊び方：スマホでもお問い合わせ先まで1画面に収める */
.panel.howto-panel { gap: 0.35em; padding: 0.8em 1.2em; }
.panel.howto-panel h1 { font-size: 1.6em; margin-bottom: 0.1em; }
.howto-panel .howto { gap: 0.45em; }
.howto-panel .howto-art { width: 92%; }
.howto-panel .howto-body p { line-height: 1.45; }
.howto-panel .share-row { gap: 0; margin-top: 0; }

/* ---- タイトル画面：空と町の絵の上に、看板のタイトル・紙の説明・ボタン ---- */
/* タイトルの看板は空の上の方に置き、ハイスコア・ボタン・製作者の案内は画面の真ん中に置く */
.panel.title-panel { justify-content: center; gap: 0.5em; padding: 0 1.4em; }
.panel.title-panel h1 { position: absolute; top: 12%; left: 50%; translate: -50% 0; }
/* ハイスコアは「スタート」のすぐ上 */
.panel.title-panel > p.muted { white-space: nowrap; margin-bottom: -0.1em; }
.panel.title-panel h1 {
  margin: 0 0 0.15em;
  padding: 0.35em 0.7em 0.4em;
  font-size: 1.9em;
  line-height: 1.15;
  white-space: nowrap;
  letter-spacing: 0.06em;
  color: #fff;
  background: #2f6fb0;            /* トラックと同じ青の看板 */
  border: 3px solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
  text-shadow: 0 3px 0 var(--ink);
  transform: rotate(-2deg);
}
.panel.title-panel h1::after {
  /* 看板の下に、荷物のテープ風の帯 */
  content: "";
  display: block;
  height: 6px;
  margin: 0.25em auto 0;
  width: 60%;
  border-radius: 3px;
  background: repeating-linear-gradient(90deg, #ffd166 0 14px, #e9a640 14px 28px);
}
.panel.title-panel > p {
  max-width: 19em;
  padding: 0.45em 0.8em;
  font-size: 0.92em;
  text-wrap: balance;
  color: var(--ink);
  background: rgba(255, 248, 232, 0.94);
  border: 2px solid var(--ink);
  border-radius: 12px;
  font-weight: bold;
  line-height: 1.5;
}
.panel.title-panel > p.muted { padding: 0.15em 0.8em; color: var(--ink); background: #ffd166; }
/* 大きな「スタート」の下に、ほかの3つを横に並べる */
.panel.title-panel .buttons { display: grid; grid-template-columns: repeat(3, 1fr); width: min(20em, 100%); gap: 0.5em; margin-top: 0.3em; }
.panel.title-panel .buttons .btn { padding: 0.45em 0.2em; }
.panel.title-panel .buttons .btn.primary { grid-column: 1 / -1; min-height: 2.6em; font-size: 1.35em; letter-spacing: 0.2em; }
.panel.title-panel a.creator {
  min-height: 44px;
  margin-top: 0.1em;
  padding: 0 0.9em;
  color: var(--ink);
  background: rgba(255, 248, 232, 0.9);
  border: 2px solid var(--ink);
  border-radius: 999px;
  text-decoration: none;
}
.panel.title-panel a.creator:hover { background: var(--paper); }
/* プレイ中・図鑑の上の文字（件数・スコア）：空の上でも読めるよう、紙の札にのせる */
.hud > span {
  padding: 0.1em 0.7em;
  color: var(--ink);
  text-shadow: none;
  background: rgba(255, 248, 232, 0.92);
  border: 2px solid var(--ink);
  border-radius: 999px;
}

/* 遊び方・設定・結果：黒ではなく、後ろの町とトラックの絵が少し透ける明るい紙の背景 */
.panel.paper-panel { background: rgba(255, 248, 232, 0.86); color: var(--ink); }
.panel.paper-panel h1 { color: #2f6fb0; }
.panel.paper-panel p, .panel.paper-panel .toggle { color: var(--ink); }
.panel.paper-panel .muted { color: #4a5468; }
.panel.paper-panel a.creator { color: var(--ink); }
.panel.paper-panel .howto-art { border-color: var(--ink); }
.panel.paper-panel .toggle { font-weight: bold; }
.panel.paper-panel .notice { color: #c2410c; }  /* 新記録：明るい背景でも読めるこい橙 */
