/* Quiz equipes - Maths V2
   Interface locale epuree. */

:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --accent: #f59e0b;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --line: #d8e0ec;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button, input, select { font: inherit; }
button, select, input { color-scheme: light; }

.app {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 16px 0 24px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 12px;
}

h1, h2, h3 { margin: 0; }

.hidden { display: none !important; }

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ghost-btn, .primary-btn, .secondary-btn, .level-btn, .wide-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  padding: 9px 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.ghost-btn:hover, .secondary-btn:hover, .level-btn:hover, .wide-btn:hover {
  border-color: #aab8ce;
  background: var(--surface-soft);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.danger { color: var(--red); }

.home-card, .quiz-board, .teams-section, .panel-card, dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.home-card {
  min-height: 620px;
  padding: clamp(18px, 3vw, 34px);
}

.intro {
  text-align: left;
  margin-bottom: 18px;
}

.intro h2 {
  font-size: clamp(1.8rem, 3vw, 2.7rem);
  line-height: 1.05;
  color: var(--text);
}

.setup-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(320px, 1.25fr);
  gap: 14px;
  align-items: stretch;
}

.setup-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface-soft);
}

.setup-panel h3, .panel-card h2 {
  color: var(--text);
  margin-bottom: 12px;
  font-size: 1.08rem;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.level-btn {
  min-height: 98px;
  padding: 22px 12px;
  font-size: 1.9rem;
  font-weight: 850;
  color: var(--primary);
  background: var(--surface);
}

.level-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.setting-line {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 12px;
  align-items: center;
  margin: 10px 0;
  color: var(--muted);
}

.setting-line select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface);
}

.game-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 12px;
}

.quiz-board, .panel-card, .teams-section {
  padding: 16px;
}

.teacher-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}

.question-header {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.question-header span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.difficulty-track {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.difficulty-step {
  border-radius: 999px;
  min-height: 8px;
  background: #e2e8f0;
}

.difficulty-step.done { background: #86efac; }
.difficulty-step.current { background: var(--primary); }

.timer-box {
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
}

.timer-text {
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  padding: 7px 0;
  font-weight: 850;
  color: var(--primary);
  background: var(--surface-soft);
  font-variant-numeric: tabular-nums;
}

.timer-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transition: width 0.2s linear;
}

.question-box {
  min-height: 144px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(18px, 3vw, 32px);
  display: grid;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
}

#questionText {
  margin: 0;
  text-align: center;
  font-size: clamp(1.35rem, 2.2vw, 2.15rem);
  line-height: 1.25;
  font-weight: 800;
}

.question-image {
  width: min(100%, 900px);
  max-height: min(48vh, 520px);
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
}

.answers-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.answer-choice {
  min-height: 64px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: clamp(0.98rem, 1.25vw, 1.12rem);
  font-weight: 700;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.answer-choice.correct-answer {
  border-color: var(--green);
  background: var(--green-soft);
  color: #14532d;
}

.answer-choice.wrong-answer {
  border-color: var(--red);
  background: var(--red-soft);
  color: #7f1d1d;
}

.answer-choice.correct-answer .answer-letter {
  color: white;
  background: var(--green);
}

.answer-choice.wrong-answer .answer-letter {
  color: white;
  background: var(--red);
}

.answer-letter {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 850;
}

.feedback-box {
  margin-top: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 12px 14px;
  background: var(--surface-soft);
  font-size: 1rem;
}

.feedback-box strong { color: var(--text); }

.controls {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-btn {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
  font-weight: 850;
  padding: 10px 18px;
}

.primary-btn:hover { background: #1d4ed8; }
.secondary-btn, .wide-btn { font-weight: 750; }

.ranking-box {
  display: grid;
  gap: 8px;
}

.ranking-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: var(--surface-soft);
}

.ranking-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  font-weight: 800;
}

.mini-bar {
  height: 7px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.mini-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
}

.dynamic-message {
  margin: 12px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.teams-section {
  grid-column: 1 / -1;
}

.teams-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 999px;
  margin-right: 5px;
}
.dot.good { background: var(--green); }
.dot.bad { background: var(--red); }
.dot.no-answer { background: var(--orange); }

.teams-grid {
  display: grid;
  grid-template-columns: repeat(var(--team-columns, 4), minmax(0, 1fr));
  gap: 10px;
}

.team-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.team-card.good {
  border-color: var(--green);
  background: var(--green-soft);
}

.team-card.bad {
  border-color: var(--red);
  background: var(--red-soft);
}

.team-card.no-answer {
  border-color: var(--orange);
  background: var(--orange-soft);
}

.team-name {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface);
  font-weight: 800;
  font-size: 1rem;
  text-align: center;
}

.team-name:focus {
  outline: none;
  border-color: var(--primary);
}

.progress-bar {
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  background: #e2e8f0;
  margin: 10px 0;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.team-answer-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.team-answer-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text);
  background: var(--surface);
  font-weight: 850;
}

.team-answer-btn:hover { border-color: var(--primary); }

.team-answer-btn.selected {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.team-answer-btn.good-choice {
  background: var(--green-soft);
  color: #14532d;
  border-color: var(--green);
}

.team-answer-btn.bad-choice {
  background: var(--red-soft);
  color: #7f1d1d;
  border-color: var(--red);
}

dialog {
  width: min(680px, 92vw);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 0;
}

dialog::backdrop { background: rgba(15, 23, 42, 0.35); }

.modal-content {
  position: relative;
  border-radius: 8px;
  padding: 24px;
  background: var(--surface);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
}

.export-area {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--text);
  background: var(--surface-soft);
}

@media (max-width: 1180px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .teacher-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .setup-grid, .teacher-panel {
    grid-template-columns: 1fr;
  }
  .teams-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .setting-line {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .topbar, .teams-title {
    flex-direction: column;
    align-items: flex-start;
  }
  .level-grid, .answers-grid, .teams-grid {
    grid-template-columns: 1fr;
  }
  .top-actions, .legend {
    justify-content: flex-start;
  }
}
.level-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.home-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.wide-action {
  width: 100%;
  text-align: center;
}

.team-setup-panel {
  grid-column: 1 / -1;
}

.team-name-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.setup-team-field, .question-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.setup-team-field input,
.question-form input,
.question-form select,
.question-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface);
  font: inherit;
}

.question-form textarea {
  resize: vertical;
  min-height: 86px;
}

.create-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: var(--surface-soft);
}

.create-panel h3 {
  margin-bottom: 14px;
}

.question-manager {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface);
}

.question-manager-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.question-manager-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.question-manager-toolbar select,
.question-manager-toolbar input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  color: var(--text);
  background: var(--surface-soft);
  font: inherit;
}

.editable-question-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-right: 4px;
}

.editable-question-item {
  display: grid;
  gap: 5px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.editable-question-item:hover,
.editable-question-item.selected {
  border-color: var(--primary);
  background: #eef4ff;
}

.editable-question-meta,
.editable-question-answer,
.editable-question-empty {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.editable-question-item strong {
  line-height: 1.3;
}

.editable-question-empty {
  margin: 0;
  padding: 10px;
}

.question-form {
  display: grid;
  gap: 12px;
}

.form-grid, .answers-create-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.placement-editor {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.placement-editor-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.extra-placement-list {
  display: grid;
  gap: 8px;
}

.extra-placement-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.35fr) minmax(160px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.extra-placement-row select,
.extra-placement-row input {
  min-height: 40px;
}

.form-line {
  display: grid;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.form-status {
  min-height: 1.4em;
  margin: 0;
  color: var(--green);
  font-weight: 700;
}

.form-status.error {
  color: var(--red);
}

.latex-image-editor {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.latex-image-editor textarea {
  min-height: 190px;
  font-family: "Cascadia Mono", "Fira Code", Consolas, monospace;
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.45;
}

.latex-image-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.latex-compile-status {
  color: var(--green);
  font-size: 0.88rem;
  font-weight: 800;
}

.latex-compile-status.error {
  color: var(--red);
}

.latex-image-preview {
  justify-self: center;
  max-width: min(100%, 560px);
  max-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
  object-fit: contain;
}

@media (max-width: 720px) {
  .question-manager-toolbar,
  .form-grid,
  .answers-create-grid,
  .extra-placement-row {
    grid-template-columns: 1fr;
  }

  .extra-placement-row .secondary-btn {
    justify-self: start;
  }
}
.topbar {
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 900;
  text-transform: lowercase;
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  display: block;
}

.site-footer {
  margin-top: 12px;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
}

.modal-action {
  margin-top: 14px;
}

.questions-review {
  display: grid;
  gap: 12px;
  max-height: min(72vh, 760px);
  overflow: auto;
  padding-right: 4px;
}

.review-question {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-soft);
}

.review-question h3 {
  margin: 6px 0 10px;
  font-size: 1.05rem;
}

.review-question ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.review-question li {
  margin: 6px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  list-style-position: inside;
  font-weight: 700;
}

.review-meta {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.review-correct {
  border-color: var(--green);
  background: var(--green-soft);
  color: #14532d;
}

.review-wrong {
  border-color: var(--red);
  background: var(--red-soft);
  color: #7f1d1d;
}

dialog {
  width: min(920px, 92vw);
}

@media (max-width: 720px) {
  .brand {
    font-size: 1.1rem;
  }

  .brand img {
    width: 42px;
    height: 42px;
  }
}
.muted-panel {
  display: none !important;
}

.game-layout.flash-mode {
  grid-template-columns: 1fr;
}

.game-layout.flash-mode .teacher-panel,
.game-layout.flash-mode .teams-section {
  display: none;
}

.game-layout.flash-mode .quiz-board {
  min-height: 70vh;
}
.setup-flow {
  display: grid;
  gap: 18px;
}

.setup-step {
  display: grid;
  gap: 18px;
}

.step-heading {
  display: grid;
  gap: 6px;
}

.compact-heading {
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 16px;
}

.step-kicker {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 0.82rem;
  font-weight: 850;
}

.step-context {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.level-grid-large {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.level-grid-large .level-btn {
  min-height: 132px;
  font-size: clamp(1.8rem, 3vw, 2.7rem);
}

.level-grid-large .level-btn[data-level="recreations"],
.level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  line-height: 1.12;
}

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

.mode-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  text-align: left;
  color: var(--text);
  background: var(--surface-soft);
  cursor: pointer;
  display: grid;
  align-content: space-between;
  gap: 14px;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.12s ease;
}

.mode-card:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.mode-card strong {
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.05;
}

.mode-card span {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(260px, 0.9fr);
  gap: 14px;
  align-items: start;
}

.settings-panel-main {
  min-height: 100%;
}

.empty-activity-panel {
  min-height: 220px;
  display: grid;
  align-items: center;
}

.empty-activity-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 750;
}

.resource-panel {
  display: grid;
  gap: 16px;
}

.resource-panel > p {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.resource-list {
  display: grid;
  gap: 18px;
  max-height: min(64vh, 720px);
  overflow: auto;
  padding-right: 4px;
}

.resource-level {
  display: grid;
  gap: 12px;
}

.resource-level-title {
  margin: 0;
  color: var(--primary);
  font-size: 1.15rem;
}

.resource-chapters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.resource-chapter {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.resource-chapter h4 {
  margin: 0;
  color: var(--text);
  font-size: 0.98rem;
  line-height: 1.25;
}

.resource-links {
  display: grid;
  gap: 7px;
}

.resource-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: var(--surface-soft);
  text-decoration: none;
  font-weight: 750;
}

.resource-link:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.resource-link span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.resource-link small {
  color: var(--primary);
  font-weight: 900;
  letter-spacing: 0.02em;
}

.resource-empty {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 900px) {
  .compact-heading,
  .settings-grid,
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .compact-heading {
    align-items: start;
  }
}
/* Setup visual refresh - Codex */
.home-card.setup-flow {
  min-height: auto;
  padding: clamp(24px, 4vw, 46px);
  border-color: #dbe4f0;
  background: #ffffff;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
}

.setup-step {
  gap: clamp(20px, 3vw, 34px);
}

.step-heading {
  max-width: none;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 14px;
  row-gap: 4px;
}

.step-heading > h2,
.step-heading > div > h2 {
  font-size: 1.7rem;
  line-height: 1.05;
  color: #0f172a;
}

.step-heading > div {
  min-width: 0;
}

.step-kicker {
  width: auto;
  min-width: 72px;
  height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #1d4ed8;
  background: #eff6ff;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.step-context {
  margin-top: 4px;
  color: #52647f;
  font-size: 0.95rem;
  font-weight: 800;
}

.compact-heading {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
}

.compact-heading > div {
  grid-column: 2;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 14px;
}

.compact-heading > div > .step-context {
  grid-column: 2;
}

.compact-heading > .secondary-btn {
  grid-column: 3;
  align-self: center;
}

.level-grid-large {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.level-grid-large .level-btn {
  min-height: 118px;
  padding: 18px 12px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
  color: #1d4ed8;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-color: #d7e2f1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  font-size: 2.1rem;
  line-height: 1.08;
  transition: transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.level-grid-large .level-btn::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 12px;
  width: 26px;
  height: 4px;
  border-radius: 999px;
  background: #bfdbfe;
}

.level-grid-large .level-btn:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.12);
}

.level-grid-large .level-btn.selected {
  border-color: #2563eb;
  color: #ffffff;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.22);
}

.level-grid-large .level-btn.selected::before {
  background: rgba(255, 255, 255, 0.68);
}

.level-grid-large .level-btn[data-level="all"] {
  font-size: 1.75rem;
}

.level-grid-large .level-btn[data-level="recreations"],
.level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
  font-size: 1.2rem;
  line-height: 1.16;
}

.mode-grid {
  gap: 14px;
}

.mode-card {
  min-height: 132px;
  position: relative;
  align-content: start;
  gap: 12px;
  padding: 20px 22px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-color: #d7e2f1;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
}

.mode-card::before {
  content: "";
  width: 34px;
  height: 5px;
  border-radius: 999px;
  background: #bfdbfe;
  margin-bottom: 4px;
}

.mode-card:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.11);
}

.mode-card strong {
  font-size: 1.5rem;
  line-height: 1.08;
  color: #0f172a;
}

.mode-card span {
  color: #52647f;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.35;
}

.mode-card[data-activity="flash"]::before { background: #93c5fd; }
.mode-card[data-activity="quiz"]::before { background: #86efac; }
.mode-card[data-activity="cours"]::before { background: #fbbf24; }
.mode-card[data-activity="exercices"]::before { background: #fca5a5; }

.secondary-btn,
.ghost-btn {
  border-color: #d7e2f1;
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.04);
}

.secondary-btn:hover,
.ghost-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

@media (max-width: 900px) {
  .compact-heading {
    grid-template-columns: auto 1fr;
  }

  .compact-heading > div {
    grid-column: 2;
  }

  .compact-heading > .secondary-btn {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

@media (max-width: 720px) {
  .home-card.setup-flow {
    padding: 18px;
  }

  .step-heading,
  .compact-heading {
    grid-template-columns: 1fr;
  }

  .compact-heading > div,
  .compact-heading > .secondary-btn {
    grid-column: auto;
  }

  .compact-heading > div {
    grid-template-columns: 1fr;
    row-gap: 8px;
  }

  .compact-heading > div > .step-context {
    grid-column: auto;
  }

  .level-grid-large {
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .level-grid-large .level-btn {
    min-height: 96px;
    font-size: 1.55rem;
  }

  .level-grid-large .level-btn[data-level="all"],
  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: 1.05rem;
  }
}

.level-grid-large .level-social-card {
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  display: grid;
  gap: 12px;
  align-content: center;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.social-card-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--text);
  font-weight: 900;
  text-align: center;
}

.youtube-logo {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #ff0033;
  position: relative;
  flex: 0 0 auto;
}

.youtube-logo::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 5px;
  border-left: 7px solid #ffffff;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.social-links {
  display: grid;
  gap: 7px;
}

.social-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
}

.social-link:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.social-link.youtube {
  color: #b91c1c;
}

.social-link.instagram {
  color: var(--primary);
}

.social-link.linkedin {
  color: #0a66c2;
}

.linkedin-logo {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  background: #0a66c2;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.instagram-logo {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, #f58529 0%, #dd2a7b 45%, #8134af 72%, #515bd4 100%);
  position: relative;
  flex: 0 0 auto;
}

.instagram-logo::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.instagram-logo::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 4px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffffff;
}

@media (max-width: 720px) {
  .level-grid-large .level-social-card {
    min-height: 96px;
  }
}


/* En-tetes simplifies : le badge porte le nom de la section. */
.setup-flow .step-heading > h2,
.setup-flow .step-heading > div > h2 {
  display: none;
}

.setup-flow .step-kicker {
  min-width: 108px;
  height: 40px;
  padding: 0 18px;
  font-size: 0.98rem;
  letter-spacing: 0;
}

.setup-flow .step-heading {
  grid-template-columns: auto;
}

.setup-flow .compact-heading {
  grid-template-columns: minmax(0, 1fr) auto;
}

.setup-flow .compact-heading > div {
  grid-column: 1;
  grid-template-columns: auto minmax(0, 1fr);
}

.setup-flow .compact-heading > div > .step-context {
  grid-column: 2;
  margin-top: 0;
}

.setup-flow .compact-heading > .secondary-btn {
  grid-column: 2;
}

@media (max-width: 720px) {
  .setup-flow .compact-heading,
  .setup-flow .compact-heading > div {
    grid-template-columns: 1fr;
  }

  .setup-flow .compact-heading > div > .step-context,
  .setup-flow .compact-heading > .secondary-btn {
    grid-column: auto;
  }
}


/* Parametres compacts et selection fine des questions. */
.settings-grid.flash-settings-grid {
  grid-template-columns: 1fr;
}

.settings-grid.flash-settings-grid .settings-panel-main {
  max-width: none;
}

.setting-block {
  display: grid;
  gap: 8px;
  margin: 8px 0;
}

.setting-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.mini-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  padding: 5px 10px;
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}

.choice-checklist,
.question-pick-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  gap: 6px;
  padding: 8px;
  max-height: 190px;
  overflow: auto;
}

