/* Huỳnh Vinh EdTech Ecosystem Design System */
:root,
[data-palette="keo-ngot"] {
  --hv-brand: #5b3fd9;
  --hv-brand-deep: #3e2a9e;
  --hv-accent: #d9501a;
  --hv-fresh: #12805a;
  --hv-berry: #b02a6b;
  --hv-sun: #ffc23c;
  --hv-paper: #fffbf4;
  --hv-ink: #1e1a3c;
  --hv-muted: #6b6684;
  --hv-line: rgba(30, 26, 60, 0.12);
  --hv-card-bg: #ffffff;
  --hv-badge-bg: rgba(91, 63, 217, 0.08);

  --bg: var(--hv-paper);
  --ink: var(--hv-ink);
  --muted: var(--hv-muted);
  --green: var(--hv-brand);
  --lime: var(--hv-sun);
  --line: var(--hv-line);
}

[data-palette="dai-duong"] {
  --hv-brand: #1d5fd1;
  --hv-brand-deep: #123f8f;
  --hv-accent: #d0531a;
  --hv-fresh: #0b7b80;
  --hv-berry: #7a3fc4;
  --hv-sun: #ffd24d;
  --hv-paper: #f4f9ff;
  --hv-ink: #0f2440;
  --hv-muted: #5e6f85;
  --hv-line: rgba(15, 36, 64, 0.12);
  --hv-badge-bg: rgba(29, 95, 209, 0.08);

  --bg: var(--hv-paper);
  --ink: var(--hv-ink);
  --muted: var(--hv-muted);
  --green: var(--hv-brand);
  --lime: var(--hv-sun);
  --line: var(--hv-line);
}

[data-palette="vuon-xanh"] {
  --hv-brand: #1c7a4e;
  --hv-brand-deep: #11512f;
  --hv-accent: #cf4527;
  --hv-fresh: #2f5fd0;
  --hv-berry: #8e3aa8;
  --hv-sun: #f5c542;
  --hv-paper: #f6fbf3;
  --hv-ink: #13301f;
  --hv-muted: #5a7363;
  --hv-line: rgba(19, 48, 31, 0.12);
  --hv-badge-bg: rgba(28, 122, 78, 0.08);

  --bg: var(--hv-paper);
  --ink: var(--hv-ink);
  --muted: var(--hv-muted);
  --green: var(--hv-brand);
  --lime: var(--hv-sun);
  --line: var(--hv-line);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .brand, .brand-title, .clock, .result-score, .timer-art strong, .font-display {
  font-family: 'Baloo 2', 'Be Vietnam Pro', system-ui, sans-serif;
  font-weight: 700;
}

button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
button {
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  padding: 11px 20px;
  color: var(--ink);
  background: rgba(30, 26, 60, 0.06);
  font-weight: 650;
  transition: all 0.18s ease;
}
button:hover { filter: brightness(0.95); }
button:disabled { opacity: 0.5; cursor: wait; }
a { color: inherit; text-decoration: none; }

.shell { max-width: 1260px; padding: 0 36px; margin: auto; }

/* HEADER */
header {
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.back-home-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(30, 26, 60, 0.05);
  padding: 8px 14px;
  border-radius: 999px;
  transition: all 0.2s ease;
}
.back-home-btn:hover {
  background: var(--green);
  color: #fff;
  transform: translateX(-2px);
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
}
.brand-icon {
  background: linear-gradient(135deg, var(--green), var(--hv-brand-deep));
  color: white;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(91, 63, 217, 0.25);
}
.brand-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.5px;
  color: var(--ink);
}
.brand-title span { color: var(--green); }
.brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
  font-family: 'Be Vietnam Pro', system-ui, sans-serif;
  letter-spacing: 0.2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.live-dot {
  height: 8px;
  width: 8px;
  border-radius: 100%;
  background: var(--hv-fresh);
  box-shadow: 0 0 0 3px rgba(18, 128, 90, 0.2);
}

/* PALETTE PICKER */
.palette-picker {
  display: flex;
  gap: 4px;
  align-items: center;
  background: rgba(30, 26, 60, 0.05);
  padding: 4px 6px;
  border-radius: 999px;
}
.palette-btn {
  background: transparent;
  border: 0;
  padding: 5px 8px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.15s, background 0.15s;
}
.palette-btn:hover { transform: scale(1.2); }
.palette-btn.active { background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.12); }

