:root {
  --bg: #070708;
  --surface: #111114;
  --surface-2: #18181d;
  --border: #27272e;
  --border-hi: #3f3f4a;
  --text: #f3f3f5;
  --muted: #8e8e9a;
  --accent: #e4e4e7;
  --ok: #22c55e;
  --err: #ef4444;
  --warn: #eab308;
  --radius: 14px;
  --mono: "JetBrains Mono", "Cascadia Code", "Courier New", monospace;
  --sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, #15151a 0%, var(--bg) 65%);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  justify-content: center;
  padding: 28px 16px 64px;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 100%;
  max-width: 700px;
}

/* ===== ПРОГРЕС-БАР ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--muted);
  font-family: var(--mono);
}

.progress-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.dot {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  user-select: none;
}

.dot.done {
  background: #14261b;
  border-color: #1f4d30;
  color: var(--ok);
}

.dot.cur {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* ===== КАРТКА ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
}

.tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 99px;
  margin-bottom: 14px;
}

h1 {
  font-size: clamp(24px, 4.5vw, 34px);
  line-height: 1.15;
  margin: 0 0 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 20px;
  margin: 0 0 12px;
  font-weight: 700;
}

p {
  font-size: 16px;
  line-height: 1.6;
  color: #d4d4dc;
  margin: 0 0 14px;
}

.muted { color: var(--muted); font-size: 14px; }
.mono { font-family: var(--mono); }

/* ===== ФОРМИ ТА КНОПКИ ===== */
.field {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}

input[type="text"],
input[type="number"],
input[type="password"] {
  flex: 1;
  min-width: 180px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s;
}

input:focus { border-color: var(--text); }
input:disabled { opacity: 0.45; cursor: not-allowed; }

button {
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 20px;
  border-radius: 10px;
  border: 1px solid var(--border-hi);
  background: var(--text);
  color: var(--bg);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}

button:hover:not(:disabled) { opacity: 0.9; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.35; cursor: not-allowed; }

button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hi);
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
  font-size: 13px;
  padding: 8px 12px;
}

button.ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-hi);
}

/* ===== ПОВІДОМЛЕННЯ ТА ПІДКАЗКИ ===== */
.msg {
  min-height: 24px;
  margin-top: 14px;
  font-size: 15px;
  font-weight: 600;
}
.msg.ok { color: var(--ok); }
.msg.err { color: var(--err); }
.msg.warn { color: var(--warn); }

.hints-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.hint-box {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  font-size: 14px;
  color: #e4e4ec;
}

.shake { animation: sh 0.35s; }
@keyframes sh {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ===== МОДАЛКИ (ПІДКАЗКИ / ПАНЕЛЬ ВЕДУЧОГО) ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* ===== МІНІ-ІГРИ: ЗАГАЛЬНІ ===== */
.game-box {
  margin-top: 16px;
  padding: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.game-stats {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 14px;
}

.game-stats b { color: var(--text); }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.choices.col1 { grid-template-columns: 1fr; }

.choice-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-hi);
  text-align: left;
  padding: 13px 16px;
  font-weight: 600;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--text);
  background: #202028;
}

/* ===== ХРЕСТИКИ-НУЛИКИ ===== */
.ttt-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  max-width: 240px;
  margin: 14px auto;
}

.ttt-cell {
  aspect-ratio: 1;
  font-size: 30px;
  font-family: var(--mono);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-hi);
  display: grid;
  place-items: center;
  padding: 0;
}

/* ===== ФЛЕШ-МАТЕМАТИКА ===== */
.flash-stage {
  height: 120px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 54px;
  font-weight: 800;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 14px 0;
}

/* ===== ТАБЛИЦЯ ШУЛЬТЕ ===== */
.schulte-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  max-width: 360px;
  margin: 12px auto 0;
}

.schulte-cell {
  aspect-ratio: 1;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 800;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-hi);
  padding: 0;
}