.question-pick-list {
  max-height: 250px;
}

.check-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--text);
  background: var(--surface-soft);
  font-weight: 750;
}

.check-card:hover {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.check-card input {
  margin-top: 2px;
  accent-color: var(--primary);
}

.check-card span {
  min-width: 0;
  line-height: 1.25;
}

.check-card small {
  color: var(--muted);
  font-weight: 850;
}

.question-check {
  grid-template-columns: auto minmax(0, 1fr);
  font-size: 0.88rem;
}

.question-check strong {
  color: var(--primary);
}

.question-pick-empty,
.question-pick-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.home-card.setup-flow {
  padding: clamp(16px, 2.6vw, 30px);
}

.setup-panel {
  padding: 14px;
}

.setting-line {
  margin: 6px 0;
}

.mode-card {
  min-height: 108px;
  padding: 14px 16px;
}

.level-grid-large .level-btn,
.level-grid-large .level-social-card {
  min-height: 96px;
}

@media (max-width: 720px) {
  .setting-block-header {
    align-items: flex-start;
    flex-direction: column;
  }
}


/* Outils d'accueil : chronometre et timer autonomes. */
.home-tools-block {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

.tools-heading {
  margin-top: 2px;
}

.home-tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.tool-launch-card,
.tool-tab {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.tool-launch-card {
  min-height: 96px;
  padding: 14px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  font: inherit;
}

.tool-launch-card:hover,
.tool-tab:hover {
  transform: translateY(-2px);
  border-color: #93c5fd;
  background: #eff6ff;
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.12);
}

.tool-launch-card strong {
  color: var(--primary);
  font-size: 1.15rem;
}

.tool-launch-icon {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--primary);
  background: var(--primary-soft);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.tool-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(14px, 2.2vw, 24px);
  background: var(--surface);
  display: grid;
  gap: 16px;
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.tool-tab {
  min-height: 44px;
  padding: 10px 12px;
  font-weight: 800;
}

.tool-tab.selected {
  border-color: #2563eb;
  color: #ffffff;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
}

.tool-display-card {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: clamp(18px, 4vw, 34px);
  background: #f8fbff;
  display: grid;
  justify-items: center;
  gap: 8px;
}

.tool-mode-label,
.tool-end-message {
  margin: 0;
  font-weight: 800;
}

.tool-mode-label {
  color: var(--primary);
}

.tool-display {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: clamp(3.2rem, 9vw, 7rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.tool-end-message {
  min-height: 1.25em;
  color: #dc2626;
}

.timer-settings {
  display: grid;
  gap: 12px;
}

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

.timer-inputs label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.timer-inputs input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-weight: 800;
}

.timer-presets,
.tool-controls {
  display: grid;
  gap: 8px;
}

.timer-presets {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tool-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tool-controls button {
  min-height: 48px;
}



.tool-view {
  display: grid;
  gap: 14px;
}

.clock-tool-view {
  gap: 14px;
}

.tool-subpanel {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
  display: grid;
  gap: 12px;
}

.tool-subpanel h3 {
  margin: 0;
}

.tool-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.tool-field-grid label,
.tool-list-manager label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.tool-field-grid input,
.tool-field-grid select,
.tool-list-manager input,
.tool-list-manager select,
.tool-list-manager textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 750;
}

.tool-list-manager textarea {
  min-height: 210px;
  resize: vertical;
  line-height: 1.35;
}

.tool-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tool-actions-row button {
  min-height: 44px;
}

.danger-outline {
  color: var(--red);
}

.tool-big-result {
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: clamp(18px, 4vw, 30px);
  background: #ffffff;
  color: var(--primary);
  text-align: center;
  font-size: clamp(2.4rem, 8vw, 5.2rem);
  font-weight: 900;
  line-height: 1;
  overflow-wrap: anywhere;
}

.tool-muted-result {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}


.dice3d-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: clamp(12px, 2vw, 20px);
  align-items: center;
}

.dice3d-card {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
}

.dice3d-stage {
  position: relative;
  width: clamp(108px, 15vw, 160px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: radial-gradient(circle at 48% 32%, #ffffff 0%, #f8fbff 42%, #eaf2ff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 12px 22px rgba(37, 99, 235, 0.12);
  overflow: hidden;
}

.dice3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.dice3d-value {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.dice3d-card.rolling .dice3d-stage {
  border-color: #93c5fd;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 18px 34px rgba(37, 99, 235, 0.2);
}

.dice3d-card.rolling .dice3d-value {
  animation: dice3d-value-pop 0.14s ease-in-out infinite alternate;
}

@keyframes dice3d-value-pop {
  from { transform: translate(-50%, -50%) scale(0.9); opacity: 0.7; }
  to { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
}

@media (max-width: 720px) {
  .dice3d-grid {
    grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
  }

  .dice3d-stage {
    width: min(29vw, 116px);
  }
}

.tool-big-result.dice-result-panel {
  min-height: clamp(190px, 28vw, 310px);
  padding: clamp(16px, 3vw, 28px);
  display: grid;
  place-items: center;
  font-size: 1rem;
  line-height: 1;
  overflow: hidden;
}

.platonic-dice-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: clamp(12px, 2vw, 20px);
  align-items: center;
}

.platonic-die {
  display: grid;
  justify-items: center;
  gap: 8px;
  min-width: 0;
}

.platonic-solid {
  position: relative;
  width: clamp(94px, 15vw, 148px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
}

.platonic-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  filter: drop-shadow(0 14px 18px rgba(37, 99, 235, 0.16));
}

.solid-face {
  fill: #eff6ff;
  stroke: #2563eb;
  stroke-width: 3.4;
  stroke-linejoin: round;
}

.solid-inner {
  fill: rgba(255, 255, 255, 0.42);
  stroke: #60a5fa;
  stroke-width: 2.4;
  stroke-linejoin: round;
}

.solid-edge {
  fill: none;
  stroke: #1d4ed8;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.78;
}

.platonic-value {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.7rem);
  font-weight: 950;
  letter-spacing: 0;
  text-shadow: 0 2px 0 #ffffff;
  font-variant-numeric: tabular-nums;
}

.platonic-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.dice-roll-result {
  color: var(--primary);
  font-size: 1rem;
  font-weight: 950;
  line-height: 1.15;
}

.platonic-die.rolling .platonic-solid {
  animation: platonic-roll 0.72s cubic-bezier(0.2, 0.7, 0.2, 1) infinite;
  animation-delay: var(--roll-delay);
}

.platonic-die.rolling .platonic-value {
  animation: platonic-pop 0.14s ease-in-out infinite alternate;
}

@keyframes platonic-roll {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1); }
  32% { transform: rotateX(62deg) rotateY(-38deg) rotateZ(24deg) scale(1.05); }
  66% { transform: rotateX(-40deg) rotateY(72deg) rotateZ(-22deg) scale(0.96); }
  100% { transform: rotateX(0deg) rotateY(0deg) rotateZ(360deg) scale(1); }
}

@keyframes platonic-pop {
  from { transform: translate(-50%, -50%) scale(0.88); opacity: 0.72; }
  to { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .platonic-die.rolling .platonic-solid,
  .platonic-die.rolling .platonic-value {
    animation: none;
  }
}

@media (max-width: 720px) {
  .tool-big-result.dice-result-panel {
    min-height: auto;
  }

  .platonic-dice-grid {
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  }

  .platonic-solid {
    width: min(30vw, 116px);
  }
}


.tool-list-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(320px, 1.15fr);
  gap: 14px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 800;
}

.inline-check input {
  width: 18px;
  height: 18px;
}

.group-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.generated-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.generated-group h4,
.generated-group p {
  margin: 0;
}

.generated-group h4 {
  color: var(--primary);
  margin-bottom: 6px;
}



.mental-question-card {
  display: grid;
  gap: 10px;
}

.mental-question-card .tool-muted-result {
  min-height: 1.2em;
}

.mental-timer-box {
  margin: 0 0 12px;
}


.mental-operation-picker .inline-check,
.mental-number-picker .inline-check {
  min-height: 42px;
}

.mental-answer-line {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 850;
}

.mental-answer-line strong {
  color: var(--primary);
}

.tool-big-result.mental-series-display {
  padding: 14px;
  text-align: left;
  font-size: 1rem;
  line-height: 1.3;
}

.mental-series-list,
.mental-correction-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.mental-series-list li,
.mental-correction-list li {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbff;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
  font-weight: 850;
}

.mental-series-list li {
  justify-content: flex-start;
}

.mental-correction-list strong {
  color: var(--primary);
  white-space: nowrap;
}

.solution-steps-list {
  display: grid;
  gap: 10px;
}

.solution-steps-card {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbff;
}

.solution-steps-card strong {
  display: block;
  color: var(--primary);
  margin-bottom: 8px;
}

.solution-steps-card ol {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 4px;
  font-weight: 750;
}

@media (max-width: 720px) {
  .mental-series-list li,
  .mental-correction-list li {
    align-items: flex-start;
    flex-direction: column;
  }
}


.operation-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.operation-picker .inline-check {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  background: #ffffff;
}

.count-puzzle-card {
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.count-target-card {
  border-radius: 8px;
  padding: 14px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  justify-items: center;
  gap: 4px;
  font-weight: 850;
}

.count-target-card strong {
  font-size: clamp(2rem, 6vw, 4rem);
  line-height: 1;
}

.count-number-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.count-number-chip {
  min-width: 54px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  padding: 9px 12px;
  background: #eff6ff;
  color: var(--primary);
  text-align: center;
  font-size: 1.2rem;
  font-weight: 900;
}

.count-solutions {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.count-solutions h4 {
  margin: 0 0 8px;
}

.solution-list {
  margin: 0;
  padding-left: 22px;
  display: grid;
  gap: 6px;
  font-weight: 750;
}


.count-method-choice {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbff;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.count-method-choice strong {
  color: var(--primary);
  margin-right: 4px;
}

.multiplication-table-card {
  border: 1px solid #dbeafe;
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  display: grid;
  gap: 10px;
}

.multiplication-table-card h4 {
  margin: 0;
  color: var(--primary);
  font-size: 1.05rem;
}

.multiplication-table-rows {
  display: grid;
  gap: 8px;
}

.multiplication-table-result {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.multiplication-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
}

.multiplication-row strong {
  color: var(--primary);
  font-size: 1.25rem;
}

.hidden-product {
  color: var(--muted) !important;
}

/* Categorie videos : liens YouTube et Instagram hors de la grille des niveaux. */
.home-social-block {
  display: grid;
  gap: 12px;
}

.home-social-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.home-social-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.home-social-copy strong {
  color: var(--text);
  font-size: 1.08rem;
}

.home-social-copy span {
  color: var(--muted);
  font-weight: 750;
}

.home-social-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 8px;
}

.home-social-links .social-link {
  min-height: 40px;
  padding: 8px 12px;
}

.home-cv-links {
  grid-template-columns: minmax(130px, 1fr);
}

/* Mobile/tablette uniquement : le rendu ordinateur reste pilote par les regles au-dessus. */
@media (max-width: 820px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app {
    width: min(100%, calc(100vw - 16px));
    padding: 8px 0 16px;
  }

  .topbar {
    gap: 10px;
    margin-bottom: 10px;
  }

  .top-actions {
    gap: 6px;
  }

  .ghost-btn,
  .primary-btn,
  .secondary-btn,
  .mini-btn {
    min-height: 42px;
    touch-action: manipulation;
  }

  .home-card,
  .quiz-board,
  .teams-section,
  .panel-card,
  dialog {
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
  }

  .home-card.setup-flow {
    padding: 12px;
  }

  .setup-flow {
    gap: 12px;
  }

  .setup-step {
    gap: 12px;
  }

  .setup-flow .step-kicker {
    min-width: 0;
    height: 36px;
    padding: 0 14px;
    font-size: 0.9rem;
    white-space: nowrap;
  }

  .level-grid-large {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .level-grid-large .level-btn,
  .level-grid-large .level-social-card {
    min-height: 86px;
    padding: 12px 10px;
  }

  .level-grid-large .level-btn {
    font-size: 1.45rem;
  }

  .level-grid-large .level-btn[data-level="all"],
  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: 0.95rem;
    line-height: 1.12;
  }

  .level-social-card {
    gap: 8px;
  }

  .home-tools-block,
  .home-social-block {
    gap: 10px;
  }

  .home-social-panel {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .home-social-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-tool-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .tool-launch-card {
    min-height: 76px;
    padding: 12px 10px;
  }

  .tool-launch-card strong {
    font-size: 0.98rem;
  }

  .tool-panel {
    gap: 12px;
    padding: 12px;
  }

  .tool-list-layout {
    grid-template-columns: 1fr;
  }

  .tool-field-grid,
  .multiplication-table-result,
  .group-results,
  .count-puzzle-card {
    grid-template-columns: 1fr;
  }

  .count-number-list {
    justify-content: center;
  }

  .tool-display {
    font-size: clamp(3rem, 18vw, 5.8rem);
  }

  .timer-inputs,
  .tool-controls {
    grid-template-columns: 1fr;
  }

  .timer-presets {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .social-card-heading {
    font-size: 0.95rem;
  }

  .social-link {
    min-height: 36px;
    font-size: 0.86rem;
  }

  .mode-grid,
  .settings-grid,
  .settings-grid.flash-settings-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .mode-card {
    min-height: 88px;
    padding: 14px;
  }

  .mode-card strong {
    font-size: 1.2rem;
  }

  .mode-card span {
    font-size: 0.9rem;
  }

  .setup-panel {
    padding: 12px;
  }

  .setup-panel h3,
  .panel-card h2 {
    margin-bottom: 8px;
  }

  .setting-line {
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 8px 0;
  }

  .setting-line select,
  .setup-team-field input,
  .question-form input,
  .question-form select,
  .question-form textarea,
  .question-manager-toolbar select,
  .question-manager-toolbar input {
    min-height: 44px;
    font-size: 1rem;
  }

  .setting-block {
    gap: 7px;
    margin: 8px 0;
  }

  .setting-block-header {
    align-items: center;
    flex-direction: row;
  }

  .mini-actions {
    justify-content: flex-end;
  }

  .mini-btn {
    padding: 7px 11px;
  }

  .choice-checklist {
    max-height: 34vh;
    padding: 7px;
  }

  .question-pick-list {
    max-height: 38vh;
    padding: 7px;
  }

  .check-card {
    min-height: 46px;
    padding: 9px;
    gap: 9px;
    font-size: 0.92rem;
  }

  .check-card input {
    width: 20px;
    height: 20px;
  }

  .question-check {
    font-size: 0.86rem;
  }

  .team-name-inputs {
    grid-template-columns: 1fr;
  }

  .home-actions {
    gap: 7px;
  }

  .wide-action {
    min-height: 46px;
  }

  .resource-list {
    gap: 8px;
  }

  .resource-link {
    min-height: 44px;
    align-items: center;
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .quiz-board,
  .panel-card,
  .teams-section {
    padding: 12px;
  }

  .question-header {
    gap: 5px;
  }

  .question-header span {
    padding: 5px 8px;
    font-size: 0.78rem;
  }

  .difficulty-track {
    gap: 3px;
    margin-bottom: 10px;
  }

  .timer-box {
    grid-template-columns: 60px 1fr;
    gap: 8px;
  }

  .question-box {
    min-height: 108px;
    padding: 14px;
  }

  #questionText {
    font-size: 1.18rem;
  }

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

  .answer-choice {
    min-height: 54px;
    padding: 10px;
    font-size: 0.98rem;
  }

  .answer-letter {
    width: 32px;
    height: 32px;
  }

  .teacher-panel {
    grid-template-columns: 1fr;
  }

  .teams-grid {
    grid-template-columns: 1fr;
  }

  .team-card {
    min-height: auto;
  }

  dialog {
    width: calc(100vw - 18px);
    max-height: 82vh;
    padding: 14px;
  }

  .question-manager {
    padding: 10px;
  }

  .question-manager-toolbar,
  .form-grid,
  .answers-create-grid {
    grid-template-columns: 1fr;
  }

  .editable-question-list {
    max-height: 42vh;
  }
}

@media (max-width: 480px) {
  .app {
    width: min(100%, calc(100vw - 10px));
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    font-size: 1.05rem;
  }

  .brand img {
    width: 40px;
    height: 40px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .top-actions .ghost-btn {
    width: 100%;
  }

  .home-card.setup-flow {
    padding: 10px;
  }

  .level-grid-large {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .level-grid-large .level-btn,
  .level-grid-large .level-social-card {
    min-height: 76px;
  }

  .level-grid-large .level-btn {
    font-size: 1.25rem;
  }

  .level-grid-large .level-btn[data-level="all"],
  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: 0.82rem;
  }

  .level-grid-large .level-btn::before {
    top: 8px;
    left: 8px;
    width: 20px;
  }

  .social-link {
    font-size: 0.8rem;
  }

  .home-tool-grid,
  .home-social-links {
    gap: 8px;
  }

  .home-social-copy strong {
    font-size: 0.98rem;
  }

  .home-social-copy span {
    font-size: 0.88rem;
  }

  .tool-launch-card {
    min-height: 72px;
  }

  .tool-tabs {
    grid-template-columns: 1fr;
  }

  .tool-launch-icon {
    padding: 5px 9px;
    font-size: 0.78rem;
  }

  .tool-display-card {
    padding: 16px 10px;
  }

  .tool-tabs {
    grid-template-columns: 1fr;
  }

  .tool-tab {
    min-height: 42px;
    padding: 8px;
    font-size: 0.82rem;
  }

  .tool-actions-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .setting-block-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .mini-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .mini-btn {
    width: 100%;
  }

  .choice-checklist {
    max-height: 30vh;
  }

  .question-pick-list {
    max-height: 34vh;
  }

  .check-card {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .chapter-check small {
    grid-column: 2;
    justify-self: start;
  }

  .question-header span {
    max-width: 100%;
  }

  #questionText {
    font-size: 1.06rem;
  }

  .answer-choice {
    align-items: flex-start;
  }
}

@media (max-width: 820px) {
  .level-grid-large,
  .home-tool-grid {
    width: 100%;
    min-width: 0;
  }

  .level-grid-large > *,
  .home-tool-grid > * {
    min-width: 0;
    max-width: 100%;
  }

  .level-grid-large .level-btn,
  .level-grid-large .level-social-card,
  .tool-launch-card {
    width: 100%;
    overflow-wrap: anywhere;
  }

  .level-grid-large .level-btn[data-level="all"],
  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"],
  .level-grid-large .level-social-card {
    grid-column: 1 / -1;
  }

  .level-social-card,
  .social-links,
  .home-social-panel,
  .home-social-copy,
  .home-social-links,
  .social-link {
    min-width: 0;
  }

  .social-link span:last-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
@media (max-width: 820px) {
  .app {
    width: 100%;
    max-width: 100vw;
    padding: 8px 8px 16px;
  }

  .home-card.setup-flow {
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .app {
    width: 100%;
    padding-left: 5px;
    padding-right: 5px;
  }
}
@media (max-width: 560px) {
  .home-social-links {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .home-tool-grid,
  .tool-tabs {
    grid-template-columns: 1fr;
  }

  .tool-launch-card {
    min-height: 72px;
  }
}
/* Grand ecran : le site suit mieux la largeur disponible et reste lisible au tableau. */
@media (min-width: 821px) {
  .app {
    width: min(1880px, calc(100vw - clamp(20px, 3vw, 56px)));
    padding: clamp(12px, 1.6vh, 24px) 0 26px;
  }

  .topbar {
    margin-bottom: clamp(12px, 1.4vh, 20px);
  }

  .brand {
    font-size: clamp(1.35rem, 1.25vw, 1.7rem);
  }

  .brand img {
    width: clamp(54px, 3.4vw, 68px);
    height: clamp(54px, 3.4vw, 68px);
  }

  .ghost-btn,
  .primary-btn,
  .secondary-btn,
  .wide-btn {
    min-height: 44px;
    font-size: clamp(1rem, 0.9vw, 1.12rem);
  }

  .home-card.setup-flow {
    padding: clamp(18px, 2vw, 34px);
  }

  .setup-flow,
  .setup-step {
    gap: clamp(16px, 2vh, 28px);
  }

  .setup-flow .step-kicker {
    min-height: 34px;
    padding: 0 18px;
    font-size: clamp(0.92rem, 0.82vw, 1.05rem);
  }

  .level-grid-large {
    grid-template-columns: repeat(auto-fit, minmax(clamp(150px, 10vw, 230px), 1fr));
    gap: clamp(10px, 1vw, 16px);
  }

  .level-grid-large .level-btn {
    min-height: clamp(116px, 8vw, 160px);
    padding: clamp(16px, 1.4vw, 24px);
    font-size: clamp(2rem, 2.1vw, 3rem);
  }

  .level-grid-large .level-btn[data-level="all"] {
    font-size: clamp(1.8rem, 1.8vw, 2.55rem);
  }

  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: clamp(1.15rem, 1.2vw, 1.65rem);
  }

  .home-tool-grid {
    grid-template-columns: repeat(auto-fit, minmax(clamp(140px, 9vw, 220px), 1fr));
    gap: clamp(10px, 1vw, 16px);
  }

  .tool-launch-card {
    min-height: clamp(108px, 7.2vw, 148px);
    padding: clamp(14px, 1.2vw, 22px);
  }

  .tool-launch-card strong {
    font-size: clamp(1.12rem, 1.08vw, 1.42rem);
    line-height: 1.16;
  }

  .tool-launch-icon {
    font-size: clamp(0.9rem, 0.82vw, 1.05rem);
  }

  .home-social-panel {
    padding: clamp(14px, 1.15vw, 22px);
  }

  .home-social-copy strong {
    font-size: clamp(1.08rem, 1vw, 1.28rem);
  }

  .home-social-copy span {
    font-size: clamp(0.96rem, 0.88vw, 1.12rem);
  }

  .home-social-links .social-link {
    min-height: 44px;
    font-size: clamp(0.94rem, 0.85vw, 1.08rem);
  }

  .mode-card strong {
    font-size: clamp(1.45rem, 1.7vw, 2rem);
  }

  .mode-card span,
  .resource-link,
  .setting-line,
  .setup-panel,
  .tool-subpanel {
    font-size: clamp(1rem, 0.9vw, 1.12rem);
  }

  #questionText {
    font-size: clamp(1.55rem, 2.35vw, 2.85rem);
  }

  .answer-choice {
    min-height: clamp(68px, 4.8vw, 92px);
    font-size: clamp(1.08rem, 1.15vw, 1.36rem);
  }

  .answer-letter {
    width: clamp(36px, 2.4vw, 46px);
    height: clamp(36px, 2.4vw, 46px);
  }
}

/* Ordinateur plus petit : les grilles se replient sans perdre en lisibilite. */
@media (min-width: 821px) and (max-width: 1280px) {
  .app {
    width: calc(100vw - 24px);
  }

  .level-grid-large {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  }

  .home-tool-grid {
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  }
}

/* Telephone : plein ecran utile, textes un peu plus genereux. */
@media (max-width: 560px) {
  .app {
    padding-left: 6px;
    padding-right: 6px;
  }

  .home-card.setup-flow {
    padding: 12px;
  }

  .setup-flow .step-kicker {
    min-height: 38px;
    font-size: 0.95rem;
  }

  .level-grid-large .level-btn {
    min-height: 86px;
    font-size: 1.36rem;
  }

  .level-grid-large .level-btn[data-level="all"],
  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: 0.92rem;
  }

  .tool-launch-card {
    min-height: 82px;
  }

  .tool-launch-card strong {
    font-size: 1.04rem;
  }
}
/* Tous les textes utiles gardent au moins la taille du libelle "Chronometre". */
@media (min-width: 821px) {
  .app {
    font-size: 1.15rem;
  }

  .app p,
  .app span,
  .app label,
  .app input,
  .app select,
  .app textarea,
  .app button,
  .app a,
  .app small,
  .app li,
  .app td,
  .app th {
    font-size: max(1.15rem, 1em);
  }

  .site-footer {
    font-size: 1.15rem;
  }

  .setup-flow .step-kicker,
  .tool-launch-icon,
  .question-header span,
  .tool-muted-result,
  .step-context,
  .resource-empty,
  .question-pick-empty,
  .question-pick-summary,
  .social-link,
  .mini-btn {
    font-size: 1.15rem;
  }

  .home-social-copy strong,
  .tool-launch-card strong,
  .resource-chapter h4,
  .setup-panel h3,
  .panel-card h2 {
    font-size: max(1.2rem, 1em);
  }

  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: max(1.35rem, 1em);
  }
}

@media (max-width: 820px) {
  .app {
    font-size: 1.08rem;
  }

  .app p,
  .app span,
  .app label,
  .app input,
  .app select,
  .app textarea,
  .app button,
  .app a,
  .app small,
  .app li {
    font-size: max(1.08rem, 1em);
  }

  .setup-flow .step-kicker,
  .tool-launch-icon,
  .question-header span,
  .tool-muted-result,
  .step-context,
  .social-link,
  .mini-btn {
    font-size: 1.08rem;
  }

  .level-grid-large .level-btn[data-level="all"],
  .level-grid-large .level-btn[data-level="recreations"],
  .level-grid-large .level-btn[data-level="scratch-tableur-geogebra"] {
    font-size: 1.08rem;
  }

  .tool-launch-card strong,
  .home-social-copy strong,
  .home-social-copy span {
    font-size: 1.08rem;
  }
}
.topbar {
  padding: 8px 0;
}

.brand {
  width: fit-content;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
  gap: 14px;
}

.brand img {
  width: clamp(86px, 5.6vw, 118px);
  height: clamp(58px, 3.8vw, 78px);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  object-fit: contain;
}

.brand span {
  color: #0f172a;
  font-size: clamp(1.55rem, 1.55vw, 2.1rem);
  font-weight: 950;
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .topbar {
    padding: 6px 0;
  }

  .brand {
    gap: 10px;
  }

  .brand img {
    width: 76px;
    height: 54px;
  }

  .brand span {
    font-size: 1.32rem;
  }
}

@media (max-width: 480px) {
  .brand {
    justify-self: start;
    max-width: 100%;
  }

  .brand img {
    width: 68px;
    height: 48px;
  }

  .brand span {
    font-size: 1.2rem;
  }
}
.mental-dropdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.settings-dropdown {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.settings-dropdown > summary {
  min-height: 56px;
  padding: 11px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  color: var(--text);
  cursor: pointer;
  list-style: none;
  font-weight: 900;
}

.settings-dropdown > summary::-webkit-details-marker {
  display: none;
}

.settings-dropdown > summary::after {
  content: "⌄";
  color: var(--primary);
  font-weight: 950;
  transition: transform 0.16s ease;
}

.settings-dropdown[open] > summary::after {
  transform: rotate(180deg);
}

.settings-dropdown > summary strong {
  color: var(--primary);
  font-size: 1em;
  white-space: nowrap;
}

.mental-dropdown .operation-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  padding: 0 12px 12px;
}

.mental-dropdown .inline-check {
  margin: 0;
  min-height: 48px;
  align-items: center;
}

@media (max-width: 900px) {
  .mental-dropdown-grid {
    grid-template-columns: 1fr;
  }
}
.secondary-btn.danger-btn {
  border-color: #dc2626;
  background: #dc2626;
  color: #fff;
}

.secondary-btn.danger-btn:hover {
  border-color: #b91c1c;
  background: #b91c1c;
  color: #fff;
}


.setting-check-line {
  align-items: center;
}

.setting-check {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 850;
}

.setting-check input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.setting-check span {
  line-height: 1.2;
}


.tool-large-toggle {
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-weight: 850;
}

.tool-large-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.count-timer-box {
  margin: 0;
}

.mental-question-card.large-active .tool-big-result,
.tool-big-result.large-active {
  min-height: clamp(260px, 44vh, 560px);
  display: grid;
  place-items: center;
  padding: clamp(24px, 5vw, 56px);
  font-size: clamp(4rem, 13vw, 10.5rem);
  line-height: 1.05;
}

.count-puzzle-card.large-active {
  min-height: clamp(300px, 48vh, 620px);
  align-items: center;
  gap: clamp(18px, 3vw, 36px);
}

.count-puzzle-card.large-active .count-target-card {
  padding: clamp(18px, 3vw, 34px);
}

.count-puzzle-card.large-active .count-target-card span {
  font-size: clamp(1.05rem, 1.4vw, 1.6rem);
}

.count-puzzle-card.large-active .count-target-card strong {
  font-size: clamp(4.8rem, 13vw, 11rem);
}

.count-puzzle-card.large-active .count-number-list {
  justify-content: center;
  gap: clamp(12px, 2vw, 24px);
}

.count-puzzle-card.large-active .count-number-chip {
  min-width: clamp(70px, 8vw, 130px);
  min-height: clamp(58px, 6vw, 100px);
  padding: clamp(12px, 2vw, 22px);
  border-radius: 16px;
  font-size: clamp(2.2rem, 5vw, 5rem);
}

@media (max-width: 720px) {
  .mental-question-card.large-active .tool-big-result,
  .tool-big-result.large-active {
    min-height: 220px;
    font-size: clamp(3rem, 16vw, 5.6rem);
  }

  .count-puzzle-card.large-active {
    min-height: 260px;
  }

  .count-puzzle-card.large-active .count-target-card strong {
    font-size: clamp(4rem, 18vw, 6.5rem);
  }

  .count-puzzle-card.large-active .count-number-chip {
    min-width: 68px;
    min-height: 56px;
    font-size: clamp(2rem, 11vw, 3.6rem);
  }
}
.theme-toggle-btn {
  min-width: 128px;
}

.utility-panel {
  align-items: center;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 2.1fr);
}

.utility-links-grid {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 8px;
  width: 100%;
}

.utility-link {
  flex: 1 1 0;
  min-width: 0;
  justify-content: center;
  padding: 8px 10px;
  white-space: nowrap;
}

.utility-logo {
  min-width: 30px;
  height: 26px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  background: #eff6ff;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 950;
  line-height: 1;
}

@media (max-width: 720px) {
  .theme-toggle-btn {
    min-width: 0;
  }

  .utility-panel {
    grid-template-columns: 1fr;
  }

  .utility-links-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.utility-links-grid .social-link {
  color: var(--primary);
  font-size: clamp(1rem, 0.92vw, 1.12rem);
  font-weight: 850;
}

.utility-links-grid .social-link:hover {
  color: var(--primary);
}

.question-admin-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.question-admin-copy {
  display: grid;
  gap: 3px;
}

.question-admin-copy strong {
  color: var(--text);
  font-weight: 900;
}

.question-admin-copy span {
  color: var(--muted);
  font-size: 0.95em;
}

.question-admin-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.projection-toggle-btn {
  min-width: 148px;
}

body.projection-mode .site-footer,
body.projection-mode #homeBtn,
body.projection-mode #themeToggleBtn {
  display: none !important;
}

body.projection-mode #gameScreen:not(.hidden) {
  grid-template-columns: 1fr;
  gap: 14px;
}

body.projection-mode #gameScreen:not(.hidden) .teacher-panel {
  display: none;
}

body.projection-mode #gameScreen:not(.hidden) .quiz-board {
  min-height: calc(100vh - 120px);
  display: grid;
  align-content: center;
  gap: clamp(16px, 2vh, 28px);
  padding: clamp(18px, 2.4vw, 42px);
}

body.projection-mode #gameScreen:not(.hidden) .difficulty-track {
  display: none;
}

body.projection-mode #gameScreen:not(.hidden) .question-header {
  justify-content: center;
}

