/* ---------- Base ---------- */
:root{
  --bg: #0b1220;
  --card: #111827;
  --muted: #6b7280;
  --text: #e5e7eb;
  --text-strong: #f9fafb;
  --primary: #6366f1; /* indigo */
  --primary-600: #5457e0;
  --warning: #f59e0b;
  --ok: #10b981;
  --err: #ef4444;
  --border: 1px solid rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 16px;
}

@media (prefers-color-scheme: light){
  :root{
    --bg: #f5f7fb;
    --card: #ffffff;
    --muted: #6b7280;
    --text: #111827;
    --text-strong: #0b1220;
    --primary: #4f46e5;
    --primary-600: #4338ca;
    --warning: #d97706;
    --ok: #059669;
    --err: #dc2626;
    --border: 1px solid rgba(17,24,39,.08);
    --shadow: 0 10px 25px rgba(0,0,0,.08);
  }
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
body{
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 20% -10%, rgba(99,102,241,.28), transparent 60%),
              radial-gradient(1200px 600px at 120% 10%, rgba(16,185,129,.20), transparent 55%),
              var(--bg);
}

/* ---------- Layout ---------- */
.app{
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 20px;
}

/* ---------- Header ---------- */
.app-header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand{
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo{
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), #22c55e);
  box-shadow: var(--shadow);
  display: grid; place-items: center;
  font-weight: 800; color: white;
  letter-spacing: .5px;
}
.titles h1{
  margin: 0;
  font-size: 1.5rem;
  color: var(--text-strong);
}
.subtitle{
  margin: 2px 0 0;
  color: var(--muted);
  font-size: .95rem;
}
.stats .chip{
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(99,102,241,.12);
  border: var(--border);
  backdrop-filter: blur(6px);
}
.chip span{ color: var(--muted); font-weight: 600; }
.chip strong{ color: var(--text-strong); font-size: 1.05rem; }

/* ---------- Status Bar ---------- */
.status-bar{
  border: var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent);
  padding: 14px 16px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
}
.status-bar p{ margin: 0; color: var(--text); }

/* ---------- Panel / Form ---------- */
.panel{
  background: var(--card);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.word-form{
  display: grid;
  gap: 14px;
}
.input-row{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}
input#wordInput{
  width: 100%;
  padding: 14px 14px;
  border-radius: 12px;
  border: var(--border);
  outline: none;
  background: rgba(255,255,255,.04);
  color: var(--text);
  font-size: 1rem;
  transition: box-shadow .2s, border-color .2s, transform .05s;
}
input#wordInput:focus{
  border-color: rgba(99,102,241,.55);
  box-shadow: 0 0 0 4px rgba(99,102,241,.18);
}
input#wordInput:disabled{
  opacity: .6; cursor: not-allowed;
}

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

/* Buttons */
.btn{
  appearance: none; border: 0; cursor: pointer;
  padding: 12px 16px; border-radius: 12px;
  font-weight: 700; letter-spacing: .2px;
  transition: transform .06s ease, opacity .2s ease, background .2s ease;
}
.btn:active{ transform: translateY(1px); }
.btn:disabled{ opacity: .6; cursor: not-allowed; }

.btn.primary{
  background: var(--primary);
  color: white;
}
.btn.primary:hover{ background: var(--primary-600); }

.btn.warn{
  background: rgba(245, 158, 11, .16);
  color: #fbbf24;
  border: var(--border);
}
.btn.warn:hover{ background: rgba(245, 158, 11, .22); }

.btn.ghost{
  background: transparent;
  color: var(--text);
  border: var(--border);
}
.btn.ghost:hover{ background: rgba(255,255,255,.05); }

/* Message */
.game-msg{
  min-height: 22px;
  font-weight: 600;
  color: var(--muted);
}
.game-msg.success{ color: var(--ok); }
.game-msg.error{ color: var(--err); }

/* ---------- Turns ---------- */
.turns{
  display: grid; gap: 14px;
}
.turn-list{
  display: grid;
  gap: 12px;
}
.turn{
  border: var(--border);
  background: var(--card);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: pop .16s ease-out both;
}
@keyframes pop{
  from{ transform: translateY(4px); opacity: 0; }
  to{ transform: translateY(0); opacity: 1; }
}

.turn::before{
  content: "";
  position: absolute; inset: 0 0 0 auto; width: 6px;
  border-radius: 0 14px 14px 0;
  opacity: .9;
}
.turn.user::before{ background: linear-gradient(180deg, #22c55e, #10b981); }
.turn.bot::before { background: linear-gradient(180deg, #6366f1, #4f46e5); }

.turn strong{
  display: inline-block; margin-right: 8px; color: var(--muted);
}
.turn .turn-word{
  display: inline-block;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: .5px;
}

/* Word info block returned from API */
.word-info{
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.03);
  border: var(--border);
}
.word-info > strong{
  font-size: 1.05rem;
  color: var(--text-strong);
}
.word-info .phonetic{
  margin-left: 8px; color: var(--muted);
  font-weight: 600;
}
.word-info audio{
  margin-left: 10px; vertical-align: middle; height: 26px;
  filter: saturate(0.9) contrast(1.05);
}
.word-info ul{
  margin: 8px 0 0; padding-left: 18px;
}
.word-info li{
  margin: 6px 0; line-height: 1.45;
}
.word-error{
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: var(--border);
  color: var(--err);
  background: rgba(239,68,68,.08);
}

/* ---------- Footer ---------- */
.app-footer{
  text-align: center;
  color: var(--muted);
  font-size: .9rem;
  margin-top: 8px;
}
kbd{
  background: rgba(255,255,255,.08);
  padding: 2px 6px;
  border-radius: 6px;
  border: var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px){
  .app{ padding: 22px 14px 36px; gap: 16px; }
  .logo{ width: 40px; height: 40px; }
  .input-row{ grid-template-columns: 1fr auto; }
  .btn{ padding: 11px 14px; }
}

/* Utility states your JS can toggle if muốn:
   document.getElementById('gameMsg').classList.add('error'|'success')
*/
