/* Тренажёр таблицы умножения: крупный пример, клавиатура под палец, карта из ста клеток. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  --bg1: #f3f0e4;
  --bg2: #e7e0c8;
  --ink: #3a3320;
  --card: #fffdf5;
  --frame: #5a8835;
  --accent: #4a6b2a;
  --accent-bg: #c8d8a4;
  --line: #a8bc80;
  --ok: #3f8a2e;
  --bad: #c0392b;
  --new: #ece7d4;
  --shaky: #f6dd9e;
  --learned: #a8cf85;

  margin: 0; min-height: 100vh; padding: 18px 12px 40px;
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
  font-family: Georgia, 'Times New Roman', serif; color: var(--ink);
}

.wrap { max-width: 640px; margin: 0 auto; }
h1 { font-size: 27px; margin: 4px 0 8px; text-align: center; color: var(--accent); }
h2 { font-size: 23px; margin: 4px 0 8px; text-align: center; color: var(--accent); }

.lead { text-align: center; font-size: 15px; line-height: 1.5; margin: 0 auto 16px; max-width: 560px; opacity: .9; }
.lead.small { font-size: 13.5px; margin-top: 18px; }
.lead a { color: var(--frame); }
.hint-tap { margin-top: 8px; opacity: .7; }

.screen {
  background: var(--card); border: 1.5px solid #b8862c; border-radius: 16px;
  padding: 20px 18px 24px; box-shadow: 0 10px 30px rgba(0,0,0,.12);
}

/* ---------- карта ста примеров ---------- */
.map-holder { margin: 4px 0 18px; }
.map {
  display: grid; grid-template-columns: repeat(11, 1fr);
  gap: 2px; max-width: 420px; margin: 0 auto;
}
.map-small { max-width: 300px; margin: 20px auto 0; opacity: .95; }

.map .c {
  aspect-ratio: 1 / 1; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #6a5a35; background: var(--new); border: 1px solid #dcd6bf;
}
.map .c.shaky { background: var(--shaky); border-color: #ddb75a; }
.map .c.learned { background: var(--learned); border-color: #7fae5c; }
.map .c.cur { box-shadow: 0 0 0 2.5px var(--bad); z-index: 2; }
.map .h {
  aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--accent); background: transparent;
}
.map .h.row { cursor: pointer; border-radius: 4px; }
.map .h.row:hover { background: var(--accent-bg); }
.map .h.done::after { content: "⭐"; font-size: 9px; position: relative; top: -6px; }
.map .corner { color: #b8a86c; }
.map-small .c { font-size: 0; }
.map-small .h { font-size: 10px; }

.map-legend {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  font-size: 12.5px; opacity: .8; margin-top: 8px;
}
.map-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }
.sw.new { background: var(--new); border: 1px solid #dcd6bf; }
.sw.shaky { background: var(--shaky); }
.sw.learned { background: var(--learned); }
.counter { text-align: center; font-size: 15px; font-weight: 700; color: var(--accent); margin-top: 8px; }

/* ---------- меню ---------- */
.menu-grid { display: grid; gap: 10px; margin: 16px 0 18px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.big-btn {
  font-family: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 14px 12px; border-radius: 14px; border: 1.5px solid var(--frame);
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(0,0,0,.02)); color: var(--ink);
}
.big-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.big-btn b { font-size: 15.5px; }
.big-btn small { font-size: 12px; opacity: .8; text-align: center; }
.big-emoji { font-size: 32px; line-height: 1; text-align: center; }

.opts { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.opt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.opt-label { font-size: 14px; opacity: .75; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; min-width: 32px; text-align: center;
  padding: 6px 9px; border-radius: 999px; border: 1.4px solid var(--line); font-size: 14px;
}
.chip input:checked + span { background: var(--accent-bg); border-color: var(--accent); font-weight: 700; }

/* ---------- тренажёр ---------- */
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.progress { font-size: 14px; opacity: .8; }

.task {
  text-align: center; font-size: 46px; font-weight: 700; color: var(--accent);
  margin: 18px 0 6px; letter-spacing: 1px; min-height: 60px;
}
.task .inp {
  display: inline-block; min-width: 1.7em; border-bottom: 4px solid var(--line);
  color: var(--ink); text-align: center;
}
.task.ok .inp { border-color: var(--ok); color: var(--ok); }
.task.bad .inp { border-color: var(--bad); color: var(--bad); animation: shake .32s; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.status { text-align: center; font-size: 16px; font-weight: 700; min-height: 24px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

/* ---------- клавиатура ---------- */
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-width: 260px; margin: 16px auto 0;
}
.key {
  font-family: inherit; cursor: pointer; height: 56px; border-radius: 12px;
  border: 1.6px solid var(--frame); background: #fffdf5; color: var(--ink);
  font-size: 24px; font-weight: 700;
}
.key:hover { background: var(--accent-bg); }
.key.wide { grid-column: span 2; }
.key.del { font-size: 20px; }

/* ---------- кнопки ---------- */
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btn {
  font-family: inherit; font-size: 15px; cursor: pointer; padding: 10px 18px; border-radius: 10px;
  border: 1.5px solid var(--frame); background: rgba(255,255,255,.5); color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-bg); border-color: var(--accent); font-weight: 700; }
.btn.ghost { border-style: dashed; opacity: .85; }
.btn.small { font-size: 13px; padding: 6px 12px; }

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .screen { padding: 14px 10px 18px; }
  .task { font-size: 38px; }
  .key { height: 50px; font-size: 21px; }
  .map { max-width: 100%; }
  .map .c, .map .h { font-size: 9px; }
}
