/* 配色テーマ：野球場 */
:root {
  --grass: #2a7238;        /* 芝 */
  --grass-2: #317f40;      /* 芝のしま模様 */
  --sky: #8fd3ff;          /* 空 */
  --fence: #174a8c;        /* 外野フェンスの青 */
  --pole: #ffd21f;         /* ポールの黄色 */
  --clay: #a94a28;         /* 赤土 */
  --clay-dark: #743019;
  --soil: #33231b;         /* 黒土 */
  --board: #103a2a;        /* スコアボードの深緑 */
  --chalk: #ffffff;        /* 白線・白文字 */
  --card: #fffaf0;
  --field-bg: #ffffff;
  --text: #22201c;
  --sub: #5c5347;
  --point: #99401f;
  --good: #1d6b30;
  --good-bg: #bde8a8;
  --danger: #b3202c;
  --nav-h: 68px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--grass); }
body {
  margin: 0;
  background: repeating-linear-gradient(90deg, var(--grass) 0 48px, var(--grass-2) 48px 96px);
  min-height: 100vh;
  color: var(--chalk);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.6;
}
main {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  outline: none;
}
/* 見出しはスコアボード風 */
h1 {
  font-size: 1.3rem; margin: 4px 0 12px; padding: 8px 14px; letter-spacing: .05em;
  background: var(--board); color: var(--chalk); border: 3px solid var(--chalk); border-radius: 10px;
}
.row > h1 { flex: 1; margin: 4px 0; }
h2 { font-size: 1.05rem; margin: 0 0 8px; }
p { margin: 6px 0; }
.sub { color: var(--chalk); font-size: .85rem; }
.center { text-align: center; }
.card {
  background: var(--card); color: var(--text); border-radius: 16px; padding: 14px; margin-bottom: 12px; min-width: 0;
  box-shadow: 0 4px 0 #0b2e1466;
}
.card .sub, dialog .sub { color: var(--sub); }

