/* BoneGuessr - cozy study-notebook theme */

:root {
  --paper: #f7f0e3;
  --paper-deep: #efe4d1;
  --ink: #3b2f2a;
  --muted: #7d6a5e;
  --line: #e2d3bd;
  --line-strong: #cbb798;
  --card: #fffaf2;
  --cream: #fff6e8;
  --accent: #c2603f;        /* terracotta */
  --accent-dark: #9e4a2e;
  --accent-soft: #f6e2d6;
  --sage: #6f8f6a;
  --sage-soft: #e6efe1;
  --good: #4f7f4a;
  --bad: #b64a3a;
  --mark: #d65a3f;
  --honey: #e9b44c;
  --shadow: 0 1px 2px rgba(59, 47, 42, .06), 0 10px 28px rgba(59, 47, 42, .08);
  --shadow-soft: 0 2px 0 rgba(59, 47, 42, .06);
  --radius: 18px;
  --serif: "Fraunces", "Lora", Georgia, "Times New Roman", serif;
  --sans: "Nunito", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(59, 47, 42, .09) 1px, transparent 1.2px),
    linear-gradient(180deg, #faf4ea 0%, var(--paper) 40%, var(--paper-deep) 100%);
  background-size: 22px 22px, 100% 100%;
  background-attachment: fixed;
  color: var(--ink);
  font: 15.5px/1.5 var(--sans);
  min-height: 100%;
}

h1, h2, h3, .prompt, .grade {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -.01em;
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 24px;
  background: rgba(255, 250, 242, .92);
  border-bottom: 2px solid var(--line);
  box-shadow: 0 4px 18px rgba(59, 47, 42, .05);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(6px);
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 24px; margin: 0; color: var(--ink); }
.tagline {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}
.tabs {
  display: flex;
  gap: 6px;
  margin-left: auto;
  padding: 4px;
  background: var(--paper-deep);
  border-radius: 999px;
  border: 1px solid var(--line);
}
.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 15px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  transition: background .15s, color .15s, transform .15s;
}
.tab:hover { background: var(--cream); color: var(--ink); }
.tab.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 0 var(--accent-dark);
}

.scorebar { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--cream);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 600;
}
.chip b { color: var(--ink); font-size: 13px; }
.chip.good b { color: var(--good); }
.chip.bad b { color: var(--bad); }

/* ---------- Layout / cards ---------- */

main { max-width: 1180px; margin: 0 auto; padding: 26px 18px 40px; }

.card {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  position: relative;
}

/* notebook margin line */
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18px;
  bottom: 18px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, var(--honey), var(--accent));
  opacity: .8;
}

.card h2 { margin: 0 0 8px; font-size: 24px; }
.card p { margin: 6px 0; }

.question-card {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(300px, 1fr);
  gap: 24px;
}
@media (max-width: 860px) { .question-card { grid-template-columns: 1fr; } }

/* ---------- Image panel ---------- */

.image-panel { display: flex; flex-direction: column; gap: 10px; }

.image-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background:
    radial-gradient(120% 120% at 50% 15%, #ffffff 0%, #f7f0e2 65%, #eadfca 100%);
  border: 2px solid var(--line-strong);
  border-radius: 16px;
  overflow: hidden;
  user-select: none;
  box-shadow: inset 0 0 0 6px var(--card), inset 0 0 0 7px var(--line);
}

.image-stage img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 76%;
  height: 76%;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  pointer-events: none;
}

.overlay { position: absolute; inset: 0; pointer-events: none; }

.ring {
  position: absolute;
  width: 7.2%;
  aspect-ratio: 1 / 1;
  border: 3px solid var(--mark);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px #fff8, inset 0 0 0 1px #fff6;
}
.ring::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  background: var(--mark);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}
.ring .tag {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -6px);
  background: var(--cream);
  border: 1.5px solid var(--mark);
  color: var(--bad);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}
