/* MARKETPLACE OF MISTAKES - overlay styling.
   The 3D scene lives in #scene-canvas; everything HUD/dialog is HTML on top. */

:root {
  --bg: #f6efe3;
  --fg: #2b2032;
  --muted: #6a5d70;
  --accent: #d65a7f;
  --good: #4caf6a;
  --bad: #c2424a;
  --panel: #fff9ee;
  --panel-border: #c8b89f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Quicksand', 'Nunito', system-ui, -apple-system, sans-serif;
  overflow: hidden;
}

#scene-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
  outline: none;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding: 16px;
  z-index: 10;
}

#hud .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.badge {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.04em;
  box-shadow: 0 2px 0 rgba(0,0,0,0.05);
  pointer-events: auto;
}

.badge .label {
  color: var(--muted);
  font-weight: 500;
  margin-right: 6px;
}

#hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 10;
  pointer-events: none;
  transition: opacity 0.15s;
  opacity: 0;
}

#hint.visible { opacity: 1; }

#controls-help {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--muted);
  z-index: 10;
  line-height: 1.7;
}

#controls-help b { color: var(--fg); }

#end-session-btn {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 14px;
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  color: var(--fg);
  cursor: pointer;
  pointer-events: auto;
}
#end-session-btn:hover { background: #fff; }

/* ---------- Title / boot overlay ---------- */

#boot {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  flex-direction: column;
  text-align: center;
  padding: 24px;
}

#boot h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 5vw, 48px);
  color: var(--accent);
  letter-spacing: 0.02em;
}
#boot h2 {
  margin: 0 0 24px;
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
}

#boot .panel {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 18px;
  padding: 24px;
  max-width: 520px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.05);
}

#boot label {
  display: block;
  text-align: left;
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 14px;
}

#name-input {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  margin-bottom: 18px;
  background: white;
  color: var(--fg);
}

#boot .controls-list {
  text-align: left;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 18px;
}

#boot .controls-list b { color: var(--fg); }

.btn {
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 12px 22px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
  transition: transform 0.05s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }

.btn.ghost {
  background: white;
  color: var(--accent);
  border: 2px solid var(--accent);
}

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

#dialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 24px;
}
#dialog.hidden { display: none; }

.dialog-panel {
  background: var(--panel);
  border: 3px solid var(--panel-border);
  border-radius: 18px;
  padding: 22px 26px;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 8px 0 rgba(0,0,0,0.1);
  max-height: 90vh;
  overflow-y: auto;
}

.npc-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.npc-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
}

.npc-stall {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.npc-blurb {
  font-style: italic;
  color: var(--muted);
  margin: 0 0 16px;
  padding: 10px 12px;
  background: rgba(0,0,0,0.03);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
}

.q-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.q-meta .qid { font-family: ui-monospace, Menlo, monospace; }
.q-meta .diff {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #ece4d6;
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.q-prompt {
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 14px;
  white-space: pre-wrap;
}

.options {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.option-btn {
  text-align: left;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 14px;
  background: white;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  cursor: pointer;
  color: var(--fg);
  transition: background 0.1s, transform 0.05s;
}
.option-btn:hover { background: #fff7e3; }
.option-btn:active { transform: translateY(1px); }

.option-btn .key {
  display: inline-block;
  width: 22px;
  font-weight: 800;
  color: var(--accent);
}

.dialog-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

/* feedback panel (shown after wrong answer) */

.feedback-correct {
  padding: 12px 14px;
  background: #e7f6ec;
  border: 2px solid #b6deca;
  border-radius: 10px;
  color: var(--fg);
  margin-bottom: 12px;
}

.feedback-wrong {
  padding: 12px 14px;
  background: #fdeaea;
  border: 2px solid #f1b8be;
  border-radius: 10px;
  color: var(--fg);
  margin-bottom: 12px;
}

.feedback-wrong b { color: var(--bad); }
.feedback-correct b { color: var(--good); }

.rationale {
  margin: 6px 0 0;
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Results / end screen ---------- */

#results {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 25;
  padding: 24px;
  overflow-y: auto;
}
#results.visible { display: flex; }

.results-panel {
  background: var(--panel);
  border: 3px solid var(--panel-border);
  border-radius: 18px;
  padding: 28px 32px;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 8px 0 rgba(0,0,0,0.1);
}

.results-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
  color: var(--accent);
}

.results-summary {
  font-size: 18px;
  margin: 0 0 18px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin: 0 0 18px;
}
.week-cell {
  background: white;
  border: 2px solid var(--panel-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}
.week-cell b { display: block; color: var(--accent); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }

.fine {
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
  line-height: 1.5;
}
.fine code {
  font-family: ui-monospace, Menlo, monospace;
  background: rgba(0,0,0,0.05);
  padding: 1px 5px;
  border-radius: 4px;
}

#err {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
#err.visible { display: flex; }