/* APP SWITCHER 9-DOTS */
.app-switcher-wrap { position: relative; }
.app-switcher-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 26, 60, 0.05);
  color: var(--ink);
  padding: 0;
  cursor: pointer;
  transition: all 0.2s;
}
.app-switcher-btn:hover { background: rgba(30, 26, 60, 0.1); }
.app-switcher-dropdown {
  position: absolute;
  right: 0;
  top: 48px;
  width: 320px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 12px;
  box-shadow: 0 20px 45px rgba(30, 26, 60, 0.15);
  z-index: 100;
  animation: dropdownIn 0.15s ease-out;
}
@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.app-switcher-header {
  padding: 6px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.app-switcher-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin: 0;
  text-transform: uppercase;
}
.app-switcher-header small { font-size: 11px; color: var(--muted); }
.app-switcher-list { display: flex; flex-direction: column; gap: 4px; }
.app-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 14px;
  text-decoration: none;
  transition: all 0.15s;
}
.app-item:hover {
  background: rgba(91, 63, 217, 0.06);
  transform: translateX(2px);
}
.app-item.current {
  background: rgba(91, 63, 217, 0.08);
  border: 1px solid rgba(91, 63, 217, 0.2);
}
.app-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.bg-portal { background: #e0e7ff; color: #4338ca; }
.bg-vuihoc { background: #fef3c7; color: #d97706; }
.bg-eduquest { background: #d1fae5; color: #059669; }
.bg-lumihoc { background: #ede9fe; color: #7c3aed; }
.bg-games { background: #fee2e2; color: #dc2626; }
.app-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-info strong { font-size: 13px; font-weight: 700; color: var(--ink); }
.app-info span { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-badge {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  padding: 3px 8px;
  border-radius: 999px;
}

/* HERO */
.hero {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 30px;
  padding: 60px 0 50px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--green);
  text-transform: uppercase;
}
h1 {
  font-size: clamp(38px, 4.8vw, 58px);
  line-height: 1.15;
  letter-spacing: -1.5px;
  margin: 18px 0;
}
h1 span {
  color: var(--green);
  background: linear-gradient(135deg, var(--green), var(--hv-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
p { color: var(--muted); margin: 0 0 20px; line-height: 1.65; }
h2 { font-size: 28px; letter-spacing: -0.5px; line-height: 1.3; margin: 9px 0 18px; }
h3 { font-size: 22px; line-height: 1.35; margin: 16px 0; }
.pills { display: flex; gap: 10px; flex-wrap: wrap; font-size: 11px; margin-top: 26px; }
.pills span {
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 7px 14px;
  background: white;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.hero-art {
  position: relative;
  min-height: 290px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse, rgba(255, 194, 60, 0.18), transparent 68%);
}
.timer-art {
  background: linear-gradient(135deg, var(--green), var(--hv-brand-deep));
  color: white;
  width: 230px;
  height: 245px;
  border-radius: 40px;
  transform: rotate(-7deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 14px 18px 0 rgba(91, 63, 217, 0.15);
  z-index: 1;
}
.timer-art small { font-size: 10px; letter-spacing: 2px; color: rgba(255, 255, 255, 0.8); font-weight: 700; }
.timer-art strong { font-size: 92px; font-weight: 800; line-height: 1.3; letter-spacing: -5px; }
.timer-art strong span { font-size: 30px; letter-spacing: 0; }
.timer-art > div {
  font-size: 10px;
  background: var(--lime);
  color: var(--hv-ink);
  border-radius: 30px;
  padding: 6px 20px;
  letter-spacing: 2px;
  font-weight: 800;
}
.orbit {
  position: absolute;
  border: 1.5px dashed rgba(91, 63, 217, 0.2);
  border-radius: 50%;
  width: 320px;
  height: 220px;
  transform: rotate(-33deg);
}
.orbit-two { transform: rotate(38deg); border-color: rgba(255, 194, 60, 0.35); }
.spark { position: absolute; color: var(--hv-sun); font-size: 44px; z-index: 2; }
.spark-one { top: 20px; right: 45px; }
.spark-two { bottom: 0; left: 40px; font-size: 60px; color: var(--green); }

/* PANELS & CARDS */
.panel, .card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #ffffff;
  padding: 28px;
  box-shadow: 0 4px 20px rgba(30, 26, 60, 0.04);
}
.auth-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 45px; }
.primary {
  background: var(--green);
  color: white;
  box-shadow: 0 4px 14px rgba(91, 63, 217, 0.25);
}
.primary:hover { filter: brightness(1.06); }
.quiet { background: transparent; color: var(--green); }
.quiet:hover { background: rgba(91, 63, 217, 0.08); }

label { display: block; font-size: 13px; font-weight: 650; margin: 0 0 16px; color: var(--ink); }
input, select, textarea {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fafbfc;
  margin-top: 6px;
  color: var(--ink);
  transition: border-color 0.15s;
}
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(91, 63, 217, 0.15);
}
.form-actions { display: flex; gap: 12px; align-items: center; }

/* TABS & NAVIGATION */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin: 12px 0 24px;
  gap: 15px;
}
nav { display: flex; gap: 6px; flex-wrap: wrap; }
nav button {
  font-size: 13px;
  background: transparent;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 12px;
}
nav button.selected {
  background: white;
  border: 1px solid var(--line);
  color: var(--green);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* CARDS GRID */
.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.card {
  padding: 26px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(30, 26, 60, 0.08);
}
.card:nth-child(3n+1) { border-top: 4px solid var(--green); }
.card:nth-child(3n+2) { border-top: 4px solid var(--hv-accent); }
.card:nth-child(3n+3) { border-top: 4px solid var(--hv-fresh); }
.card p { font-size: 13px; flex: 1; color: var(--muted); }
.badge {
  border-radius: 8px;
  background: var(--hv-badge-bg);
  color: var(--green);
  font-size: 10px;
  padding: 6px 11px;
  font-weight: 750;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.mode-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 8px;
}
.meta {
  display: flex;
  width: 100%;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 15px 0;
  font-size: 12px;
  color: var(--muted);
  margin-top: 14px;
}
.card button { width: 100%; }
.empty { text-align: center; padding: 48px; color: var(--muted); }

#notice {
  background: #fff1df;
  color: #925b1e;
  padding: 14px 20px;
  border-radius: 12px;
  margin-bottom: 20px;
  border-left: 4px solid #f59e0b;
}

/* TABLES & STATS */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
  box-shadow: 0 4px 16px rgba(30, 26, 60, 0.03);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; text-align: left; }
th, td { padding: 14px 18px; border-bottom: 1px solid rgba(30, 26, 60, 0.06); white-space: nowrap; }
th {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 1px;
  background: rgba(30, 26, 60, 0.02);
  font-weight: 700;
}
td:first-child { font-weight: 700; }
tr:last-child td { border: 0; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 160px; margin: 0; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  padding: 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}
.stat strong { display: block; font-size: 32px; font-family: 'Baloo 2', sans-serif; color: var(--green); }
.stat span { font-size: 12px; color: var(--muted); font-weight: 600; }

/* IN-GAME ARENA */
#game { max-width: 820px; margin: 0 auto; }
.game-top { display: flex; justify-content: space-between; align-items: center; }
.clock { font-size: 32px; font-weight: 800; color: var(--green); }
.clock.urgent { color: #dc2626; animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.progress {
  height: 8px;
  background: rgba(30, 26, 60, 0.08);
  border-radius: 12px;
  margin: 20px 0 26px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--hv-sun)); width: 0; transition: width 0.3s; }
.answers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 28px 0; }
.answer {
  background: #fafbfc;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  text-align: left;
  padding: 18px 22px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.answer span { color: var(--green); font-weight: 800; margin-right: 12px; font-size: 16px; }
.answer:hover {
  border-color: var(--green);
  background: rgba(91, 63, 217, 0.05);
  transform: translateY(-2px);
}
.result { text-align: center; }
.result-score {
  font-size: 80px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--green);
  margin: 18px 0;
  font-family: 'Baloo 2', sans-serif;
}
.result .stats { text-align: center; }

/* FOOTER */
footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 30px 0;
  color: var(--muted);
  font-size: 12px;
  margin-top: 70px;
}

