@font-face {
  font-family: "Instrument Serif";
  src: url("/musicbox/instrument-serif.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --han: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", SimSun, serif;
  --edge: #101414;
  --space: clamp(1.2rem, 4.5vmin, 3rem);
  --left: max(var(--space), env(safe-area-inset-left));
  --right: max(var(--space), env(safe-area-inset-right));
  --top: max(var(--space), env(safe-area-inset-top));
  --bottom: max(var(--space), env(safe-area-inset-bottom));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: #233c40;
  color: white;
  font: 1rem/1.45 system-ui, sans-serif;
  -webkit-text-stroke: 2px var(--edge);
  paint-order: stroke fill;
  text-shadow: 0 1px 4px #10141480;
}
main {
  position: fixed;
  inset: 0;
  isolation: isolate;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #365357, #223c40 65%, #1c3034);
  touch-action: manipulation;
}
#print, #art { position: absolute; inset: 0; width: 100%; height: 100%; }
#print { object-fit: cover; pointer-events: none; }
#art { touch-action: none; }
#art:focus-visible { outline: none; }
#art:focus-visible + #mark::after {
  content: "";
  position: absolute;
  bottom: -.12rem;
  width: 1.15rem;
  height: 2px;
  border-radius: 1px;
  background: white;
  box-shadow: 0 0 0 1px var(--edge);
}
h1, h2, p { margin: 0; }
button, a {
  color: inherit;
  font: inherit;
  -webkit-text-stroke: inherit;
  paint-order: stroke fill;
  text-shadow: inherit;
  -webkit-tap-highlight-color: transparent;
}
button {
  min-height: 44px;
  padding: .35rem .75rem;
  border: 0;
  border-radius: .45rem;
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}
button:hover, button:focus-visible { background: #0d171845; }
button:focus-visible, a:focus-visible { outline: 2px solid white; outline-offset: 2px; }
#mark { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
#glyph {
  display: block;
  font: 600 clamp(8rem, 36vmin, 19rem)/1 var(--han);
  -webkit-text-stroke: .032em #101414;
}
main:is([data-phase="scene"], [data-phase="meaning"]) #mark {
  inset: var(--top) auto auto var(--left);
}
main:is([data-phase="scene"], [data-phase="meaning"]) #glyph { font-size: clamp(3rem, 9vmin, 5rem); }
#reveal {
  position: absolute;
  bottom: var(--bottom);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}
kbd {
  display: inline-block;
  padding: .02em .32em;
  border: 1px solid #fffc;
  border-radius: .27em;
  box-shadow: 0 0 0 1px #10141491;
  font: 550 .77em/1.25 system-ui, sans-serif;
  vertical-align: .08em;
}
#reveal kbd { margin-left: .35rem; }
.review {
  position: absolute;
  left: var(--left);
  right: var(--right);
  bottom: var(--bottom);
  max-width: 32rem;
  pointer-events: none;
}
#answer {
  max-height: calc(100dvh - var(--top) - var(--bottom) - 9rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  pointer-events: auto;
}
#pinyin { font-size: clamp(1.05rem, 2.5vmin, 1.35rem); }
#meaning, #rest h2 {
  font: 400 clamp(2.9rem, 7.5vmin, 4.8rem)/1.08 var(--serif);
  letter-spacing: -.025em;
  -webkit-text-stroke-width: .065em;
}
#meaning:focus, #rest h2:focus { outline: none; }
#note { margin: .5rem 0; max-width: 46ch; font-size: clamp(1rem, 2vmin, 1.12rem); text-wrap: pretty; }
.example { display: flex; align-items: baseline; flex-wrap: wrap; gap: .45em; }
#example-hanzi { font: 600 1.45rem/1.3 var(--han); }
#ratings { display: flex; gap: clamp(.15rem, 1.6vw, 1rem); margin-top: .85rem; }
#ratings button { display: grid; min-width: 4.8rem; align-content: center; justify-items: start; pointer-events: auto; }
#ratings button:first-child { margin-left: -.75rem; }
#ratings small { display: block; font-size: .78rem; font-weight: 450; }
#ratings kbd { margin-right: .06rem; }
.status {
  position: absolute;
  top: var(--top);
  right: var(--right);
  max-width: min(60%, 22rem);
  font-size: .87rem;
  text-align: right;
  pointer-events: none;
}
.status button { display: block; margin-left: auto; text-decoration: underline; pointer-events: auto; }
[data-waiting] #paint-state, #scene-fallback, #rest, noscript {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(80%, 30rem);
  text-align: center;
}
[data-waiting] #paint-state, #scene-fallback { font: 400 clamp(1.6rem, 4vmin, 2.4rem)/1.2 var(--serif); }
#rest p { margin-top: .65rem; }
#rest button { margin-top: .85rem; }
#rest a { display: block; width: fit-content; margin: .75rem auto 0; font-size: .9rem; }
.sr-only { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
@media (hover: none) { #reveal kbd { display: none; } }
@media (max-height: 450px) {
  .review { max-width: min(80%, 36rem); }
  main[data-phase="meaning"] #mark { inset: var(--top) var(--right) auto auto; }
  main[data-phase="meaning"] .status { top: var(--top); right: calc(var(--right) + 4rem); }
  #answer { max-height: calc(100dvh - var(--top) - var(--bottom) - 4rem); }
  #meaning { font-size: 2.5rem; }
  #ratings { margin-top: .3rem; }
}
