:root {
  --bg: #f4f6fa; --card: #fff; --ink: #1c2433; --muted: #5d6b82; --line: #dde3ec;
  --brand: #0b5cad; --brand-ink: #fff; --thpt: #b4232a; --thcs: #0b7a4b; --warn: #a15c00;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--brand); }
.wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 48px; }
.wide { max-width: 1400px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.row { display: flex; gap: 8px; margin: 6px 0; }
.row .k { color: var(--muted); min-width: 130px; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: #fff; }
.tag.THPT { background: var(--thpt); } .tag.THCS { background: var(--thcs); }
.btn { display: inline-block; text-decoration: none; border: 0; border-radius: 10px; padding: 14px 28px; font-size: 1.1rem; font-weight: 600;
       background: var(--brand); color: var(--brand-ink); cursor: pointer; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 6px 12px; font-size: .9rem; border-radius: 8px; }
.btn.ghost { background: #e8eef7; color: var(--brand); }
.btn.danger { background: #fbe9ea; color: var(--thpt); }
.center { text-align: center; }
.big { font-size: 5.5rem; font-weight: 800; line-height: 1; margin: 16px 0 8px; font-variant-numeric: tabular-nums; }
.note { color: var(--muted); font-size: .92rem; }
.msg { padding: 12px 14px; border-radius: 10px; margin: 12px 0; }
.msg.err { background: #fbe9ea; color: var(--thpt); } .msg.ok { background: #e6f4ec; color: var(--thcs); }
.msg.warn { background: #fdf1df; color: var(--warn); }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef2f7; position: sticky; top: 0; }
input[type=text], input[type=password], select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.link { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; word-break: break-all; }

/* Màn hình trình chiếu */
.screen { background: #0e1726; color: #eef3fb; min-height: 100vh; }
.screen .wrap { max-width: none; padding: 20px 28px; }
.screen h1 { font-size: 2rem; }
.screen .sub { color: #9fb0c8; }
.stage { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; margin-bottom: 20px; }
.panel { background: #17233a; border-radius: 14px; padding: 18px 22px; }
.latest .big { font-size: 7rem; color: #ffd166; }
.latest .team { font-size: 1.9rem; font-weight: 700; }
.latest .school { font-size: 1.2rem; color: #9fb0c8; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { background: #ffd166; } 100% { background: #17233a; } }
.counts { display: flex; gap: 16px; }
.counts div { flex: 1; background: #0e1726; border-radius: 10px; padding: 12px; text-align: center; }
.counts b { display: block; font-size: 2.4rem; }
.recent { list-style: none; padding: 0; margin: 12px 0 0; }
.recent li { padding: 6px 0; border-bottom: 1px solid #24324d; display: flex; gap: 12px; }
.recent .m { font-weight: 800; color: #ffd166; min-width: 48px; }
.groups { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 10px; }
.group { background: #17233a; border-radius: 12px; padding: 10px; }
.group h3 { margin: 0 0 8px; font-size: 1.05rem; text-align: center; }
.slot { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; margin-bottom: 3px;
        background: #0e1726; font-size: .82rem; min-height: 26px; }
.slot .n { font-weight: 800; min-width: 28px; }
.slot.THPT .n { color: #ff8a8f; } .slot.THCS .n { color: #6fe0a8; }
.slot .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.taken { background: #22314f; }
@media (max-width: 1100px) { .groups { grid-template-columns: repeat(3, minmax(0, 1fr)); } .stage { grid-template-columns: 1fr; } }

/* Kết quả thi đấu */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 6px 14px; border-radius: 8px; background: #17233a; color: #cfdbee; text-decoration: none; font-weight: 600; }
.tabs a.on { background: #ffd166; color: #0e1726; }
.screen table.rank { font-size: 1.15rem; }
.screen .rank th { background: #17233a; color: #9fb0c8; border-bottom: 1px solid #24324d; }
.screen .rank td { border-bottom: 1px solid #24324d; padding: 9px 8px; }
.rank .n { text-align: right; font-variant-numeric: tabular-nums; }
.rank .h { font-weight: 800; width: 56px; }
.rank .m { font-weight: 800; color: #ffd166; width: 56px; }
.rank .b { font-weight: 700; }
.rank .u { color: #9fb0c8; }
.rank .x { font-weight: 800; color: #ffd166; font-size: 1.25rem; }
.rank .drop { text-decoration: line-through; opacity: .45; }
.rank tr.THPT .m { color: #ff8a8f; } .rank tr.THCS .m { color: #6fe0a8; }
.note2 { color: #9fb0c8; font-size: .95rem; margin-top: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.two h2 { margin: 0 0 10px; }
.two .rank { font-size: 1.02rem; }
@media (max-width: 1100px) { .two { grid-template-columns: 1fr; } }
/* Nhập điểm (trang quản trị) */
.score { width: 110px; text-align: right; font-size: 1.1rem; }
.score.changed { background: #fff6d6; border-color: #e0b100; }

/* Vòng chung kết: 1 bảng, trải rộng */
.groups.ck { grid-template-columns: 1fr; }
.groups.ck .group { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px 10px; }
.groups.ck .group h3 { grid-column: 1 / -1; }
.groups.ck .slot { font-size: .95rem; }

/* Liên kết về trang chủ trên mọi trang */
.home-nav { margin: 0 0 10px; }
.home-nav a { display: inline-flex; align-items: center; gap: 4px; font-size: .9rem; font-weight: 600;
              text-decoration: none; color: var(--brand); padding: 4px 10px; border-radius: 8px; background: #e8eef7; }
.home-nav a:hover { background: #d7e3f4; }
.screen .home-nav a { color: #cfdbee; background: #17233a; }
.screen .home-nav a:hover { background: #22314f; }
@media print { .home-nav { display: none; } }
