:root {
  --bg: #f8f1e3;
  --wood: #c9a26b;
  --wood-dark: #8b5e3c;
  --glow: #ffd700;
  --soft: #fff8ee;
  --text: #3d2b1f;
  --accent: #e8a87c;
  --success: #7ec8a3;
  --frame-dim: #d4c4a8;
  --frame-glow: #f0c14e;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, #fdf6e9 0%, #f0e0c0 100%);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
.screen { display: none; min-height: 100vh; padding: 12px; padding-bottom: 90px; }
.screen.active { display: block; }
header { text-align: center; padding: 12px 8px 8px; position: relative; }
header h1 { font-size: 1.6rem; color: var(--wood-dark); text-shadow: 1px 1px 0 #fff; letter-spacing: 0.5px; }
header .subtitle { font-size: 0.85rem; color: #8b7355; margin-top: 2px; }
.mission {
  background: var(--soft);
  border: 2px solid var(--wood);
  border-radius: 16px;
  padding: 10px 14px;
  margin: 10px auto;
  max-width: 420px;
  text-align: center;
  font-size: 0.95rem;
  box-shadow: 0 3px 0 var(--wood-dark);
}
.mission strong { color: var(--wood-dark); }
.pips { display: flex; justify-content: center; gap: 6px; margin: 10px 0; flex-wrap: wrap; }
.pip {
  width: 18px; height: 18px; border-radius: 50%;
  background: #e0d0b0; border: 2px solid #c9a26b; transition: all 0.3s;
}
.pip.filled {
  background: linear-gradient(135deg, #ffd700, #ffaa00);
  box-shadow: 0 0 8px #ffd700aa; transform: scale(1.1);
}
.hall {
  display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 14px;
  padding: 16px 12px 24px; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.portrait {
  flex: 0 0 130px; scroll-snap-align: start; background: var(--soft);
  border-radius: 14px; border: 4px solid var(--frame-dim); padding: 8px 6px 10px;
  text-align: center; transition: all 0.4s ease; position: relative;
  box-shadow: 0 4px 0 #b8956a;
}
.portrait.state-0 { opacity: 0.7; filter: grayscale(0.4); }
.portrait.state-1 { border-color: #e8b86d; box-shadow: 0 0 10px #e8b86d66, 0 4px 0 #b8956a; }
.portrait.state-2 { border-color: #f0c14e; box-shadow: 0 0 14px #f0c14e88, 0 4px 0 #b8956a; }
.portrait.state-3 {
  border-color: #ffd700;
  box-shadow: 0 0 20px #ffd700aa, 0 4px 0 #b8956a;
  background: linear-gradient(180deg, #fff9e6, #fff);
}
.portrait .num { font-size: 1.4rem; font-weight: 800; color: var(--wood-dark); line-height: 1; }
.portrait .name { font-size: 0.72rem; font-weight: 600; margin-top: 4px; line-height: 1.15; min-height: 2.3em; }
.portrait .status { font-size: 0.65rem; margin-top: 4px; padding: 2px 6px; border-radius: 10px; display: inline-block; }
.status-new { background: #e8e0d0; color: #7a6a55; }
.status-practicing { background: #ffe8c0; color: #8a5a20; }
.status-solid { background: #d4f0c8; color: #2d6a3e; }
.status-shining { background: linear-gradient(90deg,#ffe066,#ffd700); color: #5a4000; font-weight: 700; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 16px 0; }
.btn {
  background: linear-gradient(180deg, #f5d78e, #e8b86d);
  border: none; border-radius: 14px; padding: 12px 20px;
  font-size: 1rem; font-weight: 700; color: #3d2b1f;
  box-shadow: 0 4px 0 #b8956a; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s; min-width: 140px;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b8956a; }
.btn.primary {
  background: linear-gradient(180deg, #7ec8a3, #5aab84);
  box-shadow: 0 4px 0 #3d7a5c; color: #fff;
}
.btn.secondary {
  background: linear-gradient(180deg, #f0e0c8, #e0d0b0);
  box-shadow: 0 4px 0 #b0a080;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.card {
  background: var(--soft); border: 3px solid var(--wood); border-radius: 20px;
  padding: 18px 14px; max-width: 420px; margin: 0 auto;
  box-shadow: 0 6px 0 var(--wood-dark); text-align: center;
}
.big-num { font-size: 3.2rem; font-weight: 900; color: var(--wood-dark); line-height: 1; margin-bottom: 4px; }
.big-name { font-size: 1.4rem; font-weight: 700; margin-bottom: 12px; }
.mnemonic-box {
  background: #fff; border-radius: 14px; padding: 12px; margin: 12px 0;
  border: 2px dashed #e8b86d;
}
.mnemonic-box .emoji { font-size: 2.8rem; margin-bottom: 6px; }
.mnemonic-box p { font-size: 0.95rem; line-height: 1.35; }
.hint { font-size: 0.8rem; color: #8b7355; margin-top: 8px; }
.options { display: grid; gap: 10px; margin-top: 16px; }
.opt {
  background: #fff; border: 2px solid var(--wood); border-radius: 12px;
  padding: 14px; font-size: 1.05rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; text-align: center;
}
.opt:active { background: #fff8e0; }
.opt.correct { background: #d4f0c8; border-color: #5aab84; }
.opt.wrong { background: #fde8e0; border-color: #e8a07c; opacity: 0.7; }
#toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #3d2b1f; color: #fff; padding: 12px 20px; border-radius: 30px;
  font-weight: 600; font-size: 0.95rem; opacity: 0; transition: all 0.3s;
  z-index: 100; pointer-events: none; max-width: 90%; text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.success { background: #2d6a3e; }
#toast.warm { background: #8a5a20; }
nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--soft); border-top: 3px solid var(--wood);
  display: flex; justify-content: space-around;
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 50;
}
nav button {
  background: none; border: none; font-size: 0.75rem; color: #8b7355;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 10px; cursor: pointer; border-radius: 12px;
}
nav button.active { color: var(--wood-dark); background: #f5e6c8; font-weight: 700; }
nav button span.icon { font-size: 1.4rem; }
.parent-link { text-align: center; margin-top: 20px; font-size: 0.75rem; color: #a09080; }
.parent-link a { color: #8b7355; }
.profile-grid {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; padding: 16px 8px;
}
.profile-card {
  background: var(--soft); border: 3px solid var(--wood); border-radius: 16px;
  padding: 16px 20px; text-align: center; cursor: pointer;
  box-shadow: 0 4px 0 var(--wood-dark); min-width: 110px; transition: transform 0.1s;
}
.profile-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood-dark); }
.profile-card .avatar { font-size: 2.4rem; margin-bottom: 6px; }
.profile-card .pname { font-weight: 700; font-size: 0.95rem; }
.avatar-choices { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.avatar-choices span {
  font-size: 2rem; padding: 8px; border-radius: 12px; border: 2px solid transparent; cursor: pointer;
}
.avatar-choices span.selected { border-color: var(--wood-dark); background: #fff8e0; }
.kid-badge {
  display: inline-block; margin-top: 6px; background: #fff8e0;
  border: 2px solid var(--wood); border-radius: 20px; padding: 4px 12px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
@media (min-width: 500px) {
  .hall { justify-content: flex-start; padding-left: 20px; }
  .portrait { flex: 0 0 140px; }
}
