/* Mason's World 2.0 — game UI. Warm parchment + lacquer accents, readable over any time of day. */
:root {
  --mw-ink: #2b2118;
  --mw-paper: #fbf3e2;
  --mw-paper-2: #f3e5c7;
  --mw-lacquer: #a8342a;
  --mw-gold: #d9a441;
  --mw-teal: #2a7f7a;
  --mw-glass: rgba(251, 243, 226, 0.88);
  --mw-shadow: 0 10px 30px rgba(20, 12, 4, 0.28), 0 2px 6px rgba(20, 12, 4, 0.2);
  --mw-r: 14px;
  --mw-font: 'Inter', system-ui, -apple-system, 'PingFang SC', 'Noto Sans SC', sans-serif;
  --mw-display: 'Instrument Serif', 'Songti SC', 'Noto Serif SC', Georgia, serif;
}
* { box-sizing: border-box; }
html, body.mw-body { margin: 0; height: 100%; overflow: hidden; background: #0d1424; color: var(--mw-ink); font-family: var(--mw-font); -webkit-tap-highlight-color: transparent; }
#mw-canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; touch-action: none; cursor: grab; }
#mw-canvas.is-dragging { cursor: grabbing; }
#mw-ui { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
#mw-ui > :not(.mw-hud) { pointer-events: auto; }
.is-hidden { display: none !important; }
kbd { display: inline-block; min-width: 1.7em; padding: 0.12em 0.45em; border-radius: 6px; background: var(--mw-ink); color: var(--mw-paper); font: 600 0.78rem/1.4 var(--mw-font); text-align: center; box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.15); }

