/* ============================================================================
 * まちのくらし - えほんふう やさしい デザイン（第2弾 まなび追加）
 * 3さい・5さいの こどもでも タッチで おしやすい おおきな ぼたん・もじ
 * ============================================================================ */

:root {
  --cream: #fffaf0;
  --cream-deep: #f7ebd2;
  --wood: #9e6b43;
  --wood-dark: #684226;
  --wood-light: #d7a876;
  --leaf: #6aa85c;
  --leaf-dark: #4b8040;
  --coral: #e87a64;
  --coral-dark: #c95843;
  --sun: #f6c252;
  --sun-dark: #d99b26;
  --sky: #6cb4d6;
  --sky-dark: #488eb0;
  --ink: #4e331f;
  --shadow: 0 6px 18px rgba(78, 51, 31, 0.22);
  --radius-lg: 24px;
  --radius-md: 18px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #d8c8a8;
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic UI", "BIZ UDGothic", "Meiryo", sans-serif;
  touch-action: manipulation;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
}

/* ==================== タイトル画面 ==================== */
#screen-title {
  position: fixed;
  inset: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #cde0b4;
  background-size: cover;
  background-position: center;
  padding: 20px;
}

#screen-title::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(255, 250, 238, 0.18) 0%, rgba(78, 51, 31, 0.34) 100%);
  pointer-events: none;
}

.title-card {
  position: relative;
  z-index: 2;
  background: rgba(255, 250, 240, 0.92);
  border: 6px solid var(--wood);
  border-radius: 34px;
  padding: 28px 42px 34px;
  text-align: center;
  box-shadow: 0 14px 36px rgba(78, 51, 31, 0.34);
  max-width: 92vw;
  width: 520px;
}

.title-ribbon {
  display: inline-block;
  background: var(--leaf);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  padding: 6px 20px;
  border-radius: 999px;
  margin-bottom: 12px;
  letter-spacing: 0.08em;
}

.title-heading {
  margin: 0 0 24px;
  font-size: clamp(38px, 7vw, 58px);
  font-weight: 900;
  color: var(--wood-dark);
  text-shadow: 0 3px 0 #f4d69e;
  letter-spacing: 0.08em;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

/* ==================== 共通ボタン ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 58px;
  padding: 12px 28px;
  border-radius: 999px;
  border: 4px solid var(--wood-dark);
  font-family: inherit;
  font-size: 24px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 5px 0 rgba(78, 51, 31, 0.35);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.12s ease;
  text-decoration: none;
  line-height: 1.2;
}

.btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(78, 51, 31, 0.35);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.btn-primary {
  background: linear-gradient(180deg, #7ec26d 0%, var(--leaf) 100%);
  border-color: var(--leaf-dark);
}

.btn-warm {
  background: linear-gradient(180deg, #f8cf6a 0%, var(--sun) 100%);
  border-color: #a87114;
  color: var(--wood-dark);
}

.btn-coral {
  background: linear-gradient(180deg, #f39581 0%, var(--coral) 100%);
  border-color: var(--coral-dark);
}

.btn-sky {
  background: linear-gradient(180deg, #86c7e6 0%, var(--sky) 100%);
  border-color: var(--sky-dark);
}

.btn-cream {
  background: var(--cream);
  border-color: var(--wood);
  color: var(--wood-dark);
}

.btn-wide {
  width: 100%;
  max-width: 340px;
  min-height: 66px;
  font-size: 26px;
}

.btn-sm {
  min-height: 46px;
  padding: 8px 18px;
  font-size: 19px;
}

/* ==================== しゅじんこうえらび画面 ==================== */
#screen-select {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #f5e9ce 0%, #dfecc9 100%);
  padding: 18px;
  overflow-y: auto;
}

.select-box {
  background: var(--cream);
  border: 6px solid var(--wood);
  border-radius: 30px;
  padding: 22px 26px 26px;
  max-width: 820px;
  width: 96vw;
  box-shadow: var(--shadow);
  text-align: center;
}

