/* The Fire Dragon shell around the vendored game: title menu extras, the fallback credits window, text that is only for screen readers. */
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.menu-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; padding: 2rem; text-align: center; background: #050b12; color: var(--ink); z-index: 90; }
#title-notice { left: 0; right: 0; text-align: center; margin: 0; }
#credits-notice { margin: 0; color: var(--muted); font-size: .8rem; }
.level-card .kind-glyph { display: inline-block; margin-inline-end: .35em; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
@media (max-width: 760px) and (orientation: portrait) {
  .menu-pair { grid-template-columns: 1fr 1fr; }
}
@media (max-height: 520px) {
  /* a landscape phone: the logo and the intro on the left, the six menu buttons in a column on the right */
  .title-panel { width: min(820px, 96vw); max-height: 94vh; overflow: auto; padding: .6rem 1.4rem; margin-bottom: 0; display: grid; grid-template-columns: 1fr 1fr; column-gap: 1.6rem; align-content: center; align-content: safe center; text-align: left; }
  .title-panel > * { grid-column: 1; }
  .title-panel > .menu-actions { grid-column: 2; grid-row: 1 / span 5; align-self: center; }
  .logo { width: min(300px, 100%); margin: 0 0 .4rem; }
  .eyebrow { margin-bottom: .3rem; }
  .intro { margin: .2rem 0 .5rem; line-height: 1.4; font-size: .82rem; }
  .menu-actions { gap: .4rem; }
  .menu-actions button { padding: .2rem .6rem; min-height: 2.5rem; }
  .menu-pair { gap: .4rem; }
  .controls-summary { margin-top: .4rem; font-size: .68rem; }
  #title-notice { bottom: .3rem; }
}
/* on a touch layout the toast sits above the pad instead of covering it */
@media (pointer: coarse), (max-width: 760px) {
  #toast { bottom: calc(max(1rem, env(safe-area-inset-bottom)) + 132px); }
}

/* On a phone the stats box and the Hint / Pause box stack on the right in the normal flow instead of sitting at fixed offsets, so they never overlap, whatever height the painted frames add. */
@media (pointer: coarse), (max-width: 760px) {
  .hud:not(.hidden) { display: grid; grid-template-columns: minmax(0, 48vw) minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: .5rem; row-gap: .4rem; align-items: start; }
  .hud-left { grid-column: 1; grid-row: 1 / span 3; }
  .hud-center { position: static; grid-column: 2; grid-row: 1; justify-self: end; }
  .hud-right { position: static; grid-column: 2; grid-row: 2; justify-self: end; }
}

/* ---- painted chrome (assets/art/ui-*.webp, cut from the UI sheet) ------------------------------------------------------------------------- */
/* The title plate behind the title panel. */
.title-art.painted { background: url('./assets/art/title-plate.webp') center / cover no-repeat; opacity: 1; mix-blend-mode: normal; }
.title-art.painted::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 46%, rgba(2, 6, 14, .08) 0%, rgba(2, 6, 14, .5) 100%); }

/* The ending paintings, one per ending, under a veil that keeps the text readable. */
.ending-screen[data-ending] { background-size: cover; background-position: center; background-repeat: no-repeat; }

/* Panels: the painted frame (gold corners, cyan edge) around the dark glass. */
.glass { border: 14px solid transparent; border-image: url('./assets/art/ui-panel-frame.webp') 40 / 14px stretch; background: linear-gradient(150deg, rgba(13, 35, 49, .92), rgba(5, 13, 23, .9)); background-clip: padding-box; box-shadow: var(--shadow); }
.glass.compact { border-width: 9px; border-image-width: 9px; padding: .5rem .7rem; background-clip: border-box; }

/* Buttons. */
button { background: none; border: 10px solid transparent; border-width: 10px 16px; border-radius: 0; border-image: url('./assets/art/ui-button-normal.webp') 34 42 fill / 10px 16px stretch; padding: .15rem .5rem; min-height: 2.4rem; }
button:hover, button:focus-visible { border-image-source: url('./assets/art/ui-button-hover.webp'); filter: none; transform: translateY(-1px); }
button.primary { background: none; box-shadow: none; border-image-source: url('./assets/art/ui-button-primary.webp'); }
button:disabled { opacity: .42; }
.icon-button, .icon-button:hover, .icon-button:focus-visible { width: 44px; height: 44px; min-height: 0; padding: 0; border: 0; border-image: none; background: url('./assets/art/ui-close-button.webp') center / contain no-repeat; font-size: 1.4rem; line-height: 1; }
.icon-button:hover, .icon-button:focus-visible { filter: brightness(1.25); }
.tabs button.active { border-image-source: url('./assets/art/ui-button-primary.webp'); color: var(--ink); }
.level-card { border-image: none; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(180deg, rgba(34, 66, 83, .86), rgba(10, 26, 40, .92)); padding: .8rem 1rem; min-height: 142px; }
.level-card:hover, .level-card:focus-visible { border-image: none; border-color: rgba(98, 240, 230, .72); }
.hud-right button { border-width: 8px 12px; border-image-width: 8px 12px; padding: .05rem .3rem; min-height: 2rem; }
.touch button { border-width: 8px 10px; border-image-width: 8px 10px; width: 52px; height: 48px; min-height: 0; padding: 0; }
.touch button.wide { width: auto; }