/* crest */
.mw-crest { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, #c94a3b, var(--mw-lacquer) 60%, #6e1f18); box-shadow: 0 0 0 3px var(--mw-gold), 0 0 0 6px rgba(217, 164, 65, 0.25), var(--mw-shadow); }
.mw-crest span { color: #fde9b8; font: 700 30px/1 var(--mw-display); }
.mw-crest-sm { width: 30px; height: 30px; flex: none; border-radius: 50%; display: grid; place-items: center; background: var(--mw-lacquer); color: #fde9b8; font: 700 15px/1 var(--mw-display); box-shadow: 0 0 0 2px var(--mw-gold); }

/* loading + welcome */
.mw-loading, .mw-welcome { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; }
.mw-loading { background: radial-gradient(ellipse at 50% 35%, #2c3f63, #101828 70%); color: var(--mw-paper); }
.mw-welcome { background: linear-gradient(180deg, rgba(10, 14, 24, 0.05), rgba(10, 14, 24, 0.45)); }
.mw-loading-card, .mw-welcome-card { text-align: center; max-width: 520px; width: 100%; }
.mw-welcome-card { background: var(--mw-glass); backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2); border-radius: 22px; padding: 28px 30px 22px; box-shadow: var(--mw-shadow); border: 1px solid rgba(217, 164, 65, 0.45); animation: mw-rise 0.7s cubic-bezier(.2, .8, .2, 1) both; }
.mw-loading h1, .mw-welcome h1 { font: 400 clamp(2.2rem, 6vw, 3.2rem)/1 var(--mw-display); margin: 6px 0 2px; letter-spacing: 0.01em; }
.mw-sub { margin: 0 0 14px; font: italic 400 1.15rem/1.2 var(--mw-display); color: var(--mw-lacquer); }
.mw-loading .mw-sub { color: var(--mw-gold); }
.mw-tagline { margin: 0 auto 18px; max-width: 420px; line-height: 1.5; color: #4b3d30; }
.mw-bar { height: 6px; width: min(320px, 80vw); margin: 18px auto 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.mw-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mw-gold), #f6d48c); transition: width 0.3s ease; }
.mw-loading-status { font-size: 0.85rem; opacity: 0.75; margin: 0; }
.mw-btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; padding: 11px 22px; border-radius: 999px; border: 1px solid rgba(43, 33, 24, 0.2); background: #fff8ea; color: var(--mw-ink); font: 600 0.95rem/1 var(--mw-font); cursor: pointer; text-decoration: none; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.mw-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(20, 12, 4, 0.18); }
.mw-btn-primary { background: linear-gradient(180deg, #c0473a, var(--mw-lacquer)); color: #fff6e2; border-color: #7e2219; box-shadow: 0 4px 0 #6e1f18, 0 8px 18px rgba(110, 31, 24, 0.35); font-size: 1.05rem; padding: 13px 30px; }
.mw-btn-primary:hover { box-shadow: 0 5px 0 #6e1f18, 0 12px 22px rgba(110, 31, 24, 0.4); }
.mw-btn:focus-visible, .mw-chip:focus-visible, .mw-choice:focus-visible { outline: 3px solid var(--mw-gold); outline-offset: 2px; }
.mw-controls { margin: 18px 0 4px; text-align: left; }
.mw-controls summary { cursor: pointer; font-weight: 600; font-size: 0.85rem; color: #6b5a48; text-align: center; list-style: none; }
.mw-controls summary::-webkit-details-marker { display: none; }
.mw-controls summary::after { content: ' ▾'; font-size: 0.75em; }
.mw-controls[open] summary::after { content: ' ▴'; }
.mw-keys { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin-top: 10px; font-size: 0.82rem; }
.mw-key { display: flex; align-items: center; gap: 8px; }
.mw-key kbd { min-width: 4.8em; }
.mw-welcome-links { display: flex; justify-content: center; gap: 18px; margin-top: 14px; font-size: 0.88rem; }
.mw-link { color: #5b4a3a; text-decoration: none; border-bottom: 1px dashed rgba(91, 74, 58, 0.5); }
.mw-link:hover { color: var(--mw-lacquer); }

/* HUD */
.mw-hud { position: fixed; inset: 0; pointer-events: none; }
.mw-hud > * { pointer-events: auto; }
.mw-top-left { position: absolute; top: 14px; left: 14px; }
.mw-brand { display: flex; align-items: center; gap: 10px; padding: 7px 14px 7px 8px; border-radius: 999px; background: var(--mw-glass); box-shadow: var(--mw-shadow); text-decoration: none; color: var(--mw-ink); backdrop-filter: blur(8px); }
.mw-brand strong { display: block; font: 400 1.15rem/1 var(--mw-display); }
.mw-brand small { display: block; font-size: 0.72rem; color: var(--mw-teal); font-weight: 600; min-height: 0.9em; }
.mw-top-right { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: calc(100vw - 260px); }
.mw-chip { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px; border-radius: 999px; border: 0; background: var(--mw-glass); color: var(--mw-ink); font: 600 0.82rem/1 var(--mw-font); cursor: pointer; text-decoration: none; box-shadow: var(--mw-shadow); backdrop-filter: blur(8px); transition: background 0.15s; }
.mw-chip:hover { background: #fff; }
.mw-icon { width: 36px; padding: 0; justify-content: center; }
.mw-classic { background: var(--mw-ink); color: var(--mw-paper); }
.mw-classic:hover { background: #46362a; }
.mw-time { display: flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--mw-glass); box-shadow: var(--mw-shadow); backdrop-filter: blur(8px); }
.mw-time .mw-chip { box-shadow: none; background: transparent; height: 30px; padding: 0 10px; }
.mw-time .mw-chip.is-active { background: var(--mw-ink); color: var(--mw-paper); }
.mw-minimap { position: absolute; right: 18px; bottom: 18px; width: 180px; height: 180px; border-radius: 50%; box-shadow: 0 0 0 4px var(--mw-paper), 0 0 0 6px var(--mw-gold), var(--mw-shadow); overflow: hidden; cursor: pointer; }
.mw-minimap canvas { width: 100%; height: 100%; display: block; }
.mw-n { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font: 700 0.7rem/1 var(--mw-font); color: var(--mw-paper); background: var(--mw-lacquer); border-radius: 50%; width: 18px; height: 18px; display: grid; place-items: center; }
.mw-prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: rgba(27, 21, 15, 0.82); color: var(--mw-paper); font-weight: 600; font-size: 0.95rem; display: flex; gap: 10px; align-items: center; box-shadow: var(--mw-shadow); animation: mw-pop 0.25s ease both; white-space: nowrap; }
.mw-prompt kbd { background: var(--mw-gold); color: var(--mw-ink); }
.mw-toast { position: absolute; top: 15vh; left: 50%; transform: translateX(-50%); text-align: center; pointer-events: none; color: #fff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55), 0 0 2px rgba(0, 0, 0, 0.6); }
.mw-toast small { display: block; font: 600 0.8rem/1 var(--mw-font); letter-spacing: 0.32em; text-transform: uppercase; color: #fde9b8; margin-bottom: 8px; }
.mw-toast strong { display: block; font: 400 clamp(2rem, 5vw, 3rem)/1.05 var(--mw-display); }
.mw-toast::after { content: ''; display: block; width: 160px; height: 2px; margin: 12px auto 0; background: linear-gradient(90deg, transparent, #fde9b8, transparent); }
.mw-toast.is-anim { animation: mw-toast 4.2s ease both; }
.mw-hud.is-talking .mw-minimap, .mw-hud.is-talking .mw-stick, .mw-hud.is-talking .mw-touch-btns { opacity: 0; pointer-events: none; }

/* dialogue */
.mw-dialogue { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); width: min(720px, calc(100vw - 24px)); background: var(--mw-paper); border-radius: 18px; padding: 18px 22px 16px; box-shadow: var(--mw-shadow); border: 1px solid rgba(217, 164, 65, 0.55); animation: mw-rise 0.3s ease both; }
.mw-dialogue::before { content: ''; position: absolute; inset: 6px; border-radius: 13px; border: 1px solid rgba(168, 52, 42, 0.18); pointer-events: none; }
.mw-dlg-head { position: absolute; top: -16px; left: 20px; display: flex; align-items: baseline; gap: 10px; padding: 6px 14px; border-radius: 10px; background: var(--mw-lacquer); color: #fff3dc; box-shadow: 0 4px 10px rgba(110, 31, 24, 0.3); }
.mw-dlg-name { font: 400 1.2rem/1 var(--mw-display); }
.mw-dlg-role { font-size: 0.75rem; opacity: 0.85; }
.mw-dlg-text { margin: 12px 0 12px; font-size: 1.02rem; line-height: 1.55; min-height: 3.1em; }
.mw-dlg-choices { display: flex; flex-direction: column; gap: 6px; }
.mw-choice { text-align: left; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(43, 33, 24, 0.12); background: #fffaf0; font: 500 0.95rem/1.3 var(--mw-font); color: var(--mw-ink); cursor: pointer; transition: background 0.12s, transform 0.12s; }
.mw-choice:hover, .mw-choice:focus-visible { background: #fff0d2; transform: translateX(3px); }
.mw-choice-n { flex: none; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: var(--mw-ink); color: var(--mw-paper); font-size: 0.75rem; font-weight: 700; }
.mw-choice i { margin-left: auto; font-size: 0.75rem; color: var(--mw-teal); }

/* panels */
.mw-panel { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(12, 10, 8, 0.45); padding: 16px; animation: mw-fade 0.2s ease both; }
.mw-panel-card { position: relative; width: min(760px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--mw-paper); border-radius: 20px; padding: 22px 26px; box-shadow: var(--mw-shadow); border: 1px solid rgba(217, 164, 65, 0.5); }
.mw-panel-card h2 { font: 400 2rem/1 var(--mw-display); margin: 0 0 14px; }
.mw-panel-card h3 { font: 600 0.82rem/1 var(--mw-font); letter-spacing: 0.14em; text-transform: uppercase; color: var(--mw-lacquer); margin: 20px 0 10px; }
.mw-panel-card h3 small { color: #8a7a68; letter-spacing: 0; margin-left: 6px; }
.mw-panel-x { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #efe2c6; cursor: pointer; font-size: 1rem; }
.mw-bigmap { width: 100%; height: auto; aspect-ratio: 1; border-radius: 14px; display: block; box-shadow: inset 0 0 0 2px rgba(43, 33, 24, 0.15); }
.mw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mw-list li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; background: #f6ead0; color: #8a7a68; }
.mw-list li.is-done { background: #fff8e8; color: var(--mw-ink); }
.mw-list li.is-done i { color: var(--mw-teal); }
.mw-list a { color: inherit; }
.mw-menu-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mw-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed rgba(43, 33, 24, 0.12); }
.mw-seg { display: inline-flex; background: #efe2c6; border-radius: 999px; padding: 3px; }
.mw-seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 999px; font: 600 0.82rem/1 var(--mw-font); cursor: pointer; color: var(--mw-ink); }
.mw-seg button.is-active { background: var(--mw-ink); color: var(--mw-paper); }
.mw-fine { margin-top: 18px; font-size: 0.8rem; }
.mw-linkbtn { border: 0; background: none; color: #8a5a48; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* touch */
.mw-stick, .mw-touch-btns { display: none; }
.is-touch .mw-stick { display: block; position: absolute; left: 26px; bottom: 30px; width: 124px; height: 124px; border-radius: 50%; background: rgba(251, 243, 226, 0.22); border: 2px solid rgba(251, 243, 226, 0.55); touch-action: none; }
.mw-stick-knob { position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px; border-radius: 50%; background: var(--mw-paper); box-shadow: var(--mw-shadow); }
.is-touch .mw-touch-btns { display: grid; position: absolute; right: 18px; bottom: 26px; grid-template-columns: repeat(3, auto); gap: 10px; align-items: end; }
.mw-tbtn { width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--mw-glass); box-shadow: var(--mw-shadow); font-size: 1.25rem; color: var(--mw-ink); touch-action: manipulation; }
.mw-tbtn.is-on { background: var(--mw-gold); }
.mw-tbtn-sm { width: 46px; height: 46px; font-size: 1rem; }
.is-touch .mw-minimap { top: 66px; bottom: auto; right: 12px; width: 108px; height: 108px; }
.is-touch .mw-prompt { bottom: 170px; }
.is-touch .mw-time span, .mw-classic span, .mw-world span { display: inline; }

@media (max-width: 860px) {
  .mw-time span { display: none; }
  .mw-time .mw-chip { padding: 0 9px; }
  .mw-top-right { max-width: calc(100vw - 80px); gap: 6px; }
  .mw-classic span, .mw-world span { display: none; }
  .mw-brand strong { font-size: 1rem; }
  .mw-brand small { font-size: 0.68rem; }
  .is-touch .mw-time span { display: none; }
}
@media (max-width: 560px) {
  .mw-top-left { top: 10px; left: 10px; }
  .mw-top-right { top: 10px; right: 10px; }
  .mw-brand span:last-child { display: none; }
  .mw-brand { padding: 4px; }
  .is-touch .mw-minimap { top: 100px; width: 96px; height: 96px; }
  .mw-keys { grid-template-columns: 1fr; }
  .mw-welcome-card { padding: 22px 18px 18px; }
  .mw-dialogue { bottom: 12px; padding: 16px 16px 12px; }
  .mw-dlg-text { font-size: 0.95rem; }
}

.mw-fps { position: fixed; left: 12px; bottom: 12px; z-index: 5; padding: 4px 8px; border-radius: 6px; background: rgba(0, 0, 0, 0.6); color: #9f9; font: 12px/1.3 ui-monospace, monospace; pointer-events: none; }
.mw-fallback { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; background: #101828; color: var(--mw-paper); z-index: 10; }
.mw-fallback a { color: var(--mw-gold); }
.mw-fallback h1, .mw-fallback p { max-width: 34rem; margin-inline: auto; line-height: 1.5; }
[hidden] { display: none !important; }

@keyframes mw-rise { from { opacity: 0; transform: translate(var(--tx, 0), 14px); } to { opacity: 1; transform: translate(var(--tx, 0), 0); } }
.mw-dialogue { --tx: -50%; }
@keyframes mw-pop { from { opacity: 0; transform: translate(-50%, 6px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes mw-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mw-toast { 0% { opacity: 0; transform: translate(-50%, 8px); } 10% { opacity: 1; transform: translate(-50%, 0); } 80% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
