/* Digital Netizenship — chat-style story game. Theme via CSS variables. */
:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --npc: #e5e7eb;
  --you: #2563eb;
  --you-ink: #ffffff;
  --good: #16a34a;
  --bad: #dc2626;
  --radius: 16px;
  --max: 640px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); }

.app { max-width: var(--max); margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--panel); }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid #e5e7eb; background: var(--panel);
}
.brand { font-weight: 700; letter-spacing: -0.01em; color: inherit; text-decoration: none; }

/* game picker */
.menu { flex: 1; padding: 28px 20px; }
.menu-title { margin: 8px 0 4px; font-size: 22px; }
.menu-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-card { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink);
  border: 1px solid #e5e7eb; border-radius: var(--radius); padding: 16px; transition: all .12s ease; background: #fff; }
.menu-card:hover { border-color: var(--you); box-shadow: 0 4px 14px rgba(37,99,235,.12); transform: translateY(-1px); }
.menu-card b { font-size: 15px; }
.menu-card span { color: var(--muted); font-size: 12px; }
@media (max-width: 480px){ .menu-grid { grid-template-columns: 1fr; } }
.bar-right { display: flex; align-items: center; gap: 12px; }
.game-title { color: var(--muted); font-size: 13px; }
.score { font-size: 13px; font-weight: 600; background: #eef2ff; color: #4338ca; padding: 4px 10px; border-radius: 999px; }

.thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.scene-image img { width: 100%; border-radius: var(--radius); display: block; }
.scene-banner {
  text-align: center; font-size: 13px; color: var(--muted);
  background: #f9fafb; border: 1px dashed #d1d5db; border-radius: 12px; padding: 8px 12px; align-self: center;
}
.narration { text-align: center; font-style: italic; color: var(--muted); font-size: 14px; padding: 4px 8px; }

.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 90%; }
.msg-row.npc { align-self: flex-start; }
.msg-row.you { align-self: flex-end; flex-direction: row; }
.bubble-wrap { display: flex; flex-direction: column; gap: 2px; }
.name { font-size: 11px; color: var(--muted); margin-left: 6px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; }
.avatar-fallback { display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; }

.bubble { padding: 10px 14px; border-radius: 18px; line-height: 1.4; font-size: 15px; }
.bubble-npc { background: var(--npc); color: var(--ink); border-bottom-left-radius: 6px; }
.bubble-you { background: var(--you); color: var(--you-ink); border-bottom-right-radius: 6px; }

.choices { display: flex; flex-direction: column; gap: 8px; align-self: flex-end; max-width: 90%; margin-top: 4px; }
.choice {
  border: 1.5px solid var(--you); color: var(--you); background: #fff;
  padding: 10px 14px; border-radius: 18px; font-size: 15px; text-align: right;
  cursor: pointer; transition: all .12s ease;
}
.choice:hover:not(:disabled) { background: #eff6ff; }
.choice.locked { cursor: default; }
.choice.locked:not(.selected) { opacity: .35; }
.choice.selected { background: var(--you); color: #fff; }

.feedback { align-self: center; font-size: 13px; color: var(--muted); background: #f9fafb; border-radius: 12px; padding: 8px 12px; max-width: 92%; }
.feedback.good { color: #14532d; background: #f0fdf4; }
.feedback.bad { color: #7f1d1d; background: #fef2f2; }

.ending { align-self: center; text-align: center; padding: 22px 20px; margin-top: 8px; border-radius: var(--radius); width: 100%; }
.ending.win { background: #f0fdf4; border: 1px solid #bbf7d0; }
.ending.lose { background: #fef2f2; border: 1px solid #fecaca; }
.ending-title { font-size: 22px; font-weight: 700; }
.ending-msg { color: var(--ink); margin: 8px 0 4px; font-size: 14px; }
.ending-score { color: var(--muted); margin: 4px 0 16px; font-weight: 600; }
.ending-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.btn { border: none; padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  cursor: pointer; min-height: 44px; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border: 1.5px solid #d1d5db; }
.btn-primary:hover { background: #000; }
.btn-secondary:hover { border-color: var(--you); color: var(--you); }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 12px; border-top: 1px solid #e5e7eb; }

/* progress bar */
.progress { height: 4px; background: #e5e7eb; position: sticky; top: 53px; z-index: 4; }
.progress-fill { height: 100%; width: 0; background: var(--you); transition: width .4s ease; border-radius: 0 2px 2px 0; }

/* start-over button in the bar */
.startover { background: none; border: 1px solid #d1d5db; color: var(--muted); font-size: 12px;
  padding: 6px 10px; border-radius: 999px; cursor: pointer; min-height: 32px; }
.startover:hover { border-color: var(--you); color: var(--you); }

/* resume + error notices */
.resume-banner { align-self: center; font-size: 12px; color: var(--muted); background: #eef2ff;
  border-radius: 999px; padding: 5px 12px; }
.load-error { align-self: center; text-align: center; background: #fef2f2; border: 1px solid #fecaca;
  border-radius: var(--radius); padding: 20px; max-width: 92%; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.load-error-title { font-weight: 700; color: #7f1d1d; }

/* accessible focus */
:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.choice:focus-visible { outline-offset: 2px; }

/* comfortable tap targets */
.choice { min-height: 44px; }

/* reduced motion: kill transitions/animations/typewriter cursor motion */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .progress-fill { transition: none !important; }
}