[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }

/* RESPONSIVE */
@media (max-width: 850px) {
  .shell { padding: 0 24px; }
  .cards { grid-template-columns: 1fr 1fr; }
  .hero-art { min-height: 260px; }
  .timer-art { width: 180px; height: 210px; }
  .orbit { width: 260px; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .auth-panel { gap: 20px; }
  .hero { padding: 45px 0; }
  .spark-one { right: 5px; }
  .spark-two { left: 5px; }
}

@media (max-width: 640px) {
  .shell { padding: 0 16px; }
  header { height: 78px; }
  .brand-sub { display: none; }
  .back-home-btn span { display: none; }
  .hero { grid-template-columns: 1fr; padding: 25px 0; gap: 10px; }
  .hero-art { min-height: 220px; grid-row: 2; }
  .timer-art { height: 180px; width: 170px; border-radius: 28px; }
  .timer-art strong { font-size: 68px; }
  .orbit { width: 270px; height: 160px; }
  .hero h1 { margin: 16px 0; font-size: 40px; }
  .pills { margin-top: 18px; gap: 6px; }
  .pills span { padding: 5px 10px; font-size: 10px; }
  .auth-panel, .cards, .fields { grid-template-columns: 1fr; }
  .panel, .card { padding: 20px; border-radius: 16px; }
  .answers { grid-template-columns: 1fr; gap: 10px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .desktop { display: none; }
  footer { flex-direction: column; gap: 10px; text-align: center; margin-top: 40px; }
}