body.projection-mode #gameScreen:not(.hidden) .question-header span,
body.projection-mode #gameScreen:not(.hidden) .timer-text {
  font-size: clamp(1.1rem, 1.2vw, 1.55rem);
}

body.projection-mode #gameScreen:not(.hidden) .timer-box {
  grid-template-columns: minmax(90px, 130px) 1fr;
}

body.projection-mode #gameScreen:not(.hidden) .question-box {
  min-height: clamp(340px, 52vh, 720px);
  padding: clamp(28px, 4vw, 72px);
}

body.projection-mode #gameScreen:not(.hidden) #questionText {
  font-size: clamp(2.15rem, 4vw, 5.4rem);
  line-height: 1.15;
}

body.projection-mode #gameScreen:not(.hidden) .question-image {
  max-height: min(56vh, 650px);
}

body.projection-mode #gameScreen:not(.hidden) .answers-grid {
  gap: clamp(12px, 1.2vw, 22px);
}

body.projection-mode #gameScreen:not(.hidden) .answer-choice {
  min-height: clamp(78px, 8vh, 128px);
  padding: clamp(16px, 1.6vw, 26px);
  font-size: clamp(1.35rem, 2vw, 2.45rem);
}

body.projection-mode #gameScreen:not(.hidden) .answer-letter {
  width: clamp(46px, 3.4vw, 68px);
  height: clamp(46px, 3.4vw, 68px);
}

