{"id":11,"date":"2026-10-30T09:26:29","date_gmt":"2026-10-30T09:26:29","guid":{"rendered":"https:\/\/hoclieuso.site\/?p=11"},"modified":"2026-10-30T09:27:39","modified_gmt":"2026-10-30T09:27:39","slug":"tro-choi-truy-tim-kho-bau-so-nguyen-to-4-doi-choi","status":"publish","type":"post","link":"https:\/\/hoclieuso.site\/?p=11","title":{"rendered":"Tr\u00f2 ch\u01a1i truy t\u00ecm kho b\u00e1u &#8211; S\u1ed1 nguy\u00ean t\u1ed1 \u2013 4 \u0111\u1ed9i ch\u01a1i"},"content":{"rendered":"<meta charset=\"utf-8\">\r\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, viewport-fit=cover\">\r\n<title>Truy T\u00ecm Kho B\u00e1u Ban Ng\u00e0y<\/title>\r\n<meta name=\"claude:viewport-fit-sides\" content=\"cover\">\r\n<link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\">\r\n<link rel=\"stylesheet\" href=\"https:\/\/fonts.googleapis.com\/css2?family=Baloo+2:wght@600;700;800&family=Be+Vietnam+Pro:wght@400;600;700&family=Patrick+Hand&display=swap\">\r\n<style>\r\n\/* Layout: night-sea page \u2192 wooden sign bar \u2192 parchment sea-chart board (ship start \u00b7 10\u00d75 islands \u00b7 chest finish) \u2192 teams + teacher panels. Single deliberate pirate look. *\/\r\n:root{\r\n  color-scheme:dark;\r\n  --sea:#0b3a5c; --sea-deep:#06223a; --foam:#7fd4e6;\r\n  --wood:#7a4a24; --wood-dark:#4e2d13; --wood-light:#a8693a;\r\n  --paper:#f3dfae; --paper-dark:#dcc08a; --ink:#3a2410;\r\n  --gold:#ffc83d; --gold-deep:#d99a12; --red:#d8432f; --green:#2f9e5b; --sand:#f8e7bd;\r\n  --text:#fdf4dc; --muted:#c9d9e3;\r\n  --f-display:\"Baloo 2\",\"Trebuchet MS\",system-ui,sans-serif;\r\n  --f-body:\"Be Vietnam Pro\",system-ui,-apple-system,\"Segoe UI\",sans-serif;\r\n  --f-hand:\"Patrick Hand\",\"Comic Sans MS\",cursive;\r\n}\r\n[hidden]{display:none!important}\r\nhtml,body{min-height:100%}\r\nbody{margin:0;color:var(--text);font-family:var(--f-body);font-size:15px;line-height:1.5;\r\n  background:radial-gradient(ellipse 120% 60% at 50% 0%,#14608f 0%,var(--sea) 45%,var(--sea-deep) 100%) fixed,var(--sea-deep);overflow-x:hidden}\r\n.waves{position:fixed;inset:auto 0 0 0;height:120px;pointer-events:none;z-index:0;opacity:.35}\r\n.waves svg{width:200%;height:100%;animation:drift 18s linear infinite}\r\n@keyframes drift{to{transform:translateX(-50%)}}\r\n.wrap{position:relative;z-index:1;max-width:1100px;margin:0 auto;padding-block:18px 60px;\r\n  padding-left:max(16px,env(safe-area-inset-left,0px));padding-right:max(16px,env(safe-area-inset-right,0px));\r\n  display:flex;flex-direction:column;gap:16px}\r\nheader{display:flex;align-items:center;gap:14px;flex-wrap:wrap}\r\n.flag{width:64px;height:64px;flex:none;animation:wave 2.4s ease-in-out infinite;transform-origin:10% 100%}\r\n@keyframes wave{50%{transform:rotate(-4deg) skewY(2deg)}}\r\nh1{font-family:var(--f-display);font-weight:800;font-size:clamp(28px,5vw,48px);line-height:1;margin:0;\r\n  color:var(--gold);text-shadow:0 3px 0 var(--wood-dark),0 6px 14px rgb(0 0 0\/.45);text-wrap:balance;letter-spacing:.01em}\r\nh1 small{display:block;font-size:.42em;color:var(--foam);text-shadow:none;font-weight:700;letter-spacing:.08em;text-transform:uppercase;margin-top:6px}\r\n.rules{margin:0;color:var(--muted);max-width:70ch}\r\n.rules b{color:var(--gold)}\r\n\r\n\/* wooden sign bar *\/\r\n.bar{display:flex;flex-wrap:wrap;gap:10px;align-items:center;padding:12px 14px;border-radius:14px;\r\n  background:repeating-linear-gradient(90deg,var(--wood) 0 38px,var(--wood-light) 38px 40px,var(--wood) 40px 90px,#6b3f1e 90px 92px);\r\n  border:3px solid var(--wood-dark);box-shadow:0 6px 0 var(--wood-dark),0 12px 24px rgb(0 0 0\/.35)}\r\n.timer{display:flex;align-items:center;gap:8px;background:var(--paper);color:var(--ink);border-radius:10px;padding:4px 12px 4px 8px;border:2px solid var(--wood-dark)}\r\n.timer svg{width:28px;height:28px;transform-origin:50% 50%}\r\n.timer.running svg{animation:flip 4s ease-in-out infinite}\r\n@keyframes flip{0%,40%{transform:rotate(0)}50%,90%{transform:rotate(180deg)}100%{transform:rotate(360deg)}}\r\n.timer b{font-family:var(--f-display);font-weight:800;font-size:30px;font-variant-numeric:tabular-nums;line-height:1.1;min-width:70px}\r\n.timer.low{background:#ffd9cf;animation:pulse 1s infinite}\r\n.timer.low b{color:var(--red)}\r\n@keyframes pulse{50%{transform:scale(1.05)}}\r\n.who{font-family:var(--f-display);font-size:20px;font-weight:700;color:var(--text);text-shadow:0 2px 0 var(--wood-dark)}\r\n.who span{color:var(--gold)}\r\n.spacer{flex:1}\r\nbutton{font:inherit;font-weight:700;border:2px solid var(--wood-dark);background:var(--paper);color:var(--ink);border-radius:10px;\r\n  padding:8px 14px;cursor:pointer;box-shadow:0 3px 0 var(--wood-dark);transition:transform .08s}\r\nbutton:hover{transform:translateY(-1px)}\r\nbutton:active{transform:translateY(2px);box-shadow:0 1px 0 var(--wood-dark)}\r\nbutton:focus-visible,input:focus-visible,.cell:focus-visible{outline:3px solid var(--gold);outline-offset:2px}\r\nbutton.gold{background:linear-gradient(var(--gold),var(--gold-deep));color:#3a2004}\r\nbutton.on{background:var(--ink);color:var(--gold)}\r\nbutton:disabled{opacity:.5;cursor:not-allowed;transform:none}\r\n.msg{min-height:1.4em;font-family:var(--f-hand);font-size:clamp(22px,3vw,32px);line-height:1.3;padding:0 4px;color:var(--text)}\r\n.msg.bad{color:#ffb4a6} .msg.good{color:#9ff0c0}\r\n\r\n\/* parchment chart *\/\r\n.chart{position:relative;border-radius:18px;padding:18px;\r\n  background:radial-gradient(ellipse at 30% 20%,#fbecc4 0%,var(--paper) 40%,var(--paper-dark) 100%);\r\n  border:10px solid var(--wood);box-shadow:inset 0 0 40px rgb(122 74 36\/.45),0 0 0 3px var(--wood-dark),0 16px 34px rgb(0 0 0\/.45)}\r\n.chart::before{content:\"\";position:absolute;inset:8px;border:2px dashed rgb(58 36 16\/.25);border-radius:10px;pointer-events:none}\r\n.compass{position:absolute;right:-26px;top:-30px;width:78px;height:78px;z-index:2;filter:drop-shadow(0 4px 6px rgb(0 0 0\/.35))}\r\n.board-scroll{overflow-x:auto;padding:6px 2px}\r\n.board{display:grid;grid-template-columns:repeat(12,minmax(34px,1fr));gap:7px}\r\n.cell{position:relative;aspect-ratio:1;max-width:100%;display:grid;place-items:center;border-radius:12px;padding:0;\r\n  border:2px solid #c9a865;background:linear-gradient(160deg,#fff6dc,var(--sand));color:var(--ink);\r\n  font-family:var(--f-display);font-weight:800;font-size:clamp(15px,2.7vw,32px);font-variant-numeric:tabular-nums;\r\n  box-shadow:0 4px 0 #b8935a;cursor:pointer;user-select:none;transition:transform .12s,background .15s}\r\n.cell:hover{transform:translateY(-2px)}\r\n.cell.empty{visibility:hidden}\r\n.cell.end{background:linear-gradient(160deg,#ffe08a,var(--gold-deep));border-color:var(--wood-dark);box-shadow:0 4px 0 var(--wood-dark);\r\n  font-family:var(--f-body);font-size:clamp(7px,1.05vw,11px);font-weight:800;line-height:1.1;text-align:center;align-content:center;gap:2px;cursor:default;color:#3a2004}\r\n.cell.end svg{width:62%;height:auto}\r\n.cell.finish{cursor:pointer}\r\n.cell.reach{box-shadow:0 4px 0 #b8935a,0 0 0 3px var(--foam)}\r\n.cell.visited{background:linear-gradient(160deg,#ffe3b5,#f2c98a);border-color:var(--red);color:#8a2b1b}\r\n.cell.visited::after{content:\"\";position:absolute;left:6px;bottom:5px;width:10px;height:10px;border-radius:50%;background:var(--red);opacity:.7}\r\n.cell.here{background:linear-gradient(160deg,#2b9c6a,#1c7a52);border-color:#0f4d33;color:#fff;box-shadow:0 4px 0 #0f4d33;transform:scale(1.06)}\r\n.cell.here .ship{position:absolute;top:-16px;right:-12px;width:38px;height:38px;animation:bob 1.6s ease-in-out infinite;pointer-events:none}\r\n@keyframes bob{50%{transform:translateY(-4px) rotate(4deg)}}\r\n.cell.blocked{background:#ffd3c9;border-color:var(--red);color:var(--red)}\r\n.cell.wrong{animation:shake .45s;background:#ffb9aa;border-color:var(--red);color:#7a1b0d}\r\n.cell.sel{outline:4px dashed var(--red);outline-offset:2px}\r\n.cell.answer{box-shadow:0 4px 0 #b8935a,inset 0 0 0 4px var(--gold-deep)}\r\n.board.idle .cell:not(.end){cursor:default}\r\n.board.idle .cell:hover{transform:none}\r\n.board.edit .cell:not(.end){cursor:crosshair}\r\n@keyframes shake{20%{transform:translateX(-6px) rotate(-3deg)}40%{transform:translateX(6px) rotate(3deg)}60%{transform:translateX(-4px)}80%{transform:translateX(3px)}}\r\n.trail{margin-top:10px;font-family:var(--f-hand);font-size:20px;color:var(--ink);overflow-wrap:anywhere}\r\n.trail b{color:#8a2b1b;font-family:var(--f-display)}\r\n\r\n\/* callout (shark \/ rocks) *\/\r\n.callout{position:fixed;left:50%;top:38%;z-index:15;transform:translate(-50%,-50%);width:min(640px,calc(100vw - 32px));\r\n  display:flex;align-items:center;gap:14px;padding:16px 18px;border-radius:20px;background:var(--paper);color:var(--ink);\r\n  border:4px solid var(--wood-dark);box-shadow:0 10px 0 var(--wood-dark),0 20px 40px rgb(0 0 0\/.5);animation:pop .35s cubic-bezier(.3,1.6,.6,1)}\r\n.callout svg{width:130px;height:130px;flex:none}\r\n.callout p{margin:0;font-family:var(--f-hand);font-size:clamp(24px,3.4vw,36px);line-height:1.2}\r\n.callout p b{font-family:var(--f-display);color:var(--red)}\r\n@keyframes pop{from{transform:translate(-50%,-50%) scale(.4);opacity:0}}\r\n\r\n\/* panels *\/\r\n@media (max-width:760px){.compass{display:none}}\r\n.gv-panel{border-color:var(--gold);background:rgb(6 34 58\/.92)}\r\n.gv-panel h2{display:flex;align-items:center;justify-content:space-between}\r\n.gv-close{width:36px;height:36px;padding:0;border-radius:50%;font-size:22px;line-height:1}\r\n.icon-btn.on{background:var(--gold);color:#3a2004}\r\n.score-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}\r\n@media (max-width:700px){.score-grid{grid-template-columns:1fr}}\r\n.team-row{display:grid;grid-template-columns:auto minmax(0,1fr) repeat(3,auto);align-items:center;gap:14px;padding:12px 14px;border-radius:14px;\r\n  background:rgb(255 255 255\/.07);border:2px solid #2c6d93;font-variant-numeric:tabular-nums}\r\n.team-row.cur{border-color:var(--gold);background:rgb(255 200 61\/.14)}\r\n.team-row .mini-flag{width:clamp(38px,4vw,54px)}\r\n.tr-name{min-width:0;display:flex;flex-direction:column;gap:4px;align-items:flex-start}\r\n.tr-name input{font:inherit;font-family:var(--f-display);font-weight:800;font-size:clamp(18px,2.2vw,28px);width:100%;border:0;border-bottom:2px dashed #4f8fb3;background:transparent;color:var(--text);padding:0;line-height:1.2}\r\n.stat{display:flex;flex-direction:column;align-items:center;line-height:1.1}\r\n.stat small{font-size:clamp(10px,1vw,13px);text-transform:uppercase;letter-spacing:.06em;color:var(--muted);font-weight:600;white-space:nowrap}\r\n.stat b{font-family:var(--f-display);font-size:clamp(20px,2.4vw,32px)}\r\n.hint{font-family:var(--f-body);font-size:14px;font-weight:600;color:var(--muted);margin-left:8px}\r\n@media (max-width:460px){.team-row{grid-template-columns:auto minmax(0,1fr);}.team-row .stat{grid-column:auto}}\r\n.score-panel{padding:18px 22px}\r\n.score-panel h2{font-size:clamp(26px,3.4vw,38px)}\r\n.score-panel .score td{font-size:clamp(18px,2.4vw,28px);padding:12px 10px;font-weight:700}\r\n.score-panel .score th{font-size:clamp(12px,1.3vw,16px);padding:8px 10px}\r\n.score-panel .mini-flag{width:clamp(36px,4vw,54px)}\r\n.score-panel .team{min-width:220px;gap:12px}\r\n.score-panel .best{font-size:clamp(11px,1.2vw,15px);padding:2px 10px}\r\n.score-panel .note{font-size:14px}\r\n.panel{background:rgb(6 34 58\/.75);border:2px solid #2c6d93;border-radius:16px;padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0}\r\n.panel h2{font-family:var(--f-display);font-size:22px;margin:0;line-height:1.1;color:var(--gold)}\r\n.score-scroll{overflow-x:auto}\r\n.score{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}\r\n.score td,.score th{padding:7px 6px;border-bottom:1px solid #2c6d93;text-align:left;vertical-align:middle}\r\n.score th{font-size:12px;letter-spacing:.07em;text-transform:uppercase;color:var(--muted);font-weight:600}\r\n.score tr.cur td{background:rgb(255 200 61\/.12)}\r\n.score .team{display:flex;align-items:center;gap:8px;min-width:150px}\r\n.dot{width:14px;height:14px;border-radius:50%;flex:none;border:2px solid #fff3}\r\n.score input{font:inherit;font-weight:700;width:100%;border:0;border-bottom:2px dashed #4f8fb3;background:transparent;color:var(--text);padding:2px 0}\r\n.score input::placeholder{color:#88a9bd}\r\n.best{display:inline-block;margin-left:6px;font-size:11px;font-weight:800;background:var(--gold);color:#3a2004;border-radius:99px;padding:1px 8px;vertical-align:middle}\r\n.row-btns{display:flex;flex-wrap:wrap;gap:8px;align-items:center}\r\n.edit-row input{font:inherit;font-weight:800;width:90px;padding:7px 10px;border-radius:10px;border:2px solid var(--wood-dark);background:var(--paper);color:var(--ink)}\r\n#editLabel{color:var(--text)}\r\n.note{font-size:13px;color:var(--muted);margin:0}\r\n.status{font-weight:700;font-family:var(--f-hand);font-size:20px}\r\n.status.good{color:#9ff0c0} .status.bad{color:#ffb4a6}\r\n\r\n\/* flags *\/\r\n.flagsvg{display:block;width:100%;height:auto}\r\n.mini-flag{display:inline-block;width:30px;flex:none;vertical-align:middle}\r\n.who .mini-flag{width:34px;margin-right:4px}\r\n\r\n\/* welcome screen *\/\r\n.welcome{align-items:stretch}\r\n.hero{display:grid;grid-template-columns:auto 1fr;gap:20px;align-items:center}\r\n.hero-ship{width:150px;animation:bob 2.4s ease-in-out infinite}\r\n.hero h1{font-size:clamp(32px,6vw,60px)}\r\n.hero p{margin:8px 0 0;font-family:var(--f-hand);font-size:22px;line-height:1.3;color:var(--text);max-width:52ch}\r\n@media (max-width:560px){.hero{grid-template-columns:1fr}.hero-ship{width:110px}}\r\n.step-title{font-family:var(--f-display);font-size:24px;font-weight:800;color:var(--gold);margin:0;display:flex;align-items:center;gap:10px;flex-wrap:wrap}\r\n.count-pick{display:flex;gap:6px}\r\n.count-pick button{min-width:44px;padding:6px 10px}\r\n.teams-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:16px}\r\n.team-card{background:radial-gradient(ellipse at 50% 0%,#fbecc4,var(--paper));color:var(--ink);border:4px solid var(--wood);border-radius:18px;\r\n  padding:14px;display:flex;flex-direction:column;gap:10px;box-shadow:0 0 0 2px var(--wood-dark),0 8px 18px rgb(0 0 0\/.35);min-width:0}\r\n.team-card .big-flag{width:120px;margin:0 auto;animation:wave 2.6s ease-in-out infinite;transform-origin:6% 100%}\r\n.team-card label{font-size:12px;font-weight:700;letter-spacing:.07em;text-transform:uppercase;color:#6b4a26}\r\n.team-card input{font:inherit;font-family:var(--f-display);font-weight:800;font-size:20px;width:100%;box-sizing:border-box;padding:6px 10px;\r\n  border-radius:10px;border:2px solid var(--wood-dark);background:#fffaf0;color:var(--ink)}\r\n.icons{display:grid;grid-template-columns:repeat(4,1fr);gap:6px}\r\n.icons button{padding:4px;border-radius:10px;background:#1d1d26;border-color:#1d1d26;box-shadow:0 3px 0 #000;display:grid;place-items:center;gap:0}\r\n.icons button svg{width:100%;max-width:44px;height:auto}\r\n.icons button small{font-size:10px;color:#e8d8b0;font-weight:600;line-height:1.2}\r\n.icons button[aria-pressed=\"true\"]{outline:4px solid var(--gold);outline-offset:1px}\r\n.icons button.taken{opacity:.3}\r\n.go-row{display:flex;justify-content:center;align-items:center;flex-wrap:wrap;gap:12px;padding-top:6px}\r\n.go-row .fs-btn{font-size:18px;padding:12px 20px}\r\n.go-row button{font-family:var(--f-display);font-size:26px;padding:10px 34px;border-radius:14px}\r\n\r\n\/* corner controls *\/\r\n.corner{position:fixed;z-index:30;top:calc(env(safe-area-inset-top,0px) + 10px);right:max(10px,env(safe-area-inset-right,0px));display:flex;gap:8px}\r\n.icon-btn{width:46px;height:46px;padding:9px;border-radius:50%;display:grid;place-items:center;background:var(--paper);color:var(--wood-dark)}\r\n.icon-btn svg{width:100%;height:100%}\r\n.icon-btn.off{background:#c9b48a;color:#7a1b0d}\r\n\r\n\/* treasure overlay *\/\r\n.overlay{position:fixed;inset:0;display:grid;place-items:center;background:rgb(3 18 32\/.72);z-index:20;padding:16px}\r\n#coins{position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:21}\r\n.dialog{position:relative;z-index:22;background:radial-gradient(ellipse at 50% 0%,#fff1c9,var(--paper));color:var(--ink);border:5px solid var(--wood);\r\n  border-radius:22px;padding:10px 28px 26px;max-width:680px;width:100%;display:flex;flex-direction:column;gap:10px;text-align:center;\r\n  box-shadow:0 0 0 3px var(--wood-dark),0 0 60px rgb(255 200 61\/.5);animation:pop2 .45s cubic-bezier(.3,1.5,.6,1)}\r\n@keyframes pop2{from{transform:scale(.5);opacity:0}}\r\n.chest{width:250px;height:auto;margin:-60px auto 0;filter:drop-shadow(0 8px 10px rgb(0 0 0\/.35))}\r\n.chest #lid{transform-origin:30px 88px;animation:open 0.7s .35s cubic-bezier(.3,1.4,.6,1) forwards}\r\n.chest .glow{opacity:0;animation:glow .5s .5s forwards}\r\n@keyframes open{to{transform:translateY(-6px) rotate(-28deg)}}\r\n@keyframes glow{to{opacity:1}}\r\n.dialog h3{font-family:var(--f-display);font-size:clamp(36px,5vw,54px);margin:0;line-height:1.05;color:var(--wood-dark)}\r\n.dialog p{margin:0}\r\n.dialog .big{font-family:var(--f-hand);font-size:clamp(22px,3vw,32px);line-height:1.3}\r\n.dialog #dlgClose{font-size:24px;padding:12px}\r\n.dialog .note{color:#6b4a26}\r\n.dialog.lose .chest #lid,.dialog.lose .chest .glow{animation:none}\r\n@media (prefers-reduced-motion:reduce){*{animation:none!important;transition:none!important}.chest #lid{transform:translateY(-6px) rotate(-28deg)}.chest .glow{opacity:1}}\r\n\r\n\/* ===== Daytime sea (light) variant ===== *\/\r\n:root{--text:#123a52;--muted:#2f5d75}\r\nbody{background:linear-gradient(180deg,#d6f3fb 0%,#a9e3f3 45%,#6cc6e3 100%) fixed,#a9e3f3}\r\n.waves{opacity:.5}\r\nh1{color:#ffc83d;text-shadow:0 3px 0 var(--wood-dark),0 0 2px var(--wood-dark),0 6px 12px rgb(0 60 90\/.25)}\r\nh1 small{color:#0b5f86}\r\n.rules{color:var(--text)}\r\n.rules b{color:#a05a0c}\r\n.msg{color:var(--text)}\r\n.msg.good{color:#16784a} .msg.bad{color:#b8321f}\r\n.panel{background:rgb(255 255 255\/.72);border-color:#7fbfd8}\r\n.panel h2,.step-title{color:#8a4b12}\r\n.team-row{background:rgb(255 255 255\/.8);border-color:#9ccfe2}\r\n.team-row.cur{background:#fff3cf;border-color:var(--gold-deep)}\r\n.tr-name input{border-bottom-color:#5fa7c7}\r\n.status.good{color:#16784a} .status.bad{color:#b8321f}\r\n.gv-panel{background:rgb(255 255 255\/.9);border-color:var(--gold-deep)}\r\n.hero p{color:var(--text)}\r\n<\/style>\r\n\r\n<div class=\"waves\" aria-hidden=\"true\"><svg viewBox=\"0 0 1200 120\" preserveAspectRatio=\"none\"><path d=\"M0 60 Q75 20 150 60 T300 60 T450 60 T600 60 T750 60 T900 60 T1050 60 T1200 60 V120 H0Z\" fill=\"#7fd4e6\"\/><path d=\"M0 85 Q75 55 150 85 T300 85 T450 85 T600 85 T750 85 T900 85 T1050 85 T1200 85 V120 H0Z\" fill=\"#3aa0c4\"\/><\/svg><\/div>\r\n\r\n<div class=\"wrap welcome\" id=\"welcome\">\r\n  <section class=\"hero\">\r\n    <svg class=\"hero-ship\" viewBox=\"0 0 120 110\" aria-hidden=\"true\"><path d=\"M58 6 V78\" stroke=\"#4e2d13\" stroke-width=\"5\"\/><path d=\"M61 10 L102 62 H61Z\" fill=\"#fdf4dc\"\/><path d=\"M55 20 L22 62 H55Z\" fill=\"#f3dfae\"\/><path d=\"M58 4 h26 l-6 8 l6 8 h-26z\" fill=\"#1d1d26\"\/><circle cx=\"70\" cy=\"12\" r=\"3.5\" fill=\"#f3dfae\"\/><path d=\"M8 72 H112 L96 100 H24Z\" fill=\"#8a5428\" stroke=\"#4e2d13\" stroke-width=\"4\"\/><circle cx=\"40\" cy=\"84\" r=\"4\" fill=\"#ffc83d\"\/><circle cx=\"60\" cy=\"84\" r=\"4\" fill=\"#ffc83d\"\/><circle cx=\"80\" cy=\"84\" r=\"4\" fill=\"#ffc83d\"\/><path d=\"M0 102 Q15 94 30 102 T60 102 T90 102 T120 102\" stroke=\"#7fd4e6\" stroke-width=\"4\" fill=\"none\"\/><\/svg>\r\n    <div>\r\n      <h1>Ch\u00e0o m\u1eebng t\u1edbi<br>Truy T\u00ecm Kho B\u00e1u!<small>H\u1ea3i tr\u00ecnh s\u1ed1 nguy\u00ean t\u1ed1<\/small><\/h1>\r\n      <p>M\u1ed7i \u0111\u1ed9i l\u00e0 m\u1ed9t thuy\u1ec1n c\u01b0\u1edbp bi\u1ec3n. Ch\u1ec9 nh\u1eefng h\u00f2n \u0111\u1ea3o mang s\u1ed1 nguy\u00ean t\u1ed1 m\u1edbi c\u1eadp b\u1ebfn \u0111\u01b0\u1ee3c. \u0110\u1ed9i n\u00e0o t\u1edbi r\u01b0\u01a1ng kho b\u00e1u nhanh nh\u1ea5t s\u1ebd th\u1eafng!<\/p>\r\n    <\/div>\r\n  <\/section>\r\n\r\n  <h2 class=\"step-title\">S\u1ed1 \u0111\u1ed9i tham gia\r\n    <span class=\"count-pick\" id=\"countPick\"><\/span>\r\n  <\/h2>\r\n  <h2 class=\"step-title\">\u0110\u1eb7t t\u00ean v\u00e0 ch\u1ecdn c\u1edd cho \u0111\u1ed9i<\/h2>\r\n  <div class=\"teams-grid\" id=\"teamCards\"><\/div>\r\n  <div class=\"go-row\"><button class=\"gold\" id=\"goBtn\">Ra kh\u01a1i th\u00f4i!<\/button><\/div>\r\n<\/div>\r\n\r\n<div class=\"wrap\" id=\"game\" hidden>\r\n  <header>\r\n    <svg class=\"flag\" viewBox=\"0 0 64 64\" aria-hidden=\"true\"><rect x=\"6\" y=\"4\" width=\"4\" height=\"58\" rx=\"2\" fill=\"#a8693a\"\/><path d=\"M10 6 H58 Q52 20 58 34 H10Z\" fill=\"#1d1d26\"\/><circle cx=\"32\" cy=\"17\" r=\"7\" fill=\"#f3dfae\"\/><rect x=\"28\" y=\"22\" width=\"8\" height=\"5\" rx=\"2\" fill=\"#f3dfae\"\/><circle cx=\"29.5\" cy=\"16.5\" r=\"1.8\" fill=\"#1d1d26\"\/><circle cx=\"34.5\" cy=\"16.5\" r=\"1.8\" fill=\"#1d1d26\"\/><path d=\"M20 26 L44 32 M44 26 L20 32\" stroke=\"#f3dfae\" stroke-width=\"3\" stroke-linecap=\"round\"\/><\/svg>\r\n    <div>\r\n      <h1>Truy T\u00ecm Kho B\u00e1u<small>H\u1ea3i tr\u00ecnh s\u1ed1 nguy\u00ean t\u1ed1<\/small><\/h1>\r\n    <\/div>\r\n  <\/header>\r\n  <p class=\"rules\">L\u00e1i thuy\u1ec1n t\u1eeb b\u1ebfn <b>TRUY T\u00ccM KHO B\u00c1U<\/b> t\u1edbi r\u01b0\u01a1ng <b>KHO B\u00c1U<\/b>. Ch\u1ec9 \u0111i ngang ho\u1eb7c d\u1ecdc sang \u00f4 chung c\u1ea1nh, v\u00e0 ch\u1ec9 c\u1eadp b\u1ebfn \u00f4 c\u00f3 <b>s\u1ed1 nguy\u00ean t\u1ed1<\/b>. L\u1ee1 ch\u1ea1m h\u1ee3p s\u1ed1 l\u00e0 b\u1ecb c\u00e1 m\u1eadp \u0111u\u1ed5i v\u1ec1 b\u1ebfn xu\u1ea5t ph\u00e1t!<\/p>\r\n\r\n  <div class=\"bar\">\r\n    <div class=\"timer\" id=\"timerBox\"><svg viewBox=\"0 0 32 32\" aria-hidden=\"true\"><rect x=\"6\" y=\"2\" width=\"20\" height=\"4\" rx=\"2\" fill=\"#7a4a24\"\/><rect x=\"6\" y=\"26\" width=\"20\" height=\"4\" rx=\"2\" fill=\"#7a4a24\"\/><path d=\"M9 6 H23 Q23 14 16 16 Q23 18 23 26 H9 Q9 18 16 16 Q9 14 9 6Z\" fill=\"#cfe9f2\" stroke=\"#7a4a24\" stroke-width=\"1.5\"\/><path d=\"M12 24 H20 Q20 20 16 18 Q12 20 12 24Z\" fill=\"#d99a12\"\/><\/svg><b id=\"timer\">3:00<\/b><\/div>\r\n    <div class=\"who\"><span class=\"mini-flag\" id=\"whoFlag\"><\/span>L\u01b0\u1ee3t: <span id=\"who\">\u0110\u1ed9i 1<\/span><\/div>\r\n    <div class=\"spacer\"><\/div>\r\n    <button class=\"gold\" id=\"startBtn\">Nh\u1ed5 neo!<\/button>\r\n    <button id=\"nextBtn\">\u0110\u1ed9i ti\u1ebfp theo<\/button>\r\n    <button id=\"newBtn\">B\u1ea3n \u0111\u1ed3 m\u1edbi<\/button>\r\n  <\/div>\r\n\r\n  <section class=\"panel gv-panel\" id=\"gvPanel\" hidden>\r\n      <h2>D\u00e0nh cho GV <button class=\"gv-close\" id=\"gvClose\" aria-label=\"\u0110\u00f3ng ph\u1ea7n GV\">\u00d7<\/button><\/h2>\r\n      <div class=\"row-btns\">\r\n        <button id=\"editBtn\">\u0110\u1ed5i s\u1ed1 trong \u00f4<\/button>\r\n        <button id=\"answerBtn\">Hi\u1ec7n \u0111\u01b0\u1eddng \u0111i<\/button>\r\n        <button id=\"clearBtn\">X\u00f3a k\u1ebft qu\u1ea3<\/button>\r\n      <\/div>\r\n      <div class=\"row-btns edit-row\" id=\"editRow\" hidden>\r\n        <span id=\"editLabel\">Ch\u1ecdn m\u1ed9t \u00f4 tr\u00ean b\u1ea3n \u0111\u1ed3<\/span>\r\n        <input id=\"editInput\" type=\"number\" min=\"0\" max=\"999\" inputmode=\"numeric\" aria-label=\"S\u1ed1 m\u1edbi\">\r\n        <button class=\"gold\" id=\"applyBtn\">\u0110\u1ed5i<\/button>\r\n      <\/div>\r\n      <div class=\"row-btns\" id=\"clearConfirm\" hidden>\r\n        <span>X\u00f3a h\u1ebft k\u1ebft qu\u1ea3 c\u00e1c \u0111\u1ed9i?<\/span>\r\n        <button class=\"gold\" id=\"clearYes\">X\u00f3a<\/button>\r\n        <button id=\"clearNo\">Th\u00f4i<\/button>\r\n      <\/div>\r\n      <div class=\"status\" id=\"pathStatus\"><\/div>\r\n      <p class=\"note\">V\u00ed d\u1ee5: \u0111\u1ed5i 43 th\u00e0nh 45 r\u1ed3i h\u1ecfi \"\u0110\u01b0\u1eddng \u0111i c\u00f3 c\u00f2n \u0111\u00fang kh\u00f4ng?\". Trang s\u1ebd b\u00e1o c\u00f2n \u0111\u01b0\u1eddng hay b\u1ecb ch\u1eb7n. Khi \u0111ang \u0111\u1ed5i s\u1ed1, \u0111\u1ed3ng h\u1ed3 t\u1ea1m d\u1eebng.<\/p>\r\n    <\/section>\r\n\r\n  <div class=\"msg\" id=\"msg\" role=\"status\" aria-live=\"polite\">\u0110\u1eb7t t\u00ean \u0111\u1ed9i b\u00ean d\u01b0\u1edbi, r\u1ed3i b\u1ea5m \"Nh\u1ed5 neo!\" \u0111\u1ec3 t\u00ednh gi\u1edd 3 ph\u00fat.<\/div>\r\n\r\n  <div class=\"chart\">\r\n    <svg class=\"compass\" viewBox=\"0 0 80 80\" aria-hidden=\"true\"><circle cx=\"40\" cy=\"40\" r=\"36\" fill=\"#f3dfae\" stroke=\"#7a4a24\" stroke-width=\"5\"\/><path d=\"M40 8 L47 40 L40 72 L33 40Z\" fill=\"#d8432f\"\/><path d=\"M40 8 L47 40 H33Z\" fill=\"#3a2410\"\/><path d=\"M8 40 L40 34 L72 40 L40 46Z\" fill=\"#7a4a24\" opacity=\".6\"\/><circle cx=\"40\" cy=\"40\" r=\"4\" fill=\"#ffc83d\"\/><text x=\"40\" y=\"22\" text-anchor=\"middle\" font-size=\"9\" font-weight=\"800\" fill=\"#f3dfae\" font-family=\"sans-serif\">N<\/text><\/svg>\r\n    <div class=\"board-scroll\"><div class=\"board idle\" id=\"board\"><\/div><\/div>\r\n    <div class=\"trail\" id=\"trail\"><\/div>\r\n  <\/div>\r\n\r\n    <section class=\"panel score-panel\">\r\n      <h2>C\u00e1c \u0111\u1ed9i thuy\u1ec1n <small class=\"hint\">b\u1ea5m v\u00e0o t\u00ean \u0111\u1ec3 s\u1eeda<\/small><\/h2>\r\n      <div class=\"score-grid\" id=\"scoreBody\"><\/div>\r\n      <p class=\"note\">K\u1ebft qu\u1ea3 \u0111\u01b0\u1ee3c gi\u1eef l\u1ea1i khi \u0111\u1ed5i b\u1ea3n \u0111\u1ed3 m\u1edbi. \u0110\u1ed9i nhanh nh\u1ea5t \u0111\u01b0\u1ee3c g\u1eafn nh\u00e3n \"Nhanh nh\u1ea5t\".<\/p>\r\n    <\/section>\r\n\r\n<\/div>\r\n\r\n<div class=\"corner\"><button class=\"icon-btn\" id=\"gvBtn\" aria-label=\"D\u00e0nh cho GV\" title=\"D\u00e0nh cho GV\" aria-expanded=\"false\" hidden><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M12 4 1 9l11 5 9-4.1V16h2V9z\" fill=\"currentColor\"\/><path d=\"M5 12.2V17c0 1.7 3.1 3 7 3s7-1.3 7-3v-4.8l-7 3.2z\" fill=\"currentColor\"\/><\/svg><\/button><button class=\"icon-btn\" id=\"teamsBtn\" aria-label=\"\u0110\u1ed5i \u0111\u1ed9i\" title=\"\u0110\u1ed5i \u0111\u1ed9i\" hidden><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M5 2v20\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\"\/><path d=\"M6 3h13l-3 4.5 3 4.5H6z\" fill=\"currentColor\"\/><\/svg><\/button><button class=\"icon-btn\" id=\"soundBtn\" aria-label=\"T\u1eaft \u00e2m thanh\" title=\"T\u1eaft \u00e2m thanh\"><svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 9h4l5-4v14l-5-4H4z\" fill=\"currentColor\"\/><path d=\"M16 8.5a5 5 0 0 1 0 7M18.5 6a8.5 8.5 0 0 1 0 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"\/><\/svg><\/button><button class=\"icon-btn\" id=\"fsBtn\" aria-label=\"To\u00e0n m\u00e0n h\u00ecnh\" title=\"To\u00e0n m\u00e0n h\u00ecnh\"><\/button><\/div>\r\n\r\n<div class=\"callout\" id=\"callout\" hidden role=\"alert\"><span id=\"calloutArt\"><\/span><p id=\"calloutText\"><\/p><\/div>\r\n\r\n<div class=\"overlay\" id=\"overlay\" hidden>\r\n  <canvas id=\"coins\"><\/canvas>\r\n  <div class=\"dialog\" id=\"dialog\">\r\n    <svg class=\"chest\" id=\"chestArt\" viewBox=\"0 0 200 175\" aria-hidden=\"true\">\r\n      <g class=\"glow\"><path d=\"M100 70 L40 0 M100 70 L80 0 M100 70 L120 0 M100 70 L160 0 M100 70 L195 30 M100 70 L5 30\" stroke=\"#ffe27a\" stroke-width=\"10\" stroke-linecap=\"round\" opacity=\".55\"\/>\r\n        <ellipse cx=\"100\" cy=\"88\" rx=\"62\" ry=\"16\" fill=\"#ffd54a\"\/><circle cx=\"75\" cy=\"82\" r=\"10\" fill=\"#ffc83d\" stroke=\"#c98a12\" stroke-width=\"3\"\/><circle cx=\"98\" cy=\"77\" r=\"11\" fill=\"#ffc83d\" stroke=\"#c98a12\" stroke-width=\"3\"\/><circle cx=\"122\" cy=\"82\" r=\"10\" fill=\"#ffc83d\" stroke=\"#c98a12\" stroke-width=\"3\"\/><path d=\"M135 70 l8 -12 l8 12 l-8 10z\" fill=\"#4fd1a5\" stroke=\"#1c7a52\" stroke-width=\"2\"\/><path d=\"M58 72 l6 -9 l6 9 l-6 8z\" fill=\"#ff6b8a\" stroke=\"#a0263e\" stroke-width=\"2\"\/><\/g>\r\n      <rect x=\"30\" y=\"88\" width=\"140\" height=\"78\" rx=\"8\" fill=\"#8a5428\" stroke=\"#4e2d13\" stroke-width=\"4\"\/>\r\n      <rect x=\"30\" y=\"108\" width=\"140\" height=\"8\" fill=\"#6b3f1e\"\/>\r\n      <rect x=\"48\" y=\"88\" width=\"12\" height=\"78\" fill=\"#ffc83d\" stroke=\"#a0700c\" stroke-width=\"2\"\/><rect x=\"140\" y=\"88\" width=\"12\" height=\"78\" fill=\"#ffc83d\" stroke=\"#a0700c\" stroke-width=\"2\"\/>\r\n      <rect x=\"88\" y=\"98\" width=\"24\" height=\"28\" rx=\"4\" fill=\"#ffc83d\" stroke=\"#a0700c\" stroke-width=\"3\"\/><circle cx=\"100\" cy=\"110\" r=\"4\" fill=\"#4e2d13\"\/><rect x=\"98\" y=\"110\" width=\"4\" height=\"9\" fill=\"#4e2d13\"\/>\r\n      <g id=\"lid\"><path d=\"M30 90 V70 Q30 42 100 42 Q170 42 170 70 V90 Z\" fill=\"#a8693a\" stroke=\"#4e2d13\" stroke-width=\"4\"\/><path d=\"M48 46 V90 H60 V43Z M140 43 V90 H152 V46Z\" fill=\"#ffc83d\" stroke=\"#a0700c\" stroke-width=\"2\"\/><\/g>\r\n    <\/svg>\r\n    <h3 id=\"dlgTitle\">T\u00ecm \u0111\u01b0\u1ee3c kho b\u00e1u!<\/h3>\r\n    <p class=\"big\" id=\"dlgText\"><\/p>\r\n    <button class=\"gold\" id=\"dlgClose\">\u0110\u00f3ng<\/button>\r\n  <\/div>\r\n<\/div>\r\n\r\n<script>\r\nconst ROWS=5, COLS=10, TIME=180;\r\nconst $=id=>document.getElementById(id);\r\nconst isPrime=n=>{if(n<2)return false;for(let i=2;i*i<=n;i++)if(n%i===0)return false;return true};\r\nconst smallFactor=n=>{for(let i=2;i*i<=n;i++)if(n%i===0)return i;return 0};\r\nconst PRIMES=[],COMPOS=[];\r\nfor(let n=2;n<=99;n++)(isPrime(n)?PRIMES:COMPOS).push(n);\r\nconst pick=a=>a[Math.floor(Math.random()*a.length)];\r\nconst shuffle=a=>{for(let i=a.length-1;i>0;i--){const j=Math.floor(Math.random()*(i+1));[a[i],a[j]]=[a[j],a[i]]}return a};\r\nconst DIRS=[[1,0],[-1,0],[0,1],[0,-1]];\r\n\r\n\/* ---------- art ---------- *\/\r\nconst SHIP=`<svg class=\"ship\" viewBox=\"0 0 40 40\" aria-hidden=\"true\"><path d=\"M19 4 V24\" stroke=\"#4e2d13\" stroke-width=\"2.5\"\/><path d=\"M20 5 L33 21 H20Z\" fill=\"#fff\"\/><path d=\"M18 8 L8 21 H18Z\" fill=\"#f3dfae\"\/><path d=\"M19 3 h8 l-2 3 l2 3 h-8z\" fill=\"#d8432f\"\/><path d=\"M4 24 H36 L30 34 H10Z\" fill=\"#8a5428\" stroke=\"#4e2d13\" stroke-width=\"2\"\/><\/svg>`;\r\nconst START_ART=`<svg viewBox=\"0 0 40 32\" aria-hidden=\"true\"><path d=\"M19 2 V20\" stroke=\"#4e2d13\" stroke-width=\"2.5\"\/><path d=\"M20 3 L32 18 H20Z\" fill=\"#fff\"\/><path d=\"M18 6 L9 18 H18Z\" fill=\"#f3dfae\"\/><path d=\"M3 21 H37 L31 30 H9Z\" fill=\"#8a5428\" stroke=\"#4e2d13\" stroke-width=\"2\"\/><\/svg>`;\r\nconst FINISH_ART=`<svg viewBox=\"0 0 40 32\" aria-hidden=\"true\"><rect x=\"5\" y=\"14\" width=\"30\" height=\"16\" rx=\"2\" fill=\"#8a5428\" stroke=\"#4e2d13\" stroke-width=\"2\"\/><path d=\"M5 15 V11 Q5 4 20 4 Q35 4 35 11 V15Z\" fill=\"#a8693a\" stroke=\"#4e2d13\" stroke-width=\"2\"\/><rect x=\"17\" y=\"13\" width=\"6\" height=\"7\" rx=\"1\" fill=\"#ffc83d\" stroke=\"#a0700c\"\/><path d=\"M11 4 V30 M29 4 V30\" stroke=\"#ffc83d\" stroke-width=\"3\"\/><\/svg>`;\r\nconst SHARK=`<svg viewBox=\"0 0 100 100\" aria-hidden=\"true\"><circle cx=\"50\" cy=\"50\" r=\"48\" fill=\"#bfe7f2\"\/><path d=\"M22 62 Q48 8 70 18 Q60 36 66 62Z\" fill=\"#5b7280\"\/><path d=\"M30 62 Q48 22 64 24 Q57 40 61 62Z\" fill=\"#76909e\"\/><path d=\"M4 64 Q16 54 28 64 T52 64 T76 64 T100 64 V100 H0Z\" fill=\"#2a8fbf\"\/><path d=\"M4 74 Q16 66 28 74 T52 74 T76 74 T100 74\" stroke=\"#fff\" stroke-width=\"3\" fill=\"none\" opacity=\".7\"\/><\/svg>`;\r\nconst ROCKS=`<svg viewBox=\"0 0 100 100\" aria-hidden=\"true\"><circle cx=\"50\" cy=\"50\" r=\"48\" fill=\"#bfe7f2\"\/><path d=\"M50 52 m-28 0 a28 12 0 1 0 56 0 a28 12 0 1 0 -56 0\" fill=\"none\" stroke=\"#2a8fbf\" stroke-width=\"4\"\/><path d=\"M50 52 m-16 0 a16 7 0 1 0 32 0 a16 7 0 1 0 -32 0\" fill=\"none\" stroke=\"#2a8fbf\" stroke-width=\"3\"\/><path d=\"M14 74 L26 42 L38 50 L46 30 L60 46 L70 38 L86 74Z\" fill=\"#6f6a66\" stroke=\"#3e3a37\" stroke-width=\"3\" stroke-linejoin=\"round\"\/><path d=\"M26 42 L30 56 M46 30 L48 50 M70 38 L68 56\" stroke=\"#3e3a37\" stroke-width=\"2\"\/><path d=\"M4 74 Q16 66 28 74 T52 74 T76 74 T100 74 V100 H0Z\" fill=\"#2a8fbf\"\/><text x=\"78\" y=\"30\" font-size=\"26\" font-weight=\"900\" fill=\"#d8432f\" font-family=\"sans-serif\">!<\/text><\/svg>`;\r\n\r\nconst WRONG_LINES=[\r\n  n=>`C\u00e1 m\u1eadp \u0111\u1edbp r\u1ed3i! <b>${n}<\/b> l\u00e0 h\u1ee3p s\u1ed1. B\u01a1i v\u1ec1 b\u1ebfn xu\u1ea5t ph\u00e1t th\u00f4i!`,\r\n  n=>`\u1ed0i gi\u1eddi \u01a1i! <b>${n}<\/b> \u0111\u00e2u ph\u1ea3i s\u1ed1 nguy\u00ean t\u1ed1. V\u1ec1 b\u1ebfn l\u00e0m l\u1ea1i n\u00e0o!`,\r\n  n=>`B\u1eaby r\u1ed3i thuy\u1ec1n tr\u01b0\u1edfng \u01a1i! <b>${n}<\/b> chia h\u1ebft \u0111\u01b0\u1ee3c k\u00eca. Quay v\u1ec1 b\u1ebfn!`\r\n];\r\nconst DEAD_LINES=[\r\n  `<b>\u00ca \u00ea \u00ea!<\/b> \u0110i l\u1ed9n \u0111\u01b0\u1eddng r\u1ed3i m\u1ea5y n\u00ed \u01a1i, <b>quay xe l\u1eb9 n\u00e0o!<\/b>`\r\n];\r\n\r\n\/* ---------- sound (Web Audio, no files) ---------- *\/\r\nlet soundOn=true,actx=null;\r\nfunction ac(){if(!actx){try{actx=new (window.AudioContext||window.webkitAudioContext)()}catch(e){}}if(actx&&actx.state===\"suspended\")actx.resume();return actx}\r\nfunction tone(f,t0,dur,type=\"sine\",vol=.18,f2){const a=ac();if(!a||!soundOn)return;const o=a.createOscillator(),g=a.createGain();\r\n  o.type=type;o.frequency.setValueAtTime(f,a.currentTime+t0);if(f2)o.frequency.exponentialRampToValueAtTime(f2,a.currentTime+t0+dur);\r\n  g.gain.setValueAtTime(0,a.currentTime+t0);g.gain.linearRampToValueAtTime(vol,a.currentTime+t0+.02);g.gain.exponentialRampToValueAtTime(.001,a.currentTime+t0+dur);\r\n  o.connect(g).connect(a.destination);o.start(a.currentTime+t0);o.stop(a.currentTime+t0+dur+.05)}\r\nconst SFX={\r\n  step(){tone(880,0,.12,\"triangle\",.15);tone(1320,.07,.15,\"triangle\",.12)},\r\n  wrong(){tone(320,0,.5,\"sawtooth\",.14,90);tone(160,.05,.45,\"square\",.06,60)},\r\n  dead(){tone(392,0,.3,\"triangle\",.18,370);tone(370,.32,.3,\"triangle\",.18,349);tone(349,.64,.7,\"triangle\",.18,262)},\r\n  win(){[523,659,784,1047,1319].forEach((f,i)=>tone(f,i*.11,.35,\"triangle\",.17));[1568,2093,2637].forEach((f,i)=>tone(f,.65+i*.08,.5,\"sine\",.08))},\r\n  start(){tone(196,0,.25,\"square\",.08);tone(262,.18,.35,\"square\",.08)},\r\n  tick(){tone(1000,0,.05,\"square\",.05)},\r\n  lose(){tone(300,0,.4,\"sawtooth\",.12,200);tone(200,.4,.7,\"sawtooth\",.12,110)}\r\n};\r\n\r\n\/* ---------- state ---------- *\/\r\nlet grid=[],startRow=0,finishRow=0,solution=[],mapNo=0;\r\nlet pos=[\"S\"],trail=[],running=false,paused=false,left=TIME,tick=null,mistakes=0;\r\nlet player=0,editMode=false,sel=null,showAnswer=false,calloutTimer=null;\r\nconst COLORS=[\"#ff6b5b\",\"#ffc83d\",\"#4fd1a5\",\"#7fb6ff\",\"#ff8fd8\",\"#b8f05a\"];\r\nconst EMBLEMS={\r\n  skull:{name:\"\u0110\u1ea7u l\u00e2u\",svg:`<circle cx=\"20\" cy=\"15\" r=\"10\"\/><rect x=\"14\" y=\"20\" width=\"12\" height=\"7\" rx=\"2\"\/><circle cx=\"16\" cy=\"15\" r=\"2.6\" fill=\"#1d1d26\"\/><circle cx=\"24\" cy=\"15\" r=\"2.6\" fill=\"#1d1d26\"\/><path d=\"M6 30 L34 38 M34 30 L6 38\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/>`},\r\n  shark:{name:\"C\u00e1 m\u1eadp\",svg:`<path d=\"M6 30 Q18 3 33 5 Q24 18 28 30Z\"\/><path d=\"M2 35 Q8 31 14 35 T26 35 T38 35\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3\" stroke-linecap=\"round\"\/>`},\r\n  octopus:{name:\"B\u1ea1ch tu\u1ed9c\",svg:`<path d=\"M8 22 Q8 4 20 4 Q32 4 32 22Z\"\/><path d=\"M10 22 Q8 32 4 34 M16 22 Q15 32 12 37 M24 22 Q25 32 28 37 M30 22 Q32 32 36 34\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><circle cx=\"16\" cy=\"14\" r=\"2.4\" fill=\"#1d1d26\"\/><circle cx=\"24\" cy=\"14\" r=\"2.4\" fill=\"#1d1d26\"\/>`},\r\n  anchor:{name:\"M\u1ecf neo\",svg:`<circle cx=\"20\" cy=\"7\" r=\"4\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3\"\/><path d=\"M20 11 V35 M12 16 H28 M6 24 Q8 36 20 36 Q32 36 34 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/>`},\r\n  turtle:{name:\"R\u00f9a bi\u1ec3n\",svg:`<ellipse cx=\"19\" cy=\"22\" rx=\"12\" ry=\"9\"\/><circle cx=\"34\" cy=\"20\" r=\"4\"\/><path d=\"M10 30 l-4 4 M28 30 l4 4 M10 14 l-4 -4 M28 14 l3 -4\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path d=\"M13 22 H25 M19 15 V29\" stroke=\"#1d1d26\" stroke-width=\"2\"\/>`},\r\n  wheel:{name:\"B\u00e1nh l\u00e1i\",svg:`<path d=\"M20 3 V37 M3 20 H37 M8 8 L32 32 M32 8 L8 32\" stroke=\"currentColor\" stroke-width=\"3\" stroke-linecap=\"round\"\/><circle cx=\"20\" cy=\"20\" r=\"11\" fill=\"#1d1d26\" stroke=\"currentColor\" stroke-width=\"3.5\"\/><circle cx=\"20\" cy=\"20\" r=\"4\"\/>`},\r\n  swords:{name:\"Ki\u1ebfm ch\u00e9o\",svg:`<path d=\"M8 5 L32 31 M32 5 L8 31\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><path d=\"M25 31 L31 25 M9 25 L15 31\" stroke=\"currentColor\" stroke-width=\"3.5\" stroke-linecap=\"round\"\/><circle cx=\"34\" cy=\"35\" r=\"3\"\/><circle cx=\"6\" cy=\"35\" r=\"3\"\/>`},\r\n  star:{name:\"La b\u00e0n\",svg:`<path d=\"M20 2 L24 16 L38 20 L24 24 L20 38 L16 24 L2 20 L16 16Z\"\/><circle cx=\"20\" cy=\"20\" r=\"3\" fill=\"#1d1d26\"\/>`}\r\n};\r\nfunction flag(icon,color){\r\n  return `<svg class=\"flagsvg\" viewBox=\"0 0 66 58\" aria-hidden=\"true\"><rect x=\"2\" y=\"2\" width=\"4\" height=\"56\" rx=\"2\" fill=\"#a8693a\"\/>\r\n  <path d=\"M6 4 Q20 0 34 4 T63 4 V40 Q49 36 34 40 T6 40Z\" fill=\"#1d1d26\" stroke=\"${color}\" stroke-width=\"3\"\/>\r\n  <g transform=\"translate(18 6) scale(.8)\" fill=\"currentColor\" style=\"color:${color}\">${EMBLEMS[icon].svg}<\/g><\/svg>`;\r\n}\r\nconst DEFAULT_TEAMS=[[\"\u0110\u1ed9i C\u00e1 M\u1eadp\",\"shark\"],[\"\u0110\u1ed9i B\u1ea1ch Tu\u1ed9c\",\"octopus\"],[\"\u0110\u1ed9i M\u1ecf Neo\",\"anchor\"],[\"\u0110\u1ed9i R\u00f9a Bi\u1ec3n\",\"turtle\"],[\"\u0110\u1ed9i \u0110\u1ea7u L\u00e2u\",\"skull\"],[\"\u0110\u1ed9i B\u00e1nh L\u00e1i\",\"wheel\"]];\r\nlet teamCount=4;\r\nlet teams=DEFAULT_TEAMS.slice(0,teamCount).map(([n,ic])=>({name:n,icon:ic,time:null,miss:null,map:null}));\r\nfunction setTeamCount(n){\r\n  teamCount=n;\r\n  while(teams.length<n){const used=new Set(teams.map(t=>t.icon));const[dn,di]=DEFAULT_TEAMS[teams.length];\r\n    teams.push({name:dn,icon:used.has(di)?Object.keys(EMBLEMS).find(k=>!used.has(k)):di,time:null,miss:null,map:null})}\r\n  teams.length=n;if(player>=n)player=0;renderWelcome();\r\n}\r\nfunction renderWelcome(){\r\n  $(\"countPick\").innerHTML=\"\";\r\n  for(let n=2;n<=6;n++){const b=document.createElement(\"button\");b.textContent=n;b.id=\"cnt\"+n;\r\n    b.className=n===teamCount?\"gold\":\"\";b.setAttribute(\"aria-pressed\",n===teamCount);b.onclick=()=>setTeamCount(n);$(\"countPick\").appendChild(b)}\r\n  const box=$(\"teamCards\");box.innerHTML=\"\";\r\n  teams.forEach((t,i)=>{\r\n    const card=document.createElement(\"div\");card.className=\"team-card\";\r\n    const taken=new Set(teams.filter((_,j)=>j!==i).map(x=>x.icon));\r\n    card.innerHTML=`<div class=\"big-flag\">${flag(t.icon,COLORS[i])}<\/div>\r\n      <label for=\"wname${i}\">T\u00ean \u0111\u1ed9i ${i+1}<\/label><input id=\"wname${i}\" maxlength=\"24\">\r\n      <label>Ch\u1ecdn c\u1edd<\/label><div class=\"icons\"><\/div>`;\r\n    const inp=card.querySelector(\"input\");inp.value=t.name;inp.oninput=e=>{t.name=e.target.value.trim()||(\"\u0110\u1ed9i \"+(i+1))};\r\n    const ic=card.querySelector(\".icons\");\r\n    Object.entries(EMBLEMS).forEach(([k,e])=>{const b=document.createElement(\"button\");b.type=\"button\";b.id=`ic${i}-${k}`;\r\n      b.setAttribute(\"aria-pressed\",k===t.icon);b.title=taken.has(k)?e.name+\" (\u0111\u1ed9i kh\u00e1c \u0111\u00e3 ch\u1ecdn)\":e.name;\r\n      if(taken.has(k))b.classList.add(\"taken\");\r\n      b.innerHTML=`<svg viewBox=\"0 0 40 40\" fill=\"currentColor\" style=\"color:${COLORS[i]}\">${e.svg}<\/svg><small>${e.name}<\/small>`;\r\n      b.onclick=()=>{if(taken.has(k)){b.animate?.([{transform:\"translateX(-4px)\"},{transform:\"translateX(4px)\"},{transform:\"none\"}],{duration:250});return}\r\n        t.icon=k;SFX.step();renderWelcome();document.getElementById(`ic${i}-${k}`)?.focus()};\r\n      ic.appendChild(b)});\r\n    box.appendChild(card)});\r\n}\r\nfunction showWelcome(){$(\"welcome\").hidden=false;$(\"game\").hidden=true;$(\"teamsBtn\").hidden=true;$(\"gvBtn\").hidden=true;gvToggle(false);renderWelcome();scrollTo(0,0)}\r\nfunction showGame(){$(\"welcome\").hidden=true;$(\"game\").hidden=false;$(\"teamsBtn\").hidden=false;$(\"gvBtn\").hidden=false;render();scrollTo(0,0);\r\n  say(`L\u01b0\u1ee3t c\u1ee7a ${teams[player].name}. B\u1ea5m \"Nh\u1ed5 neo!\" \u0111\u1ec3 t\u00ednh gi\u1edd 3 ph\u00fat.`)}\r\nfunction setWho(){$(\"who\").textContent=teams[player].name;$(\"whoFlag\").innerHTML=flag(teams[player].icon,COLORS[player])}\r\n\r\n\/* ---------- map ---------- *\/\r\nfunction genPath(){\r\n  for(let tries=0;tries<500;tries++){\r\n    const sr=Math.floor(Math.random()*ROWS);\r\n    const path=[[sr,0]],seen=new Set([sr+\",0\"]);let r=sr,c=0,ok=false;\r\n    while(path.length<40){\r\n      if(c===COLS-1&&path.length>=14){ok=true;break}\r\n      const opts=[];\r\n      const push=(dr,dc,w)=>{const nr=r+dr,nc=c+dc;if(nr<0||nr>=ROWS||nc<0||nc>=COLS||seen.has(nr+\",\"+nc))return;\r\n        let touch=0;for(const[a,b]of DIRS)if(seen.has((nr+a)+\",\"+(nc+b)))touch++;\r\n        if(touch>1)return;for(let k=0;k<w;k++)opts.push([nr,nc])};\r\n      push(0,1,3);push(1,0,3);push(-1,0,3);push(0,-1,1);\r\n      if(!opts.length)break;[r,c]=pick(opts);path.push([r,c]);seen.add(r+\",\"+c);\r\n    }\r\n    if(ok)return path;\r\n  }\r\n}\r\nfunction newMap(){\r\n  const path=genPath();mapNo++;\r\n  startRow=path[0][0];finishRow=path[path.length-1][0];\r\n  grid=Array.from({length:ROWS},()=>Array.from({length:COLS},()=>pick(Math.random()<.1?[1,...COMPOS]:COMPOS)));\r\n  const used=new Set();\r\n  for(const[r,c]of path){let p;do p=pick(PRIMES);while(used.has(p)&&used.size<PRIMES.length);used.add(p);grid[r][c]=p}\r\n  const onPath=new Set(path.map(([r,c])=>r+\",\"+c));\r\n  shuffle([...Array(ROWS*COLS).keys()].map(i=>[Math.floor(i\/COLS),i%COLS]).filter(([r,c])=>!onPath.has(r+\",\"+c)))\r\n    .slice(0,7).forEach(([r,c])=>grid[r][c]=pick(PRIMES));\r\n  resetRun();solve();render();\r\n}\r\nfunction solve(){\r\n  const q=[],prev={};\r\n  if(isPrime(grid[startRow][0])){q.push([startRow,0]);prev[startRow+\",0\"]=null}\r\n  while(q.length){const[r,c]=q.shift();\r\n    if(r===finishRow&&c===COLS-1){const out=[];let k=r+\",\"+c;while(k){out.unshift(k);k=prev[k]}solution=out;return true}\r\n    for(const[a,b]of DIRS){const nr=r+a,nc=c+b,k=nr+\",\"+nc;\r\n      if(nr<0||nr>=ROWS||nc<0||nc>=COLS||k in prev||!isPrime(grid[nr][nc]))continue;prev[k]=r+\",\"+c;q.push([nr,nc])}}\r\n  solution=[];return false;\r\n}\r\n\r\n\/* ---------- play ---------- *\/\r\nfunction resetRun(){\r\n  clearInterval(tick);running=false;paused=false;left=TIME;mistakes=0;pos=[\"S\"];trail=[];\r\n  $(\"startBtn\").disabled=false;$(\"startBtn\").textContent=\"Nh\u1ed5 neo!\";\r\n}\r\nfunction adjacent(r,c){if(pos[0]===\"S\")return r===startRow&&c===0;const[pr,pc]=pos;return Math.abs(pr-r)+Math.abs(pc-c)===1}\r\nfunction isStuck(){\r\n  if(pos[0]===\"S\")return false;\r\n  const[r,c]=pos;if(r===finishRow&&c===COLS-1)return false;\r\n  return !DIRS.some(([a,b])=>{const nr=r+a,nc=c+b;return nr>=0&&nr<ROWS&&nc>=0&&nc<COLS&&!trail.includes(nr+\",\"+nc)&&isPrime(grid[nr][nc])});\r\n}\r\nfunction callout(art,html,ms=2600){\r\n  $(\"calloutArt\").innerHTML=art;$(\"calloutText\").innerHTML=html;const el=$(\"callout\");\r\n  el.hidden=true;void el.offsetWidth;el.hidden=false;clearTimeout(calloutTimer);calloutTimer=setTimeout(()=>el.hidden=true,ms);\r\n}\r\nfunction clickCell(r,c){\r\n  if(editMode){sel=[r,c];$(\"editLabel\").textContent=`\u00d4 \u0111ang ch\u1ecdn: ${grid[r][c]} \u2192`;$(\"editInput\").value=grid[r][c];$(\"editInput\").focus();render();return}\r\n  if(!running){say('B\u1ea5m \"Nh\u1ed5 neo!\" tr\u01b0\u1edbc \u0111\u00e3 nh\u00e9.','bad');return}\r\n  const k=r+\",\"+c;\r\n  if(trail.length>1&&trail[trail.length-2]===k){trail.pop();pos=[r,c];SFX.tick();say(\"L\u00f9i thuy\u1ec1n m\u1ed9t \u00f4.\");render();return}\r\n  if(trail.length===1&&trail[0]===k)return;\r\n  if(trail.includes(k)){say(\"\u00d4 n\u00e0y thuy\u1ec1n \u0111\u00e3 \u0111i qua r\u1ed3i.\",\"bad\");return}\r\n  if(!adjacent(r,c)){say(\"Ch\u1ec9 \u0111\u01b0\u1ee3c \u0111i sang \u00f4 chung c\u1ea1nh: ngang ho\u1eb7c d\u1ecdc, kh\u00f4ng \u0111i ch\u00e9o.\",\"bad\");return}\r\n  const n=grid[r][c];\r\n  if(!isPrime(n)){\r\n    mistakes++;SFX.wrong();\r\n    const f=smallFactor(n);const why=n<2?`${n} kh\u00f4ng ph\u1ea3i s\u1ed1 nguy\u00ean t\u1ed1.`:`${n} = ${f} \u00d7 ${n\/f}`;\r\n    trail=[];pos=[\"S\"];render();\r\n    const el=document.querySelector(`[data-r=\"${r}\"][data-c=\"${c}\"]`);el.classList.add(\"wrong\");setTimeout(()=>el.classList.remove(\"wrong\"),700);\r\n    callout(SHARK,pick(WRONG_LINES)(n)+`<br><small>(${why})<\/small>`);\r\n    say(`${why}. V\u1ec1 b\u1ebfn xu\u1ea5t ph\u00e1t!`,\"bad\");return}\r\n  pos=[r,c];trail.push(k);render();\r\n  if(isStuck()){SFX.dead();callout(ROCKS,pick(DEAD_LINES),3200);say(\"\u0110\u01b0\u1eddng b\u1ecb ch\u1eb7n! B\u1ea5m l\u1ea1i \u00f4 v\u1eeba \u0111i \u0111\u1ec3 l\u00f9i.\",\"bad\")}\r\n  else{SFX.step();say(pick([`${n} l\u00e0 s\u1ed1 nguy\u00ean t\u1ed1. Ti\u1ebfn l\u00ean!`,`Chu\u1ea9n! ${n} l\u00e0 s\u1ed1 nguy\u00ean t\u1ed1.`,`${n}: s\u1ed1 nguy\u00ean t\u1ed1, ch\u00e8o ti\u1ebfp!`]),\"good\")}\r\n}\r\nfunction clickFinish(){\r\n  if(!running||editMode)return;\r\n  if(pos[0]===\"S\"||pos[0]!==finishRow||pos[1]!==COLS-1){say(\"Ch\u01b0a t\u1edbi r\u01b0\u01a1ng! Thuy\u1ec1n ph\u1ea3i \u0111\u1ee9ng \u1edf \u00f4 ngay c\u1ea1nh KHO B\u00c1U.\",\"bad\");return}\r\n  clearInterval(tick);running=false;$(\"startBtn\").disabled=true;\r\n  const used=TIME-left;Object.assign(teams[player],{time:used,miss:mistakes,map:mapNo});renderScore();\r\n  const path=trail.map(k=>{const[r,c]=k.split(\",\");return grid[r][c]}).join(\" \u2192 \");\r\n  showDialog(true,\"T\u00ecm \u0111\u01b0\u1ee3c kho b\u00e1u!\",`<span class=\"mini-flag\" style=\"width:46px\">${flag(teams[player].icon,COLORS[player])}<\/span> ${teams[player].name} m\u1edf r\u01b0\u01a1ng sau ${fmt(used)}, b\u1ea5m sai ${mistakes} l\u1ea7n.<br>H\u1ea3i tr\u00ecnh: ${path}`);\r\n  SFX.win();say(\"Kho b\u00e1u \u0111\u00e2y r\u1ed3i!\",\"good\");\r\n}\r\nfunction start(){\r\n  if(running)return;resetRun();running=true;$(\"startBtn\").disabled=true;$(\"startBtn\").textContent=\"\u0110ang ra kh\u01a1i\";\r\n  SFX.start();startTicking();say(\"Ra kh\u01a1i! B\u1ea5m v\u00e0o \u00f4 c\u1ea1nh b\u1ebfn TRUY T\u00ccM KHO B\u00c1U.\");render();\r\n}\r\nfunction startTicking(){\r\n  clearInterval(tick);\r\n  tick=setInterval(()=>{left--;renderTimer();if(left<=10&&left>0)SFX.tick();\r\n    if(left<=0){clearInterval(tick);running=false;Object.assign(teams[player],{time:\"h\u1ebft gi\u1edd\",miss:mistakes,map:mapNo});renderScore();\r\n      showDialog(false,\"H\u1ebft gi\u1edd!\",`${teams[player].name} ch\u01b0a t\u1edbi \u0111\u01b0\u1ee3c r\u01b0\u01a1ng kho b\u00e1u. L\u1ea7n sau nh\u00e9!`);SFX.lose();say(\"H\u1ebft 3 ph\u00fat.\",\"bad\");render()}},1000);\r\n}\r\nfunction showDialog(win,title,text){\r\n  renderTimer();const d=$(\"dialog\");d.classList.toggle(\"lose\",!win);\r\n  $(\"chestArt\").style.display=win?\"\":\"none\";\r\n  $(\"dlgTitle\").textContent=title;$(\"dlgText\").innerHTML=text;\r\n  \/\/ restart chest animation\r\n  const s=$(\"chestArt\");s.replaceWith(s.cloneNode(true));\r\n  $(\"overlay\").hidden=false;$(\"dlgClose\").focus();if(win)coinRain();\r\n}\r\n\r\n\/* ---------- coin rain ---------- *\/\r\nlet coinRAF=null;\r\nfunction coinRain(){\r\n  if(matchMedia(\"(prefers-reduced-motion: reduce)\").matches)return;\r\n  const cv=$(\"coins\"),ctx=cv.getContext(\"2d\");const W=cv.width=innerWidth,H=cv.height=innerHeight;\r\n  const coins=Array.from({length:90},()=>({x:Math.random()*W,y:-Math.random()*H*.8-20,r:8+Math.random()*9,vy:2+Math.random()*3.5,vx:(Math.random()-.5)*1.5,a:Math.random()*6,va:.08+Math.random()*.15}));\r\n  const t0=performance.now();cancelAnimationFrame(coinRAF);\r\n  (function frame(t){ctx.clearRect(0,0,W,H);\r\n    for(const c of coins){c.x+=c.vx;c.y+=c.vy;c.vy+=.05;c.a+=c.va;const sx=Math.abs(Math.cos(c.a));\r\n      ctx.save();ctx.translate(c.x,c.y);ctx.scale(Math.max(sx,.15),1);\r\n      ctx.beginPath();ctx.arc(0,0,c.r,0,Math.PI*2);ctx.fillStyle=\"#ffc83d\";ctx.fill();ctx.lineWidth=2.5;ctx.strokeStyle=\"#c98a12\";ctx.stroke();\r\n      ctx.beginPath();ctx.arc(0,0,c.r*.55,0,Math.PI*2);ctx.strokeStyle=\"#ffe27a\";ctx.lineWidth=2;ctx.stroke();ctx.restore()}\r\n    if(t-t0<4200)coinRAF=requestAnimationFrame(frame);else ctx.clearRect(0,0,W,H)})(t0);\r\n}\r\n\r\n\/* ---------- render ---------- *\/\r\nconst fmt=s=>typeof s===\"number\"?`${Math.floor(s\/60)}:${String(s%60).padStart(2,\"0\")}`:s;\r\nfunction renderTimer(){$(\"timer\").textContent=fmt(left);$(\"timerBox\").classList.toggle(\"low\",left<=30&&running);$(\"timerBox\").classList.toggle(\"running\",running)}\r\nfunction say(t,cls=\"\"){const m=$(\"msg\");m.textContent=t;m.className=\"msg \"+cls}\r\nfunction render(){\r\n  const b=$(\"board\");b.innerHTML=\"\";\r\n  b.className=\"board\"+(running?\"\":\" idle\")+(editMode?\" edit\":\"\");\r\n  const sol=new Set(showAnswer?solution:[]);\r\n  for(let r=0;r<ROWS;r++){\r\n    const s=document.createElement(\"div\");\r\n    if(r===startRow){s.className=\"cell end\"+(pos[0]===\"S\"&&running?\" here\":\"\");s.innerHTML=START_ART+\"<span>TRUY T\u00ccM KHO B\u00c1U<\/span>\"}\r\n    else s.className=\"cell empty\";\r\n    b.appendChild(s);\r\n    for(let c=0;c<COLS;c++){\r\n      const k=r+\",\"+c,d=document.createElement(\"button\");\r\n      d.className=\"cell\";d.dataset.r=r;d.dataset.c=c;d.textContent=grid[r][c];d.setAttribute(\"aria-label\",\"\u00d4 s\u1ed1 \"+grid[r][c]);\r\n      if(trail.includes(k))d.classList.add(isPrime(grid[r][c])?\"visited\":\"blocked\");\r\n      if(pos[0]===r&&pos[1]===c){d.classList.add(\"here\");d.insertAdjacentHTML(\"beforeend\",SHIP.replace(\"#d8432f\",COLORS[player]))}\r\n      else if(running&&adjacent(r,c)&&!trail.includes(k))d.classList.add(\"reach\");\r\n      if(sol.has(k))d.classList.add(\"answer\");\r\n      if(sel&&sel[0]===r&&sel[1]===c)d.classList.add(\"sel\");\r\n      d.onclick=()=>clickCell(r,c);b.appendChild(d);\r\n    }\r\n    const f=document.createElement(r===finishRow?\"button\":\"div\");\r\n    if(r===finishRow){f.className=\"cell end finish\";f.innerHTML=FINISH_ART+\"<span>KHO B\u00c1U<\/span>\";f.onclick=clickFinish;f.setAttribute(\"aria-label\",\"R\u01b0\u01a1ng kho b\u00e1u\")}\r\n    else f.className=\"cell empty\";\r\n    b.appendChild(f);\r\n  }\r\n  $(\"trail\").innerHTML=trail.length?\"H\u1ea3i tr\u00ecnh: \"+trail.map(k=>{const[r,c]=k.split(\",\");return `<b>${grid[r][c]}<\/b>`}).join(\" \u2192 \"):\"\";\r\n  setWho();renderTimer();renderScore();\r\n}\r\nfunction renderScore(){\r\n  const box=$(\"scoreBody\");if(box.contains(document.activeElement))return;\r\n  const times=teams.map(t=>typeof t.time===\"number\"?t.time:Infinity);const best=Math.min(...times);\r\n  box.innerHTML=\"\";\r\n  teams.forEach((t,i)=>{const row=document.createElement(\"div\");row.className=\"team-row\"+(i===player?\" cur\":\"\");\r\n    const isBest=best!==Infinity&&times[i]===best;\r\n    row.innerHTML=`<span class=\"mini-flag\">${flag(t.icon,COLORS[i])}<\/span>\r\n      <div class=\"tr-name\"><input id=\"tname${i}\" aria-label=\"T\u00ean \u0111\u1ed9i ${i+1}\" placeholder=\"\u0110\u1ed9i ${i+1}\">${isBest?'<span class=\"best\">Nhanh nh\u1ea5t<\/span>':\"\"}<\/div>\r\n      <div class=\"stat\"><small>B\u1ea3n \u0111\u1ed3<\/small><b>${t.map==null?\"\u2013\":\"#\"+t.map}<\/b><\/div>\r\n      <div class=\"stat\"><small>Th\u1eddi gian<\/small><b>${t.time==null?\"\u2013\":fmt(t.time)}<\/b><\/div>\r\n      <div class=\"stat\"><small>B\u1ea5m sai<\/small><b>${t.miss==null?\"\u2013\":t.miss}<\/b><\/div>`;\r\n    const inp=row.querySelector(\"input\");inp.value=t.name;\r\n    inp.oninput=e=>{t.name=e.target.value.trim()||(\"\u0110\u1ed9i \"+(i+1));setWho()};\r\n    inp.onblur=()=>renderScore();\r\n    box.appendChild(row)});\r\n}\r\nfunction updateStatus(){\r\n  const ok=solve();const s=$(\"pathStatus\");\r\n  s.textContent=ok?\"V\u1eabn c\u00f2n \u0111\u01b0\u1eddng \u0111\u1ebfn r\u01b0\u01a1ng kho b\u00e1u.\":\"\u0110\u01b0\u1eddng b\u1ecb ch\u1eb7n! Kh\u00f4ng c\u00f2n l\u1ed1i n\u00e0o to\u00e0n s\u1ed1 nguy\u00ean t\u1ed1.\";\r\n  s.className=\"status \"+(ok?\"good\":\"bad\");\r\n}\r\n\r\n\/* ---------- controls ---------- *\/\r\n$(\"startBtn\").onclick=start;\r\n$(\"newBtn\").onclick=()=>{showAnswer=false;$(\"answerBtn\").classList.remove(\"on\");$(\"answerBtn\").textContent=\"Hi\u1ec7n \u0111\u01b0\u1eddng \u0111i\";$(\"pathStatus\").textContent=\"\";\r\n  newMap();say(`B\u1ea3n \u0111\u1ed3 #${mapNo} \u0111\u00e3 s\u1eb5n s\u00e0ng cho ${teams[player].name}. B\u1ea5m \"Nh\u1ed5 neo!\".`)};\r\n$(\"nextBtn\").onclick=()=>{player=(player+1)%teams.length;resetRun();render();say(`L\u01b0\u1ee3t c\u1ee7a ${teams[player].name}. B\u1ea5m \"Nh\u1ed5 neo!\".`)};\r\nconst SPK_ON=`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 9h4l5-4v14l-5-4H4z\" fill=\"currentColor\"\/><path d=\"M16 8.5a5 5 0 0 1 0 7M18.5 6a8.5 8.5 0 0 1 0 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\"\/><\/svg>`;\r\nconst SPK_OFF=`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 9h4l5-4v14l-5-4H4z\" fill=\"currentColor\"\/><path d=\"M16 9l5 6M21 9l-5 6\" stroke=\"currentColor\" stroke-width=\"2.2\" stroke-linecap=\"round\"\/><\/svg>`;\r\nfunction soundIcon(){const b=$(\"soundBtn\");b.innerHTML=soundOn?SPK_ON:SPK_OFF;b.classList.toggle(\"off\",!soundOn);const l=soundOn?\"T\u1eaft \u00e2m thanh\":\"B\u1eadt \u00e2m thanh\";b.setAttribute(\"aria-label\",l);b.title=l}\r\n$(\"soundBtn\").onclick=()=>{soundOn=!soundOn;soundIcon();if(soundOn)SFX.step()};\r\n$(\"editBtn\").onclick=()=>{editMode=!editMode;sel=null;$(\"editBtn\").classList.toggle(\"on\",editMode);$(\"editRow\").hidden=!editMode;\r\n  $(\"editBtn\").textContent=editMode?\"Xong, t\u1eaft \u0111\u1ed5i s\u1ed1\":\"\u0110\u1ed5i s\u1ed1 trong \u00f4\";$(\"editLabel\").textContent=\"Ch\u1ecdn m\u1ed9t \u00f4 tr\u00ean b\u1ea3n \u0111\u1ed3\";\r\n  if(editMode){\r\n    if(running){clearInterval(tick);running=false;paused=true;$(\"startBtn\").textContent=\"T\u1ea1m d\u1eebng\"}\r\n    say(\"Ch\u1ebf \u0111\u1ed9 GV: b\u1ea5m v\u00e0o \u00f4 mu\u1ed1n \u0111\u1ed5i s\u1ed1.\"+(paused?\" \u0110\u1ed3ng h\u1ed3 \u0111ang t\u1ea1m d\u1eebng.\":\"\"));\r\n  }else if(paused){paused=false;running=true;$(\"startBtn\").textContent=\"\u0110ang ra kh\u01a1i\";startTicking();say(\"Ti\u1ebfp t\u1ee5c ra kh\u01a1i!\")}\r\n  render()};\r\n$(\"applyBtn\").onclick=()=>{\r\n  if(!sel){$(\"editLabel\").textContent=\"H\u00e3y ch\u1ecdn m\u1ed9t \u00f4 tr\u01b0\u1edbc\";return}\r\n  const v=parseInt($(\"editInput\").value,10);\r\n  if(isNaN(v)||v<0){$(\"editLabel\").textContent=\"Nh\u1eadp m\u1ed9t s\u1ed1 t\u1ef1 nhi\u00ean\";return}\r\n  const old=grid[sel[0]][sel[1]];grid[sel[0]][sel[1]]=v;$(\"editLabel\").textContent=`\u0110\u00e3 \u0111\u1ed5i ${old} th\u00e0nh ${v}.`;updateStatus();render();\r\n};\r\n$(\"editInput\").addEventListener(\"keydown\",e=>{if(e.key===\"Enter\")$(\"applyBtn\").click()});\r\n$(\"answerBtn\").onclick=()=>{showAnswer=!showAnswer;$(\"answerBtn\").classList.toggle(\"on\",showAnswer);\r\n  $(\"answerBtn\").textContent=showAnswer?\"\u1ea8n \u0111\u01b0\u1eddng \u0111i\":\"Hi\u1ec7n \u0111\u01b0\u1eddng \u0111i\";updateStatus();render()};\r\n$(\"clearBtn\").onclick=()=>{$(\"clearConfirm\").hidden=false};\r\n$(\"clearNo\").onclick=()=>{$(\"clearConfirm\").hidden=true};\r\n$(\"clearYes\").onclick=()=>{teams.forEach(t=>Object.assign(t,{time:null,miss:null,map:null}));player=0;$(\"clearConfirm\").hidden=true;resetRun();render();say(\"\u0110\u00e3 x\u00f3a k\u1ebft qu\u1ea3. B\u1eaft \u0111\u1ea7u l\u1ea1i t\u1eeb \u0111\u1ed9i 1.\")};\r\n$(\"teamsBtn\").onclick=()=>{resetRun();editMode=false;$(\"editRow\").hidden=true;$(\"editBtn\").classList.remove(\"on\");$(\"editBtn\").textContent=\"\u0110\u1ed5i s\u1ed1 trong \u00f4\";showWelcome()};\r\n$(\"goBtn\").onclick=()=>{ac();SFX.start();showGame()};\r\n$(\"dlgClose\").onclick=()=>{$(\"overlay\").hidden=true;cancelAnimationFrame(coinRAF);const cv=$(\"coins\");cv.getContext(\"2d\").clearRect(0,0,cv.width,cv.height)};\r\ndocument.addEventListener(\"keydown\",e=>{if(e.key===\"Escape\"&&!$(\"overlay\").hidden)$(\"dlgClose\").click()});\r\n\r\n\/* fullscreen *\/\r\nconst fsEl=()=>document.fullscreenElement||document.webkitFullscreenElement;\r\nfunction toggleFS(){\r\n  try{\r\n    if(fsEl()){(document.exitFullscreen||document.webkitExitFullscreen).call(document)}\r\n    else{const el=document.documentElement;const req=el.requestFullscreen||el.webkitRequestFullscreen;\r\n      const p=req&&req.call(el);if(p&&p.catch)p.catch(()=>say(\"Tr\u00ecnh duy\u1ec7t n\u00e0y kh\u00f4ng cho to\u00e0n m\u00e0n h\u00ecnh. H\u00e3y b\u1ea5m ph\u00edm F11.\",\"bad\"));\r\n      if(!req)say(\"Tr\u00ecnh duy\u1ec7t n\u00e0y kh\u00f4ng cho to\u00e0n m\u00e0n h\u00ecnh. H\u00e3y b\u1ea5m ph\u00edm F11.\",\"bad\")}\r\n  }catch(e){say(\"Tr\u00ecnh duy\u1ec7t n\u00e0y kh\u00f4ng cho to\u00e0n m\u00e0n h\u00ecnh. H\u00e3y b\u1ea5m ph\u00edm F11.\",\"bad\")}\r\n}\r\nconst FS_IN=`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>`;\r\nconst FS_OUT=`<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M9 4v5H4M20 9h-5V4M15 20v-5h5M4 15h5v5\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"\/><\/svg>`;\r\nfunction fsLabel(){const b=$(\"fsBtn\"),on=!!fsEl();b.innerHTML=on?FS_OUT:FS_IN;const l=on?\"Tho\u00e1t to\u00e0n m\u00e0n h\u00ecnh\":\"To\u00e0n m\u00e0n h\u00ecnh\";b.setAttribute(\"aria-label\",l);b.title=l}\r\n$(\"fsBtn\").onclick=toggleFS;fsLabel();soundIcon();\r\ndocument.addEventListener(\"fullscreenchange\",fsLabel);document.addEventListener(\"webkitfullscreenchange\",fsLabel);\r\n\r\n\/* pirate music (original tune, generated live) *\/\r\nlet musicOn=true,music=null;\r\nconst mf=m=>440*Math.pow(2,(m-69)\/12);\r\nconst MELODY=[[69,2],[74,1],[74,2],[76,1],[77,2],[76,1],[74,2],[69,1],[70,2],[69,1],[67,2],[65,1],[64,3],[69,3],\r\n  [69,2],[74,1],[74,2],[77,1],[76,2],[74,1],[73,2],[69,1],[70,2],[67,1],[64,2],[73,1],[74,6]];\r\nconst BASS=[50,50,46,45,50,45,43,50];\r\nconst CHORDS={50:[62,65,69],46:[58,62,65],45:[57,61,64],43:[55,58,62]};\r\nfunction mnote(a,dest,m,t,dur,type,vol){const o=a.createOscillator(),g=a.createGain();o.type=type;o.frequency.value=mf(m);\r\n  g.gain.setValueAtTime(0.0001,t);g.gain.exponentialRampToValueAtTime(vol,t+.015);g.gain.exponentialRampToValueAtTime(vol*.5,t+dur*.5);g.gain.exponentialRampToValueAtTime(0.0001,t+dur);\r\n  o.connect(g).connect(dest);o.start(t);o.stop(t+dur+.02)}\r\nfunction kick(a,dest,t,vol){const o=a.createOscillator(),g=a.createGain();o.frequency.setValueAtTime(130,t);o.frequency.exponentialRampToValueAtTime(40,t+.14);\r\n  g.gain.setValueAtTime(vol,t);g.gain.exponentialRampToValueAtTime(0.0001,t+.18);o.connect(g).connect(dest);o.start(t);o.stop(t+.2)}\r\nfunction scheduleLoop(a,dest,t0){\r\n  const E=0.2;let t=t0;\r\n  for(const[m,d]of MELODY){mnote(a,dest,m,t,d*E*.95,\"triangle\",.32);mnote(a,dest,m+12,t,d*E*.6,\"square\",.025);t+=d*E}\r\n  BASS.forEach((r,bar)=>{const b=t0+bar*6*E;\r\n    mnote(a,dest,r-12,b,3*E*.9,\"triangle\",.4);mnote(a,dest,r-5,b+3*E,3*E*.9,\"triangle\",.32);\r\n    kick(a,dest,b,.5);kick(a,dest,b+3*E,.3);\r\n    for(const off of[1,2,4,5])CHORDS[r].forEach(m=>mnote(a,dest,m,b+off*E,E*.7,\"square\",.018))});\r\n  return t0+48*E;\r\n}\r\nfunction startMusic(){\r\n  if(!musicOn||!soundOn||music)return;const a=ac();if(!a)return;\r\n  const master=a.createGain();master.gain.setValueAtTime(0.0001,a.currentTime);master.gain.exponentialRampToValueAtTime(.55,a.currentTime+1.2);master.connect(a.destination);\r\n  let next=a.currentTime+.15;\r\n  const timer=setInterval(()=>{while(next<a.currentTime+1)next=scheduleLoop(a,master,next)},250);\r\n  next=scheduleLoop(a,master,next);\r\n  music={a,master,timer};musicLabel();\r\n}\r\nfunction stopMusic(){\r\n  if(!music)return;const{a,master,timer}=music;clearInterval(timer);\r\n  master.gain.cancelScheduledValues(a.currentTime);master.gain.setValueAtTime(master.gain.value||.3,a.currentTime);master.gain.exponentialRampToValueAtTime(0.0001,a.currentTime+.7);\r\n  setTimeout(()=>master.disconnect(),900);music=null;musicLabel();\r\n}\r\nfunction musicLabel(){}\r\n$(\"welcome\").addEventListener(\"pointerdown\",e=>{if(e.target.closest(\".corner,#goBtn\"))return;startMusic()});\r\n{const go=$(\"goBtn\").onclick;$(\"goBtn\").onclick=()=>{stopMusic();go()}}\r\n{const sb=$(\"soundBtn\").onclick;$(\"soundBtn\").onclick=()=>{sb();if(!soundOn)stopMusic();else if(!$(\"welcome\").hidden)startMusic()}}\r\n{const sw=showWelcome;showWelcome=()=>{sw();if(actx&&actx.state===\"running\")startMusic()}}\r\n\r\nfunction gvToggle(open){\r\n  $(\"gvPanel\").hidden=!open;$(\"gvBtn\").classList.toggle(\"on\",open);$(\"gvBtn\").setAttribute(\"aria-expanded\",open);\r\n  if(!open&&editMode)$(\"editBtn\").click();\r\n}\r\n$(\"gvBtn\").onclick=()=>gvToggle($(\"gvPanel\").hidden);\r\n$(\"gvClose\").onclick=()=>gvToggle(false);\r\n\r\nnewMap();showWelcome();\r\n<\/script>\r\n\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":14,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-toan-6"],"_links":{"self":[{"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/posts\/11","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11"}],"version-history":[{"count":2,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions"}],"predecessor-version":[{"id":13,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/posts\/11\/revisions\/13"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=\/wp\/v2\/media\/14"}],"wp:attachment":[{"href":"https:\/\/hoclieuso.site\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hoclieuso.site\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}