/* An NhiÃªn V38 â€“ accessibility and mobile performance refinements on V37 layout. */
.v37-mobile{display:none}
.v37-icon{width:24px;height:24px;display:inline-block;vertical-align:middle;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
@media(max-width:900px){
  :root{--v37-bg:rgba(45,26,15,.91);--v37-gold:#efc879;--v37-border:rgba(245,203,124,.31);--v37-text:#fff3df;--v37-cream:#f9f2e5}
  .v37-mobile{display:block}
  body{overflow:hidden}
  button{-webkit-tap-highlight-color:transparent}
  #v37TopTicker{position:fixed;z-index:15;top:0;left:0;right:0;height:calc(30px + env(safe-area-inset-top,0px));padding:env(safe-area-inset-top,0px) 12px 0;display:flex;gap:9px;align-items:center;overflow:hidden;white-space:nowrap;color:#ffe2a5;background:linear-gradient(90deg,#612b1d,#753b21 55%,#451d14);border-bottom:1px solid #e8b87751;font-size:12px;line-height:30px;pointer-events:none}
  .v37-ticker-icon{color:#ffe4a7;font-size:15px;flex:none}
  #v37TickerText{overflow:hidden;text-overflow:ellipsis;display:block}
  #v37PlayerCard{position:fixed;z-index:14;top:calc(37px + env(safe-area-inset-top,0px));left:10px;width:min(226px,60vw);height:66px;display:flex;gap:8px;align-items:center;padding:8px 9px!important;border:1px solid var(--v37-border);border-radius:18px;background:linear-gradient(145deg,rgba(64,37,22,.96),rgba(41,24,16,.94));box-shadow:0 8px 20px #120b0759;color:var(--v37-text);text-align:left;backdrop-filter:blur(7px)}
  .v37-player-flower{display:grid;place-items:center;width:42px;height:42px;flex:none;border-radius:50%;background:#b35c80;color:#fbe9e5;font-size:24px;line-height:1}
  .v37-player-text{flex:1;min-width:0;display:block}
  .v37-player-text strong{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;line-height:1.3}
  .v37-player-text small{display:block;color:#efdbb1;font-size:9px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin:4px 0 5px}
  .v37-player-track{display:block;height:4px;background:#a38c668c;overflow:hidden;border-radius:4px}.v37-player-track i{display:block;height:100%;width:5%;background:linear-gradient(90deg,#e0a544,#ffe3a0);border-radius:4px}
  #v37PlayerLevel{width:25px;height:25px;line-height:25px;text-align:center;border-radius:50%;flex:none;background:#e4b961;color:#50320e;font-size:12px;font-weight:800}
  header{position:fixed!important;z-index:13;left:auto!important;right:10px!important;top:calc(37px + env(safe-area-inset-top,0px))!important;display:flex;align-items:flex-start;width:auto;pointer-events:none}
  header .brand,header .merit-wallet,header #sound,header [data-page="settings"]{display:none!important}
  header .top{display:block;width:auto;pointer-events:auto}
  header .currencies{display:flex;flex-direction:column;gap:6px;border:1px solid var(--v37-border);border-radius:16px;padding:11px 10px;color:var(--v37-text);background:var(--v37-bg);font-size:10px;min-width:90px;box-shadow:0 8px 18px #1009005e}
  header .currencies span{display:flex;align-items:center;justify-content:space-between;gap:8px;white-space:nowrap}
  header .currencies b{font-size:12px;color:#ffe0a3}
  .location{position:fixed!important;z-index:12;left:12px!important;top:calc(116px + env(safe-area-inset-top,0px))!important;width:calc(100vw - 90px);max-width:320px;background:none!important;padding:0!important;pointer-events:none}
  .location>*{pointer-events:auto}
  .location .eyebrow,.location .local-note{display:none!important}
  .location h1{font-family:Georgia,serif;font-weight:700;font-size:22px!important;line-height:1.13;margin:0 0 3px!important;max-width:80%;text-shadow:0 2px 10px #180600b8;color:#fff5e8}
  .location #areaName{margin:0 0 8px!important;font-size:11px!important;color:#e5d2ad;max-width:85%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}
  .location #exit,.location #view{display:inline-flex;align-items:center;justify-content:center;min-height:38px;margin:0 5px 0 0!important;padding:9px 12px!important;border:1px solid var(--v37-border);border-radius:14px;background:var(--v37-bg);box-shadow:0 7px 16px #11080066;color:var(--v37-text);font-size:11px!important;white-space:nowrap}
  .location #view{width:39px;padding:0!important}
  .quote,.hint,.bottom .profile{display:none!important}
  .utility{position:fixed!important;z-index:14;right:10px!important;left:auto!important;top:calc(169px + env(safe-area-inset-top,0px))!important;bottom:auto!important;display:flex!important;flex-direction:column;align-items:center;gap:7px!important;width:50px!important;padding:0!important;margin:0!important;background:none!important;border:0!important;grid-template-columns:none!important;max-height:calc(100dvh - 375px - env(safe-area-inset-bottom,0px));overflow:visible}
  .utility>button{display:none!important}
  .utility>button.v37-quick,#v37MoreButton{display:grid!important;place-items:center;flex:none;width:49px;height:49px;padding:0!important;border-radius:15px!important;color:#f4dba4;background:var(--v37-bg);border:1px solid var(--v37-border)!important;box-shadow:0 7px 16px #160d0559;line-height:1}
  .utility>button.v37-quick .v37-icon,#v37MoreButton .v37-icon{width:23px;height:23px;display:block;stroke:currentColor;fill:none;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
  .utility .v37-quick>span.v37-visually-hidden{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  .utility button.v37-quick i{position:absolute;top:-5px;right:-5px;display:grid;place-items:center;min-width:17px;height:17px;border-radius:20px;background:#a7372c;font-size:10px;color:white;padding:1px 3px}
  #v37MorePanel{position:fixed;z-index:20;top:calc(168px + env(safe-area-inset-top,0px));right:68px;width:min(230px,calc(100vw - 86px));max-height:calc(100dvh - 270px);overflow:auto;background:#f6efe2;color:#42301c;border:1px solid #c9a563;border-radius:19px;padding:12px;box-shadow:0 14px 45px #120b0aae;overscroll-behavior:contain}
  #v37MorePanel[hidden]{display:none!important}
  .v37-more-head{display:flex;align-items:center;justify-content:space-between;padding:2px 4px 10px;font-size:16px}
  .v37-more-head button{border:0;background:transparent;color:#422915;font-size:27px;padding:0 7px}
  #v37MoreLinks{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  #v37MoreLinks button{display:flex;gap:7px;align-items:center;justify-content:flex-start;min-height:49px;padding:8px!important;border-radius:12px;background:#fffaf0;color:#4c3420;border:1px solid #e0ceb3;text-align:left;font-size:11px;line-height:1.3;backdrop-filter:none}
  #v37MoreLinks .v37-icon{display:block;flex:none;width:19px;height:19px;stroke:#a07a3b;fill:none;stroke-width:1.8;stroke-linejoin:round;stroke-linecap:round}
  .bottom{position:fixed!important;z-index:13;bottom:calc(10px + env(safe-area-inset-bottom,0px))!important;left:auto!important;right:10px!important;width:auto!important;display:block!important;padding:0!important;background:transparent!important}
  .bottom nav{display:grid!important;grid-template-columns:repeat(3,minmax(0,69px))!important;gap:7px!important;width:auto!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;box-shadow:none!important;background:none!important;backdrop-filter:none!important}
  .bottom nav button{width:69px;height:66px;min-width:0!important;padding:6px 2px!important;border:1px solid var(--v37-border)!important;border-radius:17px!important;background:var(--v37-bg)!important;color:var(--v37-text)!important;box-shadow:0 6px 15px #150c0759;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:3px;font-size:10px!important;line-height:1.15!important;white-space:nowrap}
  .bottom nav button.active{background:#bd9450!important;color:#231307!important}
  .bottom nav button .v37-icon{width:24px;height:24px;stroke:currentColor;fill:none;stroke-width:1.65;stroke-linejoin:round;stroke-linecap:round;display:block}
  .bottom nav #bell{display:none!important}
  .bottom nav #openChantV37{display:flex!important}
  .mobilepad{position:fixed!important;z-index:13;left:12px!important;bottom:calc(13px + env(safe-area-inset-bottom,0px))!important;width:118px!important;height:118px!important;border:1px solid #ffffff36;border-radius:50%;display:block!important;background:radial-gradient(circle,#ffffff26,#ffffff12 70%);box-shadow:inset 0 0 18px #fff2,0 7px 20px #0003;touch-action:none;overflow:visible}
  .mobilepad>div{position:static!important;display:contents!important}
  .mobilepad button{position:absolute!important;width:44px;height:44px;min-width:44px!important;padding:0!important;display:grid!important;place-items:center;border-radius:50%!important;border:1px solid #ffffff44!important;background:rgba(246,246,243,.31)!important;color:#ffffff;font-size:20px!important;line-height:1;backdrop-filter:blur(6px);touch-action:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;box-shadow:0 3px 11px #0004}
  .mobilepad>button[data-key="ArrowUp"]{top:0;left:37px}
  .mobilepad button[data-key="ArrowLeft"]{top:37px;left:0}
  .mobilepad button[data-key="ArrowRight"]{top:37px;left:74px}
  .mobilepad button[data-key="ArrowDown"]{top:74px;left:37px}
  .mobilepad button:active{background:#e1ba70!important;color:#3b291b}
  #seatButton{position:fixed!important;z-index:13;bottom:calc(151px + env(safe-area-inset-bottom,0px))!important;left:50%;right:auto!important;transform:translateX(-50%);max-width:230px;min-height:35px;padding:7px 11px!important;border:1px solid var(--v37-border);border-radius:15px;background:var(--v37-bg);font-size:11px!important;white-space:nowrap}
  #ritualStatus{position:fixed!important;z-index:12;bottom:calc(156px + env(safe-area-inset-bottom,0px))!important;left:50%!important;right:auto!important;transform:translateX(-50%)!important;padding:9px 11px!important;border-radius:13px;max-width:min(240px,66vw);min-width:0!important;background:var(--v37-bg)}
  #ritualStatus b{font-size:11px}#ritualStatus small{font-size:9px}
  #buff{position:fixed;top:calc(95px + env(safe-area-inset-top,0px));right:11px;z-index:12;font-size:9px}
  #toast{z-index:25;bottom:calc(175px + env(safe-area-inset-bottom,0px));font-size:11px;max-width:80vw;white-space:normal}
  body.entering #v37TopTicker,body.entering #v37PlayerCard,body.entering #v37MorePanel,body.entering .utility,body.entering .mobilepad{display:none!important}
  /* Meditation â€“ light, spacious modal with the original game action intact. */
  dialog#sheet{max-width:min(92vw,420px);width:92vw;border:none;border-radius:24px;background:var(--v37-cream);color:#432d1c;padding:0;box-shadow:0 20px 75px #0009}
  dialog#sheet::backdrop{background:#0d0708a8;backdrop-filter:blur(3px)}
  #sheet .sheet-head{background:var(--v37-cream);padding:22px 23px 10px;border:0;color:#38291a}
  #sheet .sheet-head .eyebrow{color:#9e825a;letter-spacing:1px}
  #sheet .sheet-head h2{font:700 30px Georgia,serif;margin:6px 0 2px;color:#35291b}
  #sheet .sheet-head button{color:#4b3b28;background:#eee3cf;border:none;padding:6px 12px}
  #sheetBody{padding:8px 23px 23px;color:#533d29}
  #sheetBody p{color:#725b44}
  #sheet.v37-meditation .sheet-head h2{font-family:Georgia,serif}
  .v37-meditation-choice{display:flex;flex-wrap:wrap;gap:9px;margin:18px 0 23px}
  #sheetBody .v37-meditation-choice button{border:1px solid #eee2cc;border-radius:25px;background:#ece4d4;color:#4f3c2b;font-size:14px;padding:12px 19px;backdrop-filter:none}
  #sheetBody .v37-meditation-choice button[aria-pressed="true"]{background:#3f2a1d;color:#fff0cf;border-color:#3f2a1d}
  #sheetBody .v37-meditation-actions{display:grid;grid-template-columns:1fr 1fr;gap:12px}
  #sheetBody .v37-meditation-actions button{padding:14px 8px;border-radius:24px;border:0;background:#ebe4d6;color:#493323;font-weight:700;font-size:14px;backdrop-filter:none}
  #sheetBody .v37-meditation-actions .v37-meditation-start{background:linear-gradient(#f8d988,#d5a540);color:#4a2f14}
  #sheetBody .v37-meditation-help{font-size:12px;color:#806b54;line-height:1.55;margin:2px 0}
  #sheetBody .v37-meditation-foot{font-size:10px;margin:18px 0 0;color:#957d5c}
  /* Beads â€“ retain original drag/rotate behavior and game background */
  #beadView{z-index:17;background:linear-gradient(180deg,rgba(20,13,9,.50),rgba(16,10,8,.79));backdrop-filter:blur(1.5px);color:#fff2d9;padding:85px 12px calc(24px + env(safe-area-inset-bottom,0px));gap:8px;justify-content:center}
  body:has(#beadView:not([hidden])) #world{visibility:visible!important}
  #closeBeads{top:calc(25px + env(safe-area-inset-top,0px));left:16px;border:1px solid #fff7;background:#fff9;color:#3e2d25;padding:10px 15px;border-radius:22px}
  .bead-title .eyebrow{font-size:9px;letter-spacing:2px}
  .bead-title h2{font:700 27px Georgia,serif;margin:10px 0}
  .bead-title p{max-width:260px;line-height:1.5;margin:6px auto!important;color:#faefd4!important}
  #beadTap{width:min(62vw,250px);height:min(62vw,250px);margin:10px auto;flex:none}
  .bead-ring i{transform:rotate(var(--a)) translateY(calc(-1 * min(26vw,103px)));background:radial-gradient(circle at 30% 20%,#e8bd81,#9a5c23 70%,#6c401b);box-shadow:0 3px 5px #0007}
  .bead-number b{font-size:54px;color:#fff2c9}.bead-number small{color:#f5dfb3}
  #beadView>p{max-width:270px;font-size:11px;color:#f0dfbd!important;margin:0 auto!important}
  #holdBeads{padding:12px 20px;background:#ddba75;color:#422917;border-radius:18px;font-size:12px;min-height:43px}
  #beadView>small{font-size:10px;max-width:270px;line-height:1.45;color:#dfd0ac}
  /* Chant/recitation dialog is independent of the bell action. */
  #v37ChantDialog{width:100vw;max-width:100vw;height:100dvh;max-height:100dvh;min-height:100dvh;margin:0;border:0;border-radius:0;inset:0;background:linear-gradient(180deg,rgba(30,16,14,.52),rgba(26,15,13,.83));color:#fff3d8;padding:calc(env(safe-area-inset-top,0px) + 14px) 19px calc(env(safe-area-inset-bottom,0px) + 14px);overflow:auto;box-shadow:none}
  #v37ChantDialog::backdrop{background:#090505bb}
  .v37-chant-head{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:10px;color:#e1bb85;letter-spacing:1px}
  .v37-chant-head button{background:#fff3;color:#fff7e4;border:1px solid #fff6;border-radius:20px;padding:10px 15px;font-size:13px}
  .v37-chant-tabs{display:flex;gap:8px;margin:35px -7px 8px;overflow-x:auto;padding:0 7px 8px;scrollbar-width:none}
  .v37-chant-tabs button{flex:none;min-width:100px;border-radius:24px;background:#ffffff0f;border:1px solid #f6ddb75a;font-size:13px;color:#fae2b8;padding:11px 14px}
  .v37-chant-tabs button[aria-selected="true"]{color:#442a18;border-color:#e0b46c;background:linear-gradient(#f9df9e,#dca642);font-weight:700}
  .v37-chant-hero{min-height:30dvh;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:12px;padding:20px 5px}
  .v37-chant-hero p{font-size:12px;color:#e4cfad}
  .v37-chant-hero h2{font:700 clamp(22px,6vw,35px) Georgia,serif;line-height:1.35;color:#ffdf8a;max-width:300px}
  .v37-chant-lower{display:grid;grid-template-columns:1fr 108px 1fr;align-items:center;gap:5px;max-width:500px;margin:0 auto}
  .v37-chant-counter{display:flex;align-items:baseline;flex-wrap:wrap;gap:5px;color:#f9e7ba}
  .v37-chant-counter b{font-size:41px}.v37-chant-counter span{font-size:15px}
  .v37-chant-counter small{display:block;flex-basis:100%;font-size:10px;line-height:1.5;color:#e1ccab}
  #v37ChantWoodfish{width:105px;height:105px;border-radius:50%;background:radial-gradient(circle at 34% 18%,#d8a55f,#9c5c26 70%,#643415);border:3px solid #c78d4f;box-shadow:inset 0 -10px 14px #3d2415a1,0 7px 17px #0007;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px}
  #v37ChantWoodfish span{color:#3c2112;font-size:48px;line-height:1}#v37ChantWoodfish small{color:#42260f;font-size:11px;font-weight:700}
  #v37ChantWoodfish:active{transform:scale(.94)}
  .v37-chant-options{display:flex;flex-direction:column;gap:8px;align-items:flex-start;font-size:11px;color:#f9ead0}
  .v37-chant-options label{margin:0;display:flex;gap:5px;align-items:center;white-space:nowrap;font-size:10px}
  .v37-chant-options input[type="checkbox"]{width:16px;height:16px;margin:0;accent-color:#e2b65d}
  .v37-chant-options input[type="range"]{width:75px;max-width:85px;margin:0;accent-color:#deb563;padding:0;background:none;border:0}
  .v37-chant-disclaimer{color:#d1b991;text-align:center;font-size:10px;line-height:1.5;margin:30px 0 0}
}
@media(max-width:355px){
  #v37PlayerCard{width:202px}.v37-player-flower{width:37px;height:37px}.v37-player-text strong{font-size:12px}
  header .currencies{min-width:77px;font-size:9px;padding:9px 6px}
  .bottom nav{grid-template-columns:repeat(3,63px)!important}.bottom nav button{width:63px;height:61px;font-size:9px!important}
  .mobilepad{left:8px!important;transform:scale(.9);transform-origin:left bottom}
  .utility{right:8px!important}
  .v37-chant-lower{grid-template-columns:1fr 90px 1fr}#v37ChantWoodfish{width:88px;height:88px}
}
@media(max-height:690px) and (max-width:900px){
  .utility{top:calc(160px + env(safe-area-inset-top,0px))!important;gap:5px!important}
  .utility>button.v37-quick,#v37MoreButton{width:43px;height:43px;border-radius:13px!important}
  .bottom nav button{height:59px}.bottom nav{gap:5px!important}
  .mobilepad{transform:scale(.88);transform-origin:left bottom}
  #v37ChantDialog{padding-top:calc(env(safe-area-inset-top,0px) + 7px)}
  .v37-chant-tabs{margin-top:18px}.v37-chant-hero{min-height:23dvh}
}
/* Explicitly preserve the hidden state of closed dialogs. */
dialog#v37ChantDialog:not([open]){display:none!important}

@media(max-width:900px){
  /* Analog joystick: four original direction buttons remain in DOM for engine compatibility. */
  .mobilepad button[data-key]{display:none!important}
  .mobilepad #v37Joystick{display:block!important;position:absolute!important;inset:0!important;width:100%!important;height:100%!important;min-width:0!important;padding:0!important;border-radius:50%!important;border:2px solid rgba(255,255,255,.45)!important;background:radial-gradient(circle at 50% 50%,rgba(235,237,234,.29),rgba(234,236,230,.10))!important;box-shadow:0 6px 21px #0003;backdrop-filter:none!important;touch-action:none!important;cursor:grab;overflow:visible}
  #v37JoystickKnob{position:absolute;left:50%;top:50%;width:47px;height:47px;margin-left:-23.5px;margin-top:-23.5px;background:linear-gradient(130deg,rgba(255,255,255,.85),rgba(209,215,214,.50));border:1px solid rgba(255,255,255,.72);border-radius:50%;box-shadow:0 3px 14px #0003;transform:translate(0px,0px);pointer-events:none;will-change:transform}
  #v37ZoomControls{display:grid;position:fixed;z-index:13;left:12px;top:50%;gap:7px}
  #v37ZoomControls button{display:grid;place-items:center;width:39px;height:39px;padding:0!important;border-radius:50%;border:1px solid var(--v37-border);background:var(--v37-bg);color:#fae1a4;font-size:25px;box-shadow:0 5px 14px #0005}
  body.entering #v37ZoomControls{display:none!important}
  #beadView{backdrop-filter:none}
}

/* V38: keep scene controls out of the way when any ritual is open. */
@media(max-width:900px){
 body:has(dialog[open]) .mobilepad,
 body:has(dialog[open]) .bottom,
 body:has(dialog[open]) .utility,
 body:has(dialog[open]) #v37ZoomControls,
 body:has(dialog[open]) #v37MorePanel,
 body:has(dialog[open]) #v37PlayerCard,
 body:has(dialog[open]) .location{pointer-events:none!important}
 body:has(dialog#v37ChantDialog[open]) .utility,
 body:has(dialog#v37ChantDialog[open]) .bottom,
 body:has(dialog#v37ChantDialog[open]) .mobilepad,
 body:has(dialog#v37ChantDialog[open]) .location,
 body:has(dialog#v37ChantDialog[open]) #v37TopTicker{visibility:hidden!important}
 body:has(#beadView:not([hidden])) .utility,
 body:has(#beadView:not([hidden])) .bottom,
 body:has(#beadView:not([hidden])) .mobilepad,
 body:has(#beadView:not([hidden])) #v37PlayerCard,
 body:has(#beadView:not([hidden])) .location{visibility:hidden!important}
 #botPilgrimLabels >div,#remotePlayerLabels >div{
   box-shadow:0 1px 5px rgba(0,0,0,.22)!important;
   border-radius:9px!important;padding:3px 7px!important;
   font-size:11px!important;max-width:140px!important;
   overflow:hidden;text-overflow:ellipsis;
 }
 #botPilgrimLabels strong,#remotePlayerLabels strong{font-size:11px!important}
 #botPilgrimLabels small,#remotePlayerLabels small{font-size:9px!important}
 #v37PlayerCard:focus-visible,.v37-quick:focus-visible,
 #v37Joystick:focus-visible,#v37MoreButton:focus-visible{
   outline:3px solid #ffe2a0!important;outline-offset:3px!important;
 }
 .v37-meditation-actions button:focus-visible,#v37ChantWoodfish:focus-visible{outline:3px solid #ba7c24;outline-offset:2px}
}
@media(max-width:420px) and (max-height:740px){
 .utility{top:calc(165px + env(safe-area-inset-top,0px))!important;gap:5px!important}
 .utility>button.v37-quick,#v37MoreButton{width:43px;height:43px;border-radius:13px!important}
 .bottom nav button{height:59px!important}
}
