/* Giao diện cạnh đàn: chữ to, nút ≥64px, tương phản cao. Tối mặc định, sáng theo hệ thống. */
:root {
  --nen: #14181f;
  --mat: #1d232d;
  --mat-2: #273040;
  --chu: #eef1f5;
  --chu-phu: #9aa6b8;
  --vien: #34405280;
  --nhan: #f2b544;
  --nhan-chu: #1a1405;
  --tot: #3fbf7f;
  --xau: #e86a5a;
  --c0: #f2b544;
  --c1: #5fb3f6;
  --c2: #c58cf0;
  --c3: #3fbf7f;
  --bo: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --nen: #f5f3ee;
    --mat: #ffffff;
    --mat-2: #ece8df;
    --chu: #1b1e24;
    --chu-phu: #5d6675;
    --vien: #c9c3b580;
    --nhan: #c27c00;
    --nhan-chu: #ffffff;
    --tot: #1d8a55;
    --xau: #c2402f;
    --c0: #c27c00;
    --c1: #1f6fc0;
    --c2: #8b3fc0;
    --c3: #1d8a55;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--nen);
  color: var(--chu);
  font: 20px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app { max-width: 1100px; margin: 0 auto; padding: 12px 16px 40px; }
h1 { font-size: 1.6rem; margin: 0.2em 0 0.4em; line-height: 1.2; }
h2 { font-size: 1.15rem; margin: 1.2em 0 0.4em; }
a { color: var(--nhan); }
.phu { color: var(--chu-phu); }
.canh-bao { background: color-mix(in srgb, var(--xau) 18%, transparent); border-left: 4px solid var(--xau); padding: 10px 14px; border-radius: 8px; }
.the { background: var(--mat); border: 1px solid var(--vien); border-radius: var(--bo); padding: 18px 20px; }
.dang-tai { text-align: center; color: var(--chu-phu); margin-top: 30vh; }

/* nút */
.nut {
  min-height: 72px; min-width: 72px; padding: 12px 22px; border-radius: 14px; border: 2px solid transparent;
  font: inherit; font-size: 1.25rem; font-weight: 650; cursor: pointer; display: inline-flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent;
}
.nut:active { transform: scale(0.98); }
.nut:focus-visible { outline: 3px solid var(--c1); outline-offset: 2px; }
.nut-chinh { background: var(--nhan); color: var(--nhan-chu); width: 100%; }
.nut-phu { background: var(--mat-2); color: var(--chu); border-color: var(--vien); }
.nut-tot { background: var(--tot); color: #fff; }
.nut-xau { background: var(--xau); color: #fff; }
.nut-nguy { background: transparent; color: var(--xau); border-color: var(--xau); }
.nut.dang-chon { border-color: var(--nhan); background: color-mix(in srgb, var(--nhan) 30%, var(--mat-2)); }
.nut[disabled] { opacity: 0.45; cursor: default; }
.goi-y-phim { font-size: 0.7rem; font-weight: 500; opacity: 0.75; }
.nut-nho { min-height: 48px; min-width: 48px; padding: 6px 14px; background: var(--mat-2); color: var(--chu); border: 1px solid var(--vien); border-radius: 10px; font: inherit; font-size: 1rem; cursor: pointer; }
.lien-ket { background: none; border: none; color: var(--nhan); font: inherit; font-size: 1rem; cursor: pointer; padding: 12px 6px; min-height: 48px; }
.hang-nut { display: flex; gap: 12px; margin: 12px 0; }
.hang-nut > .nut { flex: 1; }

/* thanh trên */
.thanh-tren { display: flex; gap: 6px 18px; align-items: center; flex-wrap: wrap; margin: 0 0 14px; font-size: 1rem; }
.thanh-tren a { text-decoration: none; padding: 10px 2px; min-height: 48px; display: inline-flex; align-items: center; }
.thanh-tren .ten-app { font-weight: 800; color: var(--chu); margin-right: auto; font-size: 1.15rem; }

/* form */
.form-dang-nhap { max-width: 460px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 12px; }
input, textarea { font: inherit; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--vien); background: var(--mat-2); color: var(--chu); min-height: 56px; width: 100%; }
textarea { min-height: 72px; resize: vertical; }

/* hôm nay */
.ds-bai { padding: 0; list-style: none; counter-reset: b; margin: 8px 0 18px; }
.ds-bai li { counter-increment: b; display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--vien); }
.ds-bai li::before { content: counter(b); min-width: 32px; height: 32px; border-radius: 50%; background: var(--mat-2); display: inline-grid; place-items: center; font-size: 0.9rem; font-weight: 700; }
.ds-bai li span:first-of-type { flex: 1; }
.phut { color: var(--chu-phu); font-variant-numeric: tabular-nums; }

/* buổi tập */
.thanh-buoi { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 8px; }
.tieu-de-buoc { display: flex; flex-direction: column; text-align: center; line-height: 1.2; }
.tieu-de-buoc small { color: var(--chu-phu); font-size: 0.85rem; }
.tieu-de-buoc strong { font-size: 1.1rem; }
.tien-do { height: 6px; background: var(--mat-2); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.tien-do > div { height: 100%; background: var(--nhan); transition: width 0.3s; }
.man-bai { background: var(--mat); border: 1px solid var(--vien); border-radius: var(--bo); padding: 16px 18px; min-height: 60dvh; }
.man-bai h2:first-child { margin-top: 0.2em; }
.chon-dan { flex-direction: column; }
.chon-dan .nut { min-height: 110px; font-size: 1.6rem; }
.hang-cam-nhan { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.hang-cam-nhan .nut { font-size: 1.6rem; padding: 0; min-width: 0; }
.chu-thich-cam-nhan { display: flex; justify-content: space-between; color: var(--chu-phu); font-size: 0.9rem; margin: 4px 0 12px; }

/* khối dùng chung cho module */
.hai-cot { display: flex; flex-direction: column; gap: 14px; }
.so-to { font-size: clamp(5rem, 28vw, 11rem); font-weight: 800; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; }
.so-vua { font-size: clamp(2.4rem, 11vw, 4rem); font-weight: 800; text-align: center; font-variant-numeric: tabular-nums; line-height: 1.1; }
.nhan-so { text-align: center; color: var(--chu-phu); }
.trung-tam { text-align: center; }
.hang-hop-am { display: flex; justify-content: center; align-items: center; gap: 8px; }
.hang-hop-am .hinh-hop-am { width: min(120px, 30%); height: auto; }
.hai-cot > div > .nut { width: 100%; margin-top: 10px; }
.thuoc-muc { height: 14px; background: var(--mat-2); border-radius: 7px; position: relative; overflow: hidden; }
.thuoc-muc > .muc { position: absolute; inset: 0 auto 0 0; background: var(--c1); transition: width 0.05s linear; }
.thuoc-muc > .nguong { position: absolute; top: 0; bottom: 0; width: 3px; background: var(--xau); }
.den-nhay { width: min(46vw, 200px); aspect-ratio: 1; border-radius: 50%; margin: 6px auto; background: var(--mat-2); border: 4px solid var(--vien); display: grid; place-items: center; font-size: clamp(3rem, 14vw, 5.5rem); font-weight: 800; transition: background 0.06s; }
.den-nhay.sang { background: var(--c1); color: #fff; }
.den-nhay.sang.nhan { background: var(--nhan); color: var(--nhan-chu); }
.nhay-dem { animation: nhay 0.25s ease-out; }
@keyframes nhay { from { color: var(--nhan); transform: scale(1.06); } to { transform: scale(1); } }
.chuoi-cham { display: flex; justify-content: center; gap: 8px; font-size: 1.6rem; letter-spacing: 2px; }
.huong-dan { padding-left: 1.2em; }
.huong-dan li { margin: 6px 0; }
.dang-ghi { color: var(--xau); font-weight: 800; text-align: center; font-size: 1.4rem; }

/* màn kết, tiến bộ */
.so-sanh, .nhat-ky { list-style: none; padding: 0; }
.so-sanh li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--vien); }
.so-sanh li span:first-child { flex: 1 1 60%; }
.so-sanh strong { font-size: 1.3rem; }
.len { color: var(--tot); font-weight: 800; font-size: 1.5rem; }
.xuong { color: var(--xau); font-weight: 800; font-size: 1.5rem; }
.nhat-ky li { padding: 10px 0; border-bottom: 1px solid var(--vien); }
.bieu-do { width: 100%; height: auto; background: var(--mat-2); border-radius: 12px; }
.bd-luoi { stroke: var(--vien); stroke-width: 1; }
.bd-chu { fill: var(--chu-phu); font-size: 13px; }
.bd-duong { stroke-width: 3; }
.bd-c0 { stroke: var(--c0); fill: var(--c0); }
.bd-c1 { stroke: var(--c1); fill: var(--c1); }
.bd-c2 { stroke: var(--c2); fill: var(--c2); }
.bd-c3 { stroke: var(--c3); fill: var(--c3); }
polyline.bd-duong { fill: none; }
.ds-ban-ghi { list-style: none; padding: 0; }
.ds-ban-ghi li { padding: 10px 0; border-bottom: 1px solid var(--vien); display: flex; flex-direction: column; gap: 6px; }
audio { width: 100%; }

/* hình hợp âm */
.hinh-hop-am { background: var(--mat-2); border-radius: 12px; }
.ha-ten { fill: var(--chu); font-size: 16px; font-weight: 800; }
.ha-luoc { fill: var(--chu); }
.ha-phim { stroke: var(--chu-phu); stroke-width: 1.5; }
.ha-day { stroke: var(--chu); stroke-width: 1.4; }
.ha-x { fill: var(--chu-phu); font-size: 14px; }
.ha-buong { fill: none; stroke: var(--chu); stroke-width: 1.6; }
.ha-cham { fill: var(--nhan); }
.ha-ngon { fill: var(--nhan-chu); font-size: 10px; font-weight: 800; }

.thong-bao { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); padding: 14px 20px; border-radius: 12px; background: var(--mat-2); border: 1px solid var(--vien); z-index: 9; max-width: 90vw; font-size: 1rem; }
.thong-bao-loi { border-color: var(--xau); }

/* tablet ngang / máy tính: màn bài 2 cột (số to bên trái, nút bên phải) */
@media (min-width: 900px) and (orientation: landscape) {
  .hai-cot { display: grid; grid-template-columns: 1.2fr 1fr; align-items: center; gap: 28px; }
  .chon-dan { flex-direction: row; }
  .hom-nay { max-width: 760px; margin: 0 auto; }
}
@media (max-height: 820px) and (orientation: landscape) {
  .so-to { font-size: clamp(4rem, 18vh, 9rem); }
  .den-nhay { width: min(30vh, 200px); }
}

/* module the-tay: cảnh 3D trên, điều khiển dưới (điện thoại); 2 cột khi màn ngang rộng */
.the-tay { display: flex; flex-direction: column; gap: 14px; }
.vung-3d { position: relative; height: min(56vh, 520px); border-radius: var(--bo); background: radial-gradient(ellipse at 50% 35%, var(--mat-2), var(--nen)); overflow: hidden; touch-action: none; }
.canh-3d { width: 100%; height: 100%; display: block; }
.vung-3d .goi-y-xoay { position: absolute; left: 10px; bottom: 8px; margin: 0; font-size: 0.85rem; color: var(--chu-phu); pointer-events: none; }
.the-tay h2 { font-size: 1rem; color: var(--chu-phu); margin: 14px 0 0; font-weight: 600; }
.the-tay .hang-nut { flex-wrap: wrap; margin: 8px 0; }
.the-tay .hang-nut > .nut { flex: 1 1 0; min-width: 64px; padding-left: 8px; padding-right: 8px; }
.hang-hop-am-3d .nut { font-size: 1.6rem; font-weight: 800; }
.chu-thich-ngon { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 0; margin: 8px 0; list-style: none; font-size: 0.95rem; }
.chu-thich-ngon i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-right: 6px; vertical-align: -2px; }
.goi-y-the { font-size: 1.05rem; line-height: 1.45; }
@media (min-width: 900px) and (orientation: landscape) {
  .the-tay { display: grid; grid-template-columns: 1.5fr 1fr; align-items: start; gap: 24px; }
  .vung-3d { height: min(78vh, 720px); position: sticky; top: 12px; }
}
