@font-face {
  font-family: "KanjiPuzzleNoto";
  src: url("/assets/fonts/kanji-puzzle.woff2") format("woff2");
  font-style: normal;
  font-weight: 800;
  font-display: block;
}

.game-board.playing-board {
  --kanji-board-dark: #203b42;
  --kanji-board-deep: #1b3039;
  --kanji-card-edge: #dfded2;
}

.game-area.game-kanji-puzzle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
  width: 100%;
  min-height: 0;
  padding: 0;
}

.kanji-board {
  position: relative;
  display: grid;
  gap: 3px;
  width: min(72vw, 320px);
  max-width: 100%;
  margin: 0 auto;
  aspect-ratio: 1;
  background: linear-gradient(155deg, var(--kanji-board-dark), var(--kanji-board-deep));
  border: 1px solid #37545a;
  border-radius: 14px;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(25, 54, 55, 0.08);
}

.kanji-praise-overlay {
  position: absolute;
  left: 50%;
  top: 67%;
  transform: translate(-50%, -50%);
  z-index: 2;
  pointer-events: none;
  white-space: nowrap;
}
.kanji-praise-overlay .brain-praise {
  margin: 0;
  padding: 0.28em 0.65em;
  border-radius: 8px;
  border: 1px solid rgba(91, 143, 123, 0.38);
  background: rgba(255, 253, 245, 0.87);
  color: #205d49;
  font-size: clamp(0.92rem, 3.6vw, 1.08rem);
}

.kanji-board-2 {
  grid-template-columns: repeat(2, 1fr);
}

.kanji-board-3 {
  grid-template-columns: repeat(3, 1fr);
}

.kanji-tile {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 2px solid var(--kanji-card-edge);
  border-radius: 8px;
  background: #f5f1e8;
  box-shadow: 0 1px 3px rgba(9, 25, 28, 0.12);
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.kanji-tile-selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(50, 102, 77, 0.45);
}

.kanji-tile-static {
  cursor: default;
  touch-action: none;
}

.kanji-board-revealed {
  box-shadow: 0 0 0 2px rgba(50, 102, 77, 0.7);
}

.kanji-tile-canvas {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
  /* Canvas source is dark; recolor only its presentation, not the puzzle data. */
  filter: invert(1) brightness(1.1);
}

.game-area .prompt {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
}

.kanji-choice-box {
  width: 100%;
}

.kanji-choice-box .choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  max-width: min(100%, 360px);
  margin: 0 auto;
}

.kanji-choice-box .choice-btn {
  font-family: "KanjiPuzzleNoto", "Yu Gothic", "Meiryo", sans-serif;
  font-weight: 800;
  font-size: clamp(1.25rem, 5vw, 1.65rem);
  min-height: 3.1rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.2;
}

.kanji-choice-box .choice-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.kanji-choice-box .choice-btn.selected-correct {
  border-color: var(--green);
  background: #e8f3ea;
}

.kanji-choice-box .choice-btn.selected-wrong {
  border-color: #b42318;
  background: #fdecea;
}

@media (max-width: 430px) {
  .kanji-board {
    width: min(92vw, 340px);
  }
  .game-area .prompt {
    font-size: 0.95rem;
  }
  .kanji-choice-box .choice-btn {
    min-height: 44px;
    font-size: clamp(1.15rem, 5.4vw, 1.4rem);
  }
  .game-area.game-kanji-puzzle {
    gap: 0.4rem;
  }
}

@media (max-height: 760px) {
  .kanji-board {
    width: min(52vh, 300px);
  }
  .game-area.game-kanji-puzzle {
    gap: 0.35rem;
  }
  .kanji-choice-box .choice-btn {
    min-height: 2.7rem;
    font-size: clamp(1.1rem, 4vw, 1.35rem);
  }
}
.question-load-error:not(:empty) { color: #a13e30; margin: 8px 0 0; }
