@import url("../hub/language-control.css");
/* Yggdrasil adapter for the pinned Asgard DS. Shared package stays byte-identical.
   Fantasy surfaces/skill geometry remain game-owned; typography and control states use shared roles. */
:root {
  --ag-ui-background: #102824;
  --ag-ui-surface: #173a32;
  --ag-ui-raised: #244537;
  --ag-ui-text: #eee9d8;
  --ag-ui-secondary: #b6c8bb;
  --ag-ui-border: #cfbf8e35;
  --ag-ui-border-strong: #718479;
  --ag-ui-accent: #d9bd7b;
  --ag-ui-on-accent: #192f28;
  font-family: var(--ag-font-sans);
  font-synthesis: none;
}
body.ag-ui {
  font: var(--ag-type-body1);
  font-synthesis: none;
}
h1,
.landing h1 {
  font: var(--ag-type-h1);
  letter-spacing: 0;
}
h2,
.panel h2 {
  font: var(--ag-type-h2);
  letter-spacing: 0;
}
h3,
.selection h3 {
  font: var(--ag-type-h3);
}
h4 {
  font: var(--ag-type-h4);
}
.stage-bar h3,
.sidebar h3 {
  font: var(--ag-type-h4);
}
p,
.panel p,
.lead {
  font: var(--ag-type-body1);
}
.logo {
  font: var(--ag-type-h2);
  letter-spacing: 0.12em;
}
.logo small,
.eyebrow,
.badge,
.footnote,
.role-card span,
.battle-footer > div:first-child,
.skill small,
.skill b,
.hp,
.tutorial,
.timer,
.stage-bar p {
  font: var(--ag-type-caption);
}
.logo small {
  margin-top: var(--ag-space-1);
}
.eyebrow {
  font-weight: 500;
}
.sidebar p,
.selection p,
.material,
.glossary p,
.panel label,
.panel .output,
.checks,
.skill-guide,
.skill-guide p,
.skill-status,
.upgrade-cards small,
.upgrade-cards button span,
.panel-language button,
.panel .output small,
#combat-energy,
.control-settings p {
  font: var(--ag-type-body2);
}
button,
select,
input {
  font-family: var(--ag-font-sans);
  font-synthesis: none;
}
button.ag-button,
button.ag-tab,
select.ag-select {
  min-height: var(--ag-control-lg);
  border-radius: var(--ag-control-radius);
  padding: var(--ag-space-2) var(--ag-space-4);
  font-size: var(--ag-body1-size);
  line-height: var(--ag-body1-line);
  font-weight: 500;
  transition:
    background-color var(--ag-duration) var(--ag-ease),
    border-color var(--ag-duration) var(--ag-ease);
}
button:active {
  transform: none;
}
button:disabled,
select:disabled {
  opacity: var(--ag-disabled-opacity);
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: var(--ag-focus-width) solid var(--ag-ui-accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 var(--ag-focus-halo)
    color-mix(in srgb, var(--ag-ui-accent) 50%, transparent);
}
.primary {
  font-weight: 500;
}
button.ag-tab[aria-pressed="true"] {
  color: var(--ag-ui-text);
}
.upgrade-cards .ag-tab[aria-pressed="true"],
.role-card.ag-tab[aria-pressed="true"],
.tiers .ag-tab[aria-pressed="true"] {
  color: var(--ag-ui-text);
  border-color: var(--ag-ui-accent);
  background: color-mix(in srgb, var(--ag-ui-accent) 20%, var(--ag-ui-surface));
}
.selection,
.material,
.upgrade-cards button,
.control-settings {
  border-radius: var(--ag-card-radius);
}
.selection,
.sidebar {
  padding: var(--ag-space-6);
  gap: var(--ag-space-4);
}
.panel.ag-dialog {
  padding: var(--ag-space-6);
  border-radius: var(--ag-dialog-radius);
  max-height: calc(100svh - 32px);
}
.overlay {
  padding: var(--ag-space-4);
}
.panel .row,
.upgrade-cards,
.encounter-cards {
  gap: var(--ag-space-4);
}
.role-card.ag-tab {
  padding: var(--ag-space-2);
}
.upgrade-cards button,
.encounter-cards button {
  display: grid;
  gap: var(--ag-space-2);
  text-align: left;
  align-content: start;
}
.upgrade-cards button b,
.encounter-cards button b {
  font: var(--ag-type-h5);
}
.upgrade-cards button small,
.encounter-cards button small {
  font: var(--ag-type-body2);
}
input:not([type="checkbox"]):not([type="range"]) {
  min-height: var(--ag-control-lg);
  font: var(--ag-type-body1);
  border-radius: var(--ag-control-radius);
}
pre {
  font-family: var(--ag-font-mono);
  font-size: var(--ag-caption-size);
  line-height: var(--ag-caption-line);
}
[lang^="zh"] h1,
[lang^="zh"] h2,
[lang^="zh"] h3,
[lang^="zh"] h4,
[lang^="zh"] .eyebrow {
  letter-spacing: 0;
}
@media (pointer: coarse), (max-width: 767px) {
  button.ag-button,
  button.ag-tab,
  select.ag-select,
  input:not([type="checkbox"]):not([type="range"]),
  summary {
    min-height: var(--ag-touch-target);
  }
  select.ag-select,
  input:not([type="checkbox"]):not([type="range"]) {
    font-size: 16px;
  }
  .panel.ag-dialog {
    padding: var(--ag-space-4);
  }
  .settings label {
    min-height: var(--ag-touch-target);
  }
  .sidebar {
    padding: var(--ag-space-4);
    gap: var(--ag-space-3);
  }
  .selection {
    padding: var(--ag-space-4);
    gap: var(--ag-space-3);
  }
  .logo {
    font: var(--ag-type-h4);
  }
  .logo small {
    font: var(--ag-type-caption);
    letter-spacing: 0.08em;
  }
  .tiers button.ag-tab {
    font: var(--ag-type-body2);
  }
}

/* Input-specific geometry; typography remains the shared DS caption role. */
.skill {
  --skill-size: 44px;
  width: var(--skill-size);
  height: var(--skill-size);
  min-width: var(--skill-size);
  min-height: var(--skill-size);
  background-size: calc(var(--skill-size) * 6) calc(var(--skill-size) * 4);
  background-position: calc(var(--skill-col) * var(--skill-size) * -1)
    calc(var(--skill-row) * var(--skill-size) * -1);
}
#objective {
  max-width: 38%;
  white-space: normal;
}
.tutorial {
  display: none;
}
#battle-hint {
  max-width: 32rem;
}
@media (pointer: coarse) {
  .skill {
    --skill-size: 56px;
  }
  .skill small {
    display: none;
  }
  #objective {
    display: none;
  }
  .battle-footer {
    flex-wrap: wrap;
  }
  #battle-hint {
    flex-basis: 100%;
  }
}

