/* ============ ĐÁY BIỂN PHÁT QUANG — design system ============ */
:root {
  --abyss-0: #04121f;
  --abyss-1: #062a3f;
  --abyss-2: #0a3a52;
  --glow: #3ee6c4;
  --glow-dim: rgba(62, 230, 196, .14);
  --teal: #0e7c86;
  --amber: #f5b942;
  --coral: #ff6b6b;
  --lime: #a3e635;
  --ink: #eaf6f3;
  --muted: #93b8b2;
  --card: rgba(10, 42, 63, .55);
  --card-border: rgba(62, 230, 196, .16);
  --radius: 20px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --font: "Be Vietnam Pro", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; overflow-x: clip; }
@supports not (overflow: clip) { html { overflow-x: hidden; } }
body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, var(--abyss-0) 0%, var(--abyss-1) 55%, #072033 100%);
  min-height: 100vh;
  line-height: 1.55;
  overflow-x: hidden;
}

/* --- background light rays --- */
.ocean-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.ray {
  position: absolute; top: -20%; width: 120px; height: 140%;
  background: linear-gradient(180deg, rgba(62,230,196,.10), transparent 70%);
  filter: blur(28px); transform: rotate(14deg);
  animation: sway 11s ease-in-out infinite alternate;
}
.ray.r1 { left: 12%; } .ray.r2 { left: 46%; animation-delay: -4s; width: 180px; }
.ray.r3 { left: 78%; animation-delay: -7s; }
@keyframes sway { from { transform: rotate(10deg) translateX(-30px); } to { transform: rotate(18deg) translateX(30px); } }

/* --- header --- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 40px);
  max-width: 860px; margin: 0 auto;
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark { width: 44px; height: 44px; filter: drop-shadow(0 0 10px rgba(62,230,196,.5)); }
.brand h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -.01em; }
.brand p { font-size: .82rem; color: var(--muted); }
.demo-badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .14em;
  color: var(--amber); border: 1px solid rgba(245,185,66,.5);
  padding: 5px 12px; border-radius: 999px; background: rgba(245,185,66,.08);
}

main { max-width: 860px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 40px; display: grid; gap: 20px; }
main > * { min-width: 0; } /* cho phép card co nhỏ hơn nội dung (bảng 480px) trên mobile */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: clamp(18px, 3.5vw, 28px);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255,255,255,.06);
}
.card h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.step {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--glow-dim); color: var(--glow);
  border: 1px solid rgba(62,230,196,.4);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 800;
}
.hidden { display: none !important; }

/* --- segmented tabs --- */
.seg { display: flex; gap: 6px; background: rgba(0,0,0,.28); border-radius: 999px; padding: 5px; margin-bottom: 16px; }
.seg-btn {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-family: var(--font); font-weight: 600; font-size: .85rem;
  padding: 10px 6px; border-radius: 999px; cursor: pointer;
  transition: all .35s var(--ease); white-space: nowrap;
}
.seg-btn.active { background: var(--glow); color: #04222b; box-shadow: 0 0 18px rgba(62,230,196,.45); }
.tab-panel { display: none; animation: fadeUp .45s var(--ease); }
.tab-panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.search-row { display: flex; gap: 10px; }
#search-input {
  flex: 1; background: rgba(0,0,0,.32); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 13px 16px; color: var(--ink);
  font-family: var(--font); font-size: .95rem; outline: none;
  transition: border-color .3s, box-shadow .3s;
}
#search-input:focus { border-color: var(--glow); box-shadow: 0 0 0 3px var(--glow-dim); }
#search-input::placeholder { color: rgba(147,184,178,.6); }
.btn-primary {
  background: var(--glow); color: #04222b; border: 0; border-radius: 14px;
  font-family: var(--font); font-weight: 700; font-size: .95rem;
  padding: 13px 22px; cursor: pointer; transition: transform .25s var(--ease), box-shadow .25s;
  box-shadow: 0 0 20px rgba(62,230,196,.35);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 0 30px rgba(62,230,196,.55); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: wait; transform: none; }

.results { list-style: none; margin-top: 10px; display: grid; gap: 8px; }
.results li button {
  width: 100%; text-align: left; background: rgba(0,0,0,.25);
  border: 1px solid transparent; border-radius: 12px; color: var(--ink);
  font-family: var(--font); padding: 12px 14px; cursor: pointer; font-size: .9rem;
  transition: all .25s var(--ease); display: flex; flex-direction: column; gap: 2px;
}
.results li button:hover { border-color: var(--glow); background: var(--glow-dim); }
.results small { color: var(--muted); font-size: .78rem; }