.ring.dim { border-color: #a08f7f; }
.ring.dim .tag { border-color: #a08f7f; color: #5e4f45; }
.ring.dim::after { background: #a08f7f; }

.image-tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hint-note { font-size: 12px; color: var(--muted); margin-left: auto; font-style: italic; }
.view-pager { justify-content: center; }
.view-label { min-width: 140px; text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: capitalize; }

/* ---------- Q & A ---------- */

.qa { display: flex; flex-direction: column; gap: 13px; }
.prompt { font-size: 23px; margin: 2px 0 0; line-height: 1.3; }

form { display: flex; gap: 8px; }
input[type=text] {
  flex: 1;
  font: inherit;
  padding: 11px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]::placeholder { color: #b3a291; }
input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled { background: var(--paper); color: var(--muted); }

button {
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  padding: 10px 16px;
  border: 2px solid var(--line);
  background: var(--cream);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--line);
  transition: transform .1s, box-shadow .1s, background .15s, border-color .15s;
}
button:hover { border-color: var(--line-strong); box-shadow: 0 2px 0 var(--line-strong); background: #fff; }
button:active { transform: translateY(2px); box-shadow: none; }
button:disabled { opacity: .5; cursor: default; transform: none; box-shadow: 0 2px 0 var(--line); }
button.primary {
  background: var(--accent);
  border-color: var(--accent-dark);
  color: #fff;
  box-shadow: 0 3px 0 var(--accent-dark);
}
button.primary:hover { background: #cf6c4a; border-color: var(--accent-dark); box-shadow: 0 3px 0 var(--accent-dark); }
button.ghost { background: transparent; box-shadow: none; border-color: var(--line); }
button.ghost:hover { background: var(--cream); box-shadow: none; }
button.small { padding: 6px 11px; font-size: 13px; }

.choices { display: flex; flex-wrap: wrap; gap: 7px; }
.choices button { padding: 7px 13px; font-size: 13.5px; background: #fff; }
.choices button:hover { background: var(--sage-soft); border-color: var(--sage); box-shadow: 0 2px 0 var(--sage); }
.choices.hidden { display: none; }

.feedback {
  border-radius: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  background: #fff;
}
.feedback.correct { border-color: #b9d2b2; background: var(--sage-soft); }
.feedback.incorrect { border-color: #e6bdb3; background: #fbeeea; }
.feedback h3 { margin: 0 0 6px; font-size: 18px; }
.feedback.correct h3 { color: var(--good); }
.feedback.incorrect h3 { color: var(--bad); }
.feedback .answer-line { margin: 2px 0 8px; }
.feedback .answer-line b { font-size: 16px; }
.feedback ul { margin: 6px 0 2px; padding-left: 20px; }
.feedback li { margin: 3px 0; }
.feedback .your-answer { color: var(--bad); }
.feedback .confusion {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1.5px dashed var(--line-strong);
  font-size: 13.5px;
  color: var(--muted);
}
.feedback .about-lm { font-size: 13.5px; color: var(--muted); margin-top: 6px; }

.qa-actions { display: flex; gap: 8px; align-items: center; }
.smallprint { font-size: 12.5px; color: var(--muted); margin: 0; }
.muted { color: var(--muted); }

.review-banner {
  margin: 0;
  font-size: 13px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border: 1.5px solid #ead0c2;
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 600;
}

/* ---------- Exam ---------- */

.exam-choices { display: flex; gap: 10px; margin: 16px 0; flex-wrap: wrap; }
.exam-progress { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); font-weight: 600; }
.exam-progress .bar { flex: 1; height: 10px; border-radius: 999px; background: var(--paper-deep); border: 1px solid var(--line); overflow: hidden; }
.exam-progress .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--honey), var(--accent)); width: 0; transition: width .25s; }

.grade { font-size: 40px; margin: 6px 0; }
.grade.pass { color: var(--good); }
.grade.fail { color: var(--bad); }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Stats ---------- */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.stat-box { border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; }
.stat-box h3 {
  margin: 0 0 8px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 800;
}
.stat-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13.5px; border-bottom: 1px dotted var(--line); }
.stat-row:last-child { border-bottom: 0; }
.missed-item { display: flex; gap: 12px; align-items: center; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.missed-item img { width: 56px; height: 56px; object-fit: contain; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; }
.missed-item .m-name { font-weight: 700; }
.missed-item .m-sub { color: var(--muted); font-size: 12.5px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Footer ---------- */

.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 10px 18px 30px;
  color: var(--muted);
  font-size: 12.5px;
}
.footer a { color: var(--accent-dark); font-weight: 600; }
.footer .made-with {
  flex-basis: 100%;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--ink);
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1.5px dashed var(--line-strong);
}
.footer .made-with .heart { color: var(--accent); font-style: normal; }

/* ---------- Dialog ---------- */

dialog.credits {
  border: 2px solid var(--line-strong);
  border-radius: var(--radius);
  max-width: 620px;
  padding: 24px;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog.credits h2 { margin-top: 0; }
dialog.credits p, dialog.credits li { font-size: 13.5px; }
dialog::backdrop { background: rgba(59, 47, 42, .45); }

/* ---------- Autocomplete ---------- */

.ac { position: relative; flex: 1; }
.ac input[type=text] { width: 100%; }
.ac-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 264px;
  overflow: auto;
  padding: 5px;
}
.ac-item {
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: space-between;
}
.ac-item:hover, .ac-item.active { background: var(--accent-soft); }
.ac-main { font-weight: 700; }
.ac-sub { color: var(--muted); font-size: 12px; }
