/* =========================================================
   두뇌 건강 게임 – 게임 화면 공통 부품
   ========================================================= */

.game-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 22px;
}

/* 상태 줄 */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 12px;
  background: var(--cream);
  font-size: 16px;
  color: var(--ink-2);
  min-height: 46px;
}
.stat b {
  font-size: 21px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat.is-accent { background: var(--terra-soft); color: var(--terra-dark); }
.stat.is-accent b { color: var(--terra-dark); }
.status-bar .spacer { flex: 1 1 auto; }

/* 카테고리 칩 */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}
.chip {
  min-height: 48px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.chip:hover { background: var(--cream); }
.chip[aria-pressed="true"] {
  background: var(--terra);
  border-color: var(--terra);
  color: #fff;
}
.chip:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

/* 문제 카드 */
.quiz-card {
  text-align: center;
  padding: 30px 20px 26px;
  border-radius: var(--radius);
  background: var(--cream);
  border: 1px solid var(--line);
}
.quiz-label {
  font-size: 16px;
  color: var(--muted);
  margin-bottom: 10px;
}
.quiz-chosung {
  font-size: clamp(34px, 8vw, 54px);
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1.4;
  color: var(--terra-dark);
  word-break: break-all;
}
.quiz-hint {
  margin: 16px auto 0;
  max-width: 560px;
  font-size: 18px;
  color: var(--ink-2);
  line-height: 1.65;
}
.quiz-hint.is-empty { visibility: hidden; }

.answer-row {
  display: flex;
  gap: 10px;
  margin: 20px auto 0;
  max-width: 520px;
}
.answer-input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 58px;
  padding: 12px 18px;
  border-radius: 14px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-family: inherit;
  font-size: 20px;
  color: var(--ink);
}
.answer-input:focus {
  outline: none;
  border-color: var(--terra);
}

.feedback {
  min-height: 34px;
  margin-top: 16px;
  font-size: 19px;
  font-weight: 700;
}
.feedback.ok { color: var(--sage); }
.feedback.no { color: var(--berry); }
.feedback.reveal { color: var(--ink-2); }
.feedback b { font-size: 21px; }

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.control-row .btn { flex: 1 1 130px; }

/* 카드 뒤집기 */
.memory-board {
  display: grid;
  gap: 10px;
  margin: 0 auto;
  max-width: 520px;
}
.memory-board.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.memory-board.cols-3 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.mcard {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 0;
  padding: 0;
  border-radius: 16px;
  background: var(--sage);
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform .25s ease, background .2s ease;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08);
}
.mcard .face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: clamp(30px, 7vw, 42px);
  opacity: 0;
}
.mcard .back {
  opacity: 1;
  color: rgba(255, 255, 255, .8);
  font-size: 24px;
  font-weight: 800;
}
.mcard.is-open, .mcard.is-done {
  background: var(--paper);
  border: 2px solid var(--sage-soft);
  box-shadow: var(--shadow-soft);
}
.mcard.is-open .face, .mcard.is-done .face { opacity: 1; }
.mcard.is-open .back, .mcard.is-done .back { opacity: 0; }
.mcard.is-done { border-color: var(--sage); }
.mcard.is-done .face { animation: pop .3s ease; }
.mcard:disabled { cursor: default; }

