:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2330;
  --muted: #5d6675;
  --line: #d9dde4;
  --fits: #16833a;
  --nofits: #c42032;
  --accent: #2b59c3;
  --accent-ink: #ffffff;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 0;
}
.topbar h1 { font-size: 20px; margin: 0; }

main { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel + .panel { margin-top: 16px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.error {
  color: var(--nofits);
  background: #fdecee;
  border: 1px solid #f3b8bf;
  border-radius: 8px;
  padding: 8px 10px;
  margin-top: 10px;
}

.status { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; margin-bottom: 12px; }
.status .game { font-weight: 600; }
.badge-training {
  background: #fff4d6; border: 1px solid #ecd08a; color: #6b5000;
  border-radius: 999px; padding: 2px 10px; font-size: 14px;
}

/* layout: card + form on the left, history on the right; stacked on narrow screens */
.game-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) { .game-grid { grid-template-columns: minmax(0, 1fr); } }

/* cards */
.card {
  background: #fff;
  border: 4px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 4px;
  text-align: center;
  position: relative;
}
.card.fits { border-color: var(--fits); }
.card.nofits { border-color: var(--nofits); }
.card svg { display: block; width: 100%; height: auto; }
.card .caption { font-size: 13px; color: var(--muted); margin-top: 2px; }
.card .verdict {
  display: inline-block; margin-top: 4px; font-weight: 700; font-size: 14px;
  padding: 1px 10px; border-radius: 999px; color: #fff;
}
.card.fits .verdict { background: var(--fits); }
.card.nofits .verdict { background: var(--nofits); }

.card.big { max-width: 400px; margin: 0 auto; border-width: 6px; padding: 10px 10px 8px; }
.card.big .caption { font-size: 16px; color: var(--ink); }
.card.big .verdict { font-size: 16px; padding: 2px 14px; }

.history { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.history .card { border-width: 3px; padding: 3px 3px 2px; }
.history .card .caption { font-size: 11px; line-height: 1.25; }
.history .card .num { position: absolute; top: 2px; left: 6px; font-size: 11px; color: var(--muted); }
.history .card.current { box-shadow: 0 0 0 3px #9db7ef; }
.card-sheet { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

h2 { font-size: 18px; margin: 0 0 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }

/* guess form */
.current-guess { margin: 14px 0 10px; padding: 10px 12px; background: #eef3ff; border-radius: 8px; }
.current-guess .g { font-weight: 600; }
fieldset { border: 0; margin: 0 0 10px; padding: 0; }
legend { font-weight: 600; margin-bottom: 6px; }
.ops label { display: block; padding: 4px 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.row label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); flex: 1 1 140px; }
select, textarea, input[type="number"] {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #b9c0cc; border-radius: 8px; padding: 8px 10px; margin-top: 3px; min-height: 42px;
}
textarea { width: 100%; min-height: 80px; resize: vertical; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
button {
  font: inherit; border-radius: 8px; padding: 10px 16px; min-height: 44px; cursor: pointer;
  border: 1px solid #aab3c2; background: #fff; color: var(--ink);
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 4px; min-height: 0; text-decoration: underline; }

.help { max-width: 1100px; margin: 8px auto 0; padding: 0 16px; }
.help .panel p { margin: 0 0 8px; }

.diff { display: flex; flex-wrap: wrap; gap: 8px; }
.diff label {
  border: 1px solid #b9c0cc; border-radius: 8px; padding: 8px 14px; cursor: pointer; background: #fff;
}
.diff input { margin-right: 6px; }

.reveal-rule { font-size: 20px; font-weight: 700; margin: 4px 0; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--muted); }
.ok { color: var(--fits); font-weight: 700; }
.bad { color: var(--nofits); font-weight: 700; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; }

/* instructions examples */
.examples { padding-left: 20px; margin: 0 0 12px; }
.examples li { margin-bottom: 8px; }
.ex-rule { font-weight: 700; }

/* survey */
.survey { max-width: 560px; }
.survey-field { display: flex; flex-direction: column; margin-bottom: 12px; font-weight: 600; }
.survey-field select, .survey-field input { font-weight: 400; width: 100%; }
input[type="number"] { width: 100%; }

/* rules reminder / hint */
.rule-hint { background: #eaf6ee; border-left: 4px solid var(--fits); padding: 6px 10px; border-radius: 6px; font-weight: 600; }

/* consent, color check */
.narrow { max-width: 640px; }
.color-row { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0 12px; }
.color-item { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 130px; }
.color-shape { width: 100px; height: 100px; }

/* tutorial */
.features { width: auto; margin: 10px 0; }
.features th { color: var(--muted); font-weight: 600; padding-right: 16px; }
.tut-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 10px 0; }
.tut-card { border: 2px solid transparent; border-radius: var(--radius); padding: 6px; background: #fff; text-align: left; }
button.tut-card { cursor: pointer; border: 2px dashed #b9c0cc; min-height: 0; }
button.tut-card.selected { border: 3px solid var(--accent); background: #eef3ff; }
.tut-card.ok-card { border-color: #bfe3c9; }
.tut-card.bad-card { border-color: #f3b8bf; background: #fff7f8; }
.check-q { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; }
.check-q p { margin: 0 0 6px; }
