/* KidsQuest - bright, chunky, kid-friendly UI. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #1d2b53; --panel: #ffffff; --ink: #222; --accent: #ff6b6b;
  --green: #2ecc71; --blue: #3498db; --yellow: #ffd93d; --purple: #8e44ad;
}
html, body { height: 100%; font-family: 'Comic Sans MS', 'Trebuchet MS', system-ui, sans-serif; }
body {
  background: radial-gradient(circle at 30% 20%, #3a5bbf, #1d2b53);
  color: var(--ink); overflow: hidden; user-select: none;
}
.hidden { display: none !important; }
button {
  font-family: inherit; cursor: pointer; border: none; border-radius: 14px;
  padding: 12px 18px; font-size: 16px; font-weight: bold; color: #fff;
  background: var(--blue); box-shadow: 0 4px 0 rgba(0,0,0,.25); transition: transform .05s;
}
button:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.25); }
button.secondary { background: #95a5a6; }
button.green { background: var(--green); }
button.red { background: var(--accent); }
button.yellow { background: var(--yellow); color: #5a4500; }

/* ---------- Login ---------- */
#login {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--panel); border-radius: 24px; padding: 28px; width: min(380px, 92vw);
  text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.login-card h1 { font-size: 34px; color: var(--purple); margin-bottom: 4px; }
.login-card p.tag { color: #888; margin-bottom: 18px; }
.who { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.who button { background: #ecf0f1; color: #333; }
.who button.sel { background: var(--yellow); color: #5a4500; outline: 3px solid #f1c40f; }
.pin-display { font-size: 30px; letter-spacing: 12px; height: 40px; margin: 8px 0; color: #333; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.pinpad button { background: #ecf0f1; color: #333; font-size: 22px; padding: 16px; }
.err { color: var(--accent); font-weight: bold; min-height: 22px; margin-top: 6px; }
.parent-link { margin-top: 14px; font-size: 13px; }
.parent-link a { color: #888; }

/* ---------- Game shell ---------- */
#game { position: fixed; inset: 0; display: flex; flex-direction: column; }
#hud {
  display: flex; align-items: center; gap: 14px; padding: 8px 14px;
  background: rgba(0,0,0,.55); color: #fff; flex-wrap: wrap;
}
#hud .avatar-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; }
#hud .name { font-weight: bold; font-size: 18px; }
#hud .lvl { background: var(--yellow); color: #5a4500; border-radius: 10px; padding: 2px 10px; font-weight: bold; }
.xpbar { width: 180px; height: 16px; background: rgba(255,255,255,.25); border-radius: 10px; overflow: hidden; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, #2ecc71, #a8ff78); width: 0%; transition: width .4s; }
#hud .points { font-weight: bold; color: var(--yellow); }
#hud .spacer { flex: 1; }
#hud .topbtns button { padding: 8px 12px; font-size: 14px; }

#stage { position: relative; flex: 1; overflow: hidden; background: #6ab04c; }
#world { display: block; image-rendering: pixelated; margin: 0 auto; }
#actionHint {
  position: absolute; bottom: 120px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.75); color: #fff; padding: 10px 18px; border-radius: 30px;
  font-weight: bold; font-size: 16px;
}

/* on-screen controls (touch) */
#touch { position: absolute; bottom: 14px; left: 14px; display: grid;
  grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 6px; opacity: .85; }
#touch button { background: rgba(0,0,0,.5); border-radius: 12px; font-size: 22px; padding: 0; }
#touch .up { grid-column: 2; grid-row: 1; }
#touch .left { grid-column: 1; grid-row: 2; }
#touch .right { grid-column: 3; grid-row: 2; }
#touch .down { grid-column: 2; grid-row: 3; }
#actionBtn { position: absolute; bottom: 24px; right: 18px; background: var(--green);
  width: 86px; height: 86px; border-radius: 50%; font-size: 15px; }

/* emote/phrase bar */
#social { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; flex-wrap: wrap; max-width: 50vw; justify-content: flex-end; }
#social button { padding: 8px 10px; font-size: 18px; background: rgba(255,255,255,.85); color: #333; }

/* chat */
#chatPanel { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  width: min(440px, 70vw); }
#chatLog { max-height: 130px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  margin-bottom: 6px; }
.chatmsg { background: rgba(255,255,255,.9); border-radius: 12px; padding: 5px 10px; font-size: 14px;
  align-self: flex-start; max-width: 90%; }
.chatmsg.me { align-self: flex-end; background: #d1f2eb; }
.chatmsg b { color: var(--purple); }
.chatmsg.flagged { outline: 2px dashed #e67e22; }
#chatForm { display: flex; gap: 6px; }
#chatForm input { flex: 1; border-radius: 12px; border: none; padding: 10px; font-size: 15px; }

/* ---------- Modal ---------- */
#modalWrap { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 22px; padding: 22px; width: min(560px, 94vw);
  max-height: 90vh; overflow-y: auto; box-shadow: 0 16px 50px rgba(0,0,0,.5); }
.modal h2 { color: var(--purple); margin-bottom: 10px; }
.modal .close { float: right; background: #bbb; padding: 6px 12px; }
.qtext { font-size: 22px; margin: 16px 0; font-weight: bold; }
.choices { display: grid; gap: 10px; }
.choices button { background: #ecf0f1; color: #222; text-align: left; font-size: 18px; }
.choices button.correct { background: var(--green); color: #fff; }
.choices button.wrong { background: var(--accent); color: #fff; }
.choices button.removed { opacity: .35; text-decoration: line-through; pointer-events: none; }
.choices button.chosen { outline: 3px solid #2980b9; }
.itembar { display: flex; gap: 8px; margin: 14px 0; flex-wrap: wrap; }
.itembar button { background: var(--yellow); color: #5a4500; font-size: 14px; padding: 8px 12px; }
.itembar button:disabled { opacity: .4; }
.progressdots { display: flex; gap: 6px; margin: 8px 0; }
.progressdots span { width: 14px; height: 14px; border-radius: 50%; background: #ddd; }
.progressdots span.done { background: var(--green); }
.progressdots span.cur { background: var(--yellow); }
.shop-item, .reward-item { display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 2px solid #eee; border-radius: 14px; margin-bottom: 8px; }
.shop-item .grow, .reward-item .grow { flex: 1; }
.cost { font-weight: bold; color: var(--purple); }
.npc-log { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 240px; overflow-y: auto; }
.npc-bubble { background: #fff7d6; padding: 10px 14px; border-radius: 14px; align-self: flex-start; }
.npc-bubble.me { background: #d6ecff; align-self: flex-end; }
.coop-view { font-size: 40px; letter-spacing: 10px; text-align: center; margin: 14px 0; color: var(--purple); }
.toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100;
  background: #2c3e50; color: #fff; padding: 12px 22px; border-radius: 30px; font-weight: bold;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.good { background: var(--green); } .toast.bad { background: var(--accent); }
.suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.suggestions button { background: #ecf0f1; color: #333; font-size: 13px; padding: 6px 10px; }