@keyframes pop {
  0% { transform: scale(.86); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* 숫자 순서 테스트 */
.schulte {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  max-width: 480px;
  margin: 0 auto;
}
.schulte button {
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(20px, 4.4vw, 26px);
  font-weight: 800;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.schulte button:hover { background: var(--cream); }
.schulte button.is-done {
  background: var(--sage-soft);
  border-color: var(--sage-soft);
  color: var(--sage);
}
.schulte button.is-next {
  border-color: var(--terra);
  box-shadow: 0 0 0 3px var(--terra-soft);
}
.schulte button:disabled { cursor: default; }

/* 모드 탭 */
.tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  margin-bottom: 20px;
  border-radius: 16px;
  background: var(--cream-2);
}
.tabs button {
  flex: 1 1 50%;
  min-height: 52px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.35;
}
.tabs button[aria-selected="true"] {
  background: var(--paper);
  color: var(--terra-dark);
  box-shadow: var(--shadow-soft);
}

/* 지뢰찾기 */
.mine-board {
  display: grid;
  gap: 4px;
  justify-content: center;
  margin: 0 auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.mcell {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: #e5d8c8;
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(97, 74, 52, .16);
  font-variant-numeric: tabular-nums;
}
.mcell.is-open {
  background: var(--cream);
  box-shadow: inset 0 0 0 1px var(--line);
  cursor: default;
  font-weight: 700;
}
.mcell.is-flag { background: var(--butter); font-size: 1em; }
.mcell.is-mine { background: #f0c9c0; }
.mcell.is-wrong { background: #dcc8c2; }
.mcell.n1 { color: #2f6db0; }
.mcell.n2 { color: #3f7a45; }
.mcell.n3 { color: #b3402f; }
.mcell.n4 { color: #5b4a97; }
.mcell.n5 { color: #8a4a1f; }
.mcell.n6 { color: #2b7d7d; }
.mcell.n7 { color: #333; }
.mcell.n8 { color: #777; }

.flag-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 12px 20px;
  margin: 16px 0 0;
  border-radius: 16px;
  border: 2px solid var(--line);
  background: var(--paper);
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}
.flag-toggle .sw {
  flex: 0 0 auto;
  width: 52px; height: 30px;
  border-radius: 999px;
  background: var(--line);
  position: relative;
  transition: background .18s ease;
}
.flag-toggle .sw::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
  transition: transform .18s ease;
}
.flag-toggle[aria-pressed="true"] {
  border-color: var(--terra);
  background: var(--terra-soft);
  color: var(--terra-dark);
}
.flag-toggle[aria-pressed="true"] .sw { background: var(--terra); }
.flag-toggle[aria-pressed="true"] .sw::after { transform: translateX(22px); }

/* 스도쿠 */
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  width: 100%;
  max-width: 468px;
  margin: 0 auto;
  background: var(--ink-2);
  gap: 1px;
  border: 3px solid var(--ink-2);
  border-radius: 10px;
  overflow: hidden;
  touch-action: manipulation;
}
.scell {
  position: relative;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  border: 0;
  padding: 0;
  background: var(--paper);
  color: var(--terra-dark);
  font-family: inherit;
  font-size: clamp(18px, 4.6vw, 26px);
  font-weight: 800;
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.scell.is-given { color: var(--ink); background: #f7f0e6; }
.scell.is-peer { background: #fbf3e6; }
.scell.is-given.is-peer { background: #f0e6d6; }
.scell.is-same { background: var(--butter-soft); }
.scell.is-selected { background: var(--terra-soft); box-shadow: inset 0 0 0 2px var(--terra); }
.scell.is-error { color: var(--berry); background: #f7e0e4; }
.scell.is-hint { color: var(--sage); background: var(--sage-soft); }
.scell.th-b { border-right: 2px solid var(--ink-2); }
.scell.th-r { border-bottom: 2px solid var(--ink-2); }
.snotes {
  position: absolute;
  inset: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
}
.snotes span { display: grid; place-items: center; }

.pad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  max-width: 468px;
  margin: 16px auto 0;
}
.pad button {
  aspect-ratio: 1 / 1.15;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 800;
  cursor: pointer;
}
.pad button:hover { background: var(--cream); }
.pad button:disabled { opacity: .4; cursor: default; }
.pad button.pad-off [data-left] { color: var(--muted); }

.sudoku-tools {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  max-width: 468px;
  margin: 10px auto 0;
}
.sudoku-tools .btn {
  min-height: 52px;
  font-size: 16px;
  padding: 8px 6px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-2);
}
.sudoku-tools .btn[aria-pressed="true"] {
  background: var(--terra);
  border-color: var(--terra);
  color: #fff;
}

/* 숨은 단어 찾기 */
.word-grid {
  display: grid;
  gap: 3px;
  max-width: 468px;
  margin: 0 auto;
  padding: 8px;
  border-radius: 16px;
  background: var(--cream-2);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.wcell {
  display: grid;
  place-items: center;
  aspect-ratio: 1 / 1;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: clamp(16px, 4.2vw, 22px);
  font-weight: 700;
  cursor: pointer;
}
.wcell.is-pick { background: var(--butter); }
.wcell.is-found {
  background: var(--sage);
  color: #fff;
}
.wcell.is-hint { box-shadow: inset 0 0 0 3px var(--terra); }

.word-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}
.word-list li {
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--cream);
  border: 1px solid var(--line);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-2);
}
.word-list li.is-found {
  background: var(--sage-soft);
  border-color: var(--sage-soft);
  color: var(--sage);
  text-decoration: line-through;
}

/* 결과 알림 */
.result-banner {
  margin-top: 18px;
  padding: 18px;
  border-radius: var(--radius-sm);
  background: var(--sage-soft);
  color: #33502f;
  font-size: 19px;
  font-weight: 700;
  text-align: center;
}
.result-banner.is-lose { background: #f6e0e3; color: var(--berry); }
.result-banner .sub {
  display: block;
  margin-top: 6px;
  font-size: 16px;
  font-weight: 500;
  color: inherit;
  opacity: .9;
}
.result-banner .btn { margin-top: 14px; }

/* 도움말 박스 */
.tips {
  margin-top: 26px;
  padding: 20px 22px;
  border-radius: var(--radius-sm);
  background: var(--paper);
  border: 1px dashed var(--line);
  color: var(--ink-2);
  font-size: 16px;
}
.tips h2 { font-size: 18px; font-weight: 800; margin-bottom: 8px; color: var(--ink); }
.tips ul { margin: 0; padding-left: 20px; }
.tips li + li { margin-top: 4px; }

@media (max-width: 560px) {
  .game-panel { padding: 16px; }
  .stat { padding: 8px 12px; font-size: 15px; min-height: 42px; }
  .stat b { font-size: 19px; }
  .quiz-card { padding: 22px 14px 20px; }
  .answer-row { flex-wrap: wrap; }
  .answer-row .btn { flex: 0 0 100%; }
  .pad { gap: 4px; }
  .sudoku-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .word-grid { padding: 5px; gap: 2px; }
}
