*{box-sizing:border-box}
html{background:#07171d}
body{min-width:320px;margin:0;color:#f9f1d9;background:radial-gradient(ellipse at 50% 5%,#326269 0,#153a44 38%,#07171d 88%);font-family:"Segoe UI",Arial,sans-serif}
button,a{-webkit-tap-highlight-color:transparent}
button{font:inherit}
.five-elements{position:relative;max-width:480px;min-height:100dvh;margin:auto;padding:0 17px max(26px,env(safe-area-inset-bottom));overflow:hidden;background:linear-gradient(180deg,#0e303b88 0,#092029cc 42%,#07171de8 100%),url("assets/mach-son-cavern-2d.png") center top/auto 1050px no-repeat;box-shadow:0 0 48px #000c}
.five-elements:before{content:"";position:absolute;inset:0;pointer-events:none;background:radial-gradient(circle at 48% 32%,#78d4b125,transparent 32%);z-index:0}
.five-elements>*{position:relative;z-index:1}
.page-header{padding:calc(20px + env(safe-area-inset-top)) 0 14px;text-align:center}
.back-link{display:flex;align-items:center;gap:8px;width:max-content;min-height:35px;padding:0 11px;border:1px solid #e0bd7e95;border-radius:18px;background:#0a292edc;color:#fff0c8;font-size:23px;line-height:1;text-decoration:none}
.back-link span{font-size:10px;font-weight:800;letter-spacing:1px}
.chapter-mark{display:block;margin-top:15px;color:#b9ebd7;font-size:9px;font-weight:800;letter-spacing:2px}
h1{margin:3px 0;color:#ffe2a5;font:700 clamp(27px,8vw,37px) "Segoe UI",Arial,sans-serif;letter-spacing:2px;text-shadow:0 2px 5px #102722,0 0 18px #e8b9706b}
.page-header p{max-width:340px;margin:2px auto 0;color:#dcf0e5;font-size:12px;line-height:1.4}
.resource-card{display:grid;grid-template-columns:1.3fr 1fr 1fr;gap:2px;padding:5px;border:1px solid #e5c486;border-radius:6px;background:linear-gradient(120deg,#0a272eea,#245157dc 52%,#12333de8);box-shadow:inset 0 0 0 1px #87caba51,0 6px 16px #0006}
.resource-card>div{min-width:0;padding:6px 7px;border-right:1px solid #b9dab172}
.resource-card>div:last-child{border:0}
.resource-card small,.cost-row small{display:block;color:#a8d9c9;font-size:8px;font-weight:800;letter-spacing:1px}
.resource-card strong{display:block;margin-top:4px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:#fff6df;font-size:12px}
.resource-card>div:not(:first-child) strong{color:#f4d391}
.formation{margin-top:13px;padding:10px 8px 12px;border:1px solid #d5b578;border-radius:6px;background:linear-gradient(135deg,#092934f0,#123c42eb 54%,#0a2732f0);box-shadow:inset 0 0 0 1px #7bb9aa49,0 7px 18px #0006}
.section-title{display:flex;justify-content:space-between;align-items:center;gap:6px;padding:0 4px 5px;border-bottom:1px solid #c7a86b73;font-size:10px;color:#f5d28d;font-weight:900;letter-spacing:1.2px}
.section-title b{color:#c9f1d9;font-size:9px;letter-spacing:.4px}
.formation-map{position:relative;width:min(100%,360px);aspect-ratio:1.18;margin:0 auto}
.formation-lines{position:absolute;inset:0;width:100%;height:100%;overflow:visible;filter:drop-shadow(0 0 5px #95efc48a)}
.outer-ring,.inner-star{fill:none;stroke:url(#line-glow);stroke-width:.65}
.outer-ring{stroke-dasharray:1.5 1.3;opacity:.8}
.inner-star{stroke-width:.8;opacity:.78}
.center-disc{fill:#143c41;stroke:#cfb270;stroke-width:.8}
.center-line{fill:none;stroke:#80dbc3;stroke-width:.4;stroke-dasharray:1 1}
.formation-heart{position:absolute;top:49%;left:50%;display:grid;place-items:center;transform:translate(-50%,-50%);pointer-events:auto;border:0;padding:0;background:transparent;color:inherit;font:inherit;cursor:pointer;text-align:center;text-shadow:0 0 10px #e4d09c}
.formation-heart:hover,.formation-heart:focus-visible{filter:brightness(1.2);outline:2px solid #ffe3a5;outline-offset:5px;border-radius:50%}
.formation-heart span{font-size:30px;line-height:1;color:#ffe2a5;font-family:"Segoe UI",Arial,sans-serif}
.formation-heart small{margin-top:5px;color:#c6f6e0;font-size:8px;font-weight:900;letter-spacing:1px}
.element-node{--tone:#f3cd83;position:absolute;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;width:clamp(57px,17vw,70px);height:clamp(57px,17vw,70px);transform:translate(-50%,-50%);border:2px solid var(--tone);border-radius:50%;background:radial-gradient(circle at 48% 32%,#386668,#102b34 72%);box-shadow:inset 0 0 0 2px #0c252e,0 0 12px color-mix(in srgb,var(--tone) 54%,transparent);color:var(--tone);cursor:pointer}
.element-node.selected{background:radial-gradient(circle at 42% 29%,#496b62,#12393b 73%);box-shadow:inset 0 0 0 2px #f9e8b891,0 0 0 2px #fff3cd,0 0 23px var(--tone)}
.element-node .ideograph{font:700 23px "Segoe UI",Arial,sans-serif;line-height:23px}
.element-node .node-name{font-size:10px;font-weight:900;line-height:10px;color:#fff8e5}
.element-node .node-level{font-size:8px;line-height:9px;color:#cbeadc}
.element-node[data-element="kim"]{left:50%;top:13%}
.element-node[data-element="thuy"]{left:84%;top:38%}
.element-node[data-element="moc"]{left:71%;top:79%}
.element-node[data-element="hoa"]{left:29%;top:79%}
.element-node[data-element="tho"]{left:16%;top:38%}
.next-drop{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:0 3px;padding:9px 11px;border:1px solid #75ad9d;background:#164447;color:#e4f3e6}
.next-drop span{font-size:9px;font-weight:900;letter-spacing:.7px}
.next-drop strong{font-size:12px;color:#ffe2a5}
.meditation-next{margin-top:-1px;border-color:#76bca8;background:#103b40}
.meditation-next strong{color:#b8f4d4}
.element-detail{--tone:#f3cd83;margin-top:13px;padding:14px;border:2px solid var(--tone);border-radius:6px;background:linear-gradient(135deg,#113e42f4,#0b2b34f8 65%,#0b252df8);box-shadow:inset 0 0 0 1px #fff7d84d,0 7px 18px #0008}
.detail-heading{display:flex;align-items:center;gap:12px}
.detail-symbol{display:grid;place-items:center;flex:none;width:57px;height:57px;border:1px solid var(--tone);border-radius:6px;background:radial-gradient(circle,#2c585a,#102c36);color:var(--tone);font:700 33px "Segoe UI",Arial,sans-serif;text-shadow:0 0 8px var(--tone)}
.detail-heading>div{min-width:0;flex:1}
.detail-heading small{color:var(--tone);font-size:9px;font-weight:900;letter-spacing:1px}
.detail-heading h2{margin:1px 0;color:#fff1d2;font:700 22px "Segoe UI",Arial,sans-serif}
.detail-heading p{margin:0;color:#cee8dc;font-size:11px;line-height:1.25}
.detail-heading>b{align-self:flex-start;white-space:nowrap;color:#ffe4aa;font-size:10px}
.effect-panel{margin-top:13px;padding:10px 11px;border-left:3px solid var(--tone);background:#0b2730c9}
.effect-panel small{display:block;color:#a9decb;font-size:9px;font-weight:900;letter-spacing:1px}
.effect-panel strong{display:block;margin-top:4px;color:#fff4d3;font-size:14px}
.effect-panel span{display:block;margin-top:5px;color:var(--tone);font-size:11px}
.element-milestone{margin:9px 0 0;padding:7px 9px;border:1px solid #a2caa086;background:#204f45a8;color:#ffe5a9;font-size:11px;font-weight:800}
.cost-row{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:11px}
.cost-row>div{padding:8px 9px;border:1px solid #8ebeb280;background:#16474a9e}
.cost-row strong{display:block;margin-top:3px;color:#fff2ce;font-size:13px}
.cost-row strong.short{color:#ffad8f}
.upgrade-button{display:block;width:100%;min-height:42px;margin-top:12px;border:1px solid #fff0bd;border-radius:4px;background:linear-gradient(135deg,#dbb66e,#a97437);box-shadow:inset 0 0 0 2px #fff6d659,0 4px 9px #0005;color:#10292d;font-size:13px;font-weight:900;letter-spacing:.7px;cursor:pointer}
.upgrade-button:disabled{opacity:.62;cursor:default;filter:saturate(.6)}
.upgrade-message{min-height:15px;margin:7px 0 0;color:#a7f2d5;font-size:10px;text-align:center}
.rules-card{margin-top:13px;padding:12px 14px;border:1px solid #86baaa;border-radius:5px;background:#0a2b32de}
.rules-card h2{margin:0 0 6px;color:#ffdda0;font:700 17px "Segoe UI",Arial,sans-serif}
.rules-card p{margin:0;color:#e5f4e7;font-size:11px;line-height:1.45}
.rules-card p+p{margin-top:8px}
.rules-card .cycle{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:5px;margin:10px 0;padding:7px 3px;background:#1a4648;color:#ffdfab;font-size:12px;font-weight:900}
.cycle span{color:#91dcc5}
.rules-card .qi-rule{color:#bfead6}
.element-overview{margin-top:13px;border-color:#d5b578;background:linear-gradient(135deg,#102f35f2,#173f43ed)}
.element-overview-grid{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.element-overview-grid>div{min-height:67px;padding:8px;border:1px solid #72ad9c80;background:#0b2931b8}
.element-overview-grid small{display:block!important;color:#9ed8c6;font-size:8px;font-weight:900;letter-spacing:.8px;line-height:1.2}
.element-overview-grid strong{display:block!important;margin-top:5px;color:#ffe5ab;font-size:12px;line-height:1.35}
.element-overview-grid span{display:block!important;margin-top:4px;color:#d2eee1;font-size:10px;line-height:1.35}
.role-button{width:100%;margin-top:6px;padding:6px 5px;border:1px solid #7fbca9;border-radius:3px;background:#1b5555;color:#ffe5ae;font-size:9px;font-weight:900;cursor:pointer}
.role-button:disabled{opacity:.45;cursor:default}
.element-build-guide{display:grid;gap:5px;margin-top:9px;color:#d8eee3;font-size:10px;line-height:1.35}
.element-build-guide span{display:block!important;padding:7px 8px;border-left:2px solid #c9a96e;background:#133b40;line-height:1.45}
.element-build-guide b{color:#ffe3a5}
.resonance-catalog{margin-top:10px;border-top:1px solid #86bbaa70;padding-top:8px;color:#ffe4a8;font-size:11px}
.resonance-catalog summary{cursor:pointer;font-weight:900}
#resonance-catalog-list{display:grid;gap:5px;margin-top:8px}
#resonance-catalog-list>div{display:flex;flex-direction:column;gap:3px;padding:7px;background:#123b40;color:#d8eee3;font-size:10px;line-height:1.4}
#resonance-catalog-list b{color:#ffe3a5;white-space:nowrap}
#resonance-catalog-list span{text-align:left;display:block}
.element-detail select{width:100%;margin-top:6px;padding:7px;border:1px solid #8ac3ad;background:#123b40;color:#fff0c8;font:inherit;font-weight:800}
.footer-back{display:block;margin:15px 0 0;padding:11px;border:1px solid #d5b578;border-radius:4px;background:#1a4848;color:#ffe7b4;font-size:12px;font-weight:900;text-align:center;text-decoration:none}
button:focus-visible,a:focus-visible{outline:3px solid #fff3c3;outline-offset:3px}
@media(max-width:370px){.five-elements{padding-left:10px;padding-right:10px}.element-node{width:58px;height:58px}.element-node .ideograph{font-size:20px}.resource-card strong{font-size:11px}.detail-heading{gap:8px}.detail-symbol{width:50px;height:50px;font-size:29px}}
@media(prefers-reduced-motion:no-preference){.formation-lines{animation:formation-glow 5s ease-in-out infinite}.element-node.selected{animation:selected-pulse 2.5s ease-in-out infinite}@keyframes formation-glow{50%{opacity:.65;filter:drop-shadow(0 0 10px #baf5d1)}}@keyframes selected-pulse{50%{box-shadow:inset 0 0 0 2px #f9e8b891,0 0 0 2px #fff3cd,0 0 29px var(--tone)}}}

/* Bố cục một màn hình điện thoại, các phần phụ mở bằng nút nhỏ. */
html,body{width:100%;height:100%;overflow:hidden}
body{display:grid;place-items:center}
.five-elements{width:min(100vw,56.5dvh,480px);height:100dvh;min-height:0;max-height:100dvh;overflow:hidden;padding:0 17px 8px}
.page-header{padding-top:8px}
.resource-card{margin-top:6px}
.formation{margin-top:7px}
.element-tools{display:grid;grid-template-columns:repeat(4,1fr);gap:6px;margin:8px 0}
.element-tools button{min-height:38px;border:1px solid #9bc9aa;border-radius:8px;background:#123d42;color:#ffe3a5;font-weight:900}
.element-tools button small{display:block;font-size:8px;color:#d8eee3}
.element-overview,.element-detail,#element-rules,.global-bottom-nav{display:none}
.element-overview.panel-open,.element-detail.panel-open,#element-rules.panel-open,.global-bottom-nav.panel-open{display:block;position:absolute;left:10px;right:10px;top:72px;bottom:8px;z-index:20;overflow:auto;margin:0;background:#09272df5;padding:12px;border:1px solid #d3b578;border-radius:10px;box-shadow:0 10px 35px #000c}
.global-bottom-nav.panel-open{display:grid;top:auto;bottom:8px;min-height:66px}
@media(max-width:430px){.five-elements{width:100vw;padding-left:10px;padding-right:10px}.page-header h1{font-size:31px}.page-header p{font-size:10px}.formation-map{height:270px}.next-drop{padding:7px 9px;font-size:9px}.element-tools{margin:6px 0}.element-tools button{min-height:34px}}


.page-guide{display:none!important}

/* Điều kiện mở rộng cần đọc rõ cả trên nền sáng và màn hình nhỏ. */
#element-detail.panel-open{background:#fff5dd!important;color:#29483e}
#element-detail .detail-heading{clear:both;align-items:flex-start;flex-wrap:wrap}
#element-detail .detail-heading h2{color:#29483e;font-size:24px}
#element-detail .detail-heading small,#element-detail .detail-heading p,#element-detail .detail-heading>b{color:#66502c}
#element-detail .detail-heading p{font-size:13px;line-height:1.5}
#element-detail .effect-panel{background:#254b47;border-color:#c4a05e}
#element-detail .effect-panel span,#element-detail .path-activation{color:#fff0cc;line-height:1.55;font-size:13px}
#element-detail .path-label{color:#cae7d5;font-size:12px;font-weight:800}
#element-detail .path-activation{margin:8px 0 0;color:#cce4d8;font-size:12px}
#element-detail .element-milestone{background:#e8eddc;color:#35583d;border-color:#b9c6a4;line-height:1.5;font-size:12px;font-weight:500}
#element-detail .cost-row>div{background:#e5eddd;border-color:#a7b496}
#element-detail .cost-row small,#element-detail .cost-row strong{color:#29483e}
#element-detail .cost-row small{font-size:10px}
#element-detail .cost-row strong{font-size:16px}
#element-detail .cost-row strong.short{color:#9c352b}
#element-detail .upgrade-message{color:#744320;font-size:13px;line-height:1.5;min-height:20px}
#element-detail .upgrade-button{min-height:46px;letter-spacing:0}
#element-detail [hidden]{display:none!important}
.detail-role-note{font-size:13px;line-height:1.5;margin:12px 0;color:#37564b}
.detail-effect-note,.detail-explanations{font-size:12px;line-height:1.5;color:#37564b}
.detail-effect-note{margin:9px 0}
.detail-explanations summary{font-weight:700;cursor:pointer;min-height:28px;padding:3px 0}
.detail-explanations p{margin:8px 0}
.element-effect-table{width:100%;border-collapse:collapse;table-layout:fixed;font-size:14px;color:#29483e}
.element-effect-table caption{text-align:left;font-size:12px;font-weight:800;letter-spacing:.3px;padding:0 0 8px}
.element-effect-table th,.element-effect-table td{padding:10px 8px;border:1px solid #c2c8ab;vertical-align:top;overflow-wrap:anywhere}
.element-effect-table thead{background:#254b47;color:#fff3d7;font-size:12px}
.element-effect-table th:first-child{width:54%;text-align:left}
.element-effect-table tbody th{background:#f7f4e5;font-weight:400}
.element-effect-table tbody strong{display:block;font-size:14px}
.element-effect-table tbody small{display:block;margin-top:5px;font-size:12px;line-height:1.45;color:#536356}
.element-effect-table td{text-align:center;vertical-align:middle;background:#eef1e3;font-size:17px;font-weight:800;white-space:normal;line-height:1.4;overflow-wrap:normal}
.element-effect-table td:last-child{color:#226342;background:#e1eddb}
@media(max-width:430px){#element-detail .detail-heading{gap:8px}#element-detail .detail-heading>b{flex-basis:100%}.element-effect-table th,.element-effect-table td{padding:8px 6px}.element-effect-table td{font-size:15px}.element-effect-table tbody strong{font-size:13px}}
#formation-detail.panel-open{background:#fff5dd!important;color:#29483e}
#formation-detail .detail-heading{clear:both;align-items:flex-start}
#formation-detail .detail-heading h2{color:#29483e;font-size:22px}
#formation-detail .detail-heading small,#formation-detail .detail-heading p,#formation-detail .detail-heading>b{color:#66502c}
#formation-detail .detail-heading p{font-size:13px;line-height:1.5}
#formation-detail .effect-panel{background:#254b47;border-color:#c4a05e}
#formation-detail .effect-panel span{color:#f8dfa4;line-height:1.5}
#formation-detail .cost-row>div{background:#e5eddd;border-color:#a7b496}
#formation-detail .cost-row small,#formation-detail .cost-row strong{color:#29483e}
#formation-detail .cost-row strong.short{color:#9c352b}
#formation-detail .formation-realm{font-weight:700;font-size:13px;margin:14px 0 8px;line-height:1.5}
#formation-detail .formation-retained{padding:9px;background:#e5eddd;line-height:1.5;font-size:12px}
#formation-requirements{display:grid;gap:6px}
#formation-requirements p{margin:0;padding:9px 10px;border:1px solid #b8c5aa;border-radius:6px;background:#edf2e5;font-size:13px;line-height:1.4}
#formation-requirements .requirement-missing{border-color:#c99777;background:#fff0df;color:#913f26}
#formation-requirements .requirement-ready{color:#245f43}
#formation-detail .upgrade-message{color:#744320;font-size:13px;line-height:1.5;min-height:20px}
#formation-detail .upgrade-button{min-height:46px;letter-spacing:0}
#formation-detail .formation-sources{margin-top:16px;border-top:1px solid #c9b88d;padding-top:12px;font-size:13px;line-height:1.5}
#formation-detail .formation-sources summary{font-weight:800;cursor:pointer;min-height:28px}
#formation-material-sources{display:grid;gap:9px}
#formation-material-sources>div{padding:10px;border:1px solid #b7b99b;border-radius:6px;background:#f6f4e5}
#formation-material-sources p{margin:4px 0}
#formation-material-sources a{display:inline-block;padding:7px 0;color:#246348;font-weight:700}
@media(max-width:430px){#formation-detail .detail-heading{flex-wrap:wrap;gap:8px}#formation-detail .detail-heading h2{font-size:19px}#formation-detail .detail-heading>b{flex-basis:100%}}

/* Fill the available phone height; reserve the persistent navigation and safe area. */
.five-elements{width:min(100%,480px);display:flex;flex-direction:column}
main.five-elements:has(.global-bottom-nav){padding-bottom:calc(70px + env(safe-area-inset-bottom,0px));overflow-y:auto}
.page-header,.resource-card,.element-tools{flex-shrink:0}
.formation{flex:1;min-height:330px;display:flex;flex-direction:column;margin-top:0}
.section-title,.next-drop{flex-shrink:0}
.formation-space{flex:1;min-height:220px;display:grid;place-items:center;container-type:size}
.formation-map{width:min(100cqw,100cqh);height:auto;aspect-ratio:1;margin:0}
.five-elements .global-bottom-nav{width:min(100%,480px);height:calc(62px + env(safe-area-inset-bottom,0px))}
.five-elements .global-bottom-nav.panel-open{position:fixed;left:50%;right:auto;top:auto;bottom:0;margin:0;min-height:0;padding:5px 10px max(5px,env(safe-area-inset-bottom));border-radius:0}
@media(max-height:740px){
  .page-header{padding-bottom:6px}
  .chapter-mark{margin-top:6px}
  .page-header h1{font-size:27px}
  .page-header p{font-size:10px}
  .formation{min-height:310px}
  .formation-space{min-height:200px}
}
@media(max-height:600px){
  .chapter-mark,.page-header p{display:none}
  .page-header h1{font-size:24px}
  .formation{min-height:270px}
  .formation-space{min-height:170px}
  .element-node{width:50px;height:50px}
  .element-node .ideograph{font-size:18px;line-height:19px}
  .element-node .game-symbol-image{width:22px;height:22px}
}


#formation-chest:not([hidden]){margin:12px 0;padding:10px 14px;border:1px solid #b8a278;border-radius:6px;background:#f4e9cf;color:#324839}
#formation-chest p{margin:0 0 4px}
#formation-chest-return{display:inline-flex;align-items:center;min-height:40px;color:#174e42;font-weight:700}
.formation-material-art{width:44px;height:44px;object-fit:contain;vertical-align:middle;margin-right:8px}
#formation-material-sources ul{padding-left:20px;font-size:12px;line-height:1.7;overflow-wrap:anywhere}
