/* =========================================================
 * 見た目
 * 風景を画面いっぱいに広げ、ボタンや状態をその上に重ねる「ゲーム画面」の構成。
 * 色は参考画像（ツヤのある明るい緑・クリーム色・オレンジの目）に合わせる。
 * 絵文字は使わず、アイコンは src/ui/icons.js のSVG。
 * ========================================================= */
:root {
  --leaf: #8bd94a;
  --leaf-2: #5fb92f;
  --leaf-edge: #3a8a1e;
  --jungle: #1f7a45;
  --jungle-deep: #0f4227;
  --cream: #fff6df;
  --cream-2: #f7ebc9;
  --cream-edge: #d9c493;
  --ink: #2e3a1f;
  --ink-soft: #6c7656;
  --orange: #ffb238;
  --orange-2: #f0861c;
  --orange-edge: #b85b0c;
  --pink: #ff8fb0;
  --pink-2: #ef5f8c;
  --pink-edge: #b33a63;
  --sky: #6fd0ff;
  --sky-2: #2fa3e8;
  --sky-edge: #19709f;
  --grape: #b994ff;
  --grape-2: #8a5ce8;
  --grape-edge: #5b36a8;
  --meat: #ff8a6b;
  --meat-2: #e8553a;
  --meat-edge: #a33520;
  --danger: #e2574c;
  --gap: 18px;
  --font: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 700;
  line-height: 1.5;
  background: #7cc8ef;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 画面いっぱいの風景 ---------- */
.game { position: fixed; inset: 0; overflow: hidden; }
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud { position: absolute; z-index: 2; pointer-events: none; }
.hud > *, .hud .tool-row > * { pointer-events: auto; }

/* アイコン */
.icon { width: 1.25em; height: 1.25em; display: block; flex: none; }
[data-icon] { display: inline-flex; }

/* 半透明のクリーム色パネル */
.panel {
  background: rgba(255, 248, 228, 0.92);
  border: 3px solid #fff;
  border-radius: 22px;
  box-shadow: 0 5px 0 rgba(15, 66, 39, 0.28), 0 12px 26px rgba(10, 40, 20, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.panel-title { margin: 0 0 4px; font-size: 1.12rem; font-weight: 900; color: var(--jungle-deep); }
.panel-sub { margin: 12px 0 6px; font-size: 0.78rem; color: var(--ink-soft); font-weight: 800; }
.panel-hint { margin: 10px 0 0; font-size: 0.74rem; color: var(--ink-soft); font-weight: 500; }
.panel-note { margin: 10px 0 0; font-size: 0.9rem; color: var(--jungle); font-weight: 800; }

.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: none; border-radius: 10px; background: transparent; color: var(--ink-soft); cursor: pointer; font-size: 0.9rem;
}
.icon-btn:hover { background: rgba(0, 0, 0, 0.06); color: var(--ink); }

/* ---------- 左上：タイトル ---------- */
.hud-left { top: var(--gap); left: var(--gap); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo-egg { width: 52px; height: 64px; object-fit: contain; filter: drop-shadow(0 4px 0 rgba(15, 66, 39, 0.35)); }
.logo-text {
  margin: 0; white-space: nowrap; color: #fff; letter-spacing: 0.04em;
  font-size: clamp(1.3rem, 2.6vw, 2.2rem); font-weight: 900;
  -webkit-text-stroke: 7px var(--jungle-deep); paint-order: stroke fill;
  text-shadow: 0 5px 0 var(--jungle-deep), 0 8px 18px rgba(0, 0, 0, 0.25);
}

.tool-row { display: flex; gap: 8px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px 7px 11px;
  border: 3px solid #fff; border-radius: 999px; cursor: pointer;
  font: 800 0.86rem var(--font); color: var(--jungle-deep);
  background: linear-gradient(180deg, #fffdf6, var(--cream-2));
  box-shadow: 0 4px 0 var(--cream-edge), 0 8px 16px rgba(10, 40, 20, 0.2);
}
.pill-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--cream-edge); }
.pill-btn[aria-expanded="true"] { background: linear-gradient(180deg, #eaffd3, #c8f19d); }

.menu-wrap { position: relative; }
.menu { position: absolute; left: 0; top: calc(100% + 10px); z-index: 5; width: 240px; padding: 8px; display: grid; gap: 2px; }
.menu button, .menu label {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: none; border-radius: 14px;
  background: transparent; font: 700 0.92rem var(--font); color: var(--ink); cursor: pointer; text-align: left;
}
.menu button:hover, .menu label:hover { background: rgba(139, 217, 74, 0.22); }
.menu [data-icon] { color: var(--jungle); }
.menu .menu-danger, .menu .menu-danger [data-icon] { color: var(--danger); }

.log-panel { width: 340px; padding: 12px 14px; }
.log-head { display: flex; align-items: center; justify-content: space-between; }
.log { list-style: none; margin: 4px 0 0; padding: 0; max-height: 38vh; overflow-y: auto; font-size: 0.84rem; font-weight: 500; }
.log li { display: flex; gap: 10px; padding: 6px 2px; border-bottom: 2px dotted #eadcb9; }
.log li:last-child { border-bottom: none; }
.log li:first-child { font-weight: 800; }
.log time { flex: none; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* かんきょうパネル */
.env-panel { width: 360px; padding: 12px 14px; }
.env-now { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 8px; }
.env-spot { display: inline-flex; align-items: center; gap: 6px; font-size: 0.95rem; font-weight: 900; color: var(--jungle-deep); }
.env-spot-icon.warm { color: var(--orange-2); }
.env-spot-icon.normal { color: var(--jungle); }
.env-spot-icon.cool { color: var(--sky-2); }
.env-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.env-row {
  display: grid; grid-template-columns: 28px 1fr auto 24px; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 14px; background: #fff; border: 2px solid transparent;
}
.env-row.ok { border-color: #c8ecaa; }
.env-row.ng { border-color: #ffd7cf; }
.env-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--cream); color: var(--jungle); }
.env-info { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.env-name { font-size: 0.76rem; color: var(--ink-soft); }
.env-value { font-size: 1rem; font-weight: 900; }
.env-like { font-size: 0.74rem; color: var(--ink-soft); white-space: nowrap; }
.env-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; color: #fff; }
.env-row.ok .env-mark { background: var(--leaf-2); }
.env-row.ng .env-mark { background: var(--danger); }
.env-hint { display: flex; align-items: center; gap: 6px; font-size: 0.74rem; color: var(--ink-soft); padding: 2px 4px; }

/* 暮らしやすさの色 */
.chip-env { background: #fff; color: var(--ink-soft); border: 2px solid var(--cream-2); }
.chip-env.lvl-great { background: #dff7c9; color: var(--leaf-edge); border-color: #bfe9a0; }
.chip-env.lvl-good { background: #eefbe2; color: var(--jungle); border-color: #d4f0bb; }
.chip-env.lvl-meh { background: #fff1d9; color: var(--orange-edge); border-color: #ffe0ad; }
.chip-env.lvl-bad { background: #ffe4df; color: #b33a2c; border-color: #ffc9bf; }

/* ---------- 右上：名前とステータス ---------- */
.hud-right {
  top: var(--gap); right: var(--gap); width: clamp(340px, 34vw, 500px);
  max-height: calc(100% - var(--gap) * 2); display: flex; flex-direction: column; gap: 10px;
}

.nameplate { padding: 10px 16px 12px; }
.np-row { display: flex; align-items: center; gap: 4px; }
.np-name { font-size: 1.5rem; font-weight: 900; color: var(--jungle-deep); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 800; white-space: nowrap; }
.chip .icon { width: 1.05em; height: 1.05em; }
.chip-species { background: var(--jungle); color: #fff; }
.chip-stage { background: var(--orange); color: #5a2c00; }
.chip-pers { background: #fff; color: var(--ink-soft); border: 2px solid var(--cream-2); }
.chip-love { background: #ffe3ec; color: var(--pink-edge); }
.np-grow-label { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--ink-soft); margin-bottom: 3px; }

/* ゲージ */
.gauge { position: relative; height: 12px; border-radius: 999px; overflow: hidden; background: #e9dcc0; box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.15); }
.gauge.thin { height: 8px; }
.gauge.big { height: 22px; border: 3px solid #fff; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.18), 0 2px 0 var(--cream-edge); }
.gauge-fill { position: relative; height: 100%; border-radius: 999px; transition: width 0.5s ease; }
.gauge-fill::after { content: ""; position: absolute; left: 6px; right: 6px; top: 2px; height: 32%; border-radius: 999px; background: rgba(255, 255, 255, 0.55); }
.gauge-fill.hunger { background: linear-gradient(180deg, var(--orange), var(--orange-2)); }
.gauge-fill.mood { background: linear-gradient(180deg, var(--pink), var(--pink-2)); }
.gauge-fill.energy { background: linear-gradient(180deg, var(--leaf), var(--leaf-2)); }
.gauge-fill.affection { background: linear-gradient(180deg, #ff9db8, #e8436e); }
.gauge-fill.grow { background: linear-gradient(180deg, var(--sky), var(--sky-2)); }
.gauge-fill.egg { background: linear-gradient(180deg, var(--leaf), var(--jungle)); }

/* ステータス（2列×2段） */
.stats { padding: 12px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; }
.stat { display: grid; grid-template-columns: 32px 1fr; gap: 8px; align-items: center; min-width: 0; }
.stat-icon {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 0.95rem;
  background: #fff; box-shadow: 0 2px 0 var(--cream-edge);
}
.stat-icon.hunger { color: var(--orange-2); }
.stat-icon.mood { color: var(--pink-2); }
.stat-icon.energy { color: var(--leaf-edge); }
.stat-icon.affection { color: #e8436e; }
.stat-head { display: flex; justify-content: space-between; gap: 6px; font-size: 0.76rem; margin-bottom: 3px; white-space: nowrap; }
.stat-val { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.stat.low .stat-icon { animation: pulse 1.2s ease-in-out infinite; background: #ffe1dc; color: var(--danger); }
.stat.low .stat-name { color: var(--danger); }
@keyframes pulse { 50% { transform: scale(1.15); } }

/* 卵を選ぶ・卵のようす */
.setup-card, .egg-card { padding: 14px 16px; overflow-y: auto; }
.spot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pattern-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 7px; border-radius: 16px; cursor: pointer; font: inherit; color: var(--ink);
  background: linear-gradient(180deg, #fff, #fbf2dc); border: 3px solid #fff; box-shadow: 0 4px 0 var(--cream-edge);
  transition: transform 0.1s;
}
.tile:hover { transform: translateY(-2px); }
.tile:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--cream-edge); }
.tile[aria-pressed="true"] { background: linear-gradient(180deg, #eaffd3, #c8f19d); border-color: var(--leaf-2); box-shadow: 0 4px 0 var(--leaf-edge); }
.tile-check {
  position: absolute; top: -8px; right: -6px; width: 22px; height: 22px; border-radius: 50%; display: none; place-items: center;
  font-size: 0.7rem; color: #fff; background: var(--leaf-edge); border: 2px solid #fff;
}
.tile[aria-pressed="true"] .tile-check { display: grid; }
.tile-icon { font-size: 1.5rem; line-height: 1; margin: 2px 0; }
.tile-icon.warm { color: var(--orange-2); }
.tile-icon.normal { color: var(--jungle); }
.tile-icon.cool { color: var(--sky-2); }
.tile-label { font-size: 0.78rem; font-weight: 800; white-space: nowrap; }
.tile-sub { font-size: 0.66rem; color: var(--ink-soft); font-weight: 700; }
.egg-icon { width: 38px; height: 48px; }

.fit-note { display: flex; align-items: center; gap: 6px; margin: 12px 0 0; padding: 7px 12px; border-radius: 14px; font-size: 0.82rem; font-weight: 800; }
.fit-note.good { background: #e3f8cf; color: var(--leaf-edge); }
.fit-note.hot { background: #ffe8cc; color: var(--orange-edge); }
.fit-note.cold { background: #dcf1fd; color: var(--sky-edge); }
.egg-time { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.egg-time-label { display: inline-flex; align-items: center; gap: 4px; font-size: 0.82rem; color: var(--ink-soft); }
.egg-time-value { font-size: 1.7rem; font-weight: 900; color: var(--jungle-deep); font-variant-numeric: tabular-nums; }

/* ---------- ぷっくりボタン ---------- */
.btn3d {
  --c1: var(--leaf); --c2: var(--leaf-2); --edge: var(--leaf-edge);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 3px solid rgba(255, 255, 255, 0.92); border-radius: 20px; cursor: pointer;
  padding: 10px 18px; font: 900 1rem var(--font); color: #fff; letter-spacing: 0.03em;
  background: linear-gradient(180deg, var(--c1), var(--c2));
  box-shadow: 0 6px 0 var(--edge), 0 10px 18px rgba(10, 40, 20, 0.25), inset 0 3px 0 rgba(255, 255, 255, 0.35);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.15s;
}
.btn3d:hover:not(:disabled) { filter: brightness(1.06); }
.btn3d:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 1px 0 var(--edge), 0 3px 6px rgba(0, 0, 0, 0.2), inset 0 3px 0 rgba(255, 255, 255, 0.35); }
.btn3d:disabled { filter: grayscale(0.85) brightness(0.95); opacity: 0.75; cursor: not-allowed; }
.btn3d:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.btn-orange { --c1: var(--orange); --c2: var(--orange-2); --edge: var(--orange-edge); }
.btn-pink { --c1: var(--pink); --c2: var(--pink-2); --edge: var(--pink-edge); }
.btn-sky { --c1: var(--sky); --c2: var(--sky-2); --edge: var(--sky-edge); }
.btn-grape { --c1: var(--grape); --c2: var(--grape-2); --edge: var(--grape-edge); }
.btn-meat { --c1: var(--meat); --c2: var(--meat-2); --edge: var(--meat-edge); }
.btn-red { --c1: #ff7a6b; --c2: var(--danger); --edge: #9e2f25; }
.btn-cream { --c1: #fffaf0; --c2: var(--cream-2); --edge: var(--cream-edge); color: var(--ink); text-shadow: none; }
.btn-big { width: 100%; margin-top: 14px; padding: 13px 18px; font-size: 1.15rem; }

/* ---------- 下：ふきだしと世話のボタン ---------- */
.hud-bottom {
  left: 50%; bottom: var(--gap); transform: translateX(-50%);
  width: max-content; max-width: calc(100% - var(--gap) * 2);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.actions { display: flex; gap: 12px; }
.action { flex-direction: column; gap: 4px; width: 128px; padding: 9px 6px 10px; border-radius: 22px; }
.action-icon {
  width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-size: 1.35rem;
  color: var(--edge); background: rgba(255, 255, 255, 0.95); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08); text-shadow: none;
}
.action-label { font-size: 0.9rem; white-space: nowrap; }

.bubble {
  position: relative; max-width: min(480px, 90vw); padding: 10px 22px; border-radius: 22px;
  background: #fff; color: var(--ink); font-size: 1rem; font-weight: 800; text-align: center;
  box-shadow: 0 5px 0 rgba(15, 66, 39, 0.22), 0 10px 24px rgba(0, 0, 0, 0.16);
}
.bubble::after { content: ""; position: absolute; left: 50%; top: -10px; transform: translateX(-50%); border: 10px solid transparent; border-bottom-color: #fff; border-top: 0; }
.bubble.show { animation: pop 0.28s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes pop { from { transform: translateY(8px) scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }

.sleep-note {
  display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 5px 16px; border-radius: 999px;
  font-size: 0.86rem; background: rgba(40, 40, 90, 0.78); color: #fff;
}

/* ---------- 右下・左下の小さな表示 ---------- */
.save-status {
  position: absolute; right: var(--gap); bottom: 10px; z-index: 2; font-size: 0.72rem; font-weight: 700;
  color: rgba(255, 255, 255, 0.9); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); pointer-events: none;
}
.debug {
  position: absolute; left: 50%; top: 8px; transform: translateX(-50%); z-index: 3; display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 10px; border-radius: 14px; font-size: 0.74rem; color: #fff; background: rgba(15, 66, 39, 0.6);
}
.debug button { font: 700 0.74rem var(--font); padding: 3px 9px; border-radius: 9px; border: none; cursor: pointer; background: var(--cream); }

/* ---------- ずかん ---------- */
.dex-overlay { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px; background: rgba(10, 40, 20, 0.5); }
.dex-card {
  width: min(980px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column;
  border-radius: 28px; border: 4px solid #fff; background: linear-gradient(180deg, #fffdf5, var(--cream));
  box-shadow: 0 8px 0 var(--cream-edge), 0 20px 50px rgba(0, 0, 0, 0.4); overflow: hidden;
  animation: pop-modal 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.dex-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 10px; }
.dex-title { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: 1.35rem; font-weight: 900; color: var(--jungle-deep); }
.dex-close { margin-left: auto; width: 38px; height: 38px; font-size: 1.1rem; }
.dex-list { display: grid; gap: 12px; padding: 4px 20px 20px; overflow-y: auto; }
.dex-entry {
  display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: center;
  padding: 14px; border-radius: 22px; background: #fff; border: 3px solid #fff; box-shadow: 0 4px 0 var(--cream-edge);
}
.dex-figure {
  height: 150px; border-radius: 18px; display: grid; place-items: center; overflow: hidden;
  background: radial-gradient(circle at 50% 70%, #eaf8de, #cfe9f6);
}
.dex-figure img { max-width: 92%; max-height: 88%; object-fit: contain; filter: drop-shadow(0 6px 6px rgba(20, 60, 30, 0.25)); }
.dex-entry.unknown .dex-figure { background: #e9e2cf; }
.dex-entry.unknown .dex-figure img { filter: brightness(0) opacity(0.22); }
.dex-name { margin: 0; font-size: 1.25rem; font-weight: 900; color: var(--jungle-deep); }
.dex-unknown { margin: 4px 0 0; font-size: 0.86rem; color: var(--ink-soft); font-weight: 500; }
.dex-fields { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 2px 0 0; font-size: 0.86rem; }
.dex-fields dt { color: var(--ink-soft); white-space: nowrap; }
.dex-fields dd { margin: 0; font-weight: 700; }
.dex-fields dd.locked { display: inline-flex; align-items: center; gap: 5px; color: #a99f88; font-weight: 600; }

/* 巣立ち */
.fledge-btn { padding: 8px 20px; font-size: 0.95rem; animation: fledge-glow 2.4s ease-in-out infinite; }
@keyframes fledge-glow { 50% { filter: brightness(1.1); transform: translateY(-2px); } }
.dex-memories { margin-top: 10px; padding-top: 10px; border-top: 2px dotted #eadcb9; }
.dex-mem-title { margin: 0 0 6px; font-size: 0.82rem; color: var(--pink-edge); font-weight: 900; }
.dex-mem-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.dex-mem { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; }
.dex-mem-icon { color: #e8436e; }
.dex-mem-name { font-weight: 900; }
.dex-mem-meta { color: var(--ink-soft); font-size: 0.78rem; font-weight: 600; }

/* ---------- モーダル ---------- */
.modal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(10, 40, 20, 0.5); }
.modal-card {
  position: relative; width: min(420px, 100%); padding: 32px 24px 22px; border-radius: 28px;
  background: linear-gradient(180deg, #fffdf5, var(--cream)); border: 4px solid #fff;
  box-shadow: 0 8px 0 var(--cream-edge), 0 20px 50px rgba(0, 0, 0, 0.4);
  animation: pop-modal 0.3s cubic-bezier(0.3, 1.5, 0.5, 1);
}
.modal.modal-top { place-items: start center; padding-top: max(16px, 12vh); background: rgba(10, 40, 20, 0.3); }
@keyframes pop-modal { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-title {
  position: absolute; left: 50%; top: -22px; transform: translateX(-50%); margin: 0; white-space: nowrap;
  padding: 8px 26px; border-radius: 999px; font-size: 1.1rem; font-weight: 900; color: #fff;
  background: linear-gradient(180deg, var(--leaf), var(--leaf-2)); border: 3px solid #fff;
  box-shadow: 0 4px 0 var(--leaf-edge); text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}
.modal-body p { margin: 6px 0; text-align: center; font-weight: 700; }
.modal-actions { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.modal-actions .btn3d { min-width: 120px; }
.text-input {
  width: 100%; margin-top: 10px; padding: 12px 14px; border-radius: 16px; text-align: center;
  border: 3px solid var(--cream-2); background: #fff; font: 800 1.15rem var(--font); color: var(--ink);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.08);
}
.text-input:focus { outline: none; border-color: var(--leaf-2); }

[hidden] { display: none !important; }

/* ---------- 少し小さい画面 ---------- */
@media (max-width: 1100px), (max-height: 720px) {
  :root { --gap: 14px; }
  .action { width: 104px; padding: 7px 4px 8px; }
  .action-icon { width: 40px; height: 40px; font-size: 1.2rem; }
  .action-label { font-size: 0.82rem; }
  .hud-right { width: clamp(300px, 36vw, 420px); }
  .logo-egg { width: 42px; height: 52px; }
}

/* ---------- スマホ（縦長） ---------- */
@media (max-width: 760px) {
  :root { --gap: 12px; }
  .hud-left { right: var(--gap); flex-direction: row; justify-content: space-between; align-items: center; }
  .logo { gap: 6px; }
  .logo-egg { width: 30px; height: 38px; }
  .logo-text { font-size: 1.15rem; -webkit-text-stroke-width: 5px; text-shadow: 0 3px 0 var(--jungle-deep); }
  .pill-btn { padding: 7px; }
  .pill-label { display: none; }
  .menu { left: auto; right: 0; }
  .log-panel, .env-panel { position: absolute; top: calc(100% + 8px); left: 0; right: 0; width: auto; z-index: 4; }
  .dex-overlay { padding: 10px; }
  .dex-head { padding: 14px 14px 8px; }
  .dex-list { padding: 4px 12px 14px; }
  .dex-entry { grid-template-columns: 1fr; gap: 10px; }
  .dex-figure { height: 130px; }
  .hud-right { top: 62px; left: var(--gap); width: auto; max-height: calc(100% - 62px - var(--gap)); gap: 8px; }
  .nameplate { padding: 8px 12px 10px; }
  .np-name { font-size: 1.2rem; }
  .np-chips { margin: 4px 0 6px; }
  .stats { padding: 8px 12px; gap: 6px 12px; }
  .stat { grid-template-columns: 26px 1fr; gap: 6px; }
  .stat-icon { width: 26px; height: 26px; font-size: 0.8rem; }
  .hud-bottom { left: var(--gap); right: var(--gap); transform: none; width: auto; max-width: none; }
  .dock { width: 100%; }
  .actions { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
  .action { width: auto; padding: 6px 2px 7px; border-radius: 16px; }
  .action-icon { width: 34px; height: 34px; font-size: 1.05rem; }
  .action-label { font-size: 0.66rem; letter-spacing: 0; }
  /* ふきだしは恐竜に重ならないよう、空の真ん中あたりに出す */
  .bubble { position: fixed; left: var(--gap); right: var(--gap); top: 46%; max-width: none; font-size: 0.88rem; padding: 8px 16px; }
  .bubble::after { top: auto; bottom: -10px; border-bottom: 0; border-top: 10px solid #fff; }
  .bubble.show { animation: pop-m 0.28s cubic-bezier(0.3, 1.6, 0.5, 1); }
  @keyframes pop-m { from { transform: scale(0.85); opacity: 0; } to { transform: none; opacity: 1; } }
  .save-status { display: none; }
  .debug { top: auto; bottom: 110px; }
}

/* ---------- せまいスマホ：上のボタンが画面からはみ出さないように ---------- */
@media (max-width: 760px) {
  .hud-left { z-index: 4; }
}
@media (max-width: 480px) {
  .logo-egg { display: none; }
  .logo-text { font-size: 1rem; -webkit-text-stroke-width: 4px; }
  .tool-row { gap: 5px; }
  .pill-btn { padding: 5px; border-width: 2px; }
}


/* =========================================================
 * アイコンの仕上げ
 * - 線画アイコンは内側をうすく塗る（icons.js の icon-fill）
 * - 丸いバッジは、色ごとのグラデーション＋白いアイコン＋ツヤ
 * - 世話のボタンは道具の画像がボタンから飛び出す
 * ========================================================= */
.icon .icon-fill { opacity: 0.22; }

.badge, .stat-icon, .tile-icon, .env-icon, .pill-btn > [data-icon] {
  --b1: var(--leaf); --b2: var(--leaf-2); --be: var(--leaf-edge);
  position: relative; display: grid; place-items: center; border-radius: 50%; color: #fff;
  background: linear-gradient(160deg, var(--b1), var(--b2));
  box-shadow: 0 2px 0 var(--be), inset 0 2px 0 rgba(255, 255, 255, 0.45);
  border: 2px solid #fff;
}
.stat-icon::after, .tile-icon::after, .env-icon::after, .pill-btn > [data-icon]::after {
  content: ""; position: absolute; left: 22%; right: 22%; top: 10%; height: 28%;
  border-radius: 999px; background: rgba(255, 255, 255, 0.35); pointer-events: none;
}
.stat-icon .icon-fill, .tile-icon .icon-fill, .env-icon .icon-fill, .pill-btn > [data-icon] .icon-fill { opacity: 0.35; }

/* ステータス */
.stat-icon { width: 34px; height: 34px; font-size: 0.92rem; }
.stat-icon.hunger { --b1: #ffc35a; --b2: var(--orange-2); --be: var(--orange-edge); color: #fff; }
.stat-icon.mood { --b1: #ffa6c0; --b2: var(--pink-2); --be: var(--pink-edge); color: #fff; }
.stat-icon.energy { --b1: #a6e86a; --b2: var(--leaf-2); --be: var(--leaf-edge); color: #fff; }
.stat-icon.affection { --b1: #ff9db8; --b2: #e8436e; --be: #a52a4c; color: #fff; }
.stat.low .stat-icon { background: linear-gradient(160deg, #ff8a7a, var(--danger)); --be: #9e2f25; color: #fff; }

/* 置き場所のタイル */
.tile-icon { width: 38px; height: 38px; margin: 2px 0 4px; font-size: 1.05rem; }
.tile-icon.warm { --b1: #ffc35a; --b2: var(--orange-2); --be: var(--orange-edge); color: #fff; }
.tile-icon.normal { --b1: #a6e86a; --b2: var(--leaf-2); --be: var(--leaf-edge); color: #fff; }
.tile-icon.cool { --b1: #8fdcff; --b2: var(--sky-2); --be: var(--sky-edge); color: #fff; }

/* かんきょうの行 */
.env-icon { width: 30px; height: 30px; color: #fff; }
.env-row:nth-child(1) .env-icon { --b1: #ffc35a; --b2: var(--orange-2); --be: var(--orange-edge); }
.env-row:nth-child(2) .env-icon { --b1: #8fdcff; --b2: var(--sky-2); --be: var(--sky-edge); }
.env-row:nth-child(3) .env-icon { --b1: #a6e86a; --b2: var(--leaf-2); --be: var(--leaf-edge); }
.env-spot-icon { width: 1.4em; height: 1.4em; }

/* 左上のボタン：アイコンを色つきの丸に */
.pill-btn > [data-icon] { width: 28px; height: 28px; border-width: 0; font-size: 0.85rem; }
#btn-log > [data-icon] { --b1: #8fdcff; --b2: var(--sky-2); --be: var(--sky-edge); }
#btn-env > [data-icon] { --b1: #a6e86a; --b2: var(--leaf-2); --be: var(--leaf-edge); }
#btn-dex > [data-icon] { --b1: #ffc35a; --b2: var(--orange-2); --be: var(--orange-edge); }
#btn-menu > [data-icon] { --b1: #cdb5ff; --b2: var(--grape-2); --be: var(--grape-edge); }
.pill-btn { padding-left: 6px; }

/* 世話のボタン：道具の画像がボタンの上に飛び出す */
.actions { padding-top: 30px; }
.action { position: relative; padding-top: 34px; overflow: visible; }
.action-img {
  position: absolute; left: 50%; top: -30px; width: 72px; height: 62px; object-fit: contain;
  transform: translateX(-50%); pointer-events: none;
  filter: drop-shadow(0 5px 4px rgba(10, 40, 20, 0.35));
  transition: transform 0.18s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.action:hover:not(:disabled) .action-img { transform: translateX(-50%) translateY(-5px) rotate(-6deg) scale(1.08); }
.action:active:not(:disabled) .action-img { transform: translateX(-50%) translateY(2px) scale(0.95); }
.action:disabled .action-img { filter: grayscale(0.9) opacity(0.7); }
.action-label { font-size: 0.92rem; }

@media (max-width: 1100px), (max-height: 720px) {
  .action-img { width: 60px; height: 52px; top: -24px; }
  .action { padding-top: 28px; }
  .actions { padding-top: 24px; }
}
@media (max-width: 760px) {
  .actions { padding-top: 22px; }
  .action { padding-top: 24px; }
  .action-img { width: 50px; height: 44px; top: -20px; }
  .action-label { font-size: 0.66rem; }
  .stat-icon { width: 28px; height: 28px; font-size: 0.8rem; }
  .pill-btn > [data-icon] { width: 30px; height: 30px; }
}
@media (max-width: 480px) {
  .pill-btn { padding: 3px; }
  .pill-btn > [data-icon] { width: 28px; height: 28px; }
  .tool-row { gap: 4px; }
}


/* =========================================================
 * ふきだし：恐竜の頭の上に出す（位置は ui.js の placeBubble）
 * 巣立ちボタン：名前プレートの中
 * ========================================================= */
.game > .bubble {
  position: absolute; z-index: 6; left: 50%; top: 40%; right: auto; bottom: auto;
  transform: translate(-50%, -100%);
  width: max-content; max-width: min(380px, calc(100vw - 24px));
  padding: 9px 18px; border-radius: 20px; font-size: 0.95rem; line-height: 1.45;
  pointer-events: none;
}
.game > .bubble::after {
  left: var(--tail, 50%); top: auto; bottom: -9px; transform: translateX(-50%);
  border: 10px solid transparent; border-top-color: #fff; border-bottom: 0;
}
.game > .bubble.show { animation: bubble-pop 0.28s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes bubble-pop {
  from { transform: translate(-50%, -88%) scale(0.85); opacity: 0; }
  to { transform: translate(-50%, -100%) scale(1); opacity: 1; }
}
@media (max-width: 760px) {
  .game > .bubble { font-size: 0.86rem; padding: 7px 14px; max-width: calc(100vw - 24px); }
}

.nameplate .fledge-btn {
  width: 100%; margin-top: 10px; padding: 7px 14px; font-size: 0.9rem; border-radius: 16px;
}