body.projection-mode #gameScreen:not(.hidden) .feedback-box {
  font-size: clamp(1.35rem, 1.6vw, 2rem);
  padding: clamp(16px, 1.6vw, 26px);
}

body.projection-mode #gameScreen:not(.hidden) .controls button {
  min-height: 56px;
  font-size: clamp(1.1rem, 1.1vw, 1.35rem);
}

html[data-theme="dark"] .question-admin-toolbar {
  background: var(--surface);
  border-color: var(--line);
}

@media (max-width: 720px) {
  .question-admin-toolbar {
    grid-template-columns: 1fr;
  }

  .question-admin-actions {
    justify-content: stretch;
  }

  .question-admin-actions button {
    flex: 1 1 140px;
  }

  .projection-toggle-btn {
    min-width: 0;
  }

  body.projection-mode #gameScreen:not(.hidden) .question-box {
    min-height: 260px;
  }

  body.projection-mode #gameScreen:not(.hidden) #questionText {
    font-size: clamp(2rem, 11vw, 3.6rem);
  }
}


/* FINAL_STYLE_POLISH_V1 */
:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-hover: #eff6ff;
  --text: #111827;
  --muted: #56677f;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #dbeafe;
  --primary-softer: #eff6ff;
  --line: #d7e2f1;
  --line-strong: #abc0dc;
  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

html[data-theme="dark"] {
  --bg: #0b1220;
  --surface: #111c2e;
  --surface-soft: #17243a;
  --surface-hover: #20314f;
  --text: #f1f5f9;
  --muted: #b6c4da;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --primary-soft: rgba(96, 165, 250, 0.18);
  --primary-softer: rgba(96, 165, 250, 0.12);
  --line: #30425f;
  --line-strong: #5b7bb2;
  --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.22);
  --shadow: 0 18px 46px rgba(0, 0, 0, 0.34);
}

body {
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(96, 165, 250, 0.12), transparent 28vw),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

input,
select,
textarea,
.question-manager-toolbar input,
.question-manager-toolbar select,
.question-form input,
.question-form select,
.question-form textarea {
  min-height: 44px;
  border-color: var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

textarea {
  line-height: 1.35;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.ghost-btn,
.primary-btn,
.secondary-btn,
.wide-btn,
.mini-btn,
.tool-tab,
.social-link,
.resource-link,
.question-admin-actions button,
.form-actions button,
.controls button,
.tool-actions-row button,
.latex-image-actions button {
  min-height: 44px;
  border-radius: 8px;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 1rem;
  line-height: 1.1;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--line);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.mini-btn {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 0.95rem;
}

.ghost-btn,
.secondary-btn,
.wide-btn,
.mini-btn,
.tool-tab,
.social-link,
.resource-link {
  background: var(--surface);
  color: var(--primary);
}

.ghost-btn:hover,
.secondary-btn:hover,
.wide-btn:hover,
.mini-btn:hover,
.tool-tab:hover,
.social-link:hover,
.resource-link:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--primary);
}

.primary-btn {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.primary-btn:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: #ffffff;
}

.secondary-btn.danger-btn,
.danger-outline {
  border-color: var(--red);
  color: var(--red);
  background: var(--surface);
}

.secondary-btn.danger-btn:hover,
.danger-outline:hover {
  border-color: var(--red);
  color: #ffffff;
  background: var(--red);
}

.top-actions .ghost-btn {
  min-width: 132px;
}

.theme-toggle-btn,
.projection-toggle-btn {
  min-width: 142px;
}

.step-kicker,
.question-header span,
.tool-launch-icon,
.timer-text,
.mental-timer-text,
.count-timer-text {
  border-color: rgba(37, 99, 235, 0.24);
  background: var(--primary-soft);
  color: var(--primary);
}

html[data-theme="dark"] .step-kicker,
html[data-theme="dark"] .question-header span,
html[data-theme="dark"] .tool-launch-icon,
html[data-theme="dark"] .timer-text,
html[data-theme="dark"] .mental-timer-text,
html[data-theme="dark"] .count-timer-text {
  border-color: rgba(96, 165, 250, 0.42);
  background: var(--primary-soft);
  color: #bfdbfe;
}

.home-card,
.quiz-board,
.teams-section,
.panel-card,
.setup-panel,
.tool-panel,
.tool-subpanel,
.home-social-panel,
.question-admin-toolbar,
.question-box,
.feedback-box,
.create-panel,
.question-manager,
.question-pick-list,
.editable-question-list,
.mode-card,
.tool-launch-card,
.resource-chapter,
.count-puzzle-card,
.mental-question-card {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}

.setup-panel,
.question-box,
.feedback-box,
.create-panel,
.tool-subpanel {
  background: var(--surface-soft);
}

html[data-theme="dark"] .home-card,
html[data-theme="dark"] .quiz-board,
html[data-theme="dark"] .teams-section,
html[data-theme="dark"] .panel-card,
html[data-theme="dark"] .setup-panel,
html[data-theme="dark"] .tool-panel,
html[data-theme="dark"] .tool-subpanel,
html[data-theme="dark"] .home-social-panel,
html[data-theme="dark"] .question-admin-toolbar,
html[data-theme="dark"] .question-box,
html[data-theme="dark"] .feedback-box,
html[data-theme="dark"] .create-panel,
html[data-theme="dark"] .question-manager,
html[data-theme="dark"] .question-pick-list,
html[data-theme="dark"] .editable-question-list,
html[data-theme="dark"] .mode-card,
html[data-theme="dark"] .tool-launch-card,
html[data-theme="dark"] .resource-chapter,
html[data-theme="dark"] .count-puzzle-card,
html[data-theme="dark"] .mental-question-card {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

html[data-theme="dark"] .setup-panel,
html[data-theme="dark"] .question-box,
html[data-theme="dark"] .feedback-box,
html[data-theme="dark"] .create-panel,
html[data-theme="dark"] .tool-subpanel {
  background: var(--surface-soft);
}

.home-social-copy strong,
.question-admin-copy strong,
.tool-launch-card strong,
.mode-card strong,
.panel-card h2,
.tool-subpanel h3 {
  color: var(--text);
}

.home-social-copy span,
.question-admin-copy span,
.tool-muted-result,
.setting-line,
.mode-card span {
  color: var(--muted);
}

.social-link.youtube,
.social-link.instagram,
.social-link.linkedin,
.social-link.utility-link,
.utility-links-grid .social-link {
  color: var(--primary);
}

.social-link.youtube:hover,
.social-link.instagram:hover,
.social-link.linkedin:hover,
.social-link.utility-link:hover {
  color: var(--primary);
}

.utility-logo {
  border-color: rgba(37, 99, 235, 0.25);
  background: var(--primary-softer);
  color: var(--primary);
}

html[data-theme="dark"] .utility-logo {
  border-color: rgba(96, 165, 250, 0.42);
  background: rgba(96, 165, 250, 0.16);
  color: #bfdbfe;
}

.tool-tab.selected,
.level-btn.selected,
.mode-card.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.tool-tab.selected:hover,
.level-btn.selected:hover,
.mode-card.selected:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
  color: #ffffff;
}

.answer-choice {
  background: var(--surface);
  border-color: var(--line);
  color: var(--text);
}

.answer-choice.correct-answer {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--text);
}

.answer-choice.wrong-answer {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--text);
}

html[data-theme="dark"] .question-image {
  background: #ffffff;
}

@media (max-width: 720px) {
  .top-actions {
    width: 100%;
  }

  .top-actions .ghost-btn,
  .theme-toggle-btn,
  .projection-toggle-btn {
    min-width: 0;
    flex: 1 1 150px;
  }

  .ghost-btn,
  .primary-btn,
  .secondary-btn,
  .wide-btn,
  .tool-tab,
  .social-link,
  .resource-link {
    min-height: 46px;
  }
}


/* DARK_LEVEL_CARDS_FIX_V1 */
.level-grid-large .level-btn {
  background: var(--surface);
  border-color: var(--line);
  color: var(--primary);
}

.level-grid-large .level-btn::before {
  background: rgba(37, 99, 235, 0.25);
}

.level-grid-large .level-btn:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: var(--primary);
}

.level-grid-large .level-btn.selected,
.level-grid-large .level-btn.selected:hover {
  border-color: var(--primary);
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
}

.level-grid-large .level-btn.selected::before {
  background: rgba(255, 255, 255, 0.68);
}

html[data-theme="dark"] .level-grid-large .level-btn {
  background: var(--surface);
  border-color: var(--line);
  color: #bfdbfe;
  box-shadow: none;
}

html[data-theme="dark"] .level-grid-large .level-btn::before {
  background: rgba(96, 165, 250, 0.45);
}

html[data-theme="dark"] .level-grid-large .level-btn:hover {
  background: var(--surface-hover);
  border-color: var(--line-strong);
  color: #dbeafe;
}

html[data-theme="dark"] .level-grid-large .level-btn.selected,
html[data-theme="dark"] .level-grid-large .level-btn.selected:hover {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.26);
}


/* DARK_TEXT_HIERARCHY_V1 */
:root {
  --ink: var(--text);
}

html[data-theme="dark"] {
  --text: #f8fafc;
  --muted: #c8d5e8;
  --primary: #93c5fd;
  --primary-hover: #bfdbfe;
  --primary-soft: rgba(147, 197, 253, 0.16);
  --primary-softer: rgba(147, 197, 253, 0.10);
  --ink: var(--text);
}

html[data-theme="dark"] .app,
html[data-theme="dark"] .app :where(h1, h2, h3, h4, h5, h6, p, label, legend, li, td, th, strong, em) {
  color: var(--text);
}

html[data-theme="dark"] .app :where(.step-context, .tool-muted-result, .resource-empty, .question-pick-empty, .question-pick-summary, .editable-question-meta, .editable-question-answer, .home-social-copy span, .question-admin-copy span, .mode-card span, .setting-line, .form-status, .site-footer) {
  color: var(--muted);
}

html[data-theme="dark"] .app :where(a, .ghost-btn, .secondary-btn, .wide-btn, .mini-btn, .tool-tab, .social-link, .resource-link, .level-btn, .tool-launch-icon, .timer-text, .mental-timer-text, .count-timer-text, .answer-letter, .utility-logo) {
  color: var(--primary);
}

html[data-theme="dark"] .step-kicker,
html[data-theme="dark"] .question-header span {
  color: var(--primary);
}

html[data-theme="dark"] .home-social-links .social-link,
html[data-theme="dark"] .utility-links-grid .social-link,
html[data-theme="dark"] .social-link.youtube,
html[data-theme="dark"] .social-link.instagram,
html[data-theme="dark"] .social-link.linkedin,
html[data-theme="dark"] .social-link.utility-link {
  color: var(--primary);
}

html[data-theme="dark"] .home-social-links .social-link span:last-child,
html[data-theme="dark"] .utility-links-grid .social-link span:last-child {
  color: var(--primary);
}

html[data-theme="dark"] .tool-launch-card strong,
html[data-theme="dark"] .mode-card strong,
html[data-theme="dark"] .home-social-copy strong,
html[data-theme="dark"] .question-admin-copy strong,
html[data-theme="dark"] .resource-chapter h4,
html[data-theme="dark"] .panel-card h2,
html[data-theme="dark"] .tool-subpanel h3,
html[data-theme="dark"] .question-form span,
html[data-theme="dark"] .team-card,
html[data-theme="dark"] .team-card input {
  color: var(--text);
}

html[data-theme="dark"] .level-grid-large .level-btn {
  color: var(--text);
}

html[data-theme="dark"] .level-grid-large .level-btn:hover {
  color: var(--text);
}