button, .button {
  font: inherit; font-weight: 700; color: var(--chalk); background: var(--fence);
  border: 0; border-radius: 12px; min-height: 44px; padding: 8px 14px; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .button:hover { filter: brightness(1.1); }
button:disabled { opacity: .4; cursor: default; }
:focus-visible { outline: 3px solid var(--pole); outline-offset: 2px; }
.primary { background: var(--clay); color: var(--chalk); border: 2px solid var(--chalk); }
.big { width: 100%; min-height: 58px; font-size: 1.2rem; box-shadow: 0 5px 0 var(--clay-dark); }
.wide { width: 100%; margin-top: 8px; }
.on { background: var(--good-bg); color: #123d1d; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.between { justify-content: space-between; }

input, select, textarea {
  font: inherit; font-size: 1rem; color: var(--text); background: var(--field-bg);
  border: 2px solid var(--fence); border-radius: 10px; min-height: 44px; padding: 6px 10px; max-width: 100%;
}
textarea { width: 100%; resize: vertical; }
label { display: block; margin: 8px 0; }
label > span { display: block; font-size: .85rem; color: var(--sub); }
label input[type="text"], label input[type="number"], label input[type="password"], label select { width: 100%; }
input[type="checkbox"] { min-height: 22px; width: 22px; height: 22px; vertical-align: middle; accent-color: var(--clay); }

/* ホーム：空・フェンス・赤土の上に卵 */
.stage { text-align: center; padding: 0 0 14px; background: var(--soil); color: var(--chalk); overflow: hidden; border: 3px solid var(--chalk); }
.stage .sub { color: #f1e3d6; }
.stage p { padding: 0 12px; }
.field {
  padding: 16px 0 10px; margin-bottom: 12px; border-bottom: 4px solid var(--chalk);
  background: linear-gradient(var(--sky) 0 42%, var(--pole) 42% 44%, var(--fence) 44% 63%, var(--clay) 63%);
}
.egg { width: min(48vw, 210px); height: auto; display: block; margin: 0 auto; transform-origin: 50% 90%; }
.egg.warm { animation: breathe 3s ease-in-out infinite; }
.egg.move { animation: wobble 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.04); } }
@keyframes wobble { 0%, 60%, 100% { transform: rotate(0); } 68% { transform: rotate(-7deg); } 76% { transform: rotate(6deg); } 84% { transform: rotate(-3deg); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; text-align: center; margin-bottom: 12px; padding: 6px; background: var(--board); border: 3px solid var(--chalk); border-radius: 12px; }
.stats .card { margin: 0; padding: 8px 4px; background: var(--board); color: var(--chalk); border: 1px solid #ffffff66; border-radius: 6px; box-shadow: none; }
.stats b { display: block; font-size: 1.7rem; color: var(--chalk); font-variant-numeric: tabular-nums; }
.stats span { font-size: .75rem; color: #d5eadd; }

/* 月ごとの姿・ずかん */
.monster { display: block; width: 100%; height: auto; border-radius: 12px; }
.mystery { max-width: 200px; margin: 0 auto; overflow: hidden; border-radius: 12px; }
.hidden-form { filter: blur(16px) brightness(.55); }
.unknown { display: flex; align-items: center; justify-content: center; aspect-ratio: 1; max-width: 200px; width: 100%; margin: 0 auto; border-radius: 12px; background: #1b2030; color: var(--pole); font-size: 2.5rem; font-weight: 800; }
.zukan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.slot { display: flex; flex-direction: column; justify-content: flex-start; gap: 2px; padding: 4px; min-width: 0; font-size: .85rem; background: var(--board); color: var(--chalk); border-radius: 10px; }
.slot small { font-size: .7rem; min-height: 1.2em; }
.slot.empty .unknown { opacity: .6; }
dialog .monster { margin-bottom: 8px; max-height: 50vh; object-fit: contain; }
@media (min-width: 800px) { .zukan-grid { grid-template-columns: repeat(6, 1fr); } }

/* 記録入力 */
.items { display: grid; gap: 10px; margin-bottom: 12px; }
.item { margin: 0; border-left: 8px solid var(--clay); }
.item .amount { width: 6.5em; text-align: right; font-size: 1.3rem; font-weight: 700; }
.item .pt { color: var(--point); font-weight: 700; }
.item .full { color: var(--good); font-weight: 700; }
.steps { margin-top: 8px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.steps button { padding: 6px 4px; }
.savebar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  background: var(--soil); border-radius: 16px; padding: 8px 8px 12px; z-index: 1; box-shadow: 0 4px 14px #0006;
}
.savebar .pt { color: var(--pole); font-weight: 700; font-size: 1.15rem; }

/* ふりかえり */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.calendar span { font-size: .75rem; color: var(--sub); }
.calendar a, .calendar i {
  min-height: 42px; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text); text-decoration: none; background: #f1e9da; font-style: normal; font-size: .85rem; line-height: 1.2;
}
.calendar i { opacity: .4; }
.calendar a.practice { background: var(--good-bg); font-weight: 700; }
.calendar a.rest { background: #bfe0ff; }
.calendar a.today { outline: 3px solid var(--clay); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: right; padding: 6px 2px; border-bottom: 1px solid #00000022; }
td:first-child, th:first-child { text-align: left; }
th { font-size: .75rem; color: var(--sub); }
.card.scoreboard { background: var(--board); color: var(--chalk); border: 3px solid var(--chalk); font-variant-numeric: tabular-nums; }
.scoreboard .sub { color: #d5eadd; }
.scoreboard td, .scoreboard th { border-bottom-color: #ffffff55; }
.scoreboard th { color: #d5eadd; }
.bars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; align-items: end; height: 120px; text-align: center; }
.bars div { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; font-size: .7rem; color: var(--sub); }
.bars b { display: block; background: var(--clay); border-radius: 6px 6px 0 0; }

.error { color: var(--danger); font-weight: 700; background: var(--card); border-radius: 12px; padding: 12px; }
.code { font-size: 1.8rem; letter-spacing: .15em; font-weight: 700; color: var(--point); }

/* 下のメニュー：黒土 */
nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--soil); border-top: 3px solid var(--chalk); padding-bottom: env(safe-area-inset-bottom); z-index: 2;
}
nav a {
  flex: 1; max-width: 140px; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: #f1e3d6; text-decoration: none; font-size: .75rem; font-weight: 700;
}
nav a span { font-size: 1.4rem; }
nav a[aria-current="page"] { color: var(--chalk); background: var(--clay); box-shadow: inset 0 4px 0 var(--pole); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 90px); transform: translateX(-50%);
  background: var(--card); color: var(--text); border: 3px solid var(--clay); font-weight: 700; border-radius: 12px; padding: 10px 16px;
  width: max-content; max-width: 90vw; z-index: 3; box-shadow: 0 6px 24px #0008;
}
#toast:empty { display: none; }

dialog { background: var(--card); color: var(--text); border: 4px solid var(--fence); border-radius: 20px; padding: 20px; width: min(92vw, 400px); text-align: center; }
dialog::backdrop { background: #0b2416b3; }
.pop { font-size: 2.6rem; font-weight: 800; color: var(--point); animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } }

/* タブレット・パソコン */
@media (min-width: 800px) {
  main { max-width: 920px; }
  main.home, main.record, main.review { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-content: start; }
  main > .full-row { grid-column: 1 / -1; }
  .items { grid-template-columns: 1fr 1fr; }
  .egg { width: 230px; }
}
/* 小さいスマホでは保存ボタンの場所を詰める */
@media (max-height: 640px) {
  .savebar p { margin: 0; }
  .savebar .big { min-height: 46px; }
}
/* 横向きのスマホなど、高さが低い画面 */
@media (max-height: 500px) {
  :root { --nav-h: 52px; }
  nav a span { font-size: 1rem; }
  .egg { width: 120px; }
  .savebar { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