.hint { color: var(--muted); font-size: .88rem; margin-bottom: 12px; }
.status { margin-top: 10px; font-size: .85rem; color: var(--muted); min-height: 1.4em; }

.chosen-place {
  margin-top: 16px; display: flex; align-items: center; gap: 10px;
  background: var(--glow-dim); border: 1px solid rgba(62,230,196,.4);
  border-radius: 14px; padding: 12px 16px; font-weight: 600;
  animation: fadeUp .45s var(--ease);
}
.chosen-place svg { width: 22px; height: 22px; color: var(--glow); flex-shrink: 0; }
.link-btn { background: none; border: 0; color: var(--glow); font-family: var(--font); font-size: .85rem; cursor: pointer; text-decoration: underline; margin-left: auto; }

/* --- prediction scene --- */
.scene { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--card-border); }
#sea { display: block; width: 100%; height: 340px; }
.scene-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; padding: 20px;
  pointer-events: none; text-align: center;
}
.gauge-wrap { position: relative; width: 200px; }
.gauge { width: 100%; display: block; filter: drop-shadow(0 0 12px rgba(62,230,196,.35)); }
#gauge-arc { transition: stroke-dashoffset 1.6s var(--ease); }
.score-num {
  position: absolute; left: 0; right: 0; bottom: 6px;
  font-size: 2.6rem; font-weight: 800; letter-spacing: -.02em;
  text-shadow: 0 0 24px rgba(62,230,196,.6);
}
.score-num small { font-size: 1rem; font-weight: 500; color: var(--muted); }
.verdict-title {
  font-size: clamp(1.7rem, 6vw, 2.6rem); font-weight: 800; letter-spacing: -.02em;
  text-shadow: 0 2px 30px rgba(0,0,0,.6);
}
.verdict-sub { color: var(--ink); opacity: .85; font-size: .95rem; max-width: 420px; text-shadow: 0 1px 12px rgba(0,0,0,.7); }

.scale-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; font-size: .78rem; color: var(--muted); }
.scale-legend span::before {
  content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--c); margin-right: 6px; box-shadow: 0 0 8px var(--c);
}

/* --- factor chips --- */
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 10px; }
.chip {
  background: rgba(0,0,0,.28); border: 1px solid var(--card-border);
  border-radius: 14px; padding: 12px 14px;
  animation: fadeUp .5s var(--ease) backwards;
}
.chip:nth-child(2) { animation-delay: .06s } .chip:nth-child(3) { animation-delay: .12s }
.chip:nth-child(4) { animation-delay: .18s } .chip:nth-child(5) { animation-delay: .24s }
.chip:nth-child(6) { animation-delay: .3s } .chip:nth-child(7) { animation-delay: .36s }
.chip:nth-child(8) { animation-delay: .42s }
.chip .k { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.chip .v { font-size: 1.02rem; font-weight: 700; }
.chip .d { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.chip.good .v { color: var(--glow); } .chip.warn .v { color: var(--amber); } .chip.bad .v { color: var(--coral); }

.ai-note {
  margin-top: 16px; display: flex; gap: 12px; align-items: flex-start;
  background: rgba(245,185,66,.07); border: 1px dashed rgba(245,185,66,.4);
  border-radius: 14px; padding: 14px 16px; font-size: .85rem; color: var(--muted);
}
.ai-note svg { width: 22px; height: 22px; color: var(--amber); flex-shrink: 0; margin-top: 2px; }

.hist-title { font-size: .85rem; font-weight: 700; color: var(--glow); margin: 14px 0 8px; letter-spacing: .02em; }
.hist-title:first-of-type { margin-top: 0; }
.hist-scroll { overflow-x: auto; max-width: 100%; border-radius: 12px; border: 1px solid var(--card-border); -webkit-overflow-scrolling: touch; }
.hist-table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 480px; }
.hist-table th, .hist-table td { padding: 9px 12px; text-align: center; white-space: nowrap; }
.hist-table thead th {
  background: rgba(62,230,196,.08); color: var(--glow);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
}
.hist-table tbody tr:nth-child(even) { background: rgba(0,0,0,.18); }
.hist-table tbody td:first-child { font-weight: 700; color: var(--ink); }
.hist-table td { color: var(--muted); }
.hist-note { margin-top: 12px; font-size: .78rem; color: var(--muted); }

footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 8px 16px 30px; }
footer a { color: var(--glow); }

@media (max-width: 560px) {
  #sea { height: 300px; }
  .search-row { flex-direction: column; }
  .btn-primary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .ray { animation: none; }
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