html[data-theme="dark"] .primary-btn,
html[data-theme="dark"] .primary-btn *,
html[data-theme="dark"] .level-btn.selected,
html[data-theme="dark"] .level-btn.selected *,
html[data-theme="dark"] .tool-tab.selected,
html[data-theme="dark"] .tool-tab.selected *,
html[data-theme="dark"] .mode-card.selected,
html[data-theme="dark"] .mode-card.selected *,
html[data-theme="dark"] .team-answer-btn.selected,
html[data-theme="dark"] .team-answer-btn.selected * {
  color: #ffffff;
}

html[data-theme="dark"] .answer-choice {
  color: var(--text);
}

html[data-theme="dark"] .answer-choice.correct-answer,
html[data-theme="dark"] .answer-choice.wrong-answer {
  color: var(--text);
}

html[data-theme="dark"] .answer-choice.correct-answer .answer-letter,
html[data-theme="dark"] .answer-choice.wrong-answer .answer-letter {
  color: #ffffff;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  color: var(--text);
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #9fb0c8;
}

html[data-theme="dark"] .danger,
html[data-theme="dark"] .danger-btn,
html[data-theme="dark"] .danger-outline,
html[data-theme="dark"] .form-status.error,
html[data-theme="dark"] .latex-compile-status.error {
  color: var(--red);
}

/* UX_LAYOUT_PASS_V1 */
.settings-panel-main,
.tool-subpanel {
  display: grid;
  gap: 16px;
}

.settings-panel-main > h3,
.tool-subpanel > h3 {
  margin: 0;
}

.settings-section,
.tool-config-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(14px, 1.1vw, 18px);
  display: grid;
  gap: 14px;
  align-content: start;
}

.settings-section-title,
.tool-config-title {
  display: grid;
  gap: 4px;
}

.settings-section-title strong,
.tool-config-title strong {
  color: var(--text);
  font-size: clamp(1.06rem, 1vw, 1.22rem);
  line-height: 1.15;
}

.settings-section-title span,
.tool-config-title span {
  color: var(--muted);
  font-size: clamp(0.95rem, 0.85vw, 1.04rem);
  font-weight: 750;
  line-height: 1.3;
}

.tool-config-title.small-title {
  margin-top: 2px;
}

.settings-section .setting-block {
  margin: 0;
}

.settings-section .setting-line {
  margin: 0;
  align-items: center;
}

.settings-section .question-pick-summary {
  margin: 0;
}

.tool-config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  align-items: start;
}

.count-config-grid {
  grid-template-columns: minmax(320px, 1.35fr) minmax(260px, 0.85fr) minmax(280px, 1fr);
}

.mental-config-grid {
  grid-template-columns: minmax(300px, 0.95fr) minmax(360px, 1.25fr);
}

.compact-tool-fields {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.tool-config-section label,
.tool-config-section .inline-check {
  margin: 0;
}

.count-operation-picker {
  grid-template-columns: repeat(4, minmax(62px, 1fr));
}

.count-operation-picker .inline-check {
  min-height: 48px;
  justify-content: center;
}

.count-operation-picker .inline-check span {
  font-size: 1.25rem;
  font-weight: 950;
}

.count-method-choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.count-method-choice > strong {
  color: var(--text);
  font-size: 1rem;
}

.tool-large-toggle {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 11px 12px;
  min-height: 48px;
}

.settings-dropdown {
  background: var(--surface);
  border-color: var(--line);
}

.settings-dropdown > summary {
  min-height: 54px;
}

.settings-dropdown > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  transform: rotate(45deg);
}

.settings-dropdown[open] > summary::after {
  transform: rotate(225deg);
}

.tool-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: stretch;
}

.tool-actions-row button {
  flex: 1 1 190px;
}

.mental-actions-row button {
  flex-basis: 230px;
}

html[data-theme="dark"] .settings-section,
html[data-theme="dark"] .tool-config-section,
html[data-theme="dark"] .settings-dropdown {
  background: var(--surface);
  border-color: var(--line);
}

html[data-theme="dark"] .count-method-choice,
html[data-theme="dark"] .tool-large-toggle {
  background: var(--surface-soft);
  border-color: var(--line);
}

@media (max-width: 1100px) {
  .count-config-grid,
  .mental-config-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .settings-section,
  .tool-config-section {
    padding: 12px;
  }

  .compact-tool-fields,
  .count-operation-picker,
  .mental-dropdown-grid {
    grid-template-columns: 1fr;
  }

  .tool-actions-row button {
    flex-basis: 100%;
  }
}

/* UX_LAYOUT_PASS_V2 */
.count-main-settings {
  gap: 12px;
}

.count-main-settings .compact-tool-fields {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.count-main-settings .tool-config-title.small-title {
  margin-top: 0;
}

.count-operation-picker {
  gap: 8px;
}

#countTool .tool-actions-row {
  margin-top: -2px;
}

@media (min-width: 1101px) {
  .count-config-grid {
    grid-template-columns: minmax(360px, 1.25fr) minmax(260px, 0.75fr) minmax(300px, 0.9fr);
  }

  #countTool .tool-actions-row button {
    flex: 1 1 220px;
  }
}

@media (max-width: 720px) {
  .count-main-settings .compact-tool-fields {
    grid-template-columns: 1fr;
  }
}

/* UX_LAYOUT_PASS_V3 */
#mentalTool .compact-tool-fields {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

#mentalTool .tool-config-section {
  gap: 12px;
}

@media (min-width: 1101px) {
  .mental-config-grid {
    grid-template-columns: minmax(410px, 0.95fr) minmax(480px, 1.05fr);
  }
}

@media (max-width: 720px) {
  #mentalTool .compact-tool-fields {
    grid-template-columns: 1fr;
  }
}

/* UX_LAYOUT_PASS_V4 */
@media (max-width: 720px) {
  .chapter-check {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .chapter-check small {
    grid-column: auto;
    justify-self: end;
    align-self: center;
  }
}

/* PROJECTION_STAGE_V1 */
.projection-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3vw, 48px);
}

.projection-stage {
  width: min(1680px, 100%);
  min-height: min(820px, calc(100vh - 120px));
  display: grid;
  place-items: center;
}

.projection-card {
  width: 100%;
  min-height: min(760px, calc(100vh - 128px));
  display: grid;
  place-items: center;
  gap: clamp(18px, 2.4vw, 42px);
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
}

.projection-timer {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr);
  align-items: center;
  gap: 18px;
}

.projection-timer-text {
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 10px 18px;
  font-family: "Courier New", monospace;
  font-size: clamp(1.25rem, 2vw, 2.2rem);
  font-weight: 950;
}

.projection-timer-bar {
  height: clamp(16px, 1.5vw, 24px);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: var(--surface-soft);
}

.projection-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--primary);
  transition: width 0.25s linear;
}

.projection-question-card {
  align-content: center;
}

.projection-question-text {
  max-width: 96%;
  font-size: clamp(2.8rem, 5.5vw, 7.4rem);
  line-height: 1.1;
  font-weight: 900;
}

.projection-question-image {
  max-width: min(88vw, 1100px);
  max-height: min(48vh, 560px);
  object-fit: contain;
  background: #ffffff;
  border-radius: 8px;
}

.projection-answers {
  width: min(1280px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 1.4vw, 24px);
}

.projection-answers .answer-choice {
  min-height: clamp(92px, 10vh, 150px);
  font-size: clamp(1.55rem, 2.2vw, 2.8rem);
}

.projection-feedback {
  width: min(1280px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(18px, 2vw, 32px);
  font-size: clamp(1.45rem, 2vw, 2.8rem);
  line-height: 1.28;
}

.projection-count-card {
  align-content: center;
}

.projection-count-target {
  display: grid;
  gap: clamp(10px, 1vw, 18px);
}

.projection-count-target span {
  color: var(--muted);
  font-size: clamp(1.2rem, 1.8vw, 2.4rem);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.projection-count-target strong {
  color: var(--primary);
  font-size: clamp(6rem, 17vw, 18rem);
  line-height: 0.9;
  font-weight: 950;
}

.projection-count-numbers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(14px, 2vw, 34px);
}

.projection-count-number {
  min-width: clamp(84px, 9vw, 160px);
  min-height: clamp(72px, 7vw, 132px);
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 18px;
  font-size: clamp(2.6rem, 5vw, 6rem);
  line-height: 1;
  font-weight: 950;
}

.projection-mental-card {
  align-content: center;
}

.projection-mental-meta {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.2rem, 1.7vw, 2.2rem);
  font-weight: 850;
}

.projection-mental-expression {
  width: 100%;
  display: grid;
  place-items: center;
  color: var(--primary);
  font-size: clamp(5rem, 12vw, 15rem);
  line-height: 1;
  font-weight: 950;
}

.projection-empty-card p {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.7rem, 3vw, 3.4rem);
  font-weight: 900;
  line-height: 1.25;
}

body.projection-mode {
  overflow: hidden;
}

body.projection-mode .app {
  width: 100vw;
  max-width: none;
  min-height: 100vh;
  padding: 0;
}

body.projection-mode .topbar {
  position: fixed;
  top: 12px;
  right: 12px;
  left: auto;
  z-index: 50;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: flex-end;
  background: transparent;
}

body.projection-mode .brand,
body.projection-mode .top-actions > :not(#projectionBtn),
body.projection-mode #homeScreen,
body.projection-mode #gameScreen,
body.projection-mode .site-footer {
  display: none !important;
}

body.projection-mode #projectionBtn {
  min-width: 230px;
  min-height: 48px;
  background: var(--surface);
  color: var(--primary);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

body.projection-mode #projectionScreen {
  display: grid !important;
}

html[data-theme="dark"] .projection-question-image {
  background: #ffffff;
}

@media (max-width: 720px) {
  .projection-screen {
    padding: 74px 12px 16px;
  }

  .projection-stage,
  .projection-card {
    min-height: calc(100vh - 104px);
  }

  body.projection-mode .topbar {
    top: 8px;
    right: 8px;
    left: 8px;
  }

  body.projection-mode #projectionBtn {
    width: 100%;
    min-width: 0;
  }

  .projection-timer {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .projection-timer-text {
    justify-self: center;
  }

  .projection-question-text {
    font-size: clamp(2.4rem, 12vw, 4.6rem);
  }

  .projection-answers {
    grid-template-columns: 1fr;
  }

  .projection-count-target strong {
    font-size: clamp(5.4rem, 28vw, 9rem);
  }

  .projection-count-number {
    min-width: 70px;
    min-height: 62px;
    font-size: clamp(2.2rem, 13vw, 4rem);
  }

  .projection-mental-expression {
    font-size: clamp(4.2rem, 22vw, 8rem);
  }
}

/* PROJECTION_STAGE_V2 */
body.projection-mode #projectionScreen .projection-count-target span {
  color: var(--muted);
  font-size: clamp(1.2rem, 1.8vw, 2.4rem);
}

body.projection-mode #projectionScreen .projection-count-target strong {
  color: var(--primary);
  font-size: clamp(6rem, 17vw, 18rem) !important;
  line-height: 0.9;
}

body.projection-mode #projectionScreen .projection-count-number {
  color: var(--text);
  font-size: clamp(2.6rem, 5vw, 6rem) !important;
  line-height: 1;
}

body.projection-mode #projectionScreen .projection-mental-expression {
  color: var(--primary);
  font-size: clamp(5rem, 12vw, 15rem) !important;
}

body.projection-mode #projectionScreen .projection-question-text {
  color: var(--text);
  font-size: clamp(2.8rem, 5.5vw, 7.4rem) !important;
}

@media (max-width: 720px) {
  body.projection-mode #projectionScreen .projection-count-target strong {
    font-size: clamp(5.4rem, 28vw, 9rem) !important;
  }

  body.projection-mode #projectionScreen .projection-count-number {
    font-size: clamp(2.2rem, 13vw, 4rem) !important;
  }

  body.projection-mode #projectionScreen .projection-mental-expression {
    font-size: clamp(4.2rem, 22vw, 8rem) !important;
  }

  body.projection-mode #projectionScreen .projection-question-text {
    font-size: clamp(2.4rem, 12vw, 4.6rem) !important;
  }
}

/* PROJECTION_STAGE_V3 */
body.projection-mode #projectionScreen .projection-question-text {
  max-width: 100%;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  body.projection-mode #projectionScreen .projection-question-text {
    font-size: clamp(2rem, 8.8vw, 3.4rem) !important;
    line-height: 1.16;
  }
}

/* PROJECTION_STAGE_V4 */
body.projection-mode #projectionScreen .projection-question-text mjx-container,
body.projection-mode #projectionScreen .projection-mental-expression mjx-container {
  max-width: 100%;
  overflow: visible;
}

body.projection-mode #projectionScreen .projection-question-text svg,
body.projection-mode #projectionScreen .projection-mental-expression svg {
  max-width: 100%;
  height: auto;
}

@media (max-width: 720px) {
  body.projection-mode #projectionScreen .projection-question-text mjx-container {
    width: 100% !important;
  }
}



/* DARK_VISIBILITY_FIX_V1 */
.question-image,
.projection-question-image {
  display: block;
  width: auto !important;
  height: auto !important;
  max-width: min(100%, 900px);
  object-fit: contain;
  object-position: center;
}

.question-image {
  max-height: min(48vh, 520px);
}

.projection-question-image {
  max-width: min(88vw, 1100px);
  max-height: min(48vh, 560px);
}

.answer-choice {
  min-width: 0;
}

.answer-choice > span:not(.answer-letter) {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.answer-letter {
  box-sizing: border-box;
  flex: 0 0 auto !important;
  width: clamp(38px, 2.4vw, 48px) !important;
  height: clamp(38px, 2.4vw, 48px) !important;
  min-width: clamp(38px, 2.4vw, 48px);
  min-height: clamp(38px, 2.4vw, 48px);
  aspect-ratio: 1 / 1;
  padding: 0;
  line-height: 1;
  text-align: center;
}

body.projection-mode #projectionScreen .answer-letter {
  width: clamp(52px, 4.2vw, 78px) !important;
  height: clamp(52px, 4.2vw, 78px) !important;
  min-width: clamp(52px, 4.2vw, 78px);
  min-height: clamp(52px, 4.2vw, 78px);
  font-size: clamp(1.35rem, 1.9vw, 2.2rem);
}

