/* 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 .ban-phim { width: min(240px, 42%); 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%; }

.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); }
}


/* bàn phím SVG */
.ban-phim { display: block; width: 100%; height: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.phim { stroke: #5a5a5a; stroke-width: 0.8; }
.phim.trang { fill: #f7f5ef; }
.phim.den { fill: #23252b; }
.co-bam .phim { cursor: pointer; }
.phim.xuong.trang { fill: #f4cf86; }
.phim.xuong.den { fill: #a5742a; }
.phim.dung { fill: var(--tot) !important; }
.phim.sai { fill: var(--xau) !important; }
.chu-phim { fill: #6b6b6b; font: 600 9px system-ui, sans-serif; }
.chu-phim.do-giua { fill: #b06b00; font-weight: 800; font-size: 10px; }
.dau-phim { stroke: #fff; stroke-width: 1; }
.so-phim { fill: #fff; font: 800 12px system-ui, sans-serif; }
.cuon-phim { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.cuon-phim .ban-phim { min-width: 640px; }

/* khuông nhạc */
.ban-nhac { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 2px solid var(--vien); border-radius: var(--bo); background: var(--mat); }
.dong-nhac { display: block; width: 100%; height: auto; color: var(--chu); flex: none; }
.dong-nhac .dong-ke, .dong-nhac .vach { stroke: var(--chu); stroke-width: 0.8; }
.dong-nhac .vach.dam { stroke-width: 2.4; }
.dong-nhac .net-khoa { fill: none; stroke: var(--chu); stroke-width: 1.7; stroke-linecap: round; }
.dong-nhac .dac { fill: var(--chu); }
.dong-nhac .net-dau { stroke: var(--chu); stroke-width: 1.1; fill: none; }
.dong-nhac .net-lang { stroke: var(--chu); stroke-width: 1.5; fill: none; stroke-linejoin: round; }
.dong-nhac .so-nhip { fill: var(--chu); font: 800 15px system-ui, sans-serif; }
.dong-nhac .so-o { fill: var(--chu-phu); font: 9px system-ui, sans-serif; }
.dong-nhac .so-ngon { font: 800 10px system-ui, sans-serif; }
.dong-nhac .dau-not { fill: var(--chu); stroke: var(--chu); stroke-width: 1.2; }
.dong-nhac .dau-not.rong { fill: var(--mat); }
.dong-nhac .duoi { stroke: var(--chu); stroke-width: 1.1; }
.dong-nhac .gach { stroke: var(--chu); stroke-width: 3.2; }
.dong-nhac .moc { stroke: var(--chu); stroke-width: 1.5; fill: none; }
.dong-nhac .con-tro { fill: color-mix(in srgb, var(--nhan) 55%, transparent); }
.dong-nhac .dau-not.dang { fill: var(--nhan); stroke: var(--nhan); }
.dong-nhac .net-dau.dang { stroke: var(--nhan); }
.dong-nhac .so-ngon.dang { font-size: 13px; }
.dong-nhac .dau-not.dung { fill: var(--tot); stroke: var(--tot); }
.dong-nhac .dau-not.sai { fill: var(--xau); stroke: var(--xau); }
.not-don { max-height: 42dvh; }

/* đọc nốt */
.hang-dem { display: flex; justify-content: space-around; gap: 16px; }
.hang-dem .nhan-so { margin: 0; }
.vung-not { max-width: 420px; margin: 0 auto; }

/* trang Thế tay, Bản nhạc */
.the-tay { display: flex; flex-direction: column; gap: 14px; }
.cot-hinh { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.vung-3d { position: relative; height: min(44vh, 460px); border-radius: var(--bo); background: radial-gradient(ellipse at 50% 35%, var(--mat-2), var(--nen)); overflow: hidden; touch-action: none; }
.vung-3d canvas { width: 100%; height: 100%; display: block; }
.vung-3d > p { padding: 24px; }
.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; }
.the-tay .dieu-khien > div > .nut { width: 100%; margin-top: 8px; }
.hang-hop-am-3d .nut { font-size: 1.25rem; font-weight: 800; flex: 1 1 22% !important; }
.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, .hien-vong { font-size: 1.05rem; line-height: 1.45; }
.tin-dan { font-size: 0.9rem; margin: 2px 0; }
.nut-bai { flex: 1 1 calc(50% - 12px) !important; }
.nut-bai small { font-size: 0.72em; font-weight: 400; color: var(--chu-phu); line-height: 1.2; }
.nut-bai.dang-chon small { color: var(--chu); }
.the-tay .ban-nhac { max-height: 34vh; overflow-y: auto; }
/* màn ngang rộng: khung hình lớn nhất có thể, cột điều khiển hẹp, chữ nhỏ vừa đủ đọc, nút vẫn ≥ 64px */
@media (min-width: 900px) and (orientation: landscape) {
  #app:has(.the-tay) { max-width: none; padding: 6px 12px 10px; }
  #app:has(.the-tay) .the { padding: 8px 12px 12px; }
  #app:has(.the-tay) h1 { font-size: 1.15rem; margin: 0 0 6px; }
  .the-tay { display: grid; grid-template-columns: minmax(0, 1fr) clamp(300px, 24vw, 380px); gap: 14px; height: calc(100dvh - 128px); min-height: 480px; }
  .cot-hinh { height: 100%; }
  .cot-hinh .vung-3d { flex: 1 1 0; height: auto; min-height: 160px; }
  .cuon-phim .ban-phim { min-width: 0; }
  .the-tay .dieu-khien { height: 100%; overflow-y: auto; font-size: 15px; padding-right: 6px; }
  .the-tay .dieu-khien h2 { font-size: 0.85rem; margin-top: 10px; }
  .the-tay .dieu-khien .nut { font-size: 0.95em; min-height: 64px; padding: 6px 8px; }
  .the-tay .dieu-khien .hang-nut { gap: 6px; margin: 6px 0; }
  .the-tay .dieu-khien .goi-y-the, .the-tay .dieu-khien .hien-vong { font-size: 1em; }
}
