/* The island overlay: toasts and dialogs (always available), plus the play-mode HUD, world labels,
   battle and mini-game panels. The canvas itself lives in #world (see site.css).
   Shares the page's colour and type tokens. */

html.is-play { overflow: hidden; }
:root { --sa-t: 0px; --sa-r: 0px; --sa-b: 0px; --sa-l: 0px; }
.g { position: fixed; inset: 0; z-index: 60; pointer-events: none; color: var(--ink); font: 400 15px/1.45 var(--sans); }
.g__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.g .ico { display: inline-block; vertical-align: middle; filter: invert(1); opacity: 0.9; flex: none; }
.g kbd {
  display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 4px; text-align: center; line-height: 18px;
  font: 500 11px/18px var(--mono); color: var(--ink); background: rgba(233, 236, 241, 0.09); border: 1px solid var(--line-2);
}
.g .muted { color: var(--ink-3); }
.g .small { font-size: 13px; }
.g .good { color: #86efac; }

/* ---------------- world labels ---------------- */
.g__fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.g__label {
  position: absolute; left: 0; top: 0; white-space: nowrap; font: 600 15px var(--sans); text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  will-change: transform, opacity;
}
.g__label--dmg { color: #fde68a; }
.g__label--crit { color: #fb923c; font-size: 19px; }
.g__label--buddy { color: #86efac; }
.g__label--heal { color: #4ade80; }
.g__label--mp { color: #7dd3fc; }
.g__label--block { color: #c7d2fe; }
.g__label--gold { color: var(--accent); }
.g__label--xp { color: #c4b5fd; }
.g__label--hurt { color: #f87171; }
.g__label--info { color: var(--ink-2); font-weight: 500; font-size: 13px; }
.g__label--super { color: #f472b6; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }

.g__plate {
  position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer;
  display: flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px;
  background: rgba(7, 10, 18, 0.84); border: 1px solid var(--line); font-size: 12.5px; white-space: nowrap;
  transition: border-color 0.2s;
}
.g__plate b { font-weight: 600; }
.g__plate-hint { display: none; color: var(--ink-2); }
.g__plate.is-near { border-color: var(--accent); }
.g__plate.is-near .g__plate-hint { display: inline-flex; align-items: center; gap: 4px; }
.g__plate-mark { display: none; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); color: #1a1300; font: 700 11px/16px var(--sans); text-align: center; }
.g__plate.has-news .g__plate-mark { display: inline-block; }
.g__plate--door, .g__plate--chest { pointer-events: none; }
.g__plate--door.is-ready { border-color: #e879f9; }
.g__plate[hidden] { display: none; }
.g__tag {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  background: rgba(7, 10, 18, 0.72); border: 1px solid var(--rc, var(--line-2)); color: var(--rc, var(--ink)); font-size: 12px; white-space: nowrap;
}
.g__tag .ico { filter: none; opacity: 1; }
.g__tag.is-expiring { animation: g-blink 0.6s steps(2) infinite; }
@keyframes g-blink { to { opacity: 0.35; } }

/* ---------------- HUD ---------------- */
.g__hud { position: absolute; inset: 0; pointer-events: none; display: none; }
html.is-play .g__hud { display: block; }
.g__hud button { pointer-events: auto; }
.hud-card {
  position: absolute; pointer-events: auto; padding: 12px 14px; border-radius: 12px;
  background: rgba(7, 10, 18, 0.82); border: 1px solid var(--line);
}
.hud-top { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: flex-start; justify-content: center; padding: 16px 20px; }
.hud-top__mid { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 40px; }
.hud-close {
  position: absolute; right: 20px; top: 16px; display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
  background: rgba(7, 10, 18, 0.82); border: 1px solid var(--line-2); color: var(--ink);
}
.hud-close:hover { border-color: var(--accent); }
.hud-zone { font-family: var(--serif); font-size: 28px; letter-spacing: 0.01em; opacity: 0; text-shadow: 0 2px 10px rgba(0,0,0,0.6); }
.hud-zone.is-in { animation: g-zone 2.6s ease-out forwards; }
@keyframes g-zone { 0% { opacity: 0; transform: translateY(6px); } 12%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
.hud-boss { display: flex; flex-direction: column; align-items: center; gap: 5px; width: min(420px, 60vw); }
.hud-boss[hidden] { display: none; }
.hud-boss__name { font: 500 13px var(--sans); color: #fca5a5; letter-spacing: 0.04em; text-transform: uppercase; }
.hud-boss__track { display: block; width: 100%; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.12); overflow: hidden; }
.hud-boss__fill { display: block; height: 100%; width: 100%; background: #ef4444; transform-origin: left; transition: transform 0.15s; }

.hud-player { left: 20px; top: 16px; width: 250px; }
.hud-player__top { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); }
.hud-lv b { color: var(--ink); font-size: 15px; }
.hud-gold { display: inline-flex; align-items: center; gap: 5px; }
.hud-gold b { color: var(--accent); }
.hud-buffs { margin-left: auto; color: #c7d2fe; font-size: 12px; }
.hbar { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; margin-top: 5px; font-size: 12px; }
.hbar__label { color: var(--ink-3); font: 500 11px var(--mono); }
.hbar__track { display: block; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; }
.hbar__fill { display: block; height: 100%; width: 100%; transform-origin: left; transition: transform 0.12s; }
.hbar--hp .hbar__fill { background: #4ade80; }
.hbar--hp.is-low .hbar__fill { background: #f87171; animation: g-blink 0.7s steps(2) infinite; }
.hbar--mp .hbar__fill { background: #38bdf8; }
.hbar--xp .hbar__fill { background: #c4b5fd; }
.hbar__text { font: 500 11px var(--mono); color: var(--ink-2); font-style: normal; min-width: 62px; text-align: right; }
.hud-buddy {
  display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 10px; padding: 8px; border-radius: 8px; text-align: left;
  background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--ink);
}
.hud-buddy:hover { border-color: var(--line-2); }
.hud-buddy__sprite img { image-rendering: pixelated; }
.hud-buddy__info { display: flex; flex-direction: column; gap: 4px; flex: 1; font-size: 13px; }
.hud-buddy__lv { color: var(--ink-3); font-size: 12px; }
.hud-buddy__meta { display: flex; align-items: center; gap: 8px; }
.type-chip { display: inline-block; padding: 0 7px; border-radius: 999px; font: 500 11px/18px var(--sans); color: #0b0e16; background: var(--tc, #94a3b8); }
.mini-bar { display: inline-block; flex: 1; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.1); overflow: hidden; }
.mini-bar span { display: block; height: 100%; width: 100%; background: #c4b5fd; transform-origin: left; }

.hud-actions {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 8px;
  border-radius: 14px; background: rgba(7, 10, 18, 0.82); border: 1px solid var(--line); pointer-events: auto;
}
.slot {
  position: relative; display: grid; place-items: center; width: 52px; height: 52px; border-radius: 10px; overflow: hidden;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--ink);
}
.slot--wide { width: 68px; }
.slot:hover { border-color: var(--line-2); }
.slot__icon { pointer-events: none; }
.slot__key { position: absolute; left: 4px; bottom: 4px; min-width: 14px; padding: 0 3px; font-size: 9.5px; line-height: 14px; background: rgba(0,0,0,0.5); }
.slot__cost { position: absolute; right: 5px; top: 3px; font: 500 10px var(--mono); color: #7dd3fc; }
.slot__cd { position: absolute; inset: 0; background: rgba(7, 10, 18, 0.75); transform-origin: bottom; transform: scaleY(var(--cd, 0)); pointer-events: none; }
.slot.is-poor .slot__icon { opacity: 0.35; }
.slot.is-denied { animation: g-deny 0.3s; border-color: #f87171; }
@keyframes g-deny { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.hud-actions__gap { width: 1px; height: 32px; margin: 0 4px; background: var(--line); }
.hud-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: transparent; border: 1px solid transparent; color: var(--ink); }
.hud-btn:hover { border-color: var(--line-2); background: rgba(255,255,255,0.05); }

.hud-tracker { right: 20px; top: 66px; width: 250px; padding: 0; }
.hud-tracker__head { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 10px 14px; background: transparent; border: 0; color: var(--ink); font-weight: 500; font-size: 13px; text-align: left; }
.hud-tracker__caret { transition: transform 0.2s; }
.hud-tracker.is-collapsed .hud-tracker__caret { transform: rotate(-90deg); }
.hud-tracker.is-collapsed .hud-quests { display: none; }
.hud-runes { display: inline-flex; gap: 6px; }
.hud-rune { opacity: 0.22; }
.hud-rune.is-lit { opacity: 1; filter: invert(1) drop-shadow(0 0 4px rgba(242,184,75,0.8)); }
.hud-quests { padding: 0 14px 10px; display: grid; gap: 8px; font-size: 12.5px; }
.hud-quests li { display: flex; gap: 8px; align-items: flex-start; }
.hud-quests li .ico { margin-top: 1px; opacity: 0.7; }
.hud-quests li span { display: flex; flex-direction: column; }
.hud-quests small { color: var(--ink-3); font-size: 12px; }
.hud-quests li.is-hot b { color: var(--accent); }

.hud-map-wrap { left: 20px; bottom: 18px; padding: 6px; }
.hud-map { display: block; width: 144px; height: 144px; border-radius: 50%; }
.hud-map-wrap { border-radius: 50%; }
.hud-help { position: absolute; right: 20px; bottom: 22px; color: var(--ink-3); font-size: 12.5px; }
.hud-help kbd { margin-right: 2px; }

/* toasts, banner, coach */
.g__toasts { position: absolute; right: 20px; top: 72px; display: grid; gap: 6px; width: 300px; pointer-events: none; }
html.is-play .g__toasts { right: auto; left: 20px; top: 232px; }
.toast { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; background: rgba(7, 10, 18, 0.8); border: 1px solid var(--line); font-size: 13px; opacity: 0; transform: translateX(-8px); transition: opacity 0.2s, transform 0.2s; }
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; }
.toast--good { border-color: rgba(74, 222, 128, 0.4); }
.toast--gold { border-color: rgba(242, 184, 75, 0.5); }
.toast--bad { border-color: rgba(248, 113, 113, 0.5); }
.g__banner { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -50%); display: none; flex-direction: column; align-items: center; gap: 6px; text-align: center; pointer-events: none; text-shadow: 0 2px 12px rgba(0,0,0,0.7); }
.g__banner.is-in { display: flex; animation: g-banner 3.2s ease-out forwards; }
@keyframes g-banner { 0% { opacity: 0; transform: translate(-50%, -40%); } 10%, 80% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; } }
.banner__title { font-family: var(--serif); font-size: 34px; }
.banner__sub { color: var(--ink-2); font-size: 14px; max-width: 440px; }
.g__coach { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); width: min(520px, 90vw); padding: 14px 18px; border-radius: 12px; background: rgba(7, 10, 18, 0.85); border: 1px solid var(--line-2); pointer-events: auto; display: grid; gap: 8px; font-size: 14px; }
.g__coach-title { font-family: var(--serif); font-size: 20px; }
.g__coach .btn { justify-self: start; }
.g__hud:has(> .g__coach) .hud-help { visibility: hidden; }   /* the coach lists the same keys; the hint ran under it */

/* ---------------- modals ---------------- */
.g__modals { position: absolute; inset: 0; pointer-events: none; }
/* Visible from the first paint (no reliance on a transition frame), with a short settle. */
.modal { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(4, 6, 12, 0.55); pointer-events: auto; }
.modal.is-closing { opacity: 0; transition: opacity 0.16s; }
.modal--dialog { place-items: end center; padding-bottom: 96px; }
.modal__panel { width: min(560px, 100%); max-height: calc(100vh - 48px); overflow: auto; border-radius: 14px; background: #0e121b; border: 1px solid var(--line-2); box-shadow: 0 30px 80px rgba(0,0,0,0.6); animation: g-pop 0.18s ease-out; }
@keyframes g-pop { from { opacity: 0.6; transform: translateY(6px); } }
.wide-panel { width: min(720px, 100%); }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 0; }
.modal__title { font-family: var(--serif); font-weight: 400; font-size: 24px; }
.modal__x { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: transparent; border: 1px solid transparent; color: var(--ink); }
.modal__x:hover { border-color: var(--line-2); }
.modal__body { padding: 14px 18px 18px; }
.modal__sub { font-family: var(--serif); font-weight: 400; font-size: 19px; margin: 18px 0 8px; }
.modal__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; background: rgba(255,255,255,0.06); border: 1px solid var(--line-2); color: var(--ink); font-size: 14px; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn--primary { background: var(--accent); color: #1a1300; border-color: var(--accent); font-weight: 600; }
.btn--small { padding: 5px 10px; font-size: 13px; }
.btn--danger { border-color: rgba(248,113,113,0.5); color: #fca5a5; }
.btn.is-on { border-color: var(--accent); color: var(--accent); }
.pill { padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,0.05); border: 1px solid var(--line-2); color: var(--ink); font-size: 13px; }
.pill.is-on { border-color: var(--accent); color: var(--accent); }
.pill.is-locked { opacity: 0.45; }
.travel, .mounts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* dialog */
.talk { display: grid; grid-template-columns: auto 1fr; gap: 16px; }
.talk__face { display: grid; place-items: start center; padding: 6px; border-radius: 10px; background: rgba(255,255,255,0.04); }
.talk__face img { image-rendering: pixelated; }
.talk__name { font-family: var(--serif); font-size: 21px; margin-bottom: 4px; }
.talk__text { min-height: 3.2em; font-size: 15.5px; line-height: 1.5; }
.talk__note { color: var(--accent); font-size: 13px; min-height: 1em; margin-top: 4px; }
.talk__choices { display: grid; gap: 6px; margin-top: 10px; }
.talk__choice { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); color: var(--ink); text-align: left; font-size: 14px; }
.talk__choice:hover, .talk__choice:focus-visible { border-color: var(--accent); }

/* shop, equip, inventory */
.shop__gold { display: flex; align-items: center; gap: 4px; color: var(--ink-2); margin-bottom: 10px; }
.shop__gold b { color: var(--accent); }
.shop__list { display: grid; gap: 6px; }
.shop__item { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.shop__info { display: flex; flex-direction: column; }
.shop__info small { color: var(--ink-3); }
.compare { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.compare__arrow { color: var(--ink-3); font-size: 20px; }
.item-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px; border-radius: 10px; text-align: center; background: rgba(255,255,255,0.04); border: 1px solid var(--rc); }
.item-card__label { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.item-card__icon { display: grid; place-items: center; height: 36px; }
.item-card__icon .ico { filter: none; opacity: 1; }
.item-card__icon img { filter: invert(1); }
.item-card small { color: var(--rc); text-transform: capitalize; }
.item-card__stats { color: var(--ink-2); font-size: 12.5px; }
.gear-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 14px; margin-top: 14px; }
.stat-grid dt { color: var(--ink-3); font-size: 12px; }
.stat-grid dd { font-weight: 600; }
.bag-row { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 14px; }
.bag-row span { display: inline-flex; align-items: center; gap: 4px; }
.rune-on { color: var(--accent); }

/* achievements, runs */
.ach-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ach { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); opacity: 0.55; }
.ach.is-on { opacity: 1; border-color: rgba(242,184,75,0.45); }
.ach__icon { grid-row: span 2; }
.ach b { font-size: 13.5px; }
.ach small { color: var(--ink-3); font-size: 12px; }
.runs { display: grid; gap: 4px; }
.runs li { display: grid; grid-template-columns: 32px 90px 60px 1fr; gap: 8px; font-size: 14px; }
.runs small { color: var(--ink-3); }

/* party */
.party__list { display: grid; gap: 6px; margin-top: 10px; }
.party__slot { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); }
.party__slot.is-active { border-color: var(--accent); }
.party__slot img { image-rendering: pixelated; }
.party__info { display: grid; gap: 4px; }
.party__name { font-weight: 600; }
.party__lv { margin-left: 8px; color: var(--ink-3); font-weight: 400; font-size: 13px; }
.party__meta { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.dex { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.dex__card { display: grid; justify-items: center; gap: 4px; padding: 10px 8px; border-radius: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--line); text-align: center; opacity: 0.55; }
.dex__card.is-seen { opacity: 0.8; }
.dex__card.is-caught { opacity: 1; border-color: var(--line-2); }
.dex__card img { image-rendering: pixelated; }
.dex__unknown { display: grid; place-items: center; width: 36px; height: 36px; color: var(--ink-3); font-size: 22px; }
.dex__name { font-weight: 600; font-size: 13.5px; }
.dex__desc { color: var(--ink-3); font-size: 12px; line-height: 1.35; }
.dex__status { font-size: 12px; color: var(--ink-2); }

/* help */
.keys { display: grid; gap: 6px; }
.keys__row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; font-size: 14px; }
.keys__row kbd { margin-right: 3px; }
.settings { display: grid; gap: 8px; margin-top: 14px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch__ui { position: relative; width: 36px; height: 20px; border-radius: 10px; background: rgba(255,255,255,0.14); transition: background 0.15s; }
.switch__ui::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.switch input:checked + .switch__ui { background: var(--accent); }
.switch input:checked + .switch__ui::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__ui { outline: 2px solid var(--accent); outline-offset: 2px; }

/* game over */
.gameover-panel { width: min(440px, 100%); text-align: center; }
.gameover__title { font-family: var(--serif); font-size: 40px; }
.gameover-panel .stat-grid { text-align: left; }
.gameover-panel .modal__actions { justify-content: center; }

/* ---------------- battle ---------------- */
.battle-panel { width: min(600px, 100%); }
.battle__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.battle__chip { font: 500 11px var(--mono); letter-spacing: 0.08em; color: var(--ink-3); }
.battle__roster i { display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 50%; background: rgba(255,255,255,0.2); }
.battle__roster i.is-on { background: var(--accent); }
.battle__roster i.is-down { background: rgba(255,255,255,0.08); }
.battle__field { display: grid; gap: 8px; padding: 14px; border-radius: 10px; background: radial-gradient(80% 60% at 50% 100%, rgba(63,157,90,0.18), transparent 70%), rgba(255,255,255,0.03); border: 1px solid var(--line); }
.fighter { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; }
.fighter--ally { grid-template-columns: auto 1fr; }
.fighter__card { display: grid; gap: 4px; padding: 8px 10px; border-radius: 8px; background: rgba(7,10,18,0.6); border: 1px solid var(--line); min-width: 220px; }
.fighter__name { display: flex; justify-content: space-between; font-weight: 600; }
.fighter__lv { color: var(--ink-3); font-weight: 400; font-size: 13px; }
.fighter__hp { display: block; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.1); overflow: hidden; }
.fighter__hp span { display: block; height: 100%; width: 100%; background: #4ade80; transform-origin: left; transition: transform 0.25s; }
.fighter__hptext { font: 500 11px var(--mono); color: var(--ink-2); text-align: right; }
.fighter__sprite img { image-rendering: pixelated; }
.fighter__sprite.is-hit { animation: g-hit 0.3s; }
@keyframes g-hit { 25% { transform: translateX(-6px); filter: brightness(2); } 75% { transform: translateX(6px); } }
.fighter__sprite.is-capturing { animation: g-capture 1s ease-in; }
@keyframes g-capture { 50% { transform: scale(0.4) rotate(20deg); opacity: 0.4; } 100% { transform: scale(0.6); opacity: 0.6; } }
.battle__log { min-height: 2.6em; margin: 10px 0; font-size: 14.5px; }
.battle__cmds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.cmd { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.05); border: 1px solid var(--line); color: var(--ink); text-align: left; font-size: 13.5px; }
.cmd small { color: var(--ink-3); font-size: 11.5px; }
.cmd:hover:not(:disabled) { border-color: var(--accent); }
.cmd:disabled { opacity: 0.4; cursor: default; }
.cmd--move { border-color: var(--line-2); }
.cmd kbd { margin-right: 4px; }

/* ---------------- mini-games ---------------- */
.game-panel { width: min(480px, 100%); }
.game__hint { color: var(--ink-2); font-size: 13.5px; margin-bottom: 10px; }
.game__stats { display: flex; gap: 18px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.game__stats b { color: var(--ink); }
.game__result { min-height: 1.4em; margin-top: 8px; color: var(--accent); font-size: 14px; }
.game__canvas { display: block; width: 100%; max-width: 320px; margin: 0 auto; border-radius: 8px; border: 1px solid var(--line); image-rendering: pixelated; }
.typing__target { padding: 10px 12px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid var(--line); font: 15px var(--mono); white-space: pre-wrap; }
.typing__target .ok { color: #86efac; }
.typing__target .bad { color: #f87171; text-decoration: underline; }
.typing__target .cur { border-bottom: 2px solid var(--accent); }
.typing__input { width: 100%; margin-top: 8px; padding: 9px 12px; border-radius: 8px; background: #070a12; border: 1px solid var(--line-2); color: var(--ink); font: 15px var(--mono); }
.typing__input.is-wrong { border-color: #f87171; }
.typing__input.is-right { border-color: #4ade80; }
.memory { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.memory__card { position: relative; height: 72px; border-radius: 8px; background: rgba(255,255,255,0.05); border: 1px solid var(--line-2); color: var(--ink); perspective: 400px; }
.memory__back, .memory__face { position: absolute; inset: 0; display: grid; place-items: center; border-radius: 8px; backface-visibility: hidden; transition: transform 0.3s; }
.memory__back { font-family: var(--serif); font-size: 26px; color: var(--ink-3); }
.memory__face { transform: rotateY(180deg); background: #131826; gap: 2px; grid-auto-rows: max-content; align-content: center; }
.memory__face img { filter: invert(1); }
.memory__face small { font-size: 11px; color: var(--ink-2); }
.memory__card.is-up .memory__back { transform: rotateY(180deg); }
.memory__card.is-up .memory__face { transform: none; }
.memory__card.is-matched { border-color: rgba(74,222,128,0.6); }

@media (max-width: 1100px) {
  .hud-tracker { display: none; }
  /* the centred action bar (~725 px) ran under the minimap (left 20-178 px) below ~1100 px: start it past the map */
  .hud-actions { left: max(50%, 548px); }
}


/* ---------------- tour mode: world labels, speech bubbles, hover tip ---------------- */
html:not(.is-play) .g__plate .g__plate-hint { display: none !important; }
html:not(.is-play) .g__plate--door, html:not(.is-play) .g__plate--chest { display: none !important; }
.g__tip {
  position: fixed; left: 0; top: 0; z-index: 5; max-width: 260px; padding: 6px 11px; border-radius: 9px; pointer-events: none;
  background: rgba(7, 10, 18, 0.92); border: 1px solid var(--line-2);
  font: 500 13px/1.3 var(--sans); color: var(--ink); white-space: nowrap;
}
.g__tip[hidden] { display: none; }
.g__say {
  position: absolute; left: 0; top: 0; max-width: min(250px, calc(100vw - 24px)); padding: 8px 12px 9px; border-radius: 14px; pointer-events: none;
  background: rgba(244, 246, 252, 0.96); color: #10131c; font: 500 13.5px/1.35 var(--sans); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  opacity: 0; transition: opacity 0.25s; white-space: normal; width: max-content;
}
.g__say.is-in { opacity: 1; }
.g__say::after { content: ''; position: absolute; left: calc(50% + var(--tail, 0px)); bottom: -6px; width: 12px; height: 12px; margin-left: -6px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.g__say--me { background: #fff3c9; }
.g__say--bit { background: #d6ecff; font-style: italic; }
.g__say--npc { background: #eef0ff; }
#world:not(.is-near) .g__plate { opacity: 0; pointer-events: none; }
.g__plate { transition: opacity 0.4s, border-color 0.2s; }

/* ---------------- round 4: the open world ---------------- */
/* travel fade (masks teleports and camera snaps) */
.g__fade { position: absolute; inset: 0; background: #04060c; opacity: 0; pointer-events: none; transition: opacity 0.22s ease; z-index: 3; }
.g__fade.is-on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .g__fade { transition: none; } }

/* the HUD fades in when you enter the world */
html.is-play .g__hud { animation: g-hud-in 0.6s ease-out 0.35s both; }
@keyframes g-hud-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { html.is-play .g__hud { animation: none; } }

/* first person crosshair */
.hud-cross { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px; display: none; pointer-events: none; }
.hud-cross::before, .hud-cross::after { content: ''; position: absolute; background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 2px rgba(0, 0, 0, 0.8); }
.hud-cross::before { left: 8px; top: 0; width: 2px; height: 18px; }
.hud-cross::after { top: 8px; left: 0; height: 2px; width: 18px; }
.g__hud.is-fp .hud-cross { display: block; }

/* world plates for things (signs, doors, portals) */
.g__plate--thing, .g__plate--portal { pointer-events: auto; }
.g__plate--portal { border-color: rgba(167, 139, 250, 0.55); }
.g__plate--thing .g__plate-hint { color: var(--accent); }

/* world map + boat: an illustrated map of where you are, and every region */
.map-panel { width: min(1040px, 100%); }
.wmap2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(230px, 1fr); gap: 16px; margin-top: 4px; }
.wmap2__left { min-width: 0; }
.wmap2__map { position: relative; aspect-ratio: 1; width: 100%; max-height: min(66vh, 620px); max-width: min(66vh, 620px); margin: 0 auto; border-radius: 50%;
  background: radial-gradient(closest-side, #0b2240 92%, #070b16); box-shadow: 0 0 0 1px var(--line), 0 18px 40px rgba(0, 0, 0, 0.45); }
.wmap2__map.is-region { border-radius: 14px; background: #070b16; }
.wmap2__canvas { display: block; width: 100%; height: 100%; border-radius: inherit; }
.wmap2__door { position: absolute; transform: translate(-50%, -50%); display: flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none;
  color: var(--ink); cursor: pointer; font-size: 11px; z-index: 2; }
.wmap2__door-dot { display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(7, 10, 18, 0.85);
  border: 2px solid var(--dc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--dc) 28%, transparent); color: var(--dc); font: 700 11px/1 var(--sans); }
.wmap2__door:not(.is-known) .wmap2__door-dot { animation: wmap-pulse 1.6s ease-in-out infinite; }
.wmap2__door.is-known .wmap2__door-dot { background: var(--dc); color: #0b1020; }
.wmap2__door.is-done .wmap2__door-dot { box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.6); }
.wmap2__door-name { display: none; padding: 2px 6px; border-radius: 6px; background: rgba(7, 10, 18, 0.9); border: 1px solid var(--dc); white-space: nowrap; }
.wmap2__door:focus-visible { z-index: 3; }
@media (hover: hover) { .wmap2__door:hover { z-index: 3; } }
@media (hover: hover) { .wmap2__door:hover .wmap2__door-name { display: inline-block; } }
.wmap2__door:focus-visible .wmap2__door-name, .wmap2__door.is-picked .wmap2__door-name { display: inline-block; }
.wmap2__door.is-picked { z-index: 4; }
@media (pointer: coarse) { .wmap2__door-dot { position: relative; } .wmap2__door-dot::before { content: ''; position: absolute; inset: -7px; border-radius: 50%; } }
@keyframes wmap-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--dc) 10%, transparent); } }
.wmap2__boat { position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px;
  background: rgba(7, 10, 18, 0.85); border: 1px solid rgba(14, 165, 233, 0.8); }
.wmap2__me { position: absolute; width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-bottom: 16px solid #fff;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.9)) drop-shadow(0 0 6px rgba(242, 193, 78, 0.8)); z-index: 4; pointer-events: none; }
.wmap2__legend { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 6px; margin: 10px 0 0; }
.wmap2__key { display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: -1px; }
.wmap2__key--door { border-radius: 50%; border: 2px solid #a78bfa; background: #a78bfa; }
.wmap2__key--me { width: 0; height: 0; border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 12px solid #fff; }
.wmap2__key--loop { height: 0; border-top: 3px dashed rgba(242, 193, 78, 0.8); }
.wmap2__side { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.wmap2__side > p { margin: 0; }
.wmap2__list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: min(46vh, 430px); overflow: auto; }
.wmap2__row { display: grid; grid-template-columns: 12px 1fr; column-gap: 8px; align-items: center; width: 100%; padding: 7px 9px; border-radius: 10px; text-align: left;
  background: rgba(14, 19, 33, 0.9); border: 1px dashed var(--line-2); color: var(--ink-3); font-size: 12.5px; }
.wmap2__row b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wmap2__row small { grid-column: 2; color: var(--ink-3); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wmap2__dot { grid-row: span 2; width: 10px; height: 10px; border-radius: 50%; background: var(--dc); opacity: 0.45; }
.wmap2__row.is-known { border-style: solid; border-color: color-mix(in srgb, var(--dc) 45%, transparent); color: var(--ink); cursor: pointer; }
.wmap2__row.is-known .wmap2__dot { opacity: 1; }
.wmap2__row.is-known:hover:not(:disabled), .wmap2__row.is-known:focus-visible { border-color: var(--dc); }
.wmap2__row.is-here { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(242, 184, 75, 0.25); }
.wmap2__row.is-done small { color: var(--accent); }
.wmap2__row:disabled { cursor: default; }
.wmap2__road { padding: 10px 12px; border-radius: 12px; background: rgba(242, 193, 78, 0.06); border: 1px solid rgba(242, 193, 78, 0.3); }
.wmap2__road-head { display: flex; align-items: center; gap: 4px; margin: 0 0 8px; font-size: 13.5px; }
.wmap2__bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.wmap2__bar i { display: block; height: 100%; background: linear-gradient(90deg, #f2c14e, #fde68a); }
.wmap2__items { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.wmap2__item { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 7px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); opacity: 0.38; }
.wmap2__item.is-got { opacity: 1; border-color: rgba(242, 193, 78, 0.7); background: rgba(242, 193, 78, 0.12); }
@media (max-width: 760px) {
  .wmap2 { grid-template-columns: 1fr; }
  .wmap2__map { max-width: min(92vw, 52vh); }
  .wmap2__list { max-height: none; }
}

/* quest log: trophy board + quests */
.trophies { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 10px; }
.trophy { display: grid; justify-items: center; gap: 3px; padding: 10px 6px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); text-align: center; opacity: 0.55; }
.trophy.is-on { opacity: 1; border-color: rgba(242, 184, 75, 0.55); box-shadow: inset 0 0 18px rgba(242, 184, 75, 0.12); }
.trophy b { font-size: 12.5px; }
.trophy small { font-size: 11px; color: var(--ink-3); line-height: 1.25; }
.qlog { display: grid; gap: 8px; }
.qlog__q { padding: 8px 12px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.qlog__q.is-done { border-color: rgba(74, 222, 128, 0.4); }
.qlog__q small { color: var(--ink-3); font-weight: 400; }
.qlog__q ul { margin: 4px 0 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
.qlog__q li.is-done { color: #86efac; text-decoration: line-through; }
@media (max-width: 700px) { .trophies { grid-template-columns: repeat(3, 1fr); } }

/* touch controls (phones / tablets) */
.touch { position: absolute; inset: 0; display: none; pointer-events: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.touch.is-on { display: block; }
.touch.is-paused { display: none; }
/* the whole screen is the gesture surface (floating stick on the left, look / pinch / tap on the right) */
.touch__pad { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
.touch__stick { position: absolute; left: calc(88px + var(--sa-l)); top: calc(100% - 100px - var(--sa-b)); width: 124px; height: 124px; margin: -62px 0 0 -62px; border-radius: 50%; pointer-events: none;
  background: rgba(7, 10, 18, 0.32); border: 2px solid rgba(233, 236, 241, 0.2); opacity: 0.55; transition: opacity 0.2s; }
.touch__stick.is-live { opacity: 1; transition: none; background: rgba(7, 10, 18, 0.42); border-color: rgba(233, 236, 241, 0.34); }
.touch__knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(233, 236, 241, 0.4); border: 2px solid rgba(255, 255, 255, 0.6); }
.touch__btn { position: relative; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; pointer-events: auto; touch-action: none; padding: 0;
  background: rgba(7, 10, 18, 0.62); border: 2px solid rgba(233, 236, 241, 0.32); color: var(--ink); font: 700 19px var(--sans);
  -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.touch__btn .ico { pointer-events: none; }
.touch__btn b { pointer-events: none; font-weight: 700; }
.touch__btn.is-down { background: rgba(242, 184, 75, 0.38); border-color: var(--accent); transform: scale(0.94); }
/* the action cluster: attack in the corner, the rest in an arc around it */
.touch__btns { position: absolute; right: calc(10px + var(--sa-r)); bottom: calc(12px + var(--sa-b)); width: 214px; height: 214px; pointer-events: none; }
.touch__btns .touch__btn { position: absolute; }
.touch__btn--attack { right: 8px; bottom: 8px; width: 80px; height: 80px; background: rgba(242, 184, 75, 0.24); border-color: rgba(242, 184, 75, 0.7); }
.touch__btn--jump { right: 104px; bottom: 4px; }
.touch__btn--use { right: 94px; bottom: 76px; }
.touch__btn--dodge { right: 16px; bottom: 104px; width: 50px; height: 50px; }
.touch__btn--spell { right: 150px; bottom: 132px; width: 52px; height: 52px; }
.touch__btn--down { right: 162px; bottom: 60px; width: 48px; height: 48px; display: none; font-size: 15px; }
.touch.is-flying .touch__btn--down { display: grid; }
.touch__btn--use.is-ready { border-color: var(--accent); background: rgba(242, 184, 75, 0.3); box-shadow: 0 0 0 4px rgba(242, 184, 75, 0.18); animation: t-ready 1.4s ease-in-out infinite; }
@keyframes t-ready { 50% { box-shadow: 0 0 0 9px rgba(242, 184, 75, 0.06); } }
.touch__tag { position: absolute; left: 50%; bottom: calc(100% + 3px); transform: translateX(-50%); padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #1a1300; font: 700 11px/16px var(--sans); white-space: nowrap; display: none; }
.touch__btn--use.is-ready .touch__tag { display: block; }
/* spell: cooldown sweep, dim when short of MP, a small hint that it can be held */
.touch__btn--spell::before { content: ''; position: absolute; inset: -2px; border-radius: 50%; background: conic-gradient(rgba(7, 10, 18, 0.78) calc(var(--cd, 0) * 360deg), transparent 0); pointer-events: none; }
.touch__btn--spell::after { content: ''; position: absolute; right: 2px; top: 2px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px rgba(7, 10, 18, 0.8); }
.touch__btn--spell .ico { position: relative; }
.touch__btn--spell.is-poor .ico { opacity: 0.35; }
.touch__picker { position: absolute; right: calc(10px + var(--sa-r)); bottom: calc(214px + var(--sa-b)); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; max-width: min(340px, 92vw); padding: 8px; border-radius: 14px; background: rgba(7, 10, 18, 0.9); border: 1px solid var(--line-2); pointer-events: auto; }
.touch__picker[hidden] { display: none; }
.touch__pick { display: grid; justify-items: center; gap: 2px; width: 60px; padding: 7px 2px 5px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); color: var(--ink); -webkit-tap-highlight-color: transparent; }
.touch__pick small { font-size: 11px; line-height: 1.1; }
.touch__pick i { font: 500 10px var(--mono); color: #7dd3fc; font-style: normal; }
.touch__pick.is-on { border-color: var(--accent); background: rgba(242, 184, 75, 0.14); }
.touch__top { position: absolute; right: calc(8px + var(--sa-r)); top: calc(8px + var(--sa-t)); display: flex; gap: 6px; pointer-events: none; }
.touch__top .touch__btn { width: 44px; height: 44px; border-width: 1.5px; }
.touch__btn--menu { background: rgba(7, 10, 18, 0.8); }
/* on touch screens the keyboard HUD bits make room for the thumbs */
html.is-play .touch.is-on ~ .hud-actions, .g__hud:has(.touch.is-on) .hud-actions, .g__hud:has(.touch.is-on) .hud-help, .g__hud:has(.touch.is-on) .hud-map-wrap, .g__hud:has(.touch.is-on) .hud-close { display: none; }
@media (pointer: coarse) {
  :root { --sa-t: env(safe-area-inset-top, 0px); --sa-r: env(safe-area-inset-right, 0px); --sa-b: env(safe-area-inset-bottom, 0px); --sa-l: env(safe-area-inset-left, 0px); }
  /* play mode owns every gesture: no page scroll, rubber band, pinch zoom, text selection or callouts */
  html.is-play, html.is-play body { overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  html.is-play .g__hud, html.is-play .g__modals { -webkit-tap-highlight-color: transparent; }
  html.is-play .modal__panel, html.is-play .wmap2__list { touch-action: pan-y; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .hud-player { left: calc(8px + var(--sa-l)); top: calc(8px + var(--sa-t)); width: 164px; padding: 7px 9px 6px; border-radius: 10px; }
  .hud-player__top { margin-bottom: 4px; gap: 8px; font-size: 12px; }
  .hud-player .hud-buddy { display: none; }
  .hbar { grid-template-columns: 20px 1fr; gap: 6px; margin-top: 3px; }
  .hbar__text { display: none; }
  .hbar__label { font-size: 10px; }
  .hbar__track { height: 6px; }
  .hbar--xp .hbar__track { height: 3px; }
  .hud-top { padding: 58px 12px 0; pointer-events: none; }
  .hud-zone { font-size: 18px; }
  .hud-boss { width: min(360px, 70vw); }
  .g__toasts { width: min(300px, 70vw); }
  html.is-play .g__toasts { left: calc(8px + var(--sa-l)); }
  /* a compact quest line under the vitals (tap to open or fold it) */
  .g__hud:has(.touch.is-on) .hud-tracker { display: block; left: calc(8px + var(--sa-l)); right: auto; top: calc(90px + var(--sa-t)); width: min(220px, 56vw); border-radius: 10px; background: rgba(7, 10, 18, 0.72); }
  .g__hud:has(.touch.is-on) .hud-tracker__head { padding: 6px 10px; font-size: 12px; }
  .g__hud:has(.touch.is-on) .hud-quests { padding: 0 10px 8px; gap: 5px; font-size: 12px; }
  .g__hud:has(.touch.is-on) .hud-quests li:nth-child(n + 3) { display: none; }
  .g__hud:has(.touch.is-on) .hud-quests small { font-size: 11px; }
  html.is-play .g__toasts { top: calc(150px + var(--sa-t)); }
  .g__coach { top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 24px)); max-height: calc(100% - 24px); overflow: auto; padding: 12px 14px; font-size: 13.5px; }
  .g__coach .btn { padding: 10px 18px; font-size: 15px; }
  .banner__title { font-size: 26px; }
  .banner__sub { max-width: 80vw; }
}
@media (pointer: coarse) and (max-width: 380px) {
  .hud-player { width: 148px; }
  .touch__top { gap: 4px; }
  .touch__top .touch__btn { width: 40px; height: 40px; }
}
/* phones held sideways: little height, keep everything in the corners */
@media (pointer: coarse) and (max-height: 500px) {
  .touch__btns { transform: scale(0.84); transform-origin: 100% 100%; }
  .touch__picker { bottom: calc(184px + var(--sa-b)); }
  .touch__stick { top: calc(100% - 84px - var(--sa-b)); }
  .hud-top { padding-top: 10px; }
  .g__hud:has(.touch.is-on) .hud-tracker { top: auto; bottom: calc(8px + var(--sa-b)); left: 50%; transform: translateX(-50%); width: min(260px, 34vw); }
  .g__hud:has(.touch.is-on) .hud-tracker .hud-quests li:nth-child(n + 2) { display: none; }
  html.is-play .g__toasts { top: calc(74px + var(--sa-t)); }
}
/* phone menu */
.menu-panel { width: min(460px, 100%); }
.gmenu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gmenu__item { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); color: var(--ink); text-align: left; font-size: 14px; }
.gmenu__item span { display: grid; }
.gmenu__item small { color: var(--ink-3); font-size: 11.5px; }
.gmenu__item--leave { background: rgba(242, 184, 75, 0.16); border-color: rgba(242, 184, 75, 0.6); }
.gmenu__spells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.gmenu__spell { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); color: var(--ink); }
.gmenu__spell small { font-size: 12px; }
.gmenu__spell i { font: 500 10.5px var(--mono); color: #7dd3fc; font-style: normal; }
.gmenu__spell.is-on { border-color: var(--accent); background: rgba(242, 184, 75, 0.12); }
.menu-panel .modal__actions .btn { flex: 1; justify-content: center; padding: 11px 14px; font-size: 15px; }
/* modals on small screens: the dynamic viewport (browser bars), bigger close button, less padding */
@supports (height: 100dvh) { .modal__panel { max-height: calc(100dvh - 48px); } }
@media (max-width: 560px), (max-height: 500px) {
  .modal { padding: 10px; }
  .modal--dialog { padding-bottom: 12px; }
  .modal__panel { max-height: calc(100vh - 20px); }
  @supports (height: 100dvh) { .modal__panel { max-height: calc(100dvh - 20px); } }
  .modal__head { padding: 10px 12px 0; }
  .modal__title { font-size: 21px; }
  .modal__x { width: 40px; height: 40px; }
  .modal__body { padding: 10px 12px 14px; }
  .talk { gap: 10px; }
  .talk__choice { min-height: 44px; }
  .keys__row { grid-template-columns: 96px 1fr; font-size: 13px; }
  .ach-grid { grid-template-columns: 1fr 1fr; }
  .gear-grid { grid-template-columns: repeat(2, 1fr); }
  .dex { grid-template-columns: repeat(3, 1fr); }
  .runs li { grid-template-columns: 28px 70px 50px 1fr; font-size: 13px; }
  .fighter__card { min-width: 0; }
  .battle__field { padding: 10px; }
  .cmd { min-height: 46px; }
}
/* battle held sideways: the fighters on the left, the commands on the right, no scrolling */
@media (max-height: 500px) and (min-width: 600px) {
  .battle-panel { width: min(780px, 100%); }
  .battle { display: grid; grid-template-columns: 1.1fr 1fr; grid-template-rows: auto auto 1fr; column-gap: 12px; }
  .battle__top { grid-column: 1 / -1; margin-bottom: 4px; }
  .battle__field { grid-row: 2 / 4; gap: 4px; padding: 8px; }
  .battle__log { grid-column: 2; margin: 0 0 6px; min-height: 2.4em; font-size: 13.5px; }
  .battle__cmds { grid-column: 2; grid-template-columns: repeat(2, 1fr); align-content: start; }
  .fighter__sprite img { width: 48px; height: auto; }
  .battle-panel .modal__head { padding-top: 6px; }
  .battle-panel .modal__title { font-size: 18px; }
}
/* thing / door / portal plates: play mode only, and only within a few steps */
html:not(.is-play) .g__plate--thing, html:not(.is-play) .g__plate--portal { display: none !important; }
.g__plate--thing.is-far, .g__plate--portal.is-far { display: none !important; }
html.is-play .phud { opacity: 0; visibility: hidden; }
.hud-help { bottom: 92px; max-width: 520px; text-align: right; line-height: 1.9; }
@media (max-width: 1250px) { .hud-help { display: none; } }
@media (pointer: coarse) { html.is-play .egg-toasts { top: max(150px, var(--toast-top, 0px)); left: 10px; right: auto; width: min(300px, 72vw); } }

/* touch: bigger close buttons and rows, no keyboard hints, the boss bar and banner clear of the corners */
@media (pointer: coarse) {
  .modal__x { width: 44px; height: 44px; }
  .btn, .cmd, .talk__choice { min-height: 44px; }
  .btn--small { min-height: 40px; }
  .cmd kbd, .talk__choice kbd, .g__plate-hint kbd { display: none; }
  html.is-play .g__banner { top: 36%; max-width: calc(100vw - 32px); }
}
@media (pointer: coarse) and (orientation: portrait) {
  .hud-top { padding-top: calc(140px + var(--sa-t)); }
  .hud-boss { width: calc(100vw - 32px); }
  html.is-play .g__toasts { top: calc(196px + var(--sa-t)); }
}
@media (pointer: coarse) and (max-height: 500px) {
  .modal--dialog { place-items: center; }
  .modal--dialog .modal__panel { width: min(760px, 100%); }
  .talk { grid-template-columns: 64px 1fr; }
  .talk__face img { width: 56px; height: auto; }
  .talk__choices { grid-template-columns: 1fr 1fr; }
  .wmap2 { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .wmap2__map { max-width: min(46vw, calc(100dvh - 90px)); }
}
@media (pointer: coarse) and (max-height: 500px) { html.is-play .egg-toasts { top: calc(10px + var(--sa-t)); left: 50%; transform: translateX(-50%); width: min(300px, 40vw); } }

/* emotes (game3d/emotes.js): X opens a row above the action bar; on touch the o/ button under the top row opens a column */
.emotes { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 30; display: flex; gap: 6px; padding: 7px; border-radius: 14px; background: rgba(7, 10, 18, 0.88); border: 1px solid var(--line-2); pointer-events: auto; }
.emotes[hidden] { display: none; }
.emotes__btn { position: relative; display: grid; justify-items: center; gap: 1px; width: 64px; padding: 6px 2px 5px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); color: var(--ink); touch-action: none; -webkit-tap-highlight-color: transparent; }
.emotes__btn:hover { border-color: var(--accent); }
.emotes__btn b { font: 700 16px/20px var(--mono); color: var(--accent); pointer-events: none; }
.emotes__btn small { font-size: 11.5px; pointer-events: none; }
.emotes__btn kbd { position: absolute; left: 4px; top: 4px; font-size: 9.5px; line-height: 13px; padding: 0 3px; pointer-events: none; }
.touch__btn--emote { position: absolute; right: calc(8px + var(--sa-r)); top: calc(58px + var(--sa-t)); width: 44px; height: 44px; border-width: 1.5px; font: 700 14px var(--mono); }
.emotes--touch { left: auto; bottom: auto; transform: none; right: calc(8px + var(--sa-r)); top: calc(108px + var(--sa-t)); flex-direction: column; }
.emotes--touch kbd { display: none; }
@media (pointer: coarse) and (max-width: 380px) { .touch__btn--emote { width: 40px; height: 40px; top: calc(54px + var(--sa-t)); } .emotes--touch { top: calc(100px + var(--sa-t)); } }
@media (pointer: coarse) and (max-height: 500px) { .emotes--touch { flex-direction: row; top: calc(56px + var(--sa-t)); right: calc(58px + var(--sa-r)); } }