.select-title {
  margin: 0 0 18px;
  font-size: clamp(24px, 4.5vw, 34px);
  color: var(--wood-dark);
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

@media (max-width: 680px) {
  .char-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.char-card {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 22px;
  padding: 14px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.char-card:hover {
  transform: translateY(-3px);
}

.char-card.selected {
  border-color: var(--leaf);
  background: #f0fae8;
  box-shadow: 0 0 0 4px rgba(106, 168, 92, 0.28);
  transform: translateY(-3px);
}

.char-card img {
  width: 108px;
  height: 122px;
  object-fit: contain;
}

.char-card-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--wood-dark);
}

.char-card-desc {
  font-size: 14px;
  color: #7c5b3e;
  line-height: 1.35;
}

.select-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ==================== メインゲーム画面 ==================== */
#screen-game {
  position: fixed;
  inset: 0;
  background: #89b26a;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* 上部HUD */
.hud-top {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
  flex-wrap: wrap;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.hud-pill {
  background: rgba(255, 250, 240, 0.94);
  border: 4px solid var(--wood);
  border-radius: 999px;
  padding: 7px 18px;
  font-size: 21px;
  font-weight: 800;
  color: var(--wood-dark);
  box-shadow: 0 4px 10px rgba(78, 51, 31, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hud-money {
  background: #fff6dc;
  border-color: #c88d28;
  color: #7e4f0a;
}

.hud-btn {
  background: rgba(255, 250, 240, 0.96);
  border: 4px solid var(--wood);
  border-radius: 999px;
  padding: 8px 18px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 800;
  color: var(--wood-dark);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(78, 51, 31, 0.28);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hud-btn:active {
  transform: translateY(2px);
}

.errand-banner {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff5d6;
  border: 4px solid #d49022;
  border-radius: 999px;
  padding: 8px 22px;
  font-size: 20px;
  font-weight: 800;
  color: #6b4108;
  box-shadow: var(--shadow);
  z-index: 10;
  display: none;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.errand-banner.visible {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* 画面下の操作エリア */
.controls-bottom {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
  z-index: 10;
}

/* バーチャルスティック */
.joystick-pad {
  width: 126px;
  height: 126px;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.55);
  border: 4px solid rgba(104, 66, 38, 0.45);
  position: relative;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 4px 12px rgba(78, 51, 31, 0.16);
}

.joystick-knob {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 250, 240, 0.94);
  border: 4px solid var(--wood);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 3px 8px rgba(78, 51, 31, 0.25);
  pointer-events: none;
}

/* 右下アクションボタン群 */
.action-area {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: auto;
}

.room-quick-bar {
  display: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.room-quick-bar.visible {
  display: flex;
}

.btn-action-main {
  min-width: 170px;
  min-height: 70px;
  font-size: 25px;
  padding: 12px 28px;
  animation: gentlePulse 1.5s infinite ease-in-out;
}

.btn-action-main.hidden {
  display: none;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

/* ==================== 家具もようがえトレイ ==================== */
.decorate-bar {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  background: rgba(255, 250, 240, 0.97);
  border: 5px solid var(--wood);
  border-radius: 26px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  z-index: 25;
  display: none;
  flex-direction: column;
  gap: 10px;
}

.decorate-bar.active {
  display: flex;
}

.decorate-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.decorate-hint {
  font-size: 20px;
  font-weight: 800;
  color: var(--wood-dark);
}

.decorate-list {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.decorate-item {
  flex: 0 0 auto;
  min-width: 112px;
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 18px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
}

.decorate-item.selected {
  border-color: var(--leaf);
  background: #ecf9e3;
}

.decorate-item img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.decorate-item-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--wood-dark);
}

/* ==================== モーダル共通 ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(62, 40, 22, 0.48);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 40;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--cream);
  border: 6px solid var(--wood);
  border-radius: 30px;
  padding: 22px 24px 24px;
  width: 680px;
  max-width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 16px 40px rgba(52, 32, 16, 0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 3px dashed var(--wood-light);
  padding-bottom: 12px;
}

.modal-title {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  color: var(--wood-dark);
}

.modal-sub {
  font-size: 20px;
  font-weight: 800;
  color: #8c5a18;
}

/* 会話ダイアログ */
.talk-card {
  width: 660px;
}

.talk-top {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 16px;
}

.talk-portrait {
  width: 112px;
  height: 124px;
  object-fit: contain;
  background: #f5ebd6;
  border: 4px solid var(--wood-light);
  border-radius: 22px;
  padding: 6px;
  flex-shrink: 0;
}

.talk-meta {
  flex: 1;
}

.talk-name {
  font-size: 28px;
  font-weight: 900;
  color: var(--wood-dark);
  margin-bottom: 6px;
}

.talk-hearts {
  font-size: 28px;
  letter-spacing: 3px;
  color: #e86262;
}

.talk-hearts-label {
  font-size: 16px;
  font-weight: 700;
  color: #7d5b3e;
  margin-left: 6px;
}

.talk-bubble {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 22px;
  padding: 18px 22px;
  font-size: 26px;
  font-weight: 800;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 18px;
  min-height: 86px;
  display: flex;
  align-items: center;
}

.talk-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

/* お店・もちものリスト */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  min-height: 52px;
  border-radius: 18px;
  border: 4px solid var(--wood-light);
  background: #f7eedb;
  font-family: inherit;
  font-size: 21px;
  font-weight: 800;
  color: var(--wood-dark);
  cursor: pointer;
}

.tab-btn.active {
  background: var(--sun);
  border-color: var(--wood-dark);
}

/* お店での おかね・おつり まなびカード */
.shop-calc-card {
  display: none;
  background: #fff7e2;
  border: 4px solid #d99b26;
  border-radius: 20px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.shop-calc-card.visible {
  display: block;
}

.shop-calc-title {
  font-size: 19px;
  font-weight: 900;
  color: #7b4c08;
  margin-bottom: 8px;
}

.shop-calc-row {
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 8px;
}

.shop-calc-part {
  background: #fffdf8;
  border: 3px solid #e6c687;
  border-radius: 14px;
  padding: 6px 12px;
  text-align: center;
  min-width: 112px;
}

.shop-calc-label {
  font-size: 13px;
  font-weight: 800;
  color: #825b36;
}

.shop-calc-num {
  font-size: 22px;
  font-weight: 900;
  color: var(--wood-dark);
}

.shop-calc-coins {
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.coin-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
  border: 2px solid var(--wood-dark);
}

.coin-chip.c100 {
  background: #e9edf2;
  color: #4a5568;
}

.coin-chip.c10 {
  background: #df9b62;
  color: #4e2b10;
}

.shop-calc-op {
  font-size: 26px;
  font-weight: 900;
  color: #b57312;
}

.item-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 560px) {
  .item-grid {
    grid-template-columns: 1fr;
  }
}

.item-card {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 20px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.item-card img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  flex-shrink: 0;
}

.item-info {
  flex: 1;
  min-width: 0;
}

.item-name {
  font-size: 21px;
  font-weight: 800;
  color: var(--wood-dark);
}

.item-price {
  font-size: 19px;
  font-weight: 800;
  color: #b26d0c;
  margin: 2px 0 6px;
}

.item-warn {
  font-size: 15px;
  font-weight: 800;
  color: #c84b3a;
}

.empty-note {
  text-align: center;
  padding: 26px 12px;
  font-size: 22px;
  font-weight: 800;
  color: #8a6a4c;
  grid-column: 1 / -1;
}

/* もちもの上部 スタンプちょう案内 */
.bag-sticker-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #fff6dc;
  border: 4px solid #d99b26;
  border-radius: 20px;
  padding: 12px 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.bag-sticker-text {
  font-size: 20px;
  font-weight: 900;
  color: #6b4108;
}

/* ちょきんばこ */
.piggy-balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.balance-box {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 20px;
  padding: 14px;
  text-align: center;
}

.balance-label {
  font-size: 18px;
  font-weight: 800;
  color: #7d5b3e;
  margin-bottom: 6px;
}

.balance-val {
  font-size: 32px;
  font-weight: 900;
  color: var(--wood-dark);
}

.piggy-row-title {
  font-size: 21px;
  font-weight: 800;
  margin: 12px 0 8px;
  color: var(--wood-dark);
}

.piggy-btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.piggy-btn-row .btn {
  flex: 1;
  min-width: 112px;
  min-height: 54px;
  font-size: 20px;
  padding: 8px 14px;
}

/* つりミニゲーム */
.fishing-card {
  width: 560px;
  text-align: center;
}

.fishing-pond {
  position: relative;
  height: 220px;
  border-radius: 24px;
  background: linear-gradient(180deg, #9dd7ef 0%, #6cb9de 100%);
  border: 5px solid #498eb0;
  overflow: hidden;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.fishing-ring {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.fishing-ring.bite {
  border-color: #ffe264;
  background: rgba(255, 232, 118, 0.35);
  transform: scale(1.22);
  box-shadow: 0 0 28px rgba(255, 230, 102, 0.9);
}

.fishing-bobber {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ef5c4c 50%, #fffdf8 50%);
  border: 4px solid var(--wood-dark);
  transition: transform 0.1s ease;
}

.fishing-ring.bite .fishing-bobber {
  transform: translateY(10px) scale(1.1);
}

.fishing-caught-img {
  width: 120px;
  height: 120px;
  object-fit: contain;
  display: none;
}

.fishing-caught-img.visible {
  display: block;
}

.fishing-status {
  font-size: 26px;
  font-weight: 900;
  color: var(--wood-dark);
  margin-bottom: 16px;
  min-height: 38px;
}

/* ==================== まなびや（メニュー・チャレンジ・スタンプちょう） ==================== */
.study-menu-card {
  width: 740px;
}

.study-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 640px) {
  .study-columns {
    grid-template-columns: 1fr;
  }
}

.study-col {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 22px;
  padding: 14px;
}

.study-col-title {
  margin: 0 0 12px;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
  color: var(--wood-dark);
}

.study-level-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.study-level-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  border: 4px solid var(--leaf-dark);
  background: linear-gradient(180deg, #f3fbec 0%, #e1f4d2 100%);
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: transform 0.08s ease;
}

.study-level-btn:active:not(:disabled) {
  transform: translateY(2px);
}

.study-level-btn.cleared {
  border-color: #c88d28;
  background: linear-gradient(180deg, #fff9e5 0%, #fcebb9 100%);
}

.study-level-btn.locked {
  border-color: #c5b49e;
  background: #efe8dc;
  opacity: 0.72;
  cursor: not-allowed;
}

.study-level-name {
  font-size: 19px;
  font-weight: 900;
  color: var(--wood-dark);
}

.study-level-badge {
  font-size: 14px;
  font-weight: 800;
  color: #7d5b3e;
}

/* チャレンジプレイ画面 */
.study-play-card {
  width: 660px;
}

.study-progress {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  justify-content: center;
}

.study-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #eadbc0;
  border: 3px solid var(--wood-light);
}

.study-dot.current {
  background: var(--sun);
  border-color: var(--wood-dark);
  transform: scale(1.18);
}

.study-dot.done {
  background: var(--leaf);
  border-color: var(--leaf-dark);
}

.study-teacher-box {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 20px;
  padding: 10px 16px;
  margin-bottom: 16px;
}

.study-teacher-box.happy {
  background: #effae6;
  border-color: var(--leaf);
}

.study-teacher-box.hint {
  background: #fff6df;
  border-color: #d99b26;
}

.study-teacher-box img {
  width: 68px;
  height: 76px;
  object-fit: contain;
  flex-shrink: 0;
}

.study-teacher-text {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.45;
  color: var(--wood-dark);
}

.study-q-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.study-correct-flash {
  animation: gentlePulse 0.4s ease 2;
}

.study-pic-frame {
  width: 170px;
  height: 170px;
  background: #fffdf7;
  border: 5px solid var(--wood-light);
  border-radius: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.study-pic-frame.study-pic-sm {
  width: 136px;
  height: 136px;
}

.study-pic-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.study-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  width: 100%;
}

.study-choice-btn {
  min-width: 160px;
  min-height: 68px;
  font-size: 28px;
  padding: 12px 24px;
}

.study-num-btn {
  min-width: 120px;
  font-size: 36px;
}

.study-slots {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.study-slot {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  border: 4px dashed var(--wood);
  background: #fffdf7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 900;
  color: var(--wood-dark);
}

.study-slot.filled {
  border-style: solid;
  border-color: var(--leaf);
  background: #f0fae8;
}

.study-tiles {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.study-tile-btn {
  min-width: 74px;
  min-height: 74px;
  font-size: 34px;
  padding: 8px 14px;
  border-radius: 20px;
}

.study-sub-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* なぞりがきキャンバス */
.study-trace-box {
  background: #fffdf7;
  border: 5px solid var(--wood);
  border-radius: 24px;
  padding: 8px;
  box-shadow: inset 0 2px 8px rgba(78, 51, 31, 0.1);
}

.trace-canvas {
  display: block;
  width: 280px;
  height: 280px;
  touch-action: none;
  cursor: crosshair;
}

/* さんすう絵・式 */
.study-count-box {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  max-width: 440px;
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 22px;
  padding: 16px;
}

.study-count-icon {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.study-math-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 20px;
  padding: 12px 18px;
}

.study-vis-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 220px;
}

.study-mini-icon {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.study-mini-icon.crossed {
  opacity: 0.28;
  filter: grayscale(0.8);
}

.study-vis-op {
  font-size: 34px;
  font-weight: 900;
  color: var(--wood-dark);
}

.study-equation {
  font-size: clamp(40px, 7vw, 54px);
  font-weight: 900;
  color: var(--wood-dark);
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 22px;
  padding: 14px 36px;
  letter-spacing: 0.06em;
}

/* クリア画面 */
.study-clear-box {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}

.study-clear-sticker img {
  width: 132px;
  height: 132px;
  object-fit: contain;
  animation: gentlePulse 1.2s infinite ease-in-out;
}

.study-clear-msg {
  font-size: 26px;
  font-weight: 900;
  color: var(--wood-dark);
}

.study-clear-bonus {
  background: #fff4cf;
  border: 4px solid #d99b26;
  border-radius: 999px;
  padding: 8px 22px;
  font-size: 22px;
  font-weight: 900;
  color: #7c4b06;
}

.study-clear-unlock {
  font-size: 20px;
  font-weight: 800;
  color: var(--leaf-dark);
}

.study-clear-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 6px;
}

/* スタンプちょう */
.sticker-progress {
  background: #f5ebd6;
  border-radius: 16px;
  padding: 10px 14px;
  text-align: center;
  font-size: 19px;
  font-weight: 800;
  color: var(--wood-dark);
  margin-bottom: 16px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 560px) {
  .sticker-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sticker-slot {
  background: #fffdf7;
  border: 4px dashed var(--wood-light);
  border-radius: 20px;
  padding: 10px 8px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
}

.sticker-slot.filled {
  border-style: solid;
  border-color: #d99b26;
  background: #fffbf0;
}

.sticker-slot img {
  width: 78px;
  height: 78px;
  object-fit: contain;
}

.sticker-slot-name {
  font-size: 14px;
  font-weight: 900;
  color: var(--wood-dark);
}

.sticker-slot-sub {
  font-size: 12px;
  font-weight: 700;
  color: #8c6a4a;
}

.sticker-slot-empty {
  font-size: 34px;
  font-weight: 900;
  color: #d6c2a2;
}

/* ==================== お礼の手紙モーダル ==================== */
.letter-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.letter-paper {
  background: #fffdf4;
  border: 4px solid #d9b482;
  border-radius: 22px;
  padding: 16px 20px;
  box-shadow: 0 4px 10px rgba(78, 51, 31, 0.1);
}

.letter-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  border-bottom: 2px dashed #e6cfa8;
  padding-bottom: 8px;
}

.letter-head img {
  width: 56px;
  height: 62px;
  object-fit: contain;
  background: #f5ebd6;
  border-radius: 14px;
  padding: 3px;
}

.letter-from {
  font-size: 22px;
  font-weight: 900;
  color: var(--wood-dark);
}

.letter-day {
  font-size: 15px;
  font-weight: 700;
  color: #8c6a4a;
}

.letter-body {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.65;
  color: var(--ink);
}

/* ねる・あさの画面 */
.morning-overlay {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 60;
  transition: background 0.6s ease;
}

.morning-overlay.active {
  display: flex;
}

.morning-overlay.night {
  background: linear-gradient(180deg, #253459 0%, #3a4f7c 100%);
  color: #fff8dc;
}

.morning-overlay.dawn {
  background: linear-gradient(180deg, #ffe2a4 0%, #fff6d9 55%, #d6ecc2 100%);
  color: var(--wood-dark);
}

.morning-icon {
  font-size: 76px;
  margin-bottom: 14px;
}

.morning-heading {
  font-size: clamp(32px, 6vw, 48px);
  font-weight: 900;
  margin: 0 0 14px;
}

.morning-sub {
  font-size: 24px;
  font-weight: 800;
  margin: 0 0 28px;
}

/* やさしいメッセージトースト */
.toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(18px);
  background: rgba(255, 250, 240, 0.97);
  border: 4px solid var(--leaf);
  border-radius: 999px;
  padding: 10px 26px;
  font-size: 22px;
  font-weight: 800;
  color: var(--wood-dark);
  box-shadow: var(--shadow);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  max-width: 92vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ==================== 4タブ・はたけ・花うえ ==================== */
.tabs-wrap {
  flex-wrap: wrap;
}

.tabs-wrap .tab-btn {
  flex: 1 1 45%;
  font-size: 18px;
  min-height: 46px;
}

.farm-modal-card {
  width: 720px;
}

.farm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  background: #f5ebd6;
  border-radius: 18px;
  padding: 10px 12px;
}

.farm-tool-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.farm-tool-active {
  box-shadow: 0 0 0 4px rgba(106, 168, 92, 0.45), 0 4px 0 rgba(78, 51, 31, 0.35);
  transform: translateY(-2px);
}

.farm-seed-empty {
  font-size: 16px;
  font-weight: 800;
  color: #7d5b3e;
  padding: 4px 8px;
}

.farm-modal-grid {
  display: grid;
  gap: 10px;
}

.farm-modal-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.farm-modal-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 560px) {
  .farm-modal-grid.cols-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}

.farm-cell {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 20px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease;
}

.farm-cell:active {
  transform: scale(0.97);
}

.farm-cell.wet {
  border-color: #6b492e;
  background: #f3f9fc;
}

.farm-cell-soil {
  width: 78px;
  height: 78px;
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  position: relative;
}

.farm-cell-soil.dry {
  background-image: url('../assets/farm/soil_dry.png');
}

.farm-cell-soil.wet {
  background-image: url('../assets/farm/soil_wet.png');
}

.farm-cell-crop {
  width: 70px;
  height: 82px;
  object-fit: contain;
  margin-bottom: 4px;
}

.farm-cell-label,
.farm-cell-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--wood-dark);
  line-height: 1.2;
}

.farm-cell-owner {
  font-size: 12px;
  font-weight: 700;
  color: #7d5b3e;
}

.farm-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.farm-badge.dry {
  background: #f6e7c8;
  color: #7a5228;
}

.farm-badge.wet {
  background: #d8eef8;
  color: #266080;
}

.farm-badge.ripe {
  background: #fde073;
  color: #6b4108;
  border: 2px solid #c98612;
}

/* ==================== きろく 1〜3・なまえ・けす ==================== */
.title-card-slots {
  width: 780px;
  max-width: 95vw;
  max-height: 92vh;
  overflow-y: auto;
  padding: 22px 28px 26px;
}

.title-card-slots .title-heading {
  margin-bottom: 10px;
}

.title-slot-guide {
  margin: 0 0 16px;
  font-size: 20px;
  font-weight: 800;
  color: #7c5b3e;
}

.save-slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

@media (max-width: 680px) {
  .save-slots-grid {
    grid-template-columns: 1fr;
  }
}

.save-slot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.save-slot-card {
  width: 100%;
  min-height: 220px;
  background: #fffdf7;
  border: 5px solid var(--wood-light);
  border-radius: 24px;
  padding: 14px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 5px 0 rgba(78, 51, 31, 0.22);
  transition: transform 0.1s ease, border-color 0.12s ease;
}

.save-slot-card:hover {
  transform: translateY(-2px);
}

.save-slot-card:active {
  transform: translateY(2px);
}

.save-slot-card.filled {
  border-color: var(--sun-dark);
  background: linear-gradient(180deg, #fffdf7 0%, #fff6df 100%);
}

.save-slot-card.empty {
  border-style: dashed;
  border-color: var(--wood-light);
  background: rgba(255, 253, 247, 0.85);
}

.slot-num-badge {
  display: inline-block;
  background: var(--wood);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: 999px;
}

.slot-char-img {
  width: 84px;
  height: 94px;
  object-fit: contain;
}

.slot-empty-mark {
  width: 84px;
  height: 94px;
  border-radius: 20px;
  border: 3px dashed #d6c2a2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: #b79c78;
}

.slot-player-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--wood-dark);
  line-height: 1.2;
}

.slot-day-text {
  font-size: 18px;
  font-weight: 800;
  color: #8c5a18;
}

.slot-action-pill {
  display: inline-block;
  padding: 5px 16px;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 800;
  color: #fff;
  background: var(--leaf);
}

.save-slot-card.filled .slot-action-pill {
  background: var(--sun);
  color: var(--wood-dark);
}

.slot-delete-btn {
  background: transparent;
  border: 2px solid rgba(158, 107, 67, 0.35);
  border-radius: 999px;
  padding: 2px 12px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: #8e6c4e;
  cursor: pointer;
  opacity: 0.72;
}

.slot-delete-btn:hover {
  opacity: 1;
  border-color: var(--coral);
  color: var(--coral-dark);
}

/* 名前入力モーダル */
.name-modal-card {
  width: 520px;
  text-align: center;
}

.name-modal-desc {
  margin: 0 0 12px;
  font-size: 21px;
  font-weight: 800;
  color: var(--wood-dark);
}

.name-input {
  width: 100%;
  max-width: 320px;
  height: 64px;
  border: 4px solid var(--wood);
  border-radius: 20px;
  background: #fffdf8;
  font-family: inherit;
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  color: var(--wood-dark);
  outline: none;
  padding: 6px 14px;
}

.name-input:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 4px rgba(106, 168, 92, 0.25);
}

.name-error {
  min-height: 26px;
  margin-top: 8px;
  font-size: 17px;
  font-weight: 800;
  color: var(--coral-dark);
}

.name-presets-label {
  margin: 8px 0 8px;
  font-size: 16px;
  font-weight: 800;
  color: #7c5b3e;
}

.name-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 18px;
}

.name-modal-actions {
  display: flex;
  justify-content: center;
}

/* 記録を消す確認モーダル */
.delete-modal-card {
  width: 480px;
  text-align: center;
}

.delete-modal-msg {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.55;
  color: var(--ink);
  margin: 12px 0 22px;
}

.delete-modal-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
}

/* ==================== 第4弾：ずかん・かんさつノート・むかしばなし・おしごと ==================== */
.shop-work-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.bag-zukan-bar {
  background: #edf7e4;
  border-color: var(--leaf);
}

.zukan-modal-card {
  width: 740px;
}

.zukan-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .zukan-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.zukan-card {
  background: #fffdf7;
  border: 4px solid var(--wood-light);
  border-radius: 20px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.zukan-card.found {
  border-color: var(--leaf);
  background: #f6fcf1;
}

.zukan-card.unknown {
  border-style: dashed;
  opacity: 0.78;
}

.zukan-card img {
  width: 74px;
  height: 74px;
  object-fit: contain;
}

.zukan-unknown-mark {
  width: 74px;
  height: 74px;
  border-radius: 18px;
  background: #f0e4cd;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 900;
  color: #a48a68;
}

.zukan-card-kind {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  background: #f2e5cb;
  color: var(--wood-dark);
  padding: 2px 10px;
  border-radius: 999px;
}

.zukan-card-name {
  font-size: 19px;
  font-weight: 900;
  color: var(--wood-dark);
}

.zukan-card-desc {
  font-size: 13px;
  font-weight: 700;
  color: #6b4e35;
  line-height: 1.4;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.note-row {
  background: #fffdf7;
  border: 3px solid var(--wood-light);
  border-radius: 18px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.note-row img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  flex-shrink: 0;
}

.note-text {
  font-size: 19px;
  font-weight: 800;
  color: var(--wood-dark);
  line-height: 1.4;
}

/* はっけんカード */
.disc-modal-card {
  width: 500px;
  text-align: center;
}

.disc-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.disc-pic {
  width: 140px;
  height: 140px;
  background: #f6fcf1;
  border: 5px solid var(--leaf);
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.disc-pic img {
  width: 110px;
  height: 110px;
  object-fit: contain;
}

.disc-name {
  font-size: 28px;
  font-weight: 900;
  color: var(--wood-dark);
}

.disc-place {
  font-size: 17px;
  font-weight: 800;
  color: #6f5236;
}

.disc-desc {
  background: #fffdf7;
  border: 3px solid var(--wood-light);
  border-radius: 18px;
  padding: 12px 16px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.5;
  width: 100%;
}

/* むかしばなし */
.mukashi-modal-card {
  width: 660px;
}

.mukashi-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mukashi-story-box {
  background: #fffdf4;
  border: 4px solid #d9b482;
  border-radius: 22px;
  padding: 16px 20px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mukashi-page {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.65;
  color: var(--ink);
}

.mukashi-actions {
  display: flex;
  justify-content: center;
}

/* しなだしのおしごと */
.shinadashi-modal-card {
  width: 640px;
  text-align: center;
}

.shinadashi-status {
  font-size: 22px;
  font-weight: 900;
  color: var(--wood-dark);
  margin-bottom: 14px;
}

.shinadashi-shelves {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.shelf-slot {
  background: #f5ebd6;
  border: 4px solid var(--wood);
  border-radius: 20px;
  padding: 10px 8px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.shelf-slot.filled {
  background: #effae6;
  border-color: var(--leaf);
}

.shelf-label {
  font-size: 17px;
  font-weight: 900;
  color: var(--wood-dark);
}

.shelf-box {
  width: 84px;
  height: 84px;
  border-radius: 16px;
  background: #fffdf7;
  border: 3px dashed var(--wood-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.shelf-slot.filled .shelf-box {
  border-style: solid;
  border-color: var(--leaf);
}

.shelf-box img {
  width: 68px;
  height: 68px;
  object-fit: contain;
}

.shelf-empty {
  font-size: 14px;
  font-weight: 800;
  color: #a68b6b;
}

.shinadashi-tray {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}


/* ==================== 第5弾: みにまっぷ・かくだいしゅくしょう・おおきなちず ==================== */
.minimap-box {
  position: fixed;
  top: 72px;
  left: 14px;
  z-index: 25;
  padding: 5px;
  border-radius: 14px;
  border: 3px solid #8c5a32;
  background: rgba(255, 248, 232, 0.92);
  box-shadow: 0 4px 12px rgba(55, 35, 18, 0.25);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.12s ease;
}
.minimap-box:active {
  transform: scale(0.96);
}
#minimap-canvas {
  display: block;
  width: 156px;
  height: 78px;
  border-radius: 9px;
  background: #8cc474;
}
.minimap-label {
  font-size: 12px;
  font-weight: 800;
  color: #5c3a1e;
  line-height: 1.1;
}

.zoom-controls {
  position: fixed;
  top: 72px;
  right: 14px;
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.zoom-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #8c5a32;
  background: rgba(255, 248, 232, 0.94);
  color: #5c3a1e;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(55, 35, 18, 0.22);
  transition: transform 0.1s ease, background 0.15s ease;
}
.zoom-btn:active {
  transform: scale(0.92);
  background: #ffe9b8;
}

.map-modal-card {
  max-width: 740px;
  width: 94vw;
}
.map-guide {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 700;
  color: #6b4c2f;
  text-align: center;
}
.big-map-wrap {
  width: 100%;
  border-radius: 14px;
  border: 4px solid #8c5a32;
  overflow: hidden;
  background: #8cc474;
  margin-bottom: 12px;
}
#big-map-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
  touch-action: manipulation;
}
.map-places-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
}
.map-place-btn {
  font-size: 15px;
  padding: 10px 8px;
  border-radius: 14px;
  border: 2px solid #c99a5b;
  background: #fff8e6;
  color: #53361c;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 0 #d6b17c;
  transition: transform 0.1s ease;
}
.map-place-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #d6b17c;
}

@media (max-width: 600px) {
  .minimap-box {
    top: 66px;
    left: 10px;
    padding: 4px;
  }
  #minimap-canvas {
    width: 120px;
    height: 60px;
  }
  .zoom-controls {
    top: 66px;
    right: 10px;
  }
  .zoom-btn {
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
}
