/* Bản 18.8 — Mini game Trễ Nhịp: bố cục & cách bấm theo phong cách game Vườn VIE (nút dày nổi khối, ruy-băng, thẻ giấy, màn chờ),
   bảng màu tối / đỏ VIE / xanh ngọc của bản chơi thử. Luôn tối (không theo giao diện sáng của site). */
.tn-body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #0b0a0d; font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif; color: #f2eef0;
    -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
html:has(.tn-body) { height: 100%; overflow: hidden; background: #0b0a0d; }
.tn { --bg: #0b0a0d; --p1: #1d1923; --p2: #131117; --line: #2c2733; --red: #e6141f; --red-d: #7a0f15; --cyan: #38e1d6; --cyan-d: #0b5f59; --gold: #f5c451; --gold-d: #8a5a00; --fg: #f2eef0; --muted: #a39aa8; --violet: #a78bfa;
    --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
    position: fixed; inset: 0; overflow: hidden; }
.tn button, .tn a { font-family: inherit; }
.tn [hidden] { display: none !important; }
.tn-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }
.tn-cv:focus-visible { outline: none; }

/* Ẩn bớt giao diện khi đang chạy để cả màn hình là vùng chạm */
.tn.is-run .tn-side, .tn.is-run .tn-dock { opacity: 0; transform: translateY(14px); pointer-events: none; }
.tn.is-run .tn-side { transform: translateX(14px); }
.tn-side, .tn-dock { transition: opacity .25s, transform .25s; }

