/* Grid Memory — hub / deviation-game theme */
.grid-memory-game .gm-phase-label {
  margin: 0 0 16px;
  font-size: 15px;
  font-weight: 600;
  color: #6b7280;
  text-align: center;
}

.grid-memory-game .gm-timer-display {
  display: block;
  margin: 0 auto 8px;
  font-size: 2rem;
  font-weight: 800;
  color: #111827;
  text-align: center;
}

.grid-memory-game .gm-timer-display[hidden] {
  display: none !important;
}

.gm-math-timer-display {
  display: block;
  margin: 0 auto 12px;
  font-size: 2rem;
  font-weight: 800;
  text-align: center;
  color: #7c3aed;
}

.gm-math-timer-display[hidden] {
  display: none !important;
}

.gm-math-timer-display.is-math-low {
  color: #dc2626;
}

.grid-memory-game .gm-timer-display.is-low {
  color: #dc2626;
}

.gm-grid-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  margin: 0 auto 20px;
  padding: 16px;
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  overflow-x: auto;
}

.gm-grid-wrap[hidden] {
  display: none !important;
}

.gm-grid-cover {
  position: absolute;
  inset: 16px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.gm-grid-cover[hidden] {
  display: none;
}

.gm-grid-cover p {
  margin: 0;
  max-width: 320px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.55;
  color: #374151;
}

.gm-grid-cover strong {
  color: #111827;
}

.gm-grid {
  display: grid;
  grid-template-columns: repeat(6, 112px);
  grid-template-rows: repeat(6, 72px);
  gap: 0;
  width: max-content;
  max-width: 100%;
  margin: 0 auto;
  border: 2px solid #111827;
  border-radius: 4px;
  overflow: hidden;
}

.gm-cell {
  background: #fff;
  border: none;
  border-right: 1px solid #d1d5db;
  border-bottom: 1px solid #d1d5db;
  width: 112px;
  height: 72px;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
  border-radius: 0;
  color: #111827;
  padding: 4px;
  word-break: break-all;
  text-align: center;
  box-sizing: border-box;
}

.gm-cell:nth-child(6n) {
  border-right: none;
}

.gm-cell:nth-child(n + 31) {
  border-bottom: none;
}

.gm-quiz {
  max-width: 640px;
  margin: 0 auto;
}

.gm-quiz-card {
  padding: 24px 22px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.gm-quiz-eyebrow {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: center;
  color: #0891b2;
}

.gm-math-eyebrow {
  color: #7c3aed;
}

.gm-math .gm-prompt {
  font-size: 1.75rem;
  font-weight: 800;
  color: #111827;
}

.gm-math-timer-hint {
  font-size: 13px;
  font-weight: 700;
  color: #7c3aed;
}

.gm-math-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 8px;
}

.gm-math-input-label {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
  text-align: center;
}

.gm-math-input {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  padding: 14px 16px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  color: #111827;
  background: #fff;
}

.gm-math-input:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.gm-math-input:disabled {
  background: #f3f4f6;
  color: #6b7280;
}

.gm-math-actions,
.gm-quiz-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.gm-math-feedback {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  color: #6b7280;
}

.gm-math-feedback.is-correct {
  color: #059669;
}

.gm-math-feedback.is-wrong {
  color: #dc2626;
}

.grid-memory-game .gm-timer-display.is-math-low {
  color: #dc2626;
}

.gm-quiz .gm-prompt {
  margin: 0 0 20px;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: #6b7280;
  line-height: 1.5;
}

.gm-cell-ref {
  display: inline-block;
  margin: 0 2px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0e7490;
  font-weight: 800;
  font-size: 1rem;
}

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

.grid-memory-game button.gm-choice {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 12px 12px 14px;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  background: #f9fafb;
  color: #111827;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.12s;
}

.grid-memory-game button.gm-choice:hover:not(:disabled) {
  background: #fff;
  border-color: #0891b2;
  box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.15);
  transform: translateY(-1px);
}

.grid-memory-game button.gm-choice:disabled {
  cursor: default;
  opacity: 1;
  transform: none;
}

.gm-choice-key {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid #111827;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.gm-choice-value {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 10px 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e5e7eb;
  font-size: clamp(1.25rem, 4vw, 2rem);
  font-weight: 800;
  line-height: 1.2;
  word-break: break-word;
  text-align: center;
}

.grid-memory-game button.gm-choice.is-correct {
  background: #dcfce7;
  border-color: #16a34a;
}

.grid-memory-game button.gm-choice.is-correct .gm-choice-value {
  border-color: #86efac;
  background: #f0fdf4;
}

.grid-memory-game button.gm-choice.is-wrong {
  background: #fee2e2;
  border-color: #dc2626;
}

.grid-memory-game button.gm-choice.is-wrong .gm-choice-value {
  border-color: #fca5a5;
  background: #fef2f2;
}

.gm-quiz-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
}

.gm-quiz-progress,
.gm-quiz-score {
  font-size: 13px;
  font-weight: 700;
  color: #6b7280;
}

.gm-quiz-score {
  color: #111827;
}

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

  .gm-choice-value {
    min-height: 56px;
  }
}

.grid-memory-game.is-finished .gm-game-view {
  display: none;
}

@media (max-width: 720px) {
  .gm-grid {
    grid-template-columns: repeat(6, 52px);
    grid-template-rows: repeat(6, 48px);
  }

  .gm-cell {
    width: 52px;
    height: 48px;
    min-height: 48px;
    font-size: 14px;
  }
}

.graph-line.gridMemory {
  stroke: #0891b2;
}

.graph-area.gridMemory {
  fill: #0891b2;
}

.graph-dot.gridMemory {
  stroke: #0891b2;
}