html[data-theme="dark"] .tool-launch-card,
html[data-theme="dark"] .tool-tab,
html[data-theme="dark"] .mode-card,
html[data-theme="dark"] .settings-section,
html[data-theme="dark"] .tool-config-section,
html[data-theme="dark"] .settings-dropdown,
html[data-theme="dark"] .setting-check,
html[data-theme="dark"] .check-card,
html[data-theme="dark"] .choice-checklist,
html[data-theme="dark"] .question-pick-list,
html[data-theme="dark"] .editable-question-item,
html[data-theme="dark"] .resource-link,
html[data-theme="dark"] .answer-choice,
html[data-theme="dark"] .team-answer-btn,
html[data-theme="dark"] .social-link,
html[data-theme="dark"] .home-social-panel {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .tool-launch-card:hover,
html[data-theme="dark"] .tool-tab:hover,
html[data-theme="dark"] .mode-card:hover,
html[data-theme="dark"] .setting-check:hover,
html[data-theme="dark"] .check-card:hover,
html[data-theme="dark"] .resource-link:hover,
html[data-theme="dark"] .answer-choice:hover,
html[data-theme="dark"] .team-answer-btn:hover,
html[data-theme="dark"] .social-link:hover {
  background: var(--surface-hover) !important;
  border-color: var(--line-strong) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .level-grid-large .level-btn:not(.selected):hover {
  background: var(--surface-hover) !important;
  border-color: var(--line-strong) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .tool-launch-card strong,
html[data-theme="dark"] .mode-card strong,
html[data-theme="dark"] .setting-check span,
html[data-theme="dark"] .check-card span,
html[data-theme="dark"] .team-answer-btn,
html[data-theme="dark"] .social-link span,
html[data-theme="dark"] .answer-choice > span:not(.answer-letter) {
  color: var(--text) !important;
}

html[data-theme="dark"] .tool-launch-icon,
html[data-theme="dark"] .utility-logo,
html[data-theme="dark"] .answer-letter {
  background: var(--primary-soft) !important;
  border-color: rgba(147, 197, 253, 0.45) !important;
  color: var(--primary) !important;
}

html[data-theme="dark"] .primary-btn,
html[data-theme="dark"] .primary-btn *,
html[data-theme="dark"] .level-btn.selected,
html[data-theme="dark"] .level-btn.selected *,
html[data-theme="dark"] .tool-tab.selected,
html[data-theme="dark"] .tool-tab.selected *,
html[data-theme="dark"] .mode-card.selected,
html[data-theme="dark"] .mode-card.selected *,
html[data-theme="dark"] .team-answer-btn.selected,
html[data-theme="dark"] .team-answer-btn.selected * {
  color: #ffffff !important;
}

html[data-theme="dark"] .tool-tab.selected,
html[data-theme="dark"] .mode-card.selected,
html[data-theme="dark"] .team-answer-btn.selected {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%) !important;
  border-color: #60a5fa !important;
}

html[data-theme="dark"] .answer-choice.correct-answer .answer-letter,
html[data-theme="dark"] .answer-choice.wrong-answer .answer-letter {
  color: #ffffff !important;
}

html[data-theme="dark"] .answer-choice.correct-answer .answer-letter {
  background: var(--green) !important;
}

html[data-theme="dark"] .answer-choice.wrong-answer .answer-letter {
  background: var(--red) !important;
}

@media (max-width: 720px) {
  .answer-letter {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px;
    min-height: 38px;
  }

  .question-image {
    max-width: 100%;
    max-height: 42vh;
  }
}


/* TOOL_DARK_AND_PROJECTION_REWORK_V1 */
html[data-theme="dark"] .brand span {
  color: #ffffff;
}

html[data-theme="dark"] .brand img {
  filter: invert(1) brightness(1.55) contrast(1.05);
}

html[data-theme="dark"] .tool-panel,
html[data-theme="dark"] .tool-subpanel,
html[data-theme="dark"] .tool-display-card,
html[data-theme="dark"] .tool-big-result,
html[data-theme="dark"] .count-puzzle-card,
html[data-theme="dark"] .count-solutions,
html[data-theme="dark"] .multiplication-table-card,
html[data-theme="dark"] .multiplication-row,
html[data-theme="dark"] .operation-picker .inline-check,
html[data-theme="dark"] .mental-operation-picker .inline-check,
html[data-theme="dark"] .mental-number-picker .inline-check,
html[data-theme="dark"] .mental-series-list li,
html[data-theme="dark"] .mental-correction-list li,
html[data-theme="dark"] .solution-steps-card,
html[data-theme="dark"] .timer-inputs label {
  background: var(--surface) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .tool-display,
html[data-theme="dark"] .tool-mode-label,
html[data-theme="dark"] .tool-big-result,
html[data-theme="dark"] .multiplication-row span,
html[data-theme="dark"] .mental-series-list li span,
html[data-theme="dark"] .mental-correction-list li span,
html[data-theme="dark"] .solution-steps-card li {
  color: var(--text) !important;
}

html[data-theme="dark"] .count-target-card,
html[data-theme="dark"] .count-number-chip {
  background: var(--primary-soft) !important;
  border-color: rgba(147, 197, 253, 0.45) !important;
  color: var(--primary) !important;
}

html[data-theme="dark"] .count-target-card strong,
html[data-theme="dark"] .multiplication-row strong,
html[data-theme="dark"] .mental-correction-list strong,
html[data-theme="dark"] .solution-steps-card strong {
  color: var(--primary) !important;
}

html[data-theme="dark"] .timer-presets .mini-btn:hover,
html[data-theme="dark"] .operation-picker .inline-check:hover,
html[data-theme="dark"] .mental-operation-picker .inline-check:hover,
html[data-theme="dark"] .mental-number-picker .inline-check:hover {
  background: var(--surface-hover) !important;
  border-color: var(--line-strong) !important;
}

body.projection-mode #projectionScreen {
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 32vw),
    var(--bg);
}

body.projection-mode .topbar {
  z-index: 25;
}

body.projection-mode #projectionBtn {
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.16);
}

.projection-stage {
  width: min(1760px, 100%);
  min-height: calc(100vh - 116px);
  align-items: stretch;
}

.projection-card {
  min-height: calc(100vh - 126px);
  align-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: clamp(18px, 2.4vw, 42px);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

.projection-question-shell,
.projection-count-shell,
.projection-mental-shell,
.projection-clock-shell {
  width: 100%;
  display: grid;
  gap: clamp(12px, 1.5vw, 24px);
  justify-items: center;
}

.projection-question-header {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.projection-question-header span {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  padding: 8px 12px;
  font-size: clamp(1rem, 1.25vw, 1.45rem);
  font-weight: 900;
  text-align: center;
}

.projection-difficulty-track {
  width: 100%;
  margin: 0;
}

.projection-question-box {
  width: 100%;
  min-height: clamp(280px, 43vh, 620px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  gap: clamp(12px, 1.4vw, 22px);
  padding: clamp(22px, 3vw, 52px);
}

body.projection-mode #projectionScreen .projection-question-text {
  color: var(--text);
  font-size: clamp(2.2rem, 4.3vw, 5.8rem) !important;
  line-height: 1.12;
  font-weight: 950;
}

.projection-question-image {
  max-width: min(100%, 1080px) !important;
  max-height: min(42vh, 520px) !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
}

.projection-actions {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.projection-actions button {
  min-height: 54px;
  min-width: min(260px, 100%);
  padding: 12px 20px;
  font-size: clamp(1rem, 1.15vw, 1.35rem);
  font-weight: 950;
}

.projection-clock-card,
.projection-dice-card,
.projection-tables-card,
.projection-count-card,
.projection-mental-card {
  align-content: center;
}

.projection-tool-title {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1.25rem, 1.8vw, 2.2rem);
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.projection-clock-value {
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: clamp(6rem, 17vw, 18rem);
  font-weight: 950;
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.projection-tool-message {
  margin: 0;
  color: var(--red);
  font-size: clamp(1.25rem, 2vw, 2.6rem);
  font-weight: 950;
}

.projection-dice-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: clamp(14px, 2vw, 28px);
}

.projection-die {
  min-height: clamp(190px, 22vw, 340px);
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 18px;
}

.projection-die-type,
.projection-die span:last-child {
  color: var(--muted);
  font-weight: 900;
}

.projection-die strong {
  color: var(--primary);
  font-size: clamp(5rem, 12vw, 14rem);
  line-height: 0.9;
  font-weight: 950;
}

.projection-table-wrap {
  width: 100%;
}

.projection-table-wrap .multiplication-table-result {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(12px, 1.4vw, 24px);
}

.projection-table-wrap .multiplication-table-card {
  padding: clamp(14px, 1.5vw, 22px);
}

.projection-table-wrap .multiplication-table-card h4 {
  font-size: clamp(1.25rem, 1.5vw, 2rem);
}

.projection-table-wrap .multiplication-row {
  min-height: 56px;
  font-size: clamp(1.15rem, 1.35vw, 1.8rem);
}

.projection-count-shell .projection-timer,
.projection-mental-shell .projection-timer {
  width: min(980px, 100%);
}

.projection-solution-panel {
  width: min(1280px, 100%);
  max-height: 34vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: clamp(14px, 1.4vw, 24px);
  text-align: left;
  font-size: clamp(1rem, 1.2vw, 1.45rem);
}

.projection-solution-panel h4 {
  margin-top: 0;
}

body.projection-mode #projectionScreen .projection-mental-expression {
  min-height: clamp(220px, 36vh, 520px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--primary);
  font-size: clamp(4rem, 10vw, 13rem) !important;
  padding: clamp(20px, 3vw, 48px);
}

@media (max-width: 820px) {
  .projection-question-header {
    grid-template-columns: 1fr 1fr;
  }

  .projection-card {
    min-height: calc(100vh - 104px);
    padding: 14px;
  }

  .projection-clock-value {
    font-size: clamp(4.4rem, 22vw, 9rem);
  }

  .projection-actions button {
    min-width: 0;
    flex: 1 1 180px;
  }
}


/* DARK_FORMS_AND_PROJECTION_FIX_V1 */
html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--surface-soft) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  caret-color: var(--text);
}

html[data-theme="dark"] input:hover,
html[data-theme="dark"] select:hover,
html[data-theme="dark"] textarea:hover {
  background: var(--surface-hover) !important;
  border-color: var(--line-strong) !important;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  outline: 2px solid rgba(147, 197, 253, 0.45);
  outline-offset: 2px;
}

html[data-theme="dark"] option {
  background: var(--surface) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #9fb0c8 !important;
}

#listTool .tool-actions-row,
#drawTool .tool-actions-row,
#groupsTool .tool-actions-row {
  gap: 6px;
}

#listTool .tool-actions-row button,
#drawTool .tool-actions-row button,
#groupsTool .tool-actions-row button {
  min-height: 38px;
  padding: 8px 12px;
  font-size: 0.95rem;
  line-height: 1.1;
  flex: 0 1 auto;
}

#groupsTool #makeGroupsBtn {
  max-width: max-content;
}

body.projection-mode #projectionScreen {
  padding: 94px clamp(14px, 2.4vw, 42px) clamp(14px, 2.4vw, 42px);
}

body.projection-mode .topbar {
  z-index: 60;
}

body.projection-mode #projectionStage {
  min-height: calc(100vh - 136px);
}

body.projection-mode #projectionScreen .projection-card {
  min-height: calc(100vh - 152px);
}

body.projection-mode #projectionScreen .projection-clock-card {
  place-items: center;
}

body.projection-mode #projectionScreen .projection-clock-shell {
  min-height: calc(100vh - 230px);
  align-content: center;
  justify-content: center;
  gap: clamp(16px, 2vw, 30px);
}

body.projection-mode #projectionScreen .projection-clock-value {
  width: min(1120px, 100%);
  text-align: center;
  font-size: clamp(7rem, 16vw, 18rem);
}

.projection-dice-card {
  align-content: center;
}

.projection-dice-grid {
  align-items: center;
}

.projection-die {
  min-height: clamp(260px, 30vw, 470px);
  align-content: center;
}

.projection-die-solid {
  width: clamp(130px, 17vw, 290px);
  aspect-ratio: 1;
  border: 3px solid var(--line);
  border-radius: 24px;
  background:
    linear-gradient(145deg, rgba(255,255,255,0.96), rgba(219,234,254,0.92));
  box-shadow:
    inset 10px 10px 22px rgba(255,255,255,0.62),
    inset -14px -14px 26px rgba(37, 99, 235, 0.16),
    0 28px 46px rgba(15, 23, 42, 0.18);
  display: grid;
  place-items: center;
  transform-style: preserve-3d;
}

html[data-theme="dark"] .projection-die-solid {
  background:
    linear-gradient(145deg, rgba(248,250,252,0.96), rgba(191,219,254,0.90));
  border-color: rgba(147, 197, 253, 0.55);
}

.projection-die-solid span {
  color: #1d4ed8;
  font-size: clamp(4.4rem, 10vw, 13rem);
  font-weight: 950;
  line-height: 0.9;
}

.projection-die.rolling .projection-die-solid {
  animation: projection-die-spin 0.72s ease-in-out infinite;
}

.projection-die.rolling .projection-die-solid span {
  animation: projection-die-number 0.18s linear infinite alternate;
}

.projection-die-result {
  color: var(--muted);
  font-size: clamp(1.05rem, 1.35vw, 1.7rem);
  font-weight: 900;
}

@keyframes projection-die-spin {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg) scale(1); }
  35% { transform: rotateX(46deg) rotateY(128deg) rotateZ(-14deg) scale(1.04); }
  70% { transform: rotateX(138deg) rotateY(244deg) rotateZ(18deg) scale(0.98); }
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(0deg) scale(1); }
}

@keyframes projection-die-number {
  from { opacity: 0.35; transform: scale(0.84); }
  to { opacity: 1; transform: scale(1.08); }
}

@media (max-width: 820px) {
  body.projection-mode #projectionScreen {
    padding: 78px 12px 14px;
  }

  body.projection-mode #projectionScreen .projection-clock-shell {
    min-height: calc(100vh - 190px);
  }
}


/* TOOL_COMPACT_ACTION_BUTTONS_V1 */
#listTool .tool-actions-row,
#drawTool .tool-actions-row,
#groupsTool .tool-actions-row {
  align-items: center;
  align-content: flex-start;
}

#listTool .tool-actions-row button,
#drawTool .tool-actions-row button,
#groupsTool .tool-actions-row button {
  align-self: flex-start;
  height: auto;
}


/* TOOL_DECLUTTER_AND_PROJECTION_FIX_V1 */
.tool-mode-label,
.timer-presets,
#diceTool .tool-subpanel > h3,
#tablesTool .tool-subpanel > h3,
.platonic-label,
.projection-die-type {
  display: none !important;
}

#groupsTool .tool-field-grid,
#diceTool .tool-field-grid,
#tablesTool .tool-field-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

#groupRemainderSelect {
  font-size: clamp(0.92rem, 0.9vw, 1rem);
  white-space: normal;
}

#countTool .count-config-grid {
  grid-template-columns: minmax(360px, 1.35fr) minmax(240px, 0.65fr);
}

#countTool .tool-config-title span,
#mentalTool .tool-config-title span {
  display: none !important;
}

#countSolutions.hidden,
#mentalAnswerDisplay.hidden {
  display: none !important;
}

body.projection-mode #projectionScreen {
  justify-items: stretch;
}

body.projection-mode #projectionStage,
body.projection-mode #projectionScreen .projection-card,
body.projection-mode #projectionScreen .projection-clock-card,
body.projection-mode #projectionScreen .projection-clock-shell {
  width: 100% !important;
  max-width: none !important;
  justify-self: stretch !important;
}

body.projection-mode #projectionScreen .projection-clock-card {
  display: grid;
  place-items: center;
}

body.projection-mode #projectionScreen .projection-clock-shell {
  place-items: center;
  text-align: center;
}

body.projection-mode #projectionScreen .projection-clock-value {
  justify-self: center;
}

body.projection-mode #projectionScreen .projection-dice-card {
  gap: clamp(18px, 2.4vw, 34px);
}

body.projection-mode #projectionScreen .projection-dice3d-grid,
body.projection-mode #projectionScreen .projection-platonic-grid {
  width: min(1400px, 100%);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(18px, 2.2vw, 34px);
  align-items: center;
}

body.projection-mode #projectionScreen .dice3d-stage,
body.projection-mode #projectionScreen .platonic-solid {
  width: clamp(180px, 20vw, 340px);
  max-width: 100%;
}

body.projection-mode #projectionScreen .dice-roll-result {
  font-size: clamp(1.4rem, 2.1vw, 2.6rem);
  font-weight: 950;
}

@media (max-width: 980px) {
  #countTool .count-config-grid {
    grid-template-columns: 1fr;
  }
}


/* PROJECTION_DICE_SHARPNESS_V1 */
body.projection-mode #projectionScreen .dice3d-canvas {
  image-rendering: auto;
}

/* PROJECTION_QUESTION_SCROLL_FIT_V1 */
body.projection-mode #projectionScreen {
  overflow-y: auto;
}