.schulte-cell.hit {
  background: #14261b;
  border-color: #1f4d30;
  color: var(--ok);
  opacity: 0.55;
}

/* ===== ІДЕАЛЬНЕ КОЛО ===== */
.circle-canvas {
  width: 100%;
  height: 320px;
  background: #0a0a0c;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

/* ===== ЗЛОМ СЕЙФА ===== */
.safe-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.safe-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-2);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--mono);
}

.safe-digits { display: flex; gap: 6px; }
.safe-d {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #222229;
  border: 1px solid var(--border-hi);
}
.safe-d.g { background: #14532d; border-color: var(--ok); color: #fff; }
.safe-d.y { background: #713f12; border-color: var(--warn); color: #fff; }

/* ===== WORDLE (НЕПРАВИЛЬНІ КОЛЬОРИ) ===== */
.wordle-board {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  margin: 12px 0;
}

.wordle-row {
  display: grid;
  grid-template-columns: repeat(5, 48px);
  gap: 6px;
}

.wordle-cell {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  border: 1px solid var(--border-hi);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  text-transform: uppercase;
  color: #fff;
}

/* ===== КНОПКА-ВТІКАЧКА ===== */
.runaway-arena {
  position: relative;
  height: 240px;
  background: #0a0a0c;
  border: 1px dashed var(--border-hi);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 14px;
}

.runaway-btn {
  position: absolute;
  transition: left 0.12s ease-out, top 0.12s ease-out;
}

/* ===== СТРУП / ГОДИННИК / ДРУК ===== */
.big-display {
  text-align: center;
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 0.04em;
  padding: 26px 12px;
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 12px 0;
}

.typing-target {
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.7;
  padding: 14px;
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 10px;
  user-select: none;
  margin-bottom: 12px;
}

.typing-target .ok-ch { color: var(--ok); }
.typing-target .err-ch { color: var(--err); text-decoration: underline; }

/* ===== ШАХИ / ГРАФІКИ / ФОТО / ФОРМИ ===== */
.svg-wrap {
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin: 14px 0;
  display: flex;
  justify-content: center;
}

.chess-grid-wrap {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 14px 0;
}

.chess-item {
  background: var(--surface-2);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
  cursor: pointer;
}

.chess-item:hover { border-color: var(--text); }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.photo-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-hi);
  background: #000;
}

.kit-card {
  display: flex;
  justify-content: center;
  padding: 20px;
  background: #0a0a0c;
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 12px 0;
}

.career-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 12px 0;
}

.career-step {
  display: flex;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 14px;
}

/* ===== СЛОВА З БУКВ ===== */
.word-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.chip {
  padding: 4px 10px;
  border-radius: 99px;
  background: #14261b;
  border: 1px solid #1f4d30;
  color: var(--ok);
  font-size: 13px;
  font-family: var(--mono);
}

/* ===== СТАТИСТИКА ФІНАЛУ ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.stat-card .val {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
}

.stat-card .lbl {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

@media (max-width: 560px) {
  .card { padding: 20px 16px; }
  .choices { grid-template-columns: 1fr; }
  .chess-grid-wrap { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
}

/* ===== НОВІ СТИЛІ: СКІП, ШУЛЬТЕ-ХАРД, ТОП-3 ===== */
.corner-skip {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 16px;
  opacity: 0.35;
  z-index: 50;
}
.corner-skip:hover { opacity: 1; color: var(--text); border-color: var(--border-hi); }

.schulte-cell.last-hit {
  background: #14532d;
  border-color: var(--ok);
  color: #fff;
}

.top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.top-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.top-box h3 {
  margin: 0 0 10px;
  font-size: 13px;
  font-family: var(--mono);
  color: var(--muted);
  text-transform: uppercase;
}

.top-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
}
.top-row:last-child { border-bottom: none; }

@media (max-width: 560px) {
  .top-grid { grid-template-columns: 1fr; }
}