/* 画面全体の基本設定 */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #24313f;
  background: linear-gradient(180deg, #bce8ff 0%, #eaf8e1 58%, #ffe7b8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

/* ゲーム画面の入れ物 */
.game {
  width: min(920px, 100%);
  min-height: auto;
  background: #fffdf7;
  border: 5px solid #5b8f54;
  border-radius: 8px;
  box-shadow: 0 14px 0 #3f6f3a, 0 22px 35px rgba(37, 62, 42, 0.22);
  overflow: visible;
}

/* 画面切り替え用。active が付いた画面だけ表示する */
.screen {
  display: none;
  min-height: min(620px, calc(100vh - 24px));
  padding: 28px;
  overflow: visible;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

#start-screen,
#result-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}

.village-screen {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
  background: linear-gradient(180deg, #fffdf7 0%, #eef8df 100%);
}

h1 {
  margin: 0;
  font-size: clamp(48px, 9vw, 92px);
  color: #2f7c48;
  text-shadow: 4px 4px 0 #ffd46b;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(40px, 7vw, 76px);
  color: #2f7c48;
}

.lead {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
  font-weight: 700;
  line-height: 1.6;
}

.title-description {
  width: min(560px, 100%);
  padding: 14px 18px;
  color: #315a42;
  background: #fff9df;
  border: 3px solid #f0bd4f;
  border-radius: 8px;
  font-size: clamp(16px, 2.2vw, 20px);
  font-weight: 800;
  line-height: 1.55;
}

.title-description p {
  margin: 0;
}

.main-button,
.choice-button {
  border: 0;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.main-button {
  padding: 18px 34px;
  font-size: 24px;
  color: #ffffff;
  background: #e35d3f;
  box-shadow: 0 7px 0 #a93d29;
}

.sub-button {
  background: #4f90bf;
  box-shadow: 0 7px 0 #32617f;
}

.main-button:hover,
.choice-button:hover,
.difficulty-button:hover,
.text-button:hover {
  transform: translateY(-2px);
}

.main-button:active,
.choice-button:active,
.difficulty-button:active {
  transform: translateY(3px);
  box-shadow: none;
}

.menu-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.home-menu {
  width: min(560px, 100%);
  display: grid;
  gap: 16px;
}

.home-button {
  min-height: 96px;
  padding: 18px 22px;
  border-radius: 8px;
  border: 4px solid #47733b;
  color: #24313f;
  background: #fff9df;
  box-shadow: 0 7px 0 #4f7b41;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.home-button:hover {
  transform: translateY(-2px);
}

.home-button:active {
  transform: translateY(3px);
  box-shadow: none;
}

.home-button strong {
  font-size: 28px;
}

.home-button span {
  font-size: 16px;
  font-weight: 800;
}

.battle-button {
  background: #ffe0c2;
  border-color: #b9643d;
  box-shadow: 0 7px 0 #8f4729;
}

.review-button {
  background: #dff1ff;
  border-color: #4f90bf;
  box-shadow: 0 7px 0 #32617f;
}

.book-button {
  background: #e9f6d8;
  border-color: #5f9251;
  box-shadow: 0 7px 0 #426f39;
}

.book-list {
  width: min(700px, 100%);
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 14px;
  padding-right: 4px;
}

.book-grade {
  display: grid;
  gap: 8px;
}

.book-grade-title {
  margin: 0;
  padding: 8px 12px;
  color: #ffffff;
  background: #5f9251;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 20px;
}

.book-count {
  padding: 3px 8px;
  color: #315a42;
  background: #fffdf7;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 900;
}

.book-grade-items {
  display: grid;
  gap: 8px;
}

.book-empty {
  margin: 0;
  padding: 10px 12px;
  color: #617080;
  background: #ffffff;
  border: 2px dashed #b6c6b0;
  border-radius: 8px;
  text-align: left;
  font-weight: 800;
}

.book-item {
  padding: 12px 14px;
  background: #ffffff;
  border: 3px solid #75a85c;
  border-radius: 8px;
  text-align: left;
}

.book-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.book-kanji {
  font-size: 34px;
  font-weight: 900;
  color: #2f7c48;
}

.book-reading {
  font-size: 20px;
  font-weight: 900;
}

.book-meaning {
  margin: 0;
  font-size: 16px;
  line-height: 1.5;
}

.difficulty-list {
  width: min(680px, 100%);
  display: grid;
  gap: 14px;
}

.difficulty-button,
.text-button {
  border-radius: 8px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.difficulty-button {
  min-height: 88px;
  padding: 16px 20px;
  color: #24313f;
  background: #ffffff;
  border: 3px solid #75a85c;
  box-shadow: 0 5px 0 #4f7b41;
  text-align: left;
}

.difficulty-button strong,
.difficulty-button span {
  display: block;
}

.difficulty-button strong {
  margin-bottom: 6px;
  font-size: 26px;
  color: #2f7c48;
}

.difficulty-button span {
  font-size: 17px;
  line-height: 1.5;
}

.text-button {
  padding: 10px 18px;
  color: #315a42;
  background: transparent;
  border: 2px solid #75a85c;
}

/* HP表示 */
.status-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.combo-display {
  position: absolute;
  top: -10px;
  right: 10px;
  min-width: 78px;
  padding: 4px 8px;
  color: #8a4a00;
  background: #fff3c4;
  border: 2px solid #e0a82f;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.1;
  transform: rotate(-4deg);
  box-shadow: 0 2px 0 rgba(138, 74, 0, 0.24);
  pointer-events: none;
}

.combo-display.active {
  color: #ffffff;
  background: #e35d3f;
  border-color: #a93d29;
}

.level-box {
  margin: -2px 86px 5px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  color: #315a42;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
}

#exp-text {
  color: #617080;
}

#battle-screen {
  gap: 10px;
  min-height: auto;
}

#battle-screen.active {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
}

.status-card {
  position: relative;
  background: #f6fbff;
  border: 3px solid #5a96d6;
  border-radius: 8px;
  padding: 10px;
}

.status-card.enemy {
  background: #fff6f2;
  border-color: #e17961;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-size: 17px;
  font-weight: 900;
}

.hp-row {
  display: grid;
  grid-template-columns: auto 1fr 48px;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 800;
}

.hp-bar {
  height: 18px;
  background: #d9e3e5;
  border: 2px solid #273947;
  border-radius: 8px;
  overflow: hidden;
}

.hp-fill {
  width: 100%;
  height: 100%;
  background: #42bd63;
  transition: width 0.25s ease;
}

.enemy-fill {
  background: #f0784e;
}

/* 戦闘フィールド */
.battle-field {
  display: grid;
  grid-template-columns: 1fr minmax(190px, 1.4fr) 1fr;
  align-items: center;
  gap: 14px;
  min-height: 132px;
  margin: 0;
  padding: 10px;
  background: #dff4c9;
  border: 4px solid #8abc68;
  border-radius: 8px;
}

.hero,
.monster {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  border-radius: 8px;
  font-weight: 900;
}

.hero {
  font-size: 48px;
}

.monster {
  color: #ffffff;
  background: #8d4acb;
  border: 5px solid #5e2e8b;
  font-size: 44px;
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.16);
}

.message {
  min-height: 64px;
  padding: 10px;
  background: #ffffff;
  border: 3px solid #5b8f54;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.45;
}

.message small {
  display: block;
  margin-top: 6px;
  font-size: 14px;
  font-weight: 700;
}

/* 問題エリア */
.question-box {
  background: #ffffff;
  border: 4px solid #f0bd4f;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.question-label {
  margin: 0 0 5px;
  font-size: 17px;
  font-weight: 900;
}

.kanji {
  margin-bottom: 8px;
  font-size: clamp(44px, 7vw, 70px);
  font-weight: 900;
  line-height: 1;
  color: #1f2933;
}

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

.choice-button {
  min-height: 44px;
  padding: 6px 10px;
  font-size: 18px;
  color: #24313f;
  background: #fff0a8;
  border: 3px solid #cc9933;
  box-shadow: 0 5px 0 #aa7b22;
}

.choice-button:disabled {
  cursor: default;
  opacity: 0.75;
}

.choice-button.correct {
  background: #a8edb6;
  border-color: #3e9c52;
}

.choice-button.wrong {
  background: #ffb8a8;
  border-color: #cf5842;
}

@media (max-width: 700px) {
  body {
    padding: 0;
    align-items: stretch;
  }

  .game {
    width: 100%;
    min-height: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .screen {
    min-height: auto;
    padding: 10px;
  }

  h2 {
    font-size: 34px;
  }

  .lead {
    font-size: 18px;
  }

  .title-description {
    padding: 10px 12px;
    font-size: 15px;
    line-height: 1.45;
  }

  #battle-screen {
    display: none;
  }

  #battle-screen.active {
    display: grid;
    grid-template-rows: auto auto auto;
    align-content: start;
    gap: 7px;
    min-height: auto;
  }

  .status-area {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .combo-display {
    top: -7px;
    right: 5px;
    min-width: 58px;
    padding: 3px 5px;
    border-width: 2px;
    font-size: 10px;
  }

  .level-box {
    margin: -2px 58px 3px 0;
    gap: 2px 5px;
    font-size: 10px;
  }

  .status-card {
    padding: 6px;
    border-width: 2px;
  }

  .label {
    margin-bottom: 3px;
    font-size: 13px;
  }

  .hp-row {
    grid-template-columns: auto 1fr 34px;
    gap: 4px;
    font-size: 12px;
  }

  .hp-bar {
    height: 12px;
    border-width: 1px;
  }

  .main-button {
    width: 100%;
  }

  .menu-buttons {
    width: 100%;
  }

  .battle-field {
    grid-template-columns: 48px 1fr 56px;
    gap: 5px;
    min-height: 0;
    padding: 6px;
    border-width: 3px;
  }

  .hero,
  .monster {
    min-height: 58px;
  }

  .hero {
    font-size: 31px;
  }

  .monster {
    border-width: 3px;
    font-size: 30px;
  }

  .message {
    min-height: 58px;
    padding: 6px;
    font-size: 13px;
    border-width: 2px;
  }

  .message small {
    margin-top: 3px;
    font-size: 11px;
  }

  .question-box {
    padding: 6px;
    border-width: 3px;
  }

  .question-label {
    margin-bottom: 3px;
    font-size: 13px;
  }

  .kanji {
    margin-bottom: 4px;
    font-size: 42px;
  }

  .choices {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .choice-button {
    min-height: 38px;
    padding: 5px;
    border-width: 2px;
    box-shadow: 0 3px 0 #aa7b22;
    font-size: 14px;
    line-height: 1.25;
  }

  .home-menu {
    gap: 12px;
  }

  .home-button {
    min-height: 86px;
  }

  .book-list {
    max-height: 58svh;
  }

  .book-grade-title {
    padding: 7px 10px;
    font-size: 17px;
  }

  .book-count {
    font-size: 13px;
  }
}