body.projection-mode #projectionStage {
  align-items: start;
}

body.projection-mode #projectionScreen .projection-question-card {
  min-height: auto !important;
  max-height: calc(100vh - 132px);
  overflow-y: auto;
  align-content: start;
}

body.projection-mode #projectionScreen .projection-question-shell {
  min-height: 0;
  align-content: start;
  gap: clamp(8px, 1.1vw, 18px);
}

body.projection-mode #projectionScreen .projection-question-box {
  min-height: min(38vh, 430px);
  max-height: min(48vh, 560px);
  overflow-y: auto;
  padding: clamp(16px, 2.4vw, 40px);
}

body.projection-mode #projectionScreen .projection-question-image {
  max-height: min(30vh, 380px) !important;
}

body.projection-mode #projectionScreen .projection-answers {
  max-height: min(31vh, 330px);
  overflow-y: auto;
  padding-right: 2px;
}

body.projection-mode #projectionScreen .projection-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 10px 0 2px;
}

@media (max-height: 780px) {
  body.projection-mode #projectionScreen {
    padding-top: 78px;
  }

  body.projection-mode #projectionScreen .projection-question-card {
    max-height: calc(100vh - 104px);
    padding: clamp(12px, 1.8vw, 26px);
  }

  body.projection-mode #projectionScreen .projection-question-header span {
    min-height: 38px;
    font-size: clamp(0.9rem, 1.45vw, 1.2rem);
  }

  body.projection-mode #projectionScreen .projection-question-box {
    min-height: min(32vh, 330px);
    max-height: min(42vh, 430px);
  }

  body.projection-mode #projectionScreen .projection-question-text {
    font-size: clamp(1.7rem, 4.2vw, 4.4rem) !important;
  }

  body.projection-mode #projectionScreen .projection-actions button {
    min-height: 48px;
    padding: 10px 16px;
  }
}

/* PROJECTION_QUESTION_ACTIONS_IN_SCROLL_V1 */
body.projection-mode #projectionScreen .projection-question-card .projection-actions {
  position: static;
  bottom: auto;
  z-index: auto;
  background: transparent;
  border-top: 0;
  padding: 0;
}

/* PROJECTION_TIMER_STAGE_CENTER_FIX_V1 */
body.projection-mode #projectionStage.projection-timer,
body.projection-mode #projectionStage.projection-stopwatch {
  width: min(1760px, 100%) !important;
  max-width: none !important;
  min-height: calc(100vh - 136px);
  display: grid !important;
  grid-template-columns: 1fr !important;
  place-items: center !important;
  gap: 0 !important;
  justify-self: stretch !important;
}

body.projection-mode #projectionStage.projection-timer .projection-clock-card,
body.projection-mode #projectionStage.projection-stopwatch .projection-clock-card {
  width: 100% !important;
  max-width: none !important;
  justify-self: stretch !important;
  align-self: center !important;
}

/* PROJECTION_BACKGROUNDS_AND_CLOCK_V1 */
.projection-background-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.projection-background-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.projection-background-heading strong {
  color: var(--primary);
}

.projection-background-heading span,
.projection-background-status {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 800;
}

.projection-background-status {
  margin: 0;
}

.projection-background-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}

.projection-bg-choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  padding: 8px;
  display: grid;
  gap: 7px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.projection-bg-choice:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.12);
}

.projection-bg-choice.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.projection-bg-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft) center / cover no-repeat;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 950;
}

body.projection-mode #projectionStage.projection-clock,
body.projection-mode #projectionStage.projection-timer,
body.projection-mode #projectionStage.projection-stopwatch {
  width: min(1760px, 100%) !important;
  max-width: none !important;
  min-height: calc(100vh - 136px);
  display: grid !important;
  grid-template-columns: 1fr !important;
  place-items: center !important;
  gap: 0 !important;
  justify-self: stretch !important;
}

body.projection-mode #projectionStage.projection-clock .projection-clock-card,
body.projection-mode #projectionStage.projection-timer .projection-clock-card,
body.projection-mode #projectionStage.projection-stopwatch .projection-clock-card {
  width: min(100%, 142vh, 1760px) !important;
  max-width: none !important;
  min-height: 0 !important;
  aspect-ratio: 16 / 9;
  align-self: center !important;
  justify-self: center !important;
  position: relative;
  overflow: hidden;
  background: var(--surface);
}

body.projection-mode #projectionScreen .projection-clock-card.has-projection-background {
  background-image:
    linear-gradient(90deg, rgba(8, 16, 32, 0.64), rgba(8, 16, 32, 0.28)),
    var(--projection-bg-image);
  background-size: cover;
  background-position: center;
}

body.projection-mode #projectionScreen .projection-clock-card.has-projection-background .projection-clock-shell {
  color: #ffffff;
}

body.projection-mode #projectionScreen .projection-clock-card.has-projection-background .projection-clock-value,
body.projection-mode #projectionScreen .projection-clock-card.has-projection-background .projection-tool-message {
  color: #ffffff;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.48);
}

body.projection-mode #projectionScreen .projection-clock-card.has-projection-background .projection-actions {
  max-width: min(760px, 100%);
}

body.projection-mode #projectionScreen .projection-clock-card.has-projection-background .projection-actions .secondary-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.34);
}

/* CLOCK_BACKGROUND_LAYOUT_V2 */
.tool-display-card {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  align-content: center;
  isolation: isolate;
}

.tool-display-card.has-tool-background {
  background-image:
    linear-gradient(90deg, rgba(8, 16, 32, 0.62), rgba(8, 16, 32, 0.24)),
    var(--clock-bg-image);
  background-size: cover;
  background-position: center;
  border-color: rgba(147, 197, 253, 0.65);
}

.tool-display-card.has-tool-background .tool-mode-label,
.tool-display-card.has-tool-background .tool-display,
.tool-display-card.has-tool-background .tool-end-message {
  color: #ffffff;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}

body.projection-mode #projectionStage.projection-clock .projection-clock-card,
body.projection-mode #projectionStage.projection-timer .projection-clock-card,
body.projection-mode #projectionStage.projection-stopwatch .projection-clock-card {
  aspect-ratio: auto !important;
  min-height: calc(100vh - 152px) !important;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(14px, 1.8vw, 28px);
  overflow: visible;
  background: transparent !important;
  border-color: transparent;
  box-shadow: none;
}

body.projection-mode #projectionScreen .projection-clock-frame {
  width: min(100%, 142vh, 1760px);
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

body.projection-mode #projectionScreen .projection-clock-frame .projection-clock-shell {
  width: 100%;
  height: 100%;
  min-height: 0 !important;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: clamp(18px, 3vw, 52px);
}

body.projection-mode #projectionScreen .projection-clock-frame.has-projection-background {
  background-image:
    linear-gradient(90deg, rgba(8, 16, 32, 0.64), rgba(8, 16, 32, 0.28)),
    var(--clock-bg-image);
  background-size: cover;
  background-position: center;
}

body.projection-mode #projectionScreen .projection-clock-frame.has-projection-background .projection-clock-value,
body.projection-mode #projectionScreen .projection-clock-frame.has-projection-background .projection-tool-message {
  color: #ffffff;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.48);
}

body.projection-mode #projectionScreen .projection-clock-card .projection-actions {
  width: min(760px, 100%);
  background: transparent;
  border-top: 0;
  padding: 0;
}

/* CLOCK_BACKGROUND_SIZE_AND_SHARPNESS_V3 */
.tool-display-card {
  width: min(100%, 720px);
  justify-self: center;
  min-height: 0;
  padding: clamp(14px, 2.4vw, 26px);
}

.tool-display-card.has-tool-background {
  background-image: none !important;
}

.tool-display-card.has-tool-background::before,
body.projection-mode #projectionScreen .projection-clock-frame.has-projection-background::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--clock-bg-image);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: auto;
}

.tool-display-card.has-tool-background::after,
body.projection-mode #projectionScreen .projection-clock-frame.has-projection-background::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(90deg, rgba(8, 16, 32, 0.50), rgba(8, 16, 32, 0.16));
  pointer-events: none;
}

.tool-display-card > * {
  position: relative;
  z-index: 1;
}

.tool-display-card .tool-display {
  font-size: clamp(2.8rem, 7vw, 5.8rem);
}

body.projection-mode #projectionScreen {
  overflow: hidden;
}

body.projection-mode #projectionStage.projection-clock,
body.projection-mode #projectionStage.projection-timer,
body.projection-mode #projectionStage.projection-stopwatch {
  min-height: calc(100vh - 118px);
  align-items: center !important;
}

body.projection-mode #projectionStage.projection-clock .projection-clock-card,
body.projection-mode #projectionStage.projection-timer .projection-clock-card,
body.projection-mode #projectionStage.projection-stopwatch .projection-clock-card {
  min-height: calc(100vh - 124px) !important;
  padding: 0 !important;
  gap: clamp(10px, 1.4vw, 20px);
  align-content: center;
}

body.projection-mode #projectionScreen .projection-clock-frame {
  width: min(calc(100vw - clamp(24px, 4vw, 78px)), calc((100vh - 178px) * 16 / 9));
  max-width: none;
  max-height: calc(100vh - 178px);
  justify-self: center;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.16);
}

body.projection-mode #projectionScreen .projection-clock-frame.has-projection-background {
  background-image: none !important;
}

body.projection-mode #projectionScreen .projection-clock-frame .projection-clock-shell {
  position: relative;
  z-index: 1;
}

body.projection-mode #projectionScreen .projection-clock-card .projection-actions {
  flex: 0 0 auto;
}

@media (min-width: 1400px) {
  .tool-display-card {
    width: min(100%, 660px);
  }
}

@media (max-height: 760px) {
  body.projection-mode #projectionScreen .projection-clock-frame {
    width: min(calc(100vw - 28px), calc((100vh - 132px) * 16 / 9));
    max-height: calc(100vh - 132px);
  }

  body.projection-mode #projectionStage.projection-clock .projection-clock-card,
  body.projection-mode #projectionStage.projection-timer .projection-clock-card,
  body.projection-mode #projectionStage.projection-stopwatch .projection-clock-card {
    gap: 8px;
  }
}

@media (max-width: 720px) {
  .tool-display-card {
    width: 100%;
  }
}

/* RESPONSIVE_TEXT_FIT_V1 */
.tool-display-card,
body.projection-mode #projectionScreen .projection-clock-frame,
body.projection-mode #projectionScreen .projection-question-box,
body.projection-mode #projectionScreen .projection-count-shell,
body.projection-mode #projectionScreen .projection-mental-shell {
  container-type: inline-size;
}

.tool-display-card .tool-display {
  max-width: 94%;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
  font-size: clamp(2.15rem, 15cqw, 5.2rem) !important;
}

body.projection-mode #projectionScreen .projection-clock-frame .projection-clock-value {
  max-width: 94%;
  white-space: nowrap;
  overflow: hidden;
  text-align: center;
  font-size: clamp(3.4rem, 15.5cqw, 16rem) !important;
  line-height: 1;
}

body.projection-mode #projectionScreen .projection-clock-frame .projection-tool-message {
  max-width: 94%;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 2.2cqw, 2.2rem) !important;
}

body.projection-mode #projectionScreen .projection-question-box .projection-question-text {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(1.55rem, 5cqw, 5rem) !important;
}

body.projection-mode #projectionScreen .projection-mental-expression {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(3rem, 12cqw, 11rem) !important;
}

body.projection-mode #projectionScreen .projection-count-target strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(4rem, 18cqw, 16rem) !important;
}

body.projection-mode #projectionScreen .projection-count-number {
  font-size: clamp(2rem, 6cqw, 5.5rem) !important;
}

@media (max-width: 520px) {
  .tool-display-card .tool-display {
    font-size: clamp(1.9rem, 14cqw, 3.4rem) !important;
  }
}

/* TINY_PROJECTION_HEIGHT_FIT_V1 */
@media (max-height: 520px) {
  body.projection-mode #projectionStage.projection-clock .projection-clock-card,
  body.projection-mode #projectionStage.projection-timer .projection-clock-card,
  body.projection-mode #projectionStage.projection-stopwatch .projection-clock-card {
    min-height: calc(100vh - 144px) !important;
    gap: 6px !important;
  }

  body.projection-mode #projectionScreen .projection-clock-frame {
    width: min(calc(100vw - 28px), calc((100vh - 156px) * 16 / 9)) !important;
    max-height: calc(100vh - 156px) !important;
  }

  body.projection-mode #projectionScreen .projection-clock-card .projection-actions {
    min-height: 0;
  }
}

/* CLOCK_PROJECTION_CLIPPING_AND_CLOCK_MODE_V1 */
.tool-display-card .tool-display {
  display: inline-block;
  width: auto !important;
  max-width: calc(100% - 24px) !important;
  padding-inline: 0.12em;
  box-sizing: content-box;
  overflow: visible !important;
}

body.projection-mode #projectionScreen .projection-clock-frame .projection-clock-value {
  display: inline-block;
  width: auto !important;
  max-width: calc(100% - clamp(34px, 6cqw, 96px)) !important;
  padding-inline: 0.12em;
  box-sizing: content-box;
  overflow: visible !important;
  font-size: clamp(3.1rem, 14.4cqw, 15rem) !important;
  letter-spacing: 0.01em;
}

body.projection-mode #projectionScreen .projection-clock-frame .projection-clock-shell {
  overflow: visible;
}

@media (max-width: 520px) {
  .tool-display-card .tool-display {
    max-width: calc(100% - 18px) !important;
    font-size: clamp(1.85rem, 13.2cqw, 3.25rem) !important;
  }
}

/* LOCAL_PROJECTION_BUTTONS_V1 */
#toolControls {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

#toolControls.clock-projection-only {
  grid-template-columns: repeat(2, minmax(220px, 360px));
  justify-content: center;
}

.local-projection-btn {
  white-space: nowrap;
}

@media (max-width: 720px) {
  #toolControls,
  #toolControls.clock-projection-only {
    grid-template-columns: 1fr;
  }
}

/* GLOBAL_BACK_AND_TOOL_TABS_SIMPLIFY_V1 */
.page-back-btn,
.tool-tabs {
  display: none !important;
}

.top-actions #gameBackBtn {
  order: -10;
}

@media (max-width: 720px) {
  .top-actions #gameBackBtn {
    grid-column: 1 / -1;
  }
}

/* BACKGROUND_TIMER_DICE_TABLE_POLISH_V1 */
.projection-background-heading {
  justify-content: flex-start;
}

.projection-background-choices {
  grid-template-columns: repeat(auto-fit, minmax(76px, 92px));
  justify-content: start;
  align-items: start;
}

.projection-bg-choice {
  padding: 5px;
  gap: 4px;
  font-size: 0.78rem;
}

.projection-bg-thumb {
  border-radius: 5px;
}

