:root {
  --app-red: #C9464F;
  --app-amber: #D89B20;
  --app-blue: #326CA8;
  --app-cyan: #20889B;
  --app-green: #2E7D5B;
  --app-purple: #7657A8;
}

body.app-page {
  min-height: 100vh;
  background: #F4F7F6;
  color: #18211D;
}

/* display:grid/flex rules must not defeat the hidden attribute */
body.app-page [hidden] { display: none !important; }

.app-site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.98);
  border-bottom: 1px solid #D8E0DC;
}

.app-site-header-inner {
  width: min(1120px, calc(100% - 32px));
  min-height: 60px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.app-site-brand {
  color: #18211D;
  font-weight: 800;
  text-decoration: none;
}
.app-site-brand:hover { color: #18211D; text-decoration: none; }
.app-site-brand span { color: #2E7D5B; }

.app-site-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.app-site-nav a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 2px solid transparent;
  color: #58645E;
  font-size: 0.88rem;
  font-weight: 650;
  text-decoration: none;
}
.app-site-nav a:hover,
.app-site-nav a[aria-current="page"] { color: #2E7D5B; text-decoration: none; }
.app-site-nav a[aria-current="page"] { border-bottom-color: #2E7D5B; }

.app-main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 38px 0 56px;
}

.app-play-page {
  min-height: 100dvh;
  background:
    radial-gradient(900px 420px at 85% -80px, rgba(46, 125, 91, 0.10), transparent 70%),
    radial-gradient(700px 380px at -60px 30%, rgba(50, 108, 168, 0.06), transparent 70%),
    linear-gradient(180deg, #F8FBF9 0%, #F1F6F3 100%);
}

.app-play-main {
  width: min(1280px, calc(100% - 32px));
  padding: 16px 0 24px;
}

.app-title-compact {
  padding-bottom: 12px;
}
.app-title-compact h1 { font-size: clamp(1.35rem, 2.4vw, 1.85rem); }
.app-title-compact p { margin-top: 4px; font-size: 0.88rem; }

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
  align-items: start;
  margin-top: 14px;
}
.play-primary { min-width: 0; }

.scoreboard {
  padding: 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #DFE8E3;
  border-radius: 14px;
  box-shadow: 0 14px 34px -24px rgba(24, 33, 29, 0.4), 0 1px 3px rgba(24, 33, 29, 0.04);
  position: sticky;
  top: 72px;
}
.scoreboard h2 {
  margin: 0 0 10px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: #2E7D5B;
}
.scoreboard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.scoreboard-list li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #F4F8F5;
  font-size: 0.8rem;
}
.scoreboard-rank {
  color: #2E7D5B;
  font-weight: 800;
  text-align: center;
}
.scoreboard-list li:nth-child(1) { background: linear-gradient(90deg, #FFF7E0, #F4F8F5 70%); }
.scoreboard-list li:nth-child(1) .scoreboard-rank { color: #C98A00; }
.scoreboard-list li:nth-child(2) { background: linear-gradient(90deg, #F0F3F2, #F4F8F5 70%); }
.scoreboard-list li:nth-child(2) .scoreboard-rank { color: #7C8A84; }
.scoreboard-list li:nth-child(3) { background: linear-gradient(90deg, #FBEFE3, #F4F8F5 70%); }
.scoreboard-list li:nth-child(3) .scoreboard-rank { color: #B4763C; }
.scoreboard-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 650;
}
.scoreboard-score {
  color: #58645E;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.scoreboard-empty {
  display: block !important;
  padding: 10px 6px;
  color: #6C7972;
  background: transparent !important;
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .play-layout {
    grid-template-columns: 1fr;
  }
  .scoreboard {
    position: static;
    order: 2;
  }
  .scoreboard-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .scoreboard-list { grid-template-columns: 1fr; }
}

.app-title-block {
  padding-bottom: 24px;
  border-bottom: 1px solid #D8E0DC;
}
.app-title-block h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); line-height: 1.15; letter-spacing: 0; }
.app-title-block p { max-width: 700px; margin-top: 10px; color: #58645E; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}
.catalog-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid #DFE8E3;
  border-radius: 12px;
  box-shadow: 0 2px 6px -4px rgba(24, 33, 29, 0.15);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.catalog-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 34px -22px rgba(24, 33, 29, 0.45);
}
.catalog-visual {
  min-height: 150px;
  display: grid;
  grid-template-columns: repeat(4, 38px);
  place-content: center;
  gap: 8px;
  border-bottom: 1px solid #D8E0DC;
  background: #EEF4F1;
}
.catalog-visual span { width: 38px; height: 38px; border: 2px solid rgba(24, 33, 29, 0.14); }
.visual-match { background: #FFF0EC; }
.visual-match span { transform: rotate(45deg); border-radius: 8px; }
.visual-match span:nth-child(1) { background: var(--app-red); }
.visual-match span:nth-child(2) { background: var(--app-amber); }
.visual-match span:nth-child(3) { background: var(--app-green); }
.visual-match span:nth-child(4) { background: var(--app-blue); }
.visual-tetris { background: #EDF3FA; align-items: end; }
.visual-tetris span { border-radius: 3px; background: var(--app-blue); }
.visual-tetris span:nth-child(2) { background: var(--app-amber); transform: translateY(-38px); }
.visual-tetris span:nth-child(3) { background: var(--app-green); }
.visual-tetris span:nth-child(4) { background: var(--app-red); transform: translateY(-38px); }
.visual-jigsaw { grid-template-columns: repeat(2, 54px); gap: 2px; background: #EDF6F2; }
.visual-jigsaw span { width: 54px; height: 54px; border-radius: 2px; background: #75AE96; }
.visual-jigsaw span:nth-child(2), .visual-jigsaw span:nth-child(3) { background: #A4CBB9; }
.visual-personality { background: #F4F0FA; }
.visual-personality span { border-radius: 50%; background: var(--app-purple); }
.visual-personality span:nth-child(2), .visual-personality span:nth-child(4) { background: #A78CC8; }
.visual-logic { background: #EEF5F7; }
.visual-logic span { display: grid; place-items: center; border-radius: 4px; background: var(--app-cyan); }
.visual-shapes { background: #F3F6F0; align-items: center; }
.visual-shapes span { border-radius: 0; background: transparent; border-color: #2E7D5B; }
.visual-shapes span:nth-child(1) { border-radius: 50%; background: #2E7D5B; }
.visual-shapes span:nth-child(2) { background: #326CA8; }
.visual-shapes span:nth-child(3) {
  width: 0; height: 0; border: 0;
  border-left: 19px solid transparent;
  border-right: 19px solid transparent;
  border-bottom: 34px solid #C9464F;
  background: transparent;
}
.visual-shapes span:nth-child(4) { transform: rotate(45deg); background: #D89B20; }

.catalog-card-body { padding: 18px; }
.catalog-card-body h2 { font-size: 1.08rem; }
.catalog-card-body p { min-height: 50px; margin-top: 7px; color: #58645E; font-size: 0.88rem; }
.catalog-card-body a {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  margin-top: 14px;
  padding: 0 14px;
  border-radius: 6px;
  background: #2E7D5B;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}
.catalog-card-body a:hover { background: #256B4E; color: #fff; text-decoration: none; }

.app-shell { margin-top: 26px; }
.app-toolbar,
.stat-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.app-toolbar { justify-content: space-between; margin-bottom: 14px; }
.stat-strip { gap: 8px; }
.stat-item {
  min-width: 92px;
  padding: 9px 14px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FAF8 100%);
  border: 1px solid #DFE8E3;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(24, 33, 29, 0.05);
}
.stat-item span { display: block; color: #6C7972; font-size: 0.7rem; letter-spacing: 0.05em; }
.stat-item strong { display: block; margin-top: 2px; font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.app-button,
.touch-button {
  min-height: 44px;
  border: 1px solid #C3CFC9;
  border-radius: 10px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F3F7F4 100%);
  color: #18211D;
  padding: 0 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(24, 33, 29, 0.06);
  transition: border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}
.app-button:hover, .touch-button:hover {
  border-color: #2E7D5B;
  color: #2E7D5B;
  box-shadow: 0 3px 10px -4px rgba(46, 125, 91, 0.4);
}
.app-button:active, .touch-button:active { transform: translateY(1px); box-shadow: none; }
.app-button-primary {
  border-color: #2E7D5B;
  background: linear-gradient(180deg, #35906A 0%, #2E7D5B 100%);
  color: #fff;
}
.app-button-primary:hover { background: linear-gradient(180deg, #2E8260 0%, #256B4E 100%); color: #fff; }

.toolbar-actions,
.audio-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.audio-button {
  min-height: 40px;
  padding: 0 10px;
  font-size: 0.78rem;
}
.audio-button[aria-pressed="false"] {
  background: #EEF2F0;
  color: #6C7972;
}

.game-stage {
  background: #fff;
  border: 1px solid #DFE8E3;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px -28px rgba(24, 33, 29, 0.5), 0 1px 3px rgba(24, 33, 29, 0.05);
}
.app-status { margin-top: 12px; color: #58645E; font-size: 0.88rem; }
.app-status[data-tone="success"] { color: #236B4C; }
.app-status[data-tone="error"] { color: #A33C43; }
.app-note { margin-top: 20px; padding-top: 16px; border-top: 1px solid #D8E0DC; color: #6C7972; font-size: 0.82rem; }
.result-panel { margin-top: 20px; padding: 20px; background: #fff; border: 1px solid #D8E0DC; border-radius: 8px; }

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible { outline: 3px solid rgba(46, 125, 91, 0.28); outline-offset: 2px; }

@media (max-width: 760px) {
  .app-site-header-inner, .app-main { width: min(100% - 24px, 1120px); }
  .app-site-header-inner { min-height: 56px; gap: 10px; }
  .app-site-nav { gap: 0; overflow-x: auto; }
  .app-site-nav a { padding: 0 8px; font-size: 0.8rem; white-space: nowrap; }
  .app-site-nav a:first-child { display: none; }
  .app-main { padding: 26px 0 44px; }
  .catalog-grid { grid-template-columns: 1fr; }
  .catalog-card { display: grid; grid-template-columns: 118px minmax(0, 1fr); }
  .catalog-visual { min-height: 100%; grid-template-columns: repeat(2, 28px); gap: 5px; border-right: 1px solid #D8E0DC; border-bottom: 0; }
  .catalog-visual span { width: 28px; height: 28px; }
  .visual-tetris span:nth-child(2), .visual-tetris span:nth-child(4) { transform: translateY(-28px); }
  .visual-jigsaw { grid-template-columns: repeat(2, 38px); }
  .visual-jigsaw span { width: 38px; height: 38px; }
  .catalog-card-body p { min-height: 0; }
}

@media (max-width: 420px) {
  .app-site-nav a { padding: 0 6px; font-size: 0.76rem; }
  .catalog-card { grid-template-columns: 92px minmax(0, 1fr); }
  .catalog-card-body { padding: 14px; }
  .catalog-visual { grid-template-columns: repeat(2, 22px); }
  .catalog-visual span { width: 22px; height: 22px; }
  .visual-jigsaw { grid-template-columns: repeat(2, 30px); }
  .visual-jigsaw span { width: 30px; height: 30px; }
}

/* Jigsaw */
.jigsaw-shell { max-width: none; }
.jigsaw-setup { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.art-picker {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #D8E4DD;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}
.art-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #36423C;
  font-size: 0.82rem;
}
.art-picker-head strong { font-size: 0.86rem; }
.art-picker-head span { color: #6C7972; font-size: 0.76rem; }
.art-picker-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(72px, 88px);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.art-card {
  display: grid;
  gap: 4px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.art-card img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border-radius: 8px;
  background: #E4EEE8;
  display: block;
}
.art-card span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.68rem;
  color: #58645E;
  font-weight: 650;
}
.art-card.is-active {
  border-color: #2E7D5B;
}
.art-card:hover img { outline: 2px solid rgba(46, 125, 91, 0.35); outline-offset: 1px; }
.puzzle-minimap {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 30;
  width: min(160px, 28%);
  padding: 8px;
  border: 1px solid #C5D4CB;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 28px -18px rgba(24, 33, 29, 0.5);
  pointer-events: none;
}
.puzzle-minimap-label {
  margin: 0 0 6px;
  color: #6C7972;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.puzzle-minimap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  background: #E8F0EA;
}
.file-picker, .difficulty-picker { display: grid; gap: 5px; color: #58645E; font-size: 0.78rem; font-weight: 650; }
.file-picker input,
.difficulty-picker select {
  min-height: 40px;
  max-width: 280px;
  border: 1px solid #B8C5BF;
  border-radius: 6px;
  background: #fff;
  color: #18211D;
  padding: 8px 10px;
  font: inherit;
}
.jigsaw-stats { margin-top: 10px; }
.jigsaw-stats b { font: inherit; }
.jigsaw-workspace {
  --puzzle-aspect: 1;
  margin-top: 10px;
  min-width: 0;
}
.puzzle-empty {
  width: 100%;
  min-height: min(58dvh, 560px);
  display: grid;
  place-content: center;
  padding: 18px;
  border: 2px dashed #AFC4B9;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F4F9F6 100%);
  color: #18211D;
  text-align: center;
  font: inherit;
  cursor: pointer;
  transition: border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}
.puzzle-empty:hover {
  border-color: #2E7D5B;
  color: #2E7D5B;
  box-shadow: 0 10px 26px -18px rgba(46, 125, 91, 0.55);
}
.puzzle-mat {
  position: relative;
  width: 100%;
  height: min(68dvh, 740px);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid #C5D4CB;
  border-radius: 16px;
  background:
    radial-gradient(ellipse 70% 55% at 28% 45%, rgba(255, 255, 255, 0.4), transparent 68%),
    repeating-linear-gradient(
      90deg,
      rgba(24, 33, 29, 0.03) 0 1px,
      transparent 1px 28px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(24, 33, 29, 0.025) 0 1px,
      transparent 1px 28px
    ),
    linear-gradient(165deg, #E8F0EA 0%, #D5E4DA 45%, #C9D9CF 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    0 16px 36px -24px rgba(24, 33, 29, 0.45);
  touch-action: none;
  user-select: none;
}
.puzzle-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.puzzle-canvas.is-grabbing {
  cursor: grabbing;
}

@media (max-width: 480px) {
  .jigsaw-setup > * { width: 100%; max-width: none; }
  .file-picker input, .difficulty-picker select { width: 100%; max-width: none; }
  .puzzle-mat { height: min(62dvh, 560px); min-height: 360px; }
}

/* Personality and logic assessments */
.assessment-shell { max-width: 780px; }
.assessment-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; color: #58645E; font-size: 0.8rem; font-weight: 650; }
.progress-track { flex: 1; height: 8px; overflow: hidden; border-radius: 4px; background: #DCE5E1; }
.progress-track span { display: block; width: 0; height: 100%; background: #2E7D5B; transition: width 180ms ease; }
.question-panel { min-height: 430px; padding: 28px; background: #fff; border: 1px solid #D8E0DC; border-radius: 8px; }
.question-number, .result-kicker { color: #2E7D5B; font-size: 0.78rem; font-weight: 750; }
.question-panel h2 { min-height: 72px; margin-top: 10px; font-size: 1.25rem; line-height: 1.5; letter-spacing: 0; }
.answer-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; margin-top: 24px; }
.answer-option {
  min-height: 76px;
  border: 1px solid #B8C5BF;
  border-radius: 6px;
  background: #fff;
  color: #36423C;
  padding: 8px;
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}
.answer-option:hover { border-color: #2E7D5B; }
.answer-option.is-selected { border-color: #2E7D5B; background: #E8F2ED; color: #1F6347; font-weight: 750; }
.assessment-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 28px; }
.assessment-actions .app-button { min-width: 112px; }
.assessment-actions .app-button:disabled { opacity: 0.45; cursor: not-allowed; }

.assessment-result h2 { margin-top: 4px; font-size: 1.45rem; }
.assessment-result > p:not(.result-kicker) { margin-top: 8px; color: #58645E; }
.result-type, .result-score { display: block; margin-top: 8px; color: #18211D; font-size: clamp(2.2rem, 8vw, 4rem); line-height: 1; letter-spacing: 0; }
.axis-results { display: grid; gap: 14px; margin: 24px 0; }
.axis-labels { display: flex; justify-content: space-between; gap: 12px; font-size: 0.78rem; }
.axis-track { height: 12px; margin-top: 6px; overflow: hidden; border-radius: 6px; background: #DDE5EE; }
.axis-track span { display: block; height: 100%; background: #2E7D5B; }

.logic-choice-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 24px; }
.logic-choice {
  min-height: 66px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #B8C5BF;
  border-radius: 6px;
  background: #fff;
  color: #18211D;
  padding: 10px 14px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.logic-choice > span { flex: 0 0 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: #EDF2F0; font-weight: 750; }
.logic-choice:hover, .logic-choice.is-selected { border-color: #326CA8; }
.logic-choice.is-selected { background: #EEF4FA; }
.logic-choice.is-selected > span { background: #326CA8; color: #fff; }
.review-list { display: grid; gap: 10px; margin: 24px 0; }
.review-item { padding: 15px 16px; border-left: 4px solid #2E7D5B; background: #F5F8F6; }
.review-item.is-wrong { border-left-color: #C9464F; background: #FFF3F3; }
.review-item h3 { font-size: 0.92rem; line-height: 1.5; }
.review-item p { margin-top: 5px; color: #4C5852; font-size: 0.82rem; }
.review-explanation { padding-top: 6px; border-top: 1px solid rgba(24, 33, 29, 0.1); }

.quiz-dist {
  margin: 20px 0;
  padding: 16px;
  background: #F5F8F6;
  border: 1px solid #D8E0DC;
  border-radius: 8px;
}
.quiz-dist-total { margin: 0 0 12px; color: #58645E; font-size: 0.86rem; }
.quiz-dist-empty { margin: 0; color: #6C7972; font-size: 0.84rem; }
.quiz-dist-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.quiz-dist-list li {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 52px;
  gap: 8px;
  align-items: center;
  font-size: 0.84rem;
}
.quiz-dist-label { font-weight: 750; }
.quiz-dist-track {
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: #DCE5E1;
}
.quiz-dist-track span {
  display: block;
  height: 100%;
  background: #2E7D5B;
}
.quiz-dist-count {
  text-align: right;
  color: #58645E;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.shape-matrix {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 360px);
  margin: 16px auto 0;
}
.shape-hint {
  margin: 12px 0 0;
  text-align: center;
  color: #6C7972;
  font-size: 0.86rem;
}
.shape-cell {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #D8E0DC;
  border-radius: 8px;
  background: #fff;
}
.shape-cell-blank {
  border-style: dashed;
  border-color: #2E7D5B;
  background: #F3F8F5;
  color: #2E7D5B;
  font-size: 1.6rem;
  font-weight: 800;
}
.shape-svg { width: 78%; height: 78%; display: block; }
.shape-choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
}
.shape-choice {
  min-height: 96px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid #B8C5BF;
  border-radius: 6px;
  background: #fff;
  color: #18211D;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.shape-choice > span {
  flex: 0 0 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #EDF2F0;
  font-weight: 750;
}
.shape-choice .shape-cell {
  width: 72px;
  height: 72px;
  aspect-ratio: auto;
  border: 0;
  background: transparent;
}
.shape-choice:hover, .shape-choice.is-selected { border-color: #2E7D5B; }
.shape-choice.is-selected { background: #E8F2ED; }
.shape-choice.is-selected > span { background: #2E7D5B; color: #fff; }

@media (max-width: 640px) {
  .question-panel { min-height: 0; padding: 20px 16px; }
  .question-panel h2 { min-height: 0; font-size: 1.08rem; }
  .answer-list { grid-template-columns: 1fr; }
  .answer-option { min-height: 50px; }
  .logic-choice-list { grid-template-columns: 1fr; }
  .shape-choice-list { grid-template-columns: 1fr; }
  .shape-matrix { width: min(100%, 300px); gap: 6px; }
  .quiz-dist-list li { grid-template-columns: 64px minmax(0, 1fr) 48px; }
}

/* Match-3 */
.match-shell { max-width: none; }
.match-stage {
  padding: 14px;
  background: linear-gradient(165deg, #E9F3ED 0%, #DDEAE2 55%, #D3E3DA 100%);
  max-height: calc(100dvh - 210px);
  display: grid;
  place-items: center;
}
.match-board {
  width: min(100%, 560px, calc(100dvh - 230px));
  aspect-ratio: 1;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 5px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 1px 4px rgba(24, 33, 29, 0.08);
  touch-action: none;
}
.gem-cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(46, 125, 91, 0.14);
  border-radius: 9px;
  background: linear-gradient(180deg, #FDFEFD 0%, #F0F6F2 100%);
  cursor: pointer;
  will-change: transform, opacity;
  transition: border-color 120ms ease, opacity 120ms ease, box-shadow 120ms ease;
}
.gem-cell:hover {
  border-color: rgba(46, 125, 91, 0.55);
  box-shadow: 0 0 0 2px rgba(46, 125, 91, 0.15);
}
.gem-cell.is-selected {
  border-color: #2E7D5B;
  box-shadow: 0 0 0 3px rgba(46, 125, 91, 0.3);
  transform: scale(0.92);
}
.gem-cell.is-empty { opacity: 0.25; }
.gem-cell.is-matching {
  opacity: 0;
  transform: scale(0.55);
  transition: opacity 160ms ease, transform 160ms ease;
}
.gem-cell span,
.gem-cell .gem-face {
  position: relative;
  width: 62%;
  aspect-ratio: 1;
  transform: rotate(45deg);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  background: #84918B;
  box-shadow:
    inset -3px -3px 0 rgba(0, 0, 0, 0.18),
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    0 2px 4px rgba(24, 33, 29, 0.18);
  pointer-events: none;
}
.gem-cell span::after,
.gem-cell .gem-face::after {
  content: '';
  position: absolute;
  top: 14%;
  left: 16%;
  width: 18%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}
/* Distinct solid hues — no outer glow */
.gem-0 span, .gem-0 .gem-face {
  background: linear-gradient(145deg, #F25563 0%, #E11D2E 55%, #B01020 100%);
  box-shadow:
    inset -3px -3px 0 rgba(100, 0, 15, 0.22),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    0 2px 4px rgba(24, 33, 29, 0.18);
}
.gem-1 span, .gem-1 .gem-face {
  background: linear-gradient(145deg, #F5D031 0%, #E6B800 55%, #C49200 100%);
  box-shadow:
    inset -3px -3px 0 rgba(120, 80, 0, 0.22),
    inset 2px 2px 0 rgba(255, 255, 255, 0.22),
    0 2px 4px rgba(24, 33, 29, 0.18);
}
.gem-2 span, .gem-2 .gem-face {
  background: linear-gradient(145deg, #3DCC5C 0%, #1FA83A 55%, #0F7A28 100%);
  box-shadow:
    inset -3px -3px 0 rgba(0, 70, 20, 0.22),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    0 2px 4px rgba(24, 33, 29, 0.18);
}
.gem-3 span, .gem-3 .gem-face {
  background: linear-gradient(145deg, #4A8FFF 0%, #1A5FE0 55%, #0A3FB0 100%);
  box-shadow:
    inset -3px -3px 0 rgba(10, 40, 120, 0.25),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    0 2px 4px rgba(24, 33, 29, 0.18);
}
.gem-4 span, .gem-4 .gem-face {
  background: linear-gradient(145deg, #C45CFF 0%, #9B2DE0 55%, #6B12A8 100%);
  box-shadow:
    inset -3px -3px 0 rgba(60, 0, 100, 0.25),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    0 2px 4px rgba(24, 33, 29, 0.18);
}
.gem-5 span, .gem-5 .gem-face {
  background: linear-gradient(145deg, #FF8A3D 0%, #F05A00 55%, #C04000 100%);
  box-shadow:
    inset -3px -3px 0 rgba(120, 40, 0, 0.25),
    inset 2px 2px 0 rgba(255, 255, 255, 0.2),
    0 2px 4px rgba(24, 33, 29, 0.18);
}

@media (max-width: 560px) {
  .match-stage { padding: 8px; max-height: none; }
  .match-board { width: min(100%, calc(100vw - 40px)); gap: 3px; }
  .gem-cell { border-width: 1px; border-radius: 5px; }
  .gem-cell span, .gem-cell .gem-face { border-width: 2px; border-radius: 6px; }
  .gem-cell span::after, .gem-cell .gem-face::after { width: 16%; height: 16%; }
}

/* Tetris */
.tetris-shell { max-width: none; }
.tetris-command-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tetris-layout {
  display: grid;
  grid-template-columns: minmax(0, 320px) 160px;
  align-items: start;
  gap: 14px;
  max-height: calc(100dvh - 210px);
}
.tetris-stage {
  background: linear-gradient(165deg, #E9F3ED 0%, #DDEAE2 100%);
  padding: 10px;
  line-height: 0;
}
.tetris-stage canvas {
  display: block;
  width: 100%;
  max-height: calc(100dvh - 240px);
  aspect-ratio: 1 / 2;
  border-radius: 8px;
  background: #FBFDFC;
  box-shadow: inset 0 1px 4px rgba(24, 33, 29, 0.1);
}
.tetris-side { display: grid; gap: 12px; }
.next-piece h2 { margin-bottom: 8px; font-size: 0.86rem; color: #58645E; }
.next-piece canvas {
  display: block;
  width: 120px;
  height: 100px;
  border: 1px solid #DFE8E3;
  border-radius: 10px;
  background: #FBFDFC;
  box-shadow: inset 0 1px 3px rgba(24, 33, 29, 0.08);
}
.touch-controls {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  gap: 6px;
}
.touch-button { width: 48px; min-height: 40px; padding: 0; font-size: 1.1rem; }
.touch-wide { grid-column: 1 / -1; width: 100%; font-size: 0.78rem; }

@media (max-width: 680px) {
  .tetris-layout {
    grid-template-columns: minmax(0, 1fr);
    max-height: none;
  }
  .tetris-stage { width: min(100%, 280px); margin: 0 auto; }
  .tetris-stage canvas { max-height: min(52dvh, 420px); }
  .tetris-side { grid-template-columns: 120px minmax(0, 1fr); align-items: end; }
  .touch-controls { grid-template-columns: repeat(3, minmax(48px, 1fr)); }
  .touch-button { width: 100%; }
}

@media (max-width: 420px) {
  .tetris-side { grid-template-columns: 100px minmax(0, 1fr); }
  .next-piece canvas { width: 100px; height: 84px; }
  .stat-item { min-width: calc(50% - 4px); }
}

@media (max-height: 820px) and (min-width: 900px) {
  .app-play-main { padding-top: 10px; }
  .app-title-compact { padding-bottom: 8px; }
  .app-toolbar { margin-bottom: 8px; }
  .stat-item { padding: 6px 10px; }
}
