:root {
  --bg: #000;
  --panel: rgba(16, 14, 12, 0.92);
  --fg: #e8dcc4;
  --accent: #c9a24a;
  --muted: #9a8f7c;
  --error: #e06c5a;
}
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
}
#mu-stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
#canvas {
  display: block;
  outline: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: #000;
}
#canvas.no-cursor { cursor: none; }

/* Hidden text field at the game's text rect: invisible while idle, shows the preedit string
   while an IME composes so the user sees what they type in place. */
.mu-ime {
  position: absolute;
  z-index: 2;
  margin: 0;
  padding: 0 2px;
  border: 0;
  outline: none;
  resize: none;
  overflow: hidden;
  white-space: nowrap;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-family: inherit;
  line-height: 1;
}
/* Desktop module: clicks go through the hidden field to the canvas. It sits over the focused
   game text box, so the game never saw a click there, as it does natively (report 46, D3). The
   host gives the field the keyboard focus after every mousedown anyway. Touch keeps it tappable:
   tapping it is what opens the on-screen keyboard. */
html:not(.mu-touch) .mu-ime { pointer-events: none; }

.mu-ime.composing {
  color: #fff;
  background: rgba(0, 0, 0, 0.75);
  box-shadow: 0 0 0 1px var(--accent);
  caret-color: #fff;
  text-decoration: underline;
}

.mu-panel {
  position: absolute;
  z-index: 5;
  min-width: min(420px, 90vw);
  max-width: min(640px, 92vw);
  padding: 22px 26px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 74, 0.35);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.mu-title { font-size: 22px; font-weight: 600; color: var(--accent); margin-bottom: 10px; }
#mu-error .mu-title { color: var(--error); }
#mu-error ul { padding-left: 20px; }
.mu-small { font-size: 12px; color: var(--muted); word-break: break-word; white-space: pre-wrap; }
/* Loading screen (2026-10-16): the designer's art, full screen, with the bar and its label at
   the bottom. loading/marco.png is the 1200x108 frame; its inner channel holds loading/relleno.png
   (1003x34 at 97,41), revealed from the left by --p (0..100, host.js setProgress). */
#mu-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #000 url("loading/fondo.jpg") center / cover no-repeat;
  transition: opacity 0.35s ease-out;
}
#mu-loading.done { opacity: 0; pointer-events: none; }
.mu-load-bottom {
  position: absolute;
  left: 50%;
  bottom: max(5vh, env(safe-area-inset-bottom));
  width: min(62vw, 1100px, 110vh);
  transform: translateX(-50%);
  text-align: center;
}
.mu-load-bar {
  position: relative;
  width: 100%;
  aspect-ratio: 1200 / 108;
  background: url("loading/marco.png") center / 100% 100% no-repeat;
}
.mu-load-fill {
  --p: 0;
  position: absolute;
  left: 8.083%;
  top: 37.963%;
  width: 83.583%;
  height: 31.481%;
  background: url("loading/relleno.png") left center / 100% 100% no-repeat;
  clip-path: inset(0 calc(100% - var(--p) * 1%) 0 0);
  transition: clip-path 0.25s linear;
}
.mu-load-text {
  margin-top: 0.6em;
  font-family: "Cinzel", "Trajan Pro", "Times New Roman", Georgia, serif;
  font-size: clamp(12px, 1.25vw, 22px);
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: #e9e3d6;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 1px 2px #000;
}
.mu-load-detail {
  margin-top: 0.35em;
  min-height: 1.3em;
  font-size: clamp(10px, 0.8vw, 13px);
  letter-spacing: 0.06em;
  color: rgba(233, 227, 214, 0.6);
  text-shadow: 0 1px 2px #000;
}
.mu-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
@media (prefers-reduced-motion: reduce) { .mu-load-fill, #mu-loading { transition: none; } }

#mu-toast, #mu-hint {
  position: absolute;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid rgba(201, 162, 74, 0.5);
  border-radius: 6px;
  pointer-events: none;
}
#mu-toast { top: 16px; }
/* The reserved-keys hint carries a fullscreen button: the only clickable part of a toast. */
#mu-toast .mu-toast-action {
  pointer-events: auto;
  margin-left: 8px;
  font: inherit;
  color: inherit;
  background: rgba(201, 162, 74, 0.25);
  border: 1px solid rgba(201, 162, 74, 0.7);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}
#mu-hint { bottom: 16px; }
#mu-hud {
  position: absolute;
  z-index: 4;
  left: 6px;
  top: 6px;
  margin: 0;
  padding: 4px 6px;
  font: 11px/1.3 ui-monospace, Menlo, Consolas, monospace;
  color: #9f9;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
  white-space: pre;
}
#mu-hud:empty { display: none; }

/* Touch module (reports/32-mobile-web.md). */
.mu-touch, .mu-touch body { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
/* ?safearea=1: keep the canvas out of the notch and the home indicator (default: edge to edge, as native). */
.mu-safe-area #mu-stage {
  top: env(safe-area-inset-top, 0);
  right: env(safe-area-inset-right, 0);
  bottom: env(safe-area-inset-bottom, 0);
  left: env(safe-area-inset-left, 0);
}
/* The keyboard did not open by itself: the field over the game's text box shows where to tap. */
.mu-ime.tap-to-type { box-shadow: 0 0 0 2px var(--accent); background: rgba(201, 162, 74, 0.12); }
#mu-rotate {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  font-size: 18px;
  background: rgba(0, 0, 0, 0.92);
}
#mu-rotate[hidden] { display: none; }
/* An error page outranks the rotate prompt (the prompt is appended after #mu-error). */
#mu-error:not([hidden]) ~ #mu-rotate { display: none; }
.mu-rotate-icon { font-size: 56px; color: var(--accent); }