/* HUD trên */
.tn-hud { position: absolute; top: calc(var(--safe-t) + 8px); left: calc(var(--safe-l) + 8px); right: calc(var(--safe-r) + 8px); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 20; }
.tn-hud > * { pointer-events: auto; }
.tn-lv { position: relative; display: flex; align-items: center; min-width: 0; padding: 0 12px 0 0; margin: 4px 0 0; border: 0; background: none; cursor: pointer; color: inherit; }
.tn-lv-badge { position: relative; z-index: 2; flex: 0 0 auto; width: 56px; height: 56px; display: grid; place-items: center; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .6)); }
.tn-lv-badge svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tn-lv-badge b { position: relative; font: 800 17px/1 "Baloo 2", sans-serif; color: #fff; -webkit-text-stroke: 4px #5c0a10; paint-order: stroke fill; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tn-lv-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; margin-left: -14px; padding: 5px 12px 6px 20px; border-radius: 0 16px 16px 0; background: rgba(19, 17, 23, .78); border: 2px solid rgba(230, 20, 31, .7); border-left: 0; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tn-name { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: 700 13px/1.15 "Baloo 2", sans-serif; color: #fff; text-align: left; }
.tn-xp { position: relative; display: block; width: clamp(96px, 30vw, 170px); height: 14px; border-radius: 8px; background: rgba(0, 0, 0, .55); overflow: hidden; border: 1.5px solid rgba(255, 255, 255, .25); }
.tn-xp i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(180deg, #7ff3ea, #1fb5aa); border-radius: 8px; transition: width .3s; }
.tn-xp em { position: relative; display: block; font: 700 10px/12px "Baloo 2", sans-serif; color: #fff; font-style: normal; text-align: center; text-shadow: 0 1px 2px rgba(0, 0, 0, .8); }
.tn-res { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.tn-pill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px; border-radius: 18px; background: rgba(19, 17, 23, .78); border: 2px solid rgba(255, 255, 255, .28); color: #fff; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.tn-pill b { font: 800 15px/1 "Baloo 2", sans-serif; font-variant-numeric: tabular-nums; }
.tn-delay i { width: 10px; height: 10px; border-radius: 3px; background: var(--zc, var(--red)); box-shadow: 0 0 10px var(--zc, var(--red)); }
.tn-delay { border-color: var(--zc, var(--red)); }
.tn-tries svg { width: 16px; height: 16px; color: var(--cyan); }
.tn-meter { position: absolute; left: 50%; top: calc(var(--safe-t) + 74px); translate: -50% 0; z-index: 15; pointer-events: none; display: flex; align-items: baseline; gap: 2px; }
.tn-meter b { font: 800 46px/1 "Baloo 2", sans-serif; color: #fff; -webkit-text-stroke: 6px rgba(11, 10, 13, .9); paint-order: stroke fill; font-variant-numeric: tabular-nums; }
.tn-meter small { font: 800 20px/1 "Baloo 2", sans-serif; color: var(--muted); -webkit-text-stroke: 4px rgba(11, 10, 13, .9); paint-order: stroke fill; }
.tn-meter.is-best b { color: var(--gold); }

/* Cột nút phải */
.tn-side { position: absolute; right: calc(var(--safe-r) + 8px); top: calc(var(--safe-t) + 132px); display: flex; flex-direction: column; gap: 10px; z-index: 19; }
.tn-sbtn { position: relative; width: 60px; padding: 0; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; color: inherit; }
.tn-sbtn svg { width: 50px; height: 50px; padding: 5px; box-sizing: border-box; border-radius: 16px; background: linear-gradient(180deg, #2a2531, #17141c); border: 3px solid var(--red); box-shadow: 0 4px 0 var(--red-d), 0 6px 12px rgba(0, 0, 0, .5); transition: transform .1s; }
.tn-sbtn:active svg { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-d); }
.tn-sbtn span { font: 700 11px/1.1 "Baloo 2", sans-serif; color: #fff; text-shadow: 0 1px 2px #000, 0 0 4px #000; white-space: nowrap; }
.tn-sbtn.is-off svg { filter: grayscale(.9) brightness(.7); }
.tn-badge { position: absolute; top: -4px; right: 0; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--cyan); color: #04211f; font: 800 12px/20px "Baloo 2", sans-serif; font-style: normal; text-align: center; border: 2px solid #fff; box-sizing: border-box; }

/* Thanh dưới */
.tn-dock { position: absolute; left: calc(var(--safe-l) + 8px); right: calc(var(--safe-r) + 8px); bottom: calc(var(--safe-b) + 8px); display: flex; align-items: flex-end; gap: 8px; z-index: 20; pointer-events: none; }
.tn-dock > * { pointer-events: auto; }
.tn-dock-l { display: flex; flex-direction: column; gap: 8px; }
.tn-rbtn { width: 48px; height: 48px; padding: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: rgba(19, 17, 23, .8); border: 2.5px solid rgba(255, 255, 255, .35); box-shadow: 0 3px 8px rgba(0, 0, 0, .5); }
.tn-rbtn svg { width: 34px; height: 34px; }
.tn-gear svg { animation: tnGear 14s linear infinite; }
@keyframes tnGear { to { transform: rotate(360deg); } }
.tn-dock-c { flex: 1 1 auto; display: flex; justify-content: center; gap: 10px; min-width: 0; }
.tn-dbtn { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 80px; padding: 6px 4px 7px; border-radius: 18px; cursor: pointer; color: var(--fg);
    background: linear-gradient(180deg, #2a2531, #17141c); border: 3px solid var(--red); box-shadow: 0 5px 0 var(--red-d), 0 8px 14px rgba(0, 0, 0, .5); transition: transform .1s; }
.tn-dbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-d); }
.tn-dico svg { width: 40px; height: 40px; display: block; }
.tn-dbtn > span:not(.tn-dico) { font: 800 12.5px/1.1 "Baloo 2", sans-serif; white-space: nowrap; }
.tn-d-play { border-color: var(--cyan); box-shadow: 0 5px 0 var(--cyan-d), 0 8px 14px rgba(0, 0, 0, .5); }
.tn-race { position: relative; display: flex; flex-direction: column; align-items: center; width: 84px; height: 84px; padding: 4px 0 0; border-radius: 26px; cursor: pointer; color: #04211f;
    background: radial-gradient(circle at 50% 35%, #a9fff8, #38e1d6 70%); border: 3.5px solid var(--cyan-d); box-shadow: 0 6px 0 #063a36, 0 10px 18px rgba(0, 0, 0, .5); animation: tnBob 3s ease-in-out infinite; }
.tn-race:active { transform: translateY(4px); box-shadow: 0 2px 0 #063a36; animation: none; }
.tn-race svg { width: 50px; height: 50px; }
.tn-race span { font: 800 13px/1 "Baloo 2", sans-serif; margin-top: -2px; }
.tn-race[disabled] { filter: grayscale(.8); opacity: .6; animation: none; cursor: not-allowed; }
@keyframes tnBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

/* Bảng dưới + hộp thoại (thẻ tối viền đỏ) */
.tn-sheet { position: absolute; left: 50%; bottom: calc(var(--safe-b) + 8px); width: min(560px, calc(100% - 16px - var(--safe-l) - var(--safe-r))); translate: -50% 0; max-height: min(66dvh, 600px); overflow: auto;
    box-sizing: border-box; padding: 14px 14px 12px; border-radius: 24px; z-index: 30; background: linear-gradient(180deg, var(--p1), var(--p2)); border: 3px solid var(--red); box-shadow: 0 6px 0 var(--red-d), 0 18px 40px rgba(0, 0, 0, .6);
    animation: tnSheetIn .25s cubic-bezier(.2, 1.3, .5, 1); overscroll-behavior: contain; touch-action: pan-y; }
@keyframes tnSheetIn { from { transform: translateY(40px); opacity: 0; } }
.tn-sheet h3, .tn-card h3 { margin: 0 34px 8px 0; font: 800 20px/1.15 "Baloo 2", sans-serif; }
.tn-x { position: absolute; top: 8px; right: 8px; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 3px solid #fff; background: var(--red); color: #fff; font: 800 22px/28px "Baloo 2", sans-serif; cursor: pointer; box-shadow: 0 3px 0 var(--red-d); z-index: 3; }
.tn-modal { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; padding: calc(var(--safe-t) + 16px) 14px calc(var(--safe-b) + 16px); background: rgba(5, 4, 8, .7); animation: tnFade .2s; }
@keyframes tnFade { from { opacity: 0; } }
.tn-card { position: relative; width: min(520px, 100%); max-height: 100%; overflow: auto; box-sizing: border-box; padding: 18px 16px 16px; border-radius: 26px;
    background: linear-gradient(180deg, var(--p1), var(--p2)); border: 3px solid var(--red); box-shadow: 0 6px 0 var(--red-d), 0 24px 50px rgba(0, 0, 0, .6); animation: tnPop .3s cubic-bezier(.2, 1.4, .5, 1); overscroll-behavior: contain; }
@keyframes tnPop { from { transform: scale(.85); opacity: 0; } }
.tn-ribbon { display: block; width: fit-content; max-width: calc(100% - 96px); margin: 0 auto 12px; padding: 6px 26px 8px; border-radius: 12px; background: linear-gradient(180deg, #ff5a62, #c40f19); border: 3px solid var(--red-d);
    color: #fff; font: 800 20px/1.1 "Baloo 2", sans-serif; text-align: center; text-shadow: 0 2px 0 var(--red-d); box-shadow: 0 4px 0 var(--red-d); }
.tn-ribbon.cyan { background: linear-gradient(180deg, #7ff3ea, #1fb5aa); border-color: var(--cyan-d); color: #04211f; text-shadow: none; box-shadow: 0 4px 0 var(--cyan-d); }
.tn-ribbon.gold { background: linear-gradient(180deg, #ffe07a, #f5a300); border-color: var(--gold-d); color: #4a2f00; text-shadow: none; box-shadow: 0 4px 0 var(--gold-d); }
.tn-p { margin: 6px 0; font-size: 14px; line-height: 1.5; color: #ddd6e0; }
.tn-muted { color: var(--muted); font-size: 12.5px; }
.tn-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 6px 16px; border-radius: 14px; cursor: pointer; text-decoration: none;
    font: 800 15px/1.1 "Baloo 2", sans-serif; color: #fff; background: linear-gradient(180deg, #ff5a62, #c40f19); border: 2.5px solid var(--red-d); box-shadow: 0 4px 0 var(--red-d); transition: transform .08s; }
.tn-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--red-d); }
.tn-btn-cyan { color: #04211f; background: linear-gradient(180deg, #7ff3ea, #1fb5aa); border-color: var(--cyan-d); box-shadow: 0 4px 0 var(--cyan-d); }
.tn-btn-ghost { background: rgba(255, 255, 255, .06); border-color: var(--line); box-shadow: 0 4px 0 #000; }
.tn-btn[disabled] { filter: grayscale(1); opacity: .5; cursor: not-allowed; }
.tn-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; }
.tn-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.tn-tabs button { padding: 6px 12px; border-radius: 12px; border: 2px solid var(--line); background: #17141c; color: var(--fg); font: 800 13px/1 "Baloo 2", sans-serif; cursor: pointer; }
.tn-tabs button.on { background: var(--red); border-color: var(--red-d); }
.tn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tn-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .05); border: 1.5px solid var(--line); font-size: 14px; }
.tn-list li.me { border-color: var(--cyan); background: rgba(56, 225, 214, .08); }
.tn-list li > b:first-child { font: 800 16px/1 "Baloo 2", sans-serif; color: var(--muted); text-align: center; }
.tn-list li:nth-child(1) > b:first-child { color: var(--gold); } .tn-list li:nth-child(2) > b:first-child { color: #d9d9e3; } .tn-list li:nth-child(3) > b:first-child { color: #e2a272; }
.tn-list li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-list li em { font-style: normal; font: 800 15px/1 "Baloo 2", sans-serif; color: var(--fg); font-variant-numeric: tabular-nums; }
.tn-list li small { display: block; color: var(--muted); font-size: 11.5px; }
.tn-dot { width: 12px; height: 12px; border-radius: 4px; justify-self: center; }
.tn-diffs { display: grid; gap: 8px; }
.tn-diff { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; border-radius: 16px; background: rgba(255, 255, 255, .05); border: 2px solid var(--line); cursor: pointer; text-align: left; color: var(--fg); font: inherit; }
.tn-diff.on { border-color: var(--red); background: rgba(230, 20, 31, .12); }
.tn-diff b { display: block; font: 800 16px/1.2 "Baloo 2", sans-serif; }
.tn-diff small { color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.tn-diff em { font-style: normal; font: 800 13px/1 "Baloo 2", sans-serif; color: var(--gold); white-space: nowrap; }
.tn-bars { display: flex; gap: 3px; align-items: flex-end; height: 30px; justify-content: center; }
.tn-bars i { width: 7px; border-radius: 2px; background: #3a3440; }
.tn-bars i.on { background: var(--red); box-shadow: 0 0 6px var(--red); }
.tn-help { display: grid; gap: 10px; }
.tn-help div { display: grid; grid-template-columns: 54px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 10px; border-radius: 14px; background: rgba(255, 255, 255, .05); }
.tn-help svg { width: 50px; height: 40px; }
.tn-help p { margin: 0; font-size: 13.5px; line-height: 1.45; color: #ddd6e0; }

/* Cài đặt */
.tn-set { display: grid; gap: 10px; }
.tn-set-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 16px; background: rgba(255, 255, 255, .05); border: 2px solid var(--line); }
.tn-set-row b { display: block; font: 800 15px/1.2 "Baloo 2", sans-serif; }
.tn-set-row small { color: var(--muted); font-size: 12px; }
.tn-set-row input[type=range] { width: 100%; accent-color: var(--cyan); margin-top: 4px; }
.tn-switch { position: relative; width: 58px; height: 32px; padding: 0; border-radius: 18px; border: 2.5px solid #4a4352; background: #2a2530; cursor: pointer; transition: background .2s; }
.tn-switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 23px; height: 23px; border-radius: 50%; background: #fff; transition: transform .2s; }
.tn-switch[aria-checked="true"] { background: var(--cyan); border-color: var(--cyan-d); }
.tn-switch[aria-checked="true"]::after { transform: translateX(26px); }

/* Thông báo */
.tn-toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 132px); translate: -50% 0; z-index: 50; max-width: min(90vw, 440px); padding: 9px 16px; border-radius: 16px; background: rgba(11, 95, 89, .95); border: 2px solid #fff; color: #fff;
    font: 700 14px/1.3 "Baloo 2", sans-serif; text-align: center; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); animation: tnToast .25s cubic-bezier(.2, 1.4, .5, 1); pointer-events: none; }
.tn-toast.is-bad { background: rgba(170, 20, 30, .95); }
@keyframes tnToast { from { transform: translateY(-14px); opacity: 0; } }

/* Màn hình chờ */
.tn-splash { position: absolute; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; text-align: center; color: #fff;
    background: radial-gradient(120% 90% at 50% 0%, #3a0a10 0%, #160a0d 55%, #07060a 100%); transition: opacity .45s, visibility .45s; }
.tn-splash::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(255, 255, 255, .025) 0 2px, transparent 2px 4px); pointer-events: none; }
.tn-splash.is-out { opacity: 0; visibility: hidden; }
.tn-splash-in { position: relative; display: grid; justify-items: center; gap: 10px; max-width: 380px; }
.tn-logo svg { width: 128px; height: 128px; animation: tnLogo 1.2s steps(2) infinite; filter: drop-shadow(0 0 18px rgba(255, 138, 61, .55)); }
@keyframes tnLogo { 50% { transform: translateY(-6px); } }
.tn-splash h1 { margin: 0; font: 800 54px/1 "Baloo 2", sans-serif; letter-spacing: 1px; -webkit-text-stroke: 7px #2a0508; paint-order: stroke fill; }
.tn-splash h1 span { color: var(--red); }
.tn-splash p { margin: 0; font-weight: 600; opacity: .9; }
.tn-splash small { opacity: .75; font-size: 12.5px; }
.tn-load { width: 240px; height: 16px; border-radius: 10px; background: rgba(0, 0, 0, .5); border: 2.5px solid #fff; overflow: hidden; }
.tn-load i { display: block; width: 10%; height: 100%; background: linear-gradient(180deg, #7ff3ea, #1fb5aa); transition: width .4s; }
.tn-play { display: inline-flex; justify-content: center; align-items: center; min-width: 220px; min-height: 56px; padding: 8px 22px; margin-top: 6px; border-radius: 20px; cursor: pointer; text-decoration: none;
    font: 800 22px/1 "Baloo 2", sans-serif; color: #04211f; background: linear-gradient(180deg, #a9fff8, #38e1d6); border: 3.5px solid var(--cyan-d); box-shadow: 0 6px 0 #063a36, 0 10px 20px rgba(0, 0, 0, .5); }
.tn-play:not([disabled]) { animation: tnBob 1.6s ease-in-out infinite; }
.tn-play[disabled] { font-size: 16px; opacity: .85; cursor: progress; }
.tn-sec { color: #fff; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.tn-guest { max-width: 320px; font-size: 14px; }
.tn-sponsor { display: grid; justify-items: center; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .12); width: 100%; }
.tn-sponsor img { max-width: 160px; max-height: 54px; object-fit: contain; filter: drop-shadow(0 0 12px rgba(56, 225, 214, .25)); }
.tn-noscript { position: absolute; inset: auto 0 0; padding: 12px; background: #b91c1c; color: #fff; text-align: center; z-index: 99; }

@media (prefers-reduced-motion: reduce) { .tn *, .tn svg * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; } }
@media (min-width: 900px) {
    .tn-sheet { left: calc(var(--safe-l) + 76px); translate: none; bottom: calc(var(--safe-b) + 112px); width: 420px; max-height: calc(100dvh - 220px); }
    .tn-dbtn { width: 90px; }
}
@media (max-height: 520px) {
    .tn-side { flex-direction: row; top: auto; bottom: calc(var(--safe-b) + 10px); right: calc(var(--safe-r) + 100px); gap: 6px; }
    .tn-sbtn span { display: none; } .tn-sbtn svg { width: 42px; height: 42px; }
    .tn-dock-c { justify-content: flex-start; } .tn-dbtn { width: 64px; padding: 4px 3px 5px; } .tn-dico svg { width: 30px; height: 30px; }
    .tn-race { width: 70px; height: 70px; } .tn-race svg { width: 40px; height: 40px; }
    .tn-meter { top: calc(var(--safe-t) + 8px); } .tn-meter b { font-size: 34px; }
    .tn-splash h1 { font-size: 38px; } .tn-logo svg { width: 80px; height: 80px; }
}
@media (max-width: 360px) { .tn-dbtn { width: 66px; } .tn-dock-c { gap: 6px; } .tn-race { width: 74px; height: 74px; } }