/* The grade, the toast and the sliders. */
.grade { background: url('./assets/art/ui-badge-disc.webp') center / contain no-repeat; border: 0; box-shadow: none; width: 124px; height: 124px; }
#toast { background: none; border: 14px solid transparent; border-image: url('./assets/art/ui-toast-plate.webp') 44 54 fill / 14px 22px stretch; border-radius: 0; padding: .3rem 1rem; }
.settings input[type=range] { -webkit-appearance: none; appearance: none; height: 26px; background: url('./assets/art/ui-slider-track.webp') center / 100% 100% no-repeat; border: 0; padding: 0; }
.settings input[type=range]::-webkit-slider-runnable-track { background: transparent; height: 26px; }
.settings input[type=range]::-moz-range-track { background: transparent; height: 26px; }
.settings input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -1px; border: 0; background: url('./assets/art/ui-slider-knob.webp') center / contain no-repeat; }
.settings input[type=range]::-moz-range-thumb { width: 28px; height: 28px; border: 0; background: url('./assets/art/ui-slider-knob.webp') center / contain no-repeat; }

/* Integrity: a lit and an unlit crystal for each of the three hits. */
#integrity { display: inline-flex; gap: 2px; align-items: center; justify-content: center; min-height: 22px; }
#integrity .pip { display: inline-block; width: 15px; height: 22px; background: url('./assets/art/ui-integrity-full.webp') center / contain no-repeat; }
#integrity .pip.empty { background-image: url('./assets/art/ui-integrity-empty.webp'); }
.logo { height: auto; }

/* The ending text has to fit a 720 px tall window with its buttons: tighter sizes under 800 px of height. */
@media (max-height: 800px) {
  .ending-panel { padding: 1rem 1.6rem; }
  .ending-sigil { width: 52px; height: 52px; font-size: 1.6rem; margin: 0 auto .35rem; }
  .ending-panel h2 { font-size: clamp(1.5rem, 5vh, 2.3rem); margin: .15rem 0 .5rem; }
  .ending-body { font-size: .92rem; line-height: 1.5; margin: .3rem 0; }
  .ending-epilogue { font-size: .82rem; line-height: 1.45; margin: .3rem auto .5rem; }
  .ending-ledger { margin: .55rem 0; }
  .ending-ledger div { padding: .4rem; }
  .ending-panel p { margin-top: .3rem; margin-bottom: .3rem; }
  .ending-panel button { margin-top: .3rem; }
}

/* A landscape phone has no room above the pad: the toast goes to the top, between the two top panels. */
@media (max-height: 520px) {
  #toast { bottom: auto; top: 10px; max-width: min(400px, 46vw); font-size: .8rem; }
}

/* A panel taller than the window (a phone on its side) scrolls inside its screen instead of running off the edge, so every button stays reachable. */
.screen { overflow-y: auto; overscroll-behavior: contain; place-items: center; place-items: safe center; padding: min(4vw, 3vh); }

/* The result card on a landscape phone: the grade on the left, the text, the three numbers and the three buttons beside it. */
@media (max-height: 520px) {
  .modal.result { width: min(760px, 94vw); padding: .5rem 1.2rem; gap: .3rem .8rem; grid-template-columns: 130px repeat(3, 1fr); text-align: left; align-items: center; }
  .modal.result > * { grid-column: 2 / -1; margin: 0; }
  .modal.result > .grade { grid-column: 1; grid-row: 1 / span 5; width: 104px; height: 104px; margin: 0 auto; font-size: 2.6rem; }
  .modal.result > button { grid-column: auto; margin: 0; padding: .1rem .4rem; font-size: .8rem; }
  .modal.result h2 { font-size: 1.5rem; }
  .modal.result #result-copy { font-size: .85rem; line-height: 1.35; }
  .modal.result .result-stats { gap: .4rem; }
  .modal.result .result-stats div { padding: .35rem; }
}
