* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg1: #002242;
  --bg2: #0d4a8f;
  --card: #ffffff;
  --ink: #2d2a4a;
  --accent: #ffb703;
  --good: #2ec27e;
  --bad: #ff6b6b;
  --btn: #f4f1ff;
}

html, body { height: 100%; }

body {
  font-family: "Itim", "Baloo 2", "Sukhumvit Set", "Noto Sans Thai", -apple-system, sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  color: var(--ink);
  overflow-x: hidden;
}

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

#topbar { display: flex; align-items: center; gap: 12px; padding: 14px 16px 6px; }
#brand { font-weight: 800; font-size: 1.1rem; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.3); white-space: nowrap; }
#progress-wrap { flex: 1; }
#progress-track { position: relative; height: 14px; background: rgba(255,255,255,.25); border-radius: 999px; }
#progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #ffd166, #ffb703); border-radius: 999px; transition: width .5s ease; }
#progress-rocket { position: absolute; top: -10px; left: 0%; font-size: 1.5rem; transform: translateX(-50%); transition: left .5s ease; filter: drop-shadow(0 2px 3px rgba(0,0,0,.3)); }

#screen { flex: 1; display: flex; flex-direction: column; padding: 12px 16px 28px; }

.card {
  background: var(--card);
  border-radius: 24px;
  padding: 22px 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  animation: pop-in .35s ease;
}
@keyframes pop-in { from { transform: scale(.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.big-emoji { font-size: 4.5rem; line-height: 1.2; }
.title { font-size: 1.7rem; font-weight: 800; text-align: center; }
.subtitle { font-size: 1.05rem; text-align: center; color: #6b678c; }
.thai-prompt { font-size: 1.45rem; font-weight: 700; text-align: center; }
.en-hint { font-size: .85rem; color: #9a96b8; text-align: center; }

.btn {
  font-family: inherit;
  border: none; cursor: pointer;
  border-radius: 18px;
  font-size: 1.25rem; font-weight: 700;
  padding: 16px 28px;
  background: var(--accent); color: #4a3200;
  box-shadow: 0 4px 0 #d99a00;
  transition: transform .08s ease;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #d99a00; }
.btn.whatsapp { background: #25d366; color: #fff; box-shadow: 0 4px 0 #1da851; }
.btn.whatsapp:active { box-shadow: 0 1px 0 #1da851; }
.btn.secondary { background: var(--btn); color: var(--ink); box-shadow: 0 4px 0 #d5d0ee; font-size: 1rem; padding: 12px 20px; }

.audio-btn {
  border: none; cursor: pointer;
  background: var(--btn); border-radius: 999px;
  font-size: 1.6rem; padding: 10px 22px;
  box-shadow: 0 3px 0 #d5d0ee;
}
.audio-btn:active { transform: translateY(2px); box-shadow: none; }

.prompt-area { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.prompt-visual { font-size: 3.4rem; text-align: center; line-height: 1.3; letter-spacing: 4px; }
.prompt-visual.text-mode { font-size: 2.4rem; font-weight: 800; letter-spacing: 1px; }

.options {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%;
}
.opt {
  font-family: inherit;
  border: 3px solid #e8e4fb; cursor: pointer;
  background: var(--btn); border-radius: 20px;
  min-height: 88px;
  font-size: 2.6rem; font-weight: 800; color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: transform .08s ease, background .15s, border-color .15s;
  padding: 8px;
}
.opt.word { font-size: 1.6rem; letter-spacing: 1px; }
.opt:active { transform: scale(.96); }
.opt.correct { background: #d9f7e8; border-color: var(--good); }
.opt.wrong { background: #ffe3e3; border-color: var(--bad); animation: shake .3s; }
.opt.reveal { border-color: var(--good); }
.opt:disabled { cursor: default; opacity: .95; }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.feedback-burst {
  position: fixed; top: 40%; left: 50%; transform: translate(-50%,-50%);
  font-size: 5rem; pointer-events: none; z-index: 50;
  animation: burst .8s ease forwards;
}
@keyframes burst { 0% { transform: translate(-50%,-50%) scale(.3); opacity: 0; } 30% { transform: translate(-50%,-50%) scale(1.3); opacity: 1; } 100% { transform: translate(-50%,-60%) scale(1); opacity: 0; } }

.memory-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; }
.mem-btn {
  border: 3px solid #e8e4fb; background: var(--btn); border-radius: 20px;
  font-size: 2.8rem; min-height: 90px; cursor: pointer;
  transition: transform .1s, background .12s, border-color .12s;
}
.mem-btn.lit { background: #fff3c4; border-color: var(--accent); transform: scale(1.08); }
.mem-btn.tapped { background: #e5f6ff; border-color: #58b7e6; }
.mem-btn:disabled { cursor: default; }

.stars-row { font-size: 2.2rem; letter-spacing: 6px; }

.results-box { width: 100%; display: flex; flex-direction: column; gap: 12px; }
.result-line { background: var(--btn); border-radius: 14px; padding: 12px 14px; font-size: 1rem; }
.result-line b { display: block; font-size: 1.05rem; }
.result-line span { color: #6b678c; font-size: .9rem; }
.code-area {
  width: 100%; min-height: 90px; font-family: monospace; font-size: .7rem;
  border: 2px dashed #c9c3ea; border-radius: 12px; padding: 10px; color: #555;
  word-break: break-all;
}
.modal-back { position: fixed; inset: 0; background: rgba(20,15,60,.6); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal { background: #fff; border-radius: 20px; padding: 22px; max-width: 480px; max-height: 80vh; overflow-y: auto; font-size: .95rem; line-height: 1.6; }
.modal h3 { margin-bottom: 8px; }

.link-btn { background: none; border: none; color: #7a76a0; text-decoration: underline; font-size: .9rem; cursor: pointer; font-family: inherit; margin-top: 14px; }

@media (max-width: 400px) {
  .opt { min-height: 76px; font-size: 2.2rem; }
  .title { font-size: 1.45rem; }
}