@media (max-width: 760px) {
  #objective {
    display: none;
  }
}

/* Shared full-page route: never keep two combat engines mounted. */
.hall-return{display:inline-flex;align-items:center;min-height:48px;padding:8px 12px;font:var(--ag-type-body2);color:inherit;text-decoration:underline;text-underline-offset:3px}
.hall-return:focus-visible{outline:2px solid var(--ag-color-primary,#74d7df);outline-offset:3px}

/* Shared control geometry is unchanged; game-specific placement stays outside combat. */
[data-ygg-language] { display: inline-flex; align-items: center; }
.panel-language[data-ygg-language] { display: flex; justify-content: flex-end; margin-block-end: var(--ag-space-3, 12px); }
.top .actions { flex-wrap: wrap; }

/* Navigation lives in document flow, never over a landmark or the player. */
.battle-guidance {
  flex: 1;
  min-width: 0;
}
#navigation-cue {
  color: var(--ag-ui-accent);
  font: var(--ag-type-caption);
  overflow-wrap: anywhere;
}
.navigation-arrow { display: inline-block; }
@media (pointer: coarse) {
  .battle-guidance { flex-basis: 100%; }
}
/* Short narrow landscape keeps scene and guidance together; details stay below. */
@media (max-width: 760px) and (max-height: 500px) and (orientation: landscape) {
  .field-wrap { height: calc(100svh - 64px); }
  .stage-bar, .battle-footer { flex-shrink: 0; }
  .canvas-wrap { flex: 1; min-height: 0; aspect-ratio: auto; }
  .canvas-wrap canvas { width: 100%; height: 100%; aspect-ratio: auto; }
}

.navigation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font: var(--ag-type-caption);
  margin-bottom: var(--ag-space-1);
}
#landmark-cue { overflow-wrap: anywhere; }
@media (max-width: 1000px) and (max-height: 500px) and (orientation: landscape) {
  .stage-bar { padding: 8px 14px; min-height: 0; }
  .battle-footer { padding: 8px 12px; gap: 8px; }
}

