/* muonline-web shell — dark fantasy chrome around the untouched 0.97k canvas */

:root {
  --bg: #06080c;
  --panel: #0e1420;
  --line: #1d2a3f;
  --ink: #dbe6f5;
  --muted: #7e8ea6;
  --gold: #c9a227;
  --gold-soft: #e8c766;
  --ok: #34d399;
  --bad: #f87171;
  --bar: 34px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── boot overlay ───────────────────────────────────────────────────────── */

.boot {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, #16233a 0%, transparent 60%),
    radial-gradient(800px 400px at 50% 110%, #1a1206 0%, transparent 60%),
    var(--bg);
  transition: opacity .45s ease, visibility .45s ease;
}

.boot.done { opacity: 0; visibility: hidden; pointer-events: none; }

.boot-card { width: min(460px, 100%); text-align: center; }

.boot-mark {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(48px, 12vw, 78px);
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1;
  color: var(--gold-soft);
  text-shadow: 0 0 42px rgba(201, 162, 39, .45);
}

.boot-mark span { color: #9fb3cc; font-size: .55em; letter-spacing: .2em; margin-left: .12em; }

.boot-sub {
  margin: 10px 0 26px;
  color: var(--muted);
  font-size: 14px;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.boot-bar {
  height: 4px;
  border-radius: 999px;
  background: #16202f;
  overflow: hidden;
}

.boot-fill {
  height: 100%;
  width: 2%;
  border-radius: 999px;
  background: linear-gradient(90deg, #8a6a12, var(--gold-soft));
  transition: width .3s ease;
}

.boot-msg { margin: 16px 0 4px; font-size: 14px; color: var(--ink); }
.boot-detail { margin: 0; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── top bar ────────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--bar);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  background: linear-gradient(#101827, #0a0f18);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.topbar-brand {
  font-family: Georgia, serif;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--gold-soft);
}
.topbar-brand span { color: #9fb3cc; font-size: .8em; margin-left: .1em; }

.conn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}
.conn::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}
.conn.ok { color: var(--ok); }
.conn.bad { color: var(--bad); }
.conn.busy { color: var(--gold-soft); }

.topbar-hint {
  margin-left: auto;
  color: #56657c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.keybtn {
  display: none;
  background: #16202f;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 30px; height: 24px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

/* ── canvas ─────────────────────────────────────────────────────────────── */

#canvas {
  display: block;
  position: fixed;
  left: 0;
  top: var(--bar);
  width: 100%;
  height: calc(100% - var(--bar));
  outline: none;
  border: 0;
  background: #000;
  image-rendering: pixelated;
  touch-action: none;
  cursor: none;
}

.fullscreen-btn {
  flex: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 8px;
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

.guest-save-button {
  border: 1px solid #c9a22788;
  border-radius: 6px;
  padding: 4px 10px;
  background: #17150f;
  color: var(--gold-soft);
  font: 700 13px/1.2 system-ui, sans-serif;
  cursor: pointer;
}

.client-actions {
  position: fixed;
  z-index: 45;
  inset: var(--bar) 0 0;
  pointer-events: none;
}

.client-actions button, .client-actions .guest-entry-message {
  position: absolute;
  pointer-events: auto;
}

.guest-save-button:hover, .account-primary:hover { filter: brightness(1.12); }
.guest-entry-message {
  transform: translate(-50%, 0);
  width: min(260px, 80vw);
  margin: 0;
  color: #ffe2ab;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
  text-shadow: 0 1px 3px #000;
}
.guest-entry-message:empty { display: none; }
.guest-save-button[hidden], .account-overlay[hidden], .account-message:empty { display: none !important; }

.guest-save-button {
  top: 4px;
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  min-height: 26px;
  border-color: #b8913b;
  border-radius: 2px;
  background: linear-gradient(#302719, #17130d);
  color: #f4d88b;
  box-shadow: inset 0 0 0 1px #f4d88b22, 0 2px 5px #000a;
  font: 700 12px/1.2 Georgia, "Times New Roman", serif;
}

.account-overlay {
  position: fixed;
  z-index: 90;
  inset: var(--bar) 0 0;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 24px;
  background: rgba(4, 5, 7, .86);
  backdrop-filter: blur(5px);
}

.account-card {
  width: min(440px, 100%);
  padding: clamp(22px, 5vw, 34px);
  border: 1px solid #88703c;
  border-radius: 4px;
  background: linear-gradient(145deg, #20201e, #101113 72%);
  box-shadow: 0 18px 70px #000b, inset 0 0 0 1px #ffffff0a;
}

.account-card h1, .account-card h2 {
  margin: 0;
  color: var(--gold-soft);
  font: 700 25px/1.2 Georgia, "Times New Roman", serif;
  text-align: center;
}

.account-kicker {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-align: center;
}

.account-description {
  margin: 12px 0 22px;
  color: #c0bdaf;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
}

.account-card label {
  display: block;
  margin: 14px 0 6px;
  color: #d7d2c5;
  font-size: 13px;
}

.account-card input {
  width: 100%;
  min-height: 42px;
  border: 1px solid #625d50;
  border-radius: 2px;
  padding: 9px 11px;
  outline: none;
  background: #08090a;
  color: #f4efe3;
  font: inherit;
}

.account-card input:focus { border-color: var(--gold-soft); box-shadow: 0 0 0 2px #c9a22725; }

.account-primary, .account-secondary {
  min-height: 42px;
  border: 1px solid #8b7137;
  border-radius: 3px;
  padding: 9px 16px;
  font: 700 14px Georgia, "Times New Roman", serif;
  cursor: pointer;
}

.account-primary { background: linear-gradient(#e3c870, #a98229); color: #17140c; }
.account-primary:disabled { opacity: .6; cursor: wait; }
.account-secondary { background: #171719; color: #d8d2c3; border-color: #55514a; }

.account-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 20px; }
.account-message { margin: 14px 0 0; color: #d7c17e; font-size: 13px; line-height: 1.5; text-align: center; }
.account-message.error { color: #ff9b91; }
.account-message.success { color: #b7dfa4; }

:root:fullscreen #canvas {
  top: 0;
  height: 100%;
}

:root:fullscreen .client-actions { top: 0; }
:root:fullscreen .account-overlay { top: 0; }
:root:fullscreen .guest-save-button { top: calc(var(--bar) + 12px); }

:root:fullscreen .topbar {
  background: transparent;
  border: 0;
  pointer-events: none;
}

:root:fullscreen .topbar > :not(button) { visibility: hidden; }
:root:fullscreen .topbar button { pointer-events: auto; }
:root:fullscreen .fullscreen-btn { margin-left: auto; }

/* ── touch controls ─────────────────────────────────────────────────────── */

/* ── reconnect notice ───────────────────────────────────────────────────── */

.reconnect {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 10, .82);
  backdrop-filter: blur(4px);
}

.reconnect[hidden] { display: none; }

.reconnect-card {
  width: min(400px, 100%);
  padding: 26px 24px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.reconnect-card h2 {
  margin: 0 0 10px;
  font: 700 20px Georgia, serif;
  letter-spacing: .04em;
  color: var(--gold-soft);
}

.reconnect-card p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.reconnect-card button {
  border: 0;
  border-radius: 9px;
  padding: 11px 24px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  color: #14100a;
  background: linear-gradient(#c9a227, #a5811a);
}

#muStick, #muRBtn, .keys { display: none; }

.keys {
  position: fixed;
  z-index: 45;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: min(680px, calc(100% - 16px));
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 4px;
  padding: 8px;
  border-radius: 12px;
  background: rgba(10, 15, 24, .94);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.keys.on { display: grid; }

.keys button {
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #131c2b;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.keys button.lit { background: var(--gold); color: #14100a; border-color: var(--gold-soft); }

@media (pointer: coarse), (max-width: 900px) {
  .keybtn { display: block; }
  .topbar-hint { display: none; }

  #muStick {
    display: block;
    position: fixed;
    left: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
    width: 104px;
    height: 104px;
    border-radius: 50%;
    border: 2px solid rgba(201, 162, 39, .35);
    background: rgba(10, 15, 24, .35);
    z-index: 44;
    touch-action: none;
  }

  #muStickKnob {
    position: absolute;
    left: 50%; top: 50%;
    width: 46px; height: 46px;
    margin: -23px 0 0 -23px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #e8c766, #8a6a12);
    box-shadow: 0 0 18px rgba(201, 162, 39, .45);
    pointer-events: none;
  }

  #muRBtn {
    display: block;
    position: fixed;
    right: 22px;
    bottom: calc(34px + env(safe-area-inset-bottom));
    width: 74px;
    height: 74px;
    border-radius: 50%;
    border: 2px solid rgba(201, 162, 39, .35);
    background: rgba(10, 15, 24, .45);
    color: var(--gold-soft);
    font-size: 28px;
    z-index: 44;
    touch-action: none;
  }

  #muRBtn.on { background: rgba(201, 162, 39, .35); }
}