.timer-inputs {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

/* TOOL_TITLE_TABLE_COUNT_POLISH_V1 */
.tool-page-title {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-left: 10px;
  color: var(--text);
  font-size: clamp(1.3rem, 2vw, 2rem);
  line-height: 1.05;
  font-weight: 950;
}

.count-puzzle-card {
  grid-template-columns: minmax(120px, 0.32fr) minmax(220px, 1fr) minmax(170px, 0.42fr);
}

.count-operations-display,
.count-operations-display-inner {
  min-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  padding: 12px;
  display: grid;
  place-items: center;
  gap: 7px;
  text-align: center;
  font-weight: 900;
}

.count-operations-display-inner {
  width: 100%;
}

.count-operations-display span,
.count-operations-display-inner span {
  font-size: 0.94rem;
}

.count-operations-display strong,
.count-operations-display-inner strong {
  color: var(--primary);
  font-size: clamp(1.45rem, 2.6vw, 2.4rem);
  line-height: 1;
  letter-spacing: 0.08em;
}

.projection-count-operations {
  width: min(100%, 900px);
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: clamp(12px, 1.6vw, 24px);
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 950;
  text-align: center;
}

.projection-count-operations span {
  font-size: clamp(1.1rem, 1.6vw, 2rem);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.projection-count-operations strong {
  color: var(--primary);
  font-size: clamp(2.4rem, 5cqw, 5.5rem);
  line-height: 1;
  letter-spacing: 0.1em;
}

@media (max-width: 780px) {
  .tool-page-title {
    display: flex;
    margin: 8px 0 0;
  }

  .count-puzzle-card {
    grid-template-columns: 1fr;
  }
}

/* NAV_TABLE_MENTAL_FLOW_V1 */
.multiplication-table-rows {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  align-items: start;
}

.multiplication-column {
  display: grid;
  gap: 8px;
  align-content: start;
}

.multiplication-row {
  min-height: 48px;
  padding: 10px 12px;
  font-size: clamp(1rem, 1.15vw, 1.25rem);
}

.multiplication-row span {
  white-space: nowrap;
}

.projection-table-wrap .multiplication-table-rows {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: clamp(10px, 1vw, 18px);
}

.projection-table-wrap .multiplication-column {
  gap: clamp(8px, 0.8vw, 12px);
}

.projection-table-wrap .multiplication-row {
  min-height: clamp(42px, 4.8vh, 58px);
  padding: clamp(8px, 0.8vw, 12px);
  font-size: clamp(1.2rem, 1.65vw, 2.05rem);
}

.projection-table-wrap .multiplication-row strong {
  font-size: 1.12em;
}

@media (max-width: 720px) {
  .multiplication-table-rows,
  .projection-table-wrap .multiplication-table-rows {
    grid-template-columns: 1fr;
  }

  .multiplication-row span {
    white-space: normal;
  }
}

/* PROJECTION_TABLE_FIT_AND_MENTAL_GRID_V1 */
body.projection-mode #projectionScreen .projection-tables-card {
  align-content: stretch;
  padding: clamp(8px, 1vw, 16px);
}

body.projection-mode #projectionScreen .projection-table-wrap {
  height: 100%;
  max-height: calc(100vh - 96px);
  overflow: hidden;
  display: grid;
  align-items: center;
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-table-result {
  height: 100%;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: clamp(8px, 0.9vw, 14px);
  align-items: stretch;
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-table-card {
  min-height: 0;
  height: 100%;
  padding: clamp(8px, 0.9vw, 14px);
  gap: clamp(5px, 0.6vw, 9px);
  align-content: center;
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-table-card h4 {
  font-size: clamp(1rem, 1.15vw, 1.45rem);
  line-height: 1;
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-table-rows {
  min-height: 0;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: clamp(4px, 0.5vw, 8px);
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-column {
  min-height: 0;
  gap: clamp(3px, 0.4vw, 5px);
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-row {
  min-height: 0;
  padding: clamp(4px, 0.5vw, 7px) clamp(8px, 0.7vw, 11px);
  border-radius: 6px;
  font-size: clamp(1rem, 1.1vw, 1.42rem);
  line-height: 1;
}

body.projection-mode #projectionScreen .projection-table-wrap .multiplication-row strong {
  font-size: 1.08em;
}

#mentalTool .mental-config-grid {
  grid-template-columns: minmax(420px, 1.35fr) minmax(240px, 0.65fr);
}

#mentalTool .mental-main-settings .compact-tool-fields {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

#mentalTool .mental-chrono-settings .compact-tool-fields {
  grid-template-columns: 1fr;
}

#mentalTool .mental-dropdown-grid {
  margin-top: 12px;
}

@media (max-width: 980px) {
  #mentalTool .mental-config-grid {
    grid-template-columns: 1fr;
  }
}

/* FLASH_CHOICES_AND_MENTAL_DETAILS_V1 */
#mentalTool .mental-dropdown-grid {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

#mentalTool .mental-dropdown {
  flex: 1 1 300px;
  min-width: min(260px, 100%);
  align-self: flex-start;
  height: auto;
}

.setting-choice-toggle {
  align-items: center;
}

.choice-toggle-btn {
  justify-self: end;
  min-width: min(100%, 310px);
}

.choice-toggle-btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

html[data-theme="dark"] .choice-toggle-btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

@media (max-width: 720px) {
  .choice-toggle-btn {
    width: 100%;
    justify-self: stretch;
  }
}

/* SEPARATE_QUESTION_BANKS_AND_BACKGROUND_NAMES_V1 */
.question-bank-mode-label {
  color: var(--primary);
  font-weight: 900;
}

.quiz-question-field.hidden {
  display: none !important;
}



/* QUIZ_DIFFICULTY_BANK_REWORK_V1 */
.flash-question-field.hidden,
.quiz-question-field.hidden {
  display: none !important;
}

.difficulty-check small {
  color: var(--primary);
  font-weight: 900;
}

.quiz-difficulty-block .difficulty-check {
  align-items: center;
}


/* FLASH_OPEN_QUESTION_MODE_V1 */
.quiz-answer-field.hidden {
  display: none !important;
}


/* Icônes personnalisées d'accueil. */
.tool-launch-icon.tool-launch-image {
  width: clamp(54px, 5vw, 76px);
  height: clamp(54px, 5vw, 76px);
  border: 0;
  border-radius: 0;
  padding: 0;
  background: transparent;
  display: grid;
  place-items: center;
}

.tool-launch-icon.tool-launch-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.utility-logo.utility-logo-image {
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 4px;
  background: #ffffff;
  border-color: #dbeafe;
}

.utility-logo.utility-logo-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#toolControls.clock-projection-only {
  grid-template-columns: repeat(2, minmax(220px, 360px));
}

.clock-seconds-toggle {
  white-space: nowrap;
}


.level-main-kicker {
  height: auto;
  min-height: 30px;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.15;
  padding-block: 7px;
}


/* Section articles de la page d'accueil. */
.article-panel {
  grid-template-columns: minmax(220px, 0.75fr) minmax(0, 2.25fr);
}

.article-links-grid {
  flex-wrap: wrap;
  align-items: stretch;
}

.article-links-grid .article-link {
  flex: 1 1 210px;
  justify-content: flex-start;
  min-width: min(100%, 210px);
  white-space: normal;
  text-align: left;
}

.article-logo {
  min-width: 42px;
  width: 42px;
  height: 30px;
  font-size: 0.72rem;
}

@media (max-width: 720px) {
  .article-panel {
    grid-template-columns: 1fr;
  }

  .article-links-grid {
    display: grid;
    grid-template-columns: 1fr;
  }
}


.article-logo-image {
  width: 52px;
  min-width: 52px;
  height: 34px;
  padding: 5px 7px;
}

.article-logo-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.culturemath-logo {
  width: 62px;
  min-width: 62px;
  height: 40px;
  background: #ffffff;
  border-color: #fecaca;
}

.hal-logo {
  width: 66px;
  min-width: 66px;
  height: 38px;
  padding: 4px 8px;
}


/* TANGRAM_TOOL_V1 */
.tangram-tool-panel {
  gap: 16px;
}

.tangram-layout {
  display: grid;
  grid-template-columns: minmax(220px, 310px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.tangram-picker {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  display: grid;
  gap: 12px;
}

.tangram-filter {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 850;
}

.tangram-filter select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 10px;
}

.tangram-list {
  max-height: min(62vh, 620px);
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.tangram-choice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 10px 12px;
  display: grid;
  gap: 3px;
  text-align: left;
  cursor: pointer;
}

.tangram-choice:hover {
  border-color: #93c5fd;
  background: var(--primary-soft);
}

.tangram-choice.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.tangram-choice span {
  font-weight: 950;
}

.tangram-choice small {
  color: inherit;
  opacity: 0.78;
  font-weight: 800;
}

.tangram-workspace {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.tangram-actions {
  justify-content: end;
}

.tangram-title {
  margin: 0;
  text-align: center;
  color: var(--primary);
  font-size: clamp(1.25rem, 2vw, 2rem);
  font-weight: 950;
}

.tangram-stage {
  display: grid;
  grid-template-columns: minmax(220px, min(100%, 620px));
  justify-content: center;
  gap: 16px;
  align-items: start;
  transition: grid-template-columns 0.18s ease;
}

.tangram-stage.show-correction {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.tangram-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: clamp(10px, 1.3vw, 16px);
  display: grid;
  place-items: center;
  min-height: 260px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
}

.tangram-card img {
  display: block;
  width: min(100%, 620px);
  max-height: min(68vh, 760px);
  object-fit: contain;
}

.tangram-correction-card {
  background: #fffdf8;
}

.projection-tangram-card {
  width: min(100%, 1500px);
}

.projection-tangram-shell {
  width: 100%;
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: clamp(10px, 1.6vw, 20px);
  align-items: start;
}

.projection-tangram-shell .projection-actions {
  justify-content: center;
}

.projection-tangram-shell h2 {
  margin: 0;
  color: var(--primary);
  font-size: clamp(2rem, 3vw, 4.2rem);
  text-align: center;
  font-weight: 950;
}

.projection-tangram-stage {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, min(100%, 760px));
  justify-content: center;
  gap: clamp(16px, 2vw, 28px);
  align-items: center;
}

.projection-tangram-stage.show-correction {
  grid-template-columns: repeat(2, minmax(280px, 1fr));
}

.projection-tangram-figure {
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: clamp(10px, 1.5vw, 22px);
  display: grid;
  place-items: center;
  min-height: 0;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.12);
}

.projection-tangram-figure img {
  display: block;
  width: 100%;
  max-width: 760px;
  max-height: calc(100vh - 260px);
  object-fit: contain;
}

html[data-theme="dark"] .tangram-picker,
html[data-theme="dark"] .tangram-card,
html[data-theme="dark"] .projection-tangram-figure {
  border-color: var(--line);
}

html[data-theme="dark"] .tangram-card,
html[data-theme="dark"] .projection-tangram-figure {
  background: #f8fafc;
}

html[data-theme="dark"] .tangram-correction-card {
  background: #fff7ed;
}

html[data-theme="dark"] .tangram-choice.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

@media (max-width: 980px) {
  .tangram-layout {
    grid-template-columns: 1fr;
  }

  .tangram-list {
    max-height: 260px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  }

  .tangram-stage.show-correction,
  .projection-tangram-stage.show-correction {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .tangram-actions {
    justify-content: stretch;
  }

  .tangram-actions .secondary-btn {
    width: 100%;
  }

  .projection-tangram-shell {
    min-height: calc(100vh - 118px);
  }

  .projection-tangram-figure img {
    max-height: 42vh;
  }
}


/* MOBILE_HOME_AND_PICKER_FIXES_V1 */
@media (min-width: 1100px) {
  .home-tool-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

.question-pick-list {
  min-width: 0;
  overflow-x: hidden;
}

.question-check {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  min-width: 0;
}

.question-check span {
  display: block;
  min-width: 0;
  max-width: 100%;
  line-height: 1.32;
  overflow-wrap: anywhere;
  white-space: normal;
}

.question-check mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.clock-tool-view,
.clock-tool-view .tool-display-card {
  min-width: 0;
  max-width: 100%;
}

.clock-tool-view .tool-display-card .tool-display {
  max-width: calc(100% - 28px) !important;
  padding-inline: 0 !important;
  font-size: clamp(2rem, 12cqw, 5rem) !important;
}

@media (max-width: 640px) {
  .question-pick-block .setting-block-header {
    gap: 8px;
  }

  .question-pick-block .mini-actions {
    flex-wrap: wrap;
  }

  .question-check {
    gap: 8px;
    padding: 9px 8px;
    font-size: 0.9rem;
  }

  .question-check mjx-container {
    display: inline-block !important;
    max-width: 100%;
    vertical-align: middle;
  }
}

@media (max-width: 520px) {
  .clock-tool-view .tool-display-card {
    width: 100%;
    padding: 12px;
  }

  .clock-tool-view .tool-display-card .tool-display {
    max-width: calc(100% - 12px) !important;
    font-size: clamp(1.45rem, 10.6cqw, 2.75rem) !important;
  }
}


/* MOBILE_CLOCK_PROJECTION_FIT_V1 */
@media (max-width: 520px) {
  body.projection-mode #projectionScreen .projection-clock-frame {
    width: min(calc(100vw - 18px), calc((100vh - 142px) * 16 / 9)) !important;
    max-width: calc(100vw - 18px) !important;
    overflow: hidden;
  }

  body.projection-mode #projectionScreen .projection-clock-frame .projection-clock-value {
    max-width: calc(100% - 14px) !important;
    padding-inline: 0 !important;
    font-size: clamp(2.1rem, 13.5cqw, 4rem) !important;
    line-height: 1;
  }
}


/* TANGRAM_DOWNLOAD_BUTTON_V1 */
.tangram-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  flex: 1 1 260px;
  text-align: center;
  text-decoration: none;
  line-height: 1.15;
}

/* PHONE_CLOCK_AND_MANUAL_PICKER_FIX_V1 */
.question-check-body {
  display: grid !important;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}

.question-check-meta {
  color: var(--primary);
  font-weight: 900;
  line-height: 1.15;
}

.question-check-text {
  display: block;
  min-width: 0;
  max-width: 100%;
  line-height: 1.28;
  overflow-wrap: anywhere;
  white-space: normal;
}

.question-check-text mjx-container {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  line-height: 1.2;
  font-size: 0.92em !important;
}

.question-check-text mjx-container[jax="SVG"] {
  display: inline-block !important;
  vertical-align: baseline;
}

.question-check-text mjx-container[jax="SVG"] svg {
  max-width: 100% !important;
  height: auto !important;
}

@media (max-width: 720px) {
  #clockTool,
  #clockTool.clock-tool-view,
  #clockTool .tool-display-card,
  #clockTool #toolControls,
  #clockTool #projectionBackgroundSettings {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #clockTool {
    overflow: hidden;
  }

  #clockTool .tool-display-card {
    justify-self: stretch;
    padding: clamp(12px, 3vw, 18px);
    overflow: hidden;
  }

  #clockTool[data-tool-mode="clock"] .tool-display-card .tool-display {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    padding-inline: 0 !important;
    overflow: hidden;
    text-align: center;
    font-size: clamp(1.7rem, 10.8cqw, 3.2rem) !important;
    line-height: 1;
  }

  #clockTool #toolControls,
  #clockTool #toolControls.clock-projection-only {
    grid-template-columns: 1fr !important;
  }

  #clockTool #toolControls button {
    width: 100%;
    max-width: 100%;
    white-space: normal;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  #clockTool .projection-background-settings {
    overflow: hidden;
  }

  #clockTool .projection-background-choices {
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    max-width: 100%;
  }

  #clockTool .projection-bg-choice {
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .question-pick-list {
    gap: 8px;
    max-height: 42vh;
  }

  .question-check {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    min-height: auto;
    padding: 10px;
  }

  .question-check input {
    width: 24px;
    height: 24px;
    margin-top: 3px;
  }

  .question-check-body {
    gap: 5px;
  }

  .question-check-text {
    font-size: clamp(0.95rem, 3.6vw, 1.12rem);
    line-height: 1.28;
  }

  .question-check-text mjx-container {
    font-size: 0.86em !important;
    vertical-align: baseline;
  }
}

@media (max-width: 520px) {
  #clockTool .tool-display-card {
    padding: 10px;
    border-radius: 8px;
  }

  #clockTool[data-tool-mode="clock"] .tool-display-card .tool-display {
    font-size: clamp(1.35rem, 9.4cqw, 2.55rem) !important;
  }

  #clockTool .projection-background-choices {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