.token-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  background: currentColor;
  mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  vertical-align: -.1em;
}
.token-panel { border-top: 1px solid var(--ag-ui-border); padding-top: var(--ag-space-2); }
/* Full-viewport game surface; lobby keeps its own website layout. */
body[data-ygg-screen="game"]{overflow:hidden;overscroll-behavior:none;width:100%;height:100dvh;}
.game-shell{position:fixed;inset:0;height:100vh;height:100dvh;overflow:hidden;isolation:isolate;background:#102824;}
.game-shell .canvas-wrap{position:absolute;inset:0;display:block;min-height:0;height:100%;aspect-ratio:auto;}
.game-shell .canvas-wrap canvas{position:absolute;inset:0;width:100%;height:100%;aspect-ratio:auto;touch-action:none;}
.game-shell button,.move-pad{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none;}
.play-top{position:absolute;z-index:2;top:0;left:0;right:0;display:flex;align-items:start;justify-content:space-between;gap:8px;padding:max(10px,env(safe-area-inset-top)) max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));pointer-events:none;}
.play-top>*{pointer-events:auto;}
.play-vitals{width:145px;max-width:40%;padding:7px 9px;border:1px solid var(--line);border-radius:10px;background:#102a27ed;display:grid;gap:4px;font:var(--ag-type-caption);}
.play-vitals .track{height:7px;background:#061d1a;border-radius:6px;overflow:hidden;}
.play-vitals .fill{height:100%;background:#a8dab2;width:100%;}
.play-menu{display:flex;gap:4px;align-items:start;}
.play-menu button.ag-button{padding:8px;min-width:44px;min-height:44px;background:#102a27ed;font:var(--ag-type-body2);}
.quest-card{position:absolute;z-index:2;top:calc(84px + env(safe-area-inset-top));left:max(12px,env(safe-area-inset-left));width:min(400px,calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));padding:10px 12px;display:grid;gap:4px;text-align:left;background:#102a27e8;border-radius:10px;font:var(--ag-type-body2);}
.quest-card strong{font:var(--ag-type-body1);}
.game-shell #objective{display:block;max-width:none;}
.play-navigation{position:absolute;top:calc(186px + env(safe-area-inset-top));left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));width:max-content;max-width:calc(100% - 24px);gap:6px;background:#102a27dd;border-radius:6px;padding:4px 7px;pointer-events:none;font:var(--ag-type-caption);}
.play-navigation [hidden]{display:none;}
.move-pad{display:none;position:absolute;left:max(18px,env(safe-area-inset-left));bottom:max(22px,env(safe-area-inset-bottom));width:130px;height:142px;touch-action:none;z-index:3;}
.move-pad .joystick{display:block;left:7px;top:8px;bottom:auto;width:112px;height:112px;background:#102a2755;border:2px solid #dfd6a077;}
.move-pad .joystick i{left:34px;top:34px;width:40px;height:40px;}
.move-pad>span{position:absolute;bottom:0;left:0;width:100%;text-align:center;font:var(--ag-type-caption);color:var(--ink);text-shadow:0 1px 3px #000;pointer-events:none;}
.play-actions{position:absolute;z-index:3;right:max(18px,env(safe-area-inset-right));bottom:max(22px,env(safe-area-inset-bottom));display:grid;justify-items:end;gap:8px;}
.game-shell .skills{display:flex;gap:10px;}
.game-shell .skill{--skill-size:56px;touch-action:manipulation;border:2px solid #ddca9299;box-shadow:0 3px 10px #031c18aa;}
.game-shell .skill small{background:#102a27e8;padding:2px 4px;border-radius:3px;}
.skill-feedback{position:absolute;right:0;bottom:76px;width:min(330px,calc(100vw - 32px));pointer-events:none;text-align:right;font:var(--ag-type-body2);}
.skill-feedback p{margin:4px 0 0;padding:5px 8px;border-radius:6px;background:#102a27e8;}
.skill-feedback p:empty{display:none;}
.game-shell .cast-cancel[hidden]{display:none;}
.game-shell .cast-cancel{position:absolute;right:0;bottom:138px;min-height:44px;max-width:220px;background:#402e25;}
.play-context{position:absolute;z-index:3;bottom:calc(204px + env(safe-area-inset-bottom));left:50%;transform:translateX(-50%);display:grid;gap:6px;text-align:center;width:min(320px,calc(100% - 32px));pointer-events:none;}
.play-context button{pointer-events:auto;}
.play-context [hidden]{display:none;}
.play-context span{background:#102a27e8;border-radius:6px;font:var(--ag-type-body2);}
.play-context span:empty{display:none;}
.pickup-notice{position:absolute;z-index:2;top:42%;left:50%;transform:translateX(-50%);width:min(360px,calc(100% - 32px));padding:10px 12px;border:1px solid #e1c98988;background:#1b3e32ee;border-radius:10px;font:var(--ag-type-body2);pointer-events:none;}
.pickup-notice:empty{display:none;}
.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;}
body[data-ygg-screen="game"] .overlay{padding:max(8px,env(safe-area-inset-top)) max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left));height:100dvh;overscroll-behavior:contain;}
.adventure-sheet.panel{max-height:calc(100dvh - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));width:min(700px,100%);overscroll-behavior:contain;}
.adventure-sheet .item-card,.workshop-objective{border:1px solid var(--line);border-radius:8px;padding:12px;margin:10px 0;background:#102a2755;}
.adventure-sheet .item-card p{margin:6px 0 0;}
.adventure-sheet details{margin:12px 0;}
.adventure-sheet summary{min-height:44px;display:list-item;padding:10px 0;cursor:pointer;}
.adventure-sheet pre{max-width:100%;overflow:auto;}
@media(pointer:coarse){.move-pad{display:block;}}
@media(max-height:500px) and (orientation:landscape){
 .quest-card{top:calc(76px + env(safe-area-inset-top));width:min(350px,52%);padding:8px 10px;}
 .play-navigation{top:auto;bottom:max(10px,env(safe-area-inset-bottom));left:170px;right:220px;max-width:calc(100% - 390px);}
 .move-pad{width:120px;height:126px;bottom:max(10px,env(safe-area-inset-bottom));}
 .move-pad .joystick{width:100px;height:100px;}
 .move-pad .joystick i{left:28px;top:28px;}
 .play-actions{bottom:max(12px,env(safe-area-inset-bottom));}
 .skill-feedback{width:min(300px,48vw);}
 .play-context{bottom:78px;width:min(280px,42%);}
 .pickup-notice{top:46%;width:min(340px,55%);}
}
@media(min-width:900px) and (min-height:600px){.quest-card{width:380px;}.play-actions{right:30px;bottom:30px;}.game-shell .skill{--skill-size:64px;}.play-navigation{top:188px;}}

/* Quest text and navigation reflow together as translations wrap. */
.play-quest-stack{position:absolute;z-index:2;top:calc(84px + env(safe-area-inset-top));left:max(12px,env(safe-area-inset-left));width:min(400px,calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));}
.play-quest-stack .quest-card{position:relative;inset:auto;width:100%;}
.play-quest-stack .play-navigation{position:relative;inset:auto;max-width:100%;width:fit-content;margin:6px 0 0;}
.skill-feedback{width:min(290px,calc(100vw - 174px));}
@media(max-height:500px) and (orientation:landscape){.play-quest-stack{top:calc(76px + env(safe-area-inset-top));width:min(350px,42%);}}
@media(min-width:900px) and (min-height:600px){.play-quest-stack{width:380px;}.skill-feedback{width:330px;}}

/* Shared dialog/form rhythm; combat skill hit areas stay game-owned. */
.panel .row,.panel .steps,.tiers{gap:var(--ag-space-3)}
.panel .row{align-items:stretch}
.panel .row>button{min-width:0;white-space:normal;overflow-wrap:anywhere}
.control-settings>label{display:grid;gap:var(--ag-space-2);margin-block:var(--ag-space-3)}
.control-settings select{margin:0;width:100%;max-width:100%}
.panel label>select{margin-block-start:var(--ag-space-2)}
.panel .steps button{white-space:normal;min-height:48px}

/* The selection header contains three text rows plus a 48px Hall link.
   Size it from its contents; fixed 76/64px shells vertically clipped the brand. */
body[data-ygg-screen="select"] .top {
  height: auto;
  min-height: 76px;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: max(12px, env(safe-area-inset-top)) max(4vw, env(safe-area-inset-right))
    12px max(4vw, env(safe-area-inset-left));
}
body[data-ygg-screen="select"] .top .logo {
  flex: 1 1 200px;
  min-width: 0;
}
body[data-ygg-screen="select"] .top .logo small,
body[data-ygg-screen="select"] .top .hall-return {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
body[data-ygg-screen="select"] .top .actions {
  flex-wrap: wrap;
  max-width: 100%;
}
@media (max-width: 760px) {
  body[data-ygg-screen="select"] .top {
    min-height: 64px;
    column-gap: 12px;
    padding-inline: max(15px, env(safe-area-inset-left)) max(15px, env(safe-area-inset-right));
  }
}

/* Mobile adventure HUD: one objective, one route, on-demand detail. */
.play-menu-toggle,.radar-toggle-icon{display:none;}
.game-menu-sheet{display:grid;gap:12px;}
.game-menu-sheet button{min-height:48px;}
@media(max-width:900px),(max-height:500px){
 .game-shell .play-menu-full{display:none;}
 .game-shell .play-menu-toggle{display:grid;place-items:center;min-width:48px;min-height:48px;padding:8px;background:#102a27ed;font-size:24px;line-height:1;border-radius:10px;}
 .game-shell .play-quest-stack{top:calc(84px + env(safe-area-inset-top));width:min(380px,calc(100% - 148px - env(safe-area-inset-left) - env(safe-area-inset-right)));}
 .game-shell .quest-card{display:flex;align-items:center;gap:10px;min-height:48px;padding:8px 10px;}
 .game-shell .quest-card .eyebrow{display:none;}
 .game-shell .quest-card strong{flex:1;min-width:0;text-align:left;}
 .game-shell #collection-progress{flex:none;white-space:nowrap;}
 .game-shell #collection-progress:empty{display:none;}
 .game-shell .play-navigation{display:none;}
 .game-shell .mission-radar{top:calc(84px + env(safe-area-inset-top));right:max(12px,env(safe-area-inset-right));width:108px;padding:3px;}
 .game-shell .mission-radar button{min-height:44px;height:44px;padding:4px;display:grid;place-items:center;}
 .game-shell .radar-toggle-copy{display:none;}
 .game-shell .radar-toggle-icon{display:inline;font-size:24px;line-height:1;}
 .game-shell .mission-radar svg{width:100%;height:64px;}
 .game-shell .mission-radar p{margin:2px;text-align:center;}
 .game-shell .route-edge{max-width:80px;padding:5px 7px;}
 .game-shell .route-copy{display:none;}
 .game-shell[data-movement-learned="true"] .move-pad>span{display:none;}
 .game-shell .move-pad{height:126px;}
 .game-shell .first-run-coach{left:12px;bottom:154px;width:min(260px,calc(100% - 148px));padding:8px;}
 .game-shell .pickup-notice{padding:8px 10px;width:max-content;max-width:calc(100% - 32px);}
 .game-shell[data-workshop-ready="true"] .play-quest-stack{display:none;}
 .game-shell #return-hint{display:none;}
}
@media(max-height:500px) and (orientation:landscape){
 .game-shell .play-quest-stack,.game-shell .mission-radar{top:calc(76px + env(safe-area-inset-top));}
 .game-shell .play-quest-stack{width:min(330px,calc(100% - 148px - env(safe-area-inset-left) - env(safe-area-inset-right)));}
 .game-shell .first-run-coach{left:150px;bottom:12px;width:min(260px,calc(100% - 380px));}
 .game-shell .mission-radar{width:104px;}
 .game-shell .mission-radar svg{height:56px;}
 .game-shell .move-pad{height:112px;}
}

/* Purpose, not colour alone: objective flag, control callout, interaction button,
   alarm diamond and on-demand learning sheets remain distinct. */
.quest-symbol,.quest-open{display:none;}
.sheet-toolbar{position:sticky;top:-1px;z-index:5;display:flex;align-items:center;justify-content:space-between;gap:12px;background:#173c31;padding:8px 0;border-bottom:1px solid var(--line);}
.sheet-toolbar button{min-height:48px;flex:none;}
.quest-next h2{margin:8px 0;}.quest-next p{margin:8px 0;}
.quest-items{list-style:none;padding:0;display:grid;gap:8px;}.quest-items li{padding:8px;border-bottom:1px solid var(--line);}
.battle-alert{display:none;pointer-events:none;}
@media(max-width:900px),(max-height:500px){
 .game-shell .quest-symbol{display:inline;flex:none;font-size:20px;}
 .game-shell .quest-open{display:inline;flex:none;border-left:1px solid #cdbb8270;padding-left:8px;white-space:nowrap;}
 .game-shell .quest-card{border-radius:4px;border-left:4px solid #cdbb82;gap:7px;}
 .game-shell .first-run-coach{border-radius:18px 18px 18px 3px;border-style:dashed;}
 .game-shell .first-run-coach[data-kind="skill"]{left:auto;right:12px;bottom:152px;border-radius:18px 18px 3px 18px;}
 .game-shell .battle-alert:not([hidden]){display:flex;gap:8px;align-items:center;position:absolute;left:12px;top:148px;z-index:4;width:min(240px,calc(100% - 148px));padding:8px;background:#3c2222f2;border:2px solid #ffb57d;border-radius:3px;}
 .battle-alert>span{display:grid;place-items:center;flex:none;border:2px solid currentColor;transform:rotate(45deg);width:22px;height:22px;font-weight:bold;}
 .battle-alert p{margin:0;font:var(--ag-type-body2);}
 .game-shell .skill-feedback p{border-left:3px solid #b2e1df;text-align:left;border-radius:10px 10px 3px 10px;}
 .game-shell .skill-feedback #skill-lock-status:not(:empty)::before{content:'⌖ ';}
 .game-shell .skill-feedback .skill-status:not(:empty)::before{content:'◇ ';}
 .game-shell .skill-feedback .skill-outcome:not(:empty)::before{content:'✦ ';}
 .game-shell .pickup-notice{border-radius:20px;}
 .game-shell .play-context button{border-radius:24px;border:2px solid #f4df9a;}
 .game-shell .play-context button::before{content:'⌂ ';}
}
@media(max-height:500px) and (orientation:landscape){
 .game-shell .battle-alert:not([hidden]){top:132px;width:min(230px,calc(100% - 380px));}
 .game-shell .first-run-coach[data-kind="skill"]{right:220px;bottom:12px;width:min(260px,calc(100% - 390px));}
}
