/* ==========================================================
   ENG 跑酷 遊戲介面主題 — 卡通風格
   配合 Kenney 美術：粗深色描邊、實心錯位陰影、圓潤粗體字、扁平飽和色
   載入順序：放在所有其他 CSS 之後
   ========================================================== */

:root {
  /* --- 色彩 --- */
  --ink: #1d2340;            /* 描邊與主要文字 */
  --ink-soft: #3a4166;
  --paper: #fff8ea;          /* 面板底色 */
  --paper-2: #ffefd2;
  --white: #ffffff;
  --sky: #bfe6ff;
  --sky-2: #8fd0fb;

  --c-sky: #42b0f5;
  --c-pink: #ff7bab;
  --c-grass: #74cc45;
  --c-sun: #ffc93c;
  --c-red: #ff5f5f;
  --c-grape: #a07cf0;
  --c-blue: #5b8cf5;

  --text: var(--ink);
  --text-dim: #5d6487;
  --text-mute: #8a90ad;

  /* 舊變數名稱（部分 JSX 行內樣式仍引用） */
  --nx-cyan: var(--c-sky);
  --nx-magenta: var(--c-pink);
  --nx-lime: var(--c-grass);
  --nx-amber: var(--c-sun);
  --nx-red: var(--c-red);
  --nx-violet: var(--c-grape);
  --nx-blue: var(--c-blue);
  --nx-text: var(--ink);
  --nx-text-dim: var(--text-dim);
  --nx-text-mute: var(--text-mute);
  --nx-line: rgba(29, 35, 64, 0.18);
  --nx-line-strong: var(--ink);
  --nx-surface-solid: var(--paper);

  /* --- 字體 --- */
  --font-round: "Fredoka", "Noto Sans TC", ui-rounded, system-ui, sans-serif;
  --font-body: "Noto Sans TC", "Fredoka", system-ui, sans-serif;
  --nx-font-display: var(--font-round);
  --nx-font-ui: var(--font-body);
  --nx-font-mono: var(--font-round);

  /* --- 形狀 --- */
  --bw: 3px;                 /* 描邊粗細 */
  --r-lg: 22px;
  --r-md: 14px;
  --r-sm: 10px;
  --lift: 5px;               /* 實心陰影高度 */
  --nx-ease: cubic-bezier(.34, 1.4, .64, 1);

  color-scheme: light;
}

/* 帶描邊的卡通文字（白字黑邊） */
.toon-text,
.nx-brand__en,
.nx-loader__logo {
  color: var(--white);
  text-shadow:
    -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink),
    0 -2px 0 var(--ink), 0 2px 0 var(--ink), -2px 0 0 var(--ink), 2px 0 0 var(--ink),
    0 5px 0 var(--ink);
}

/* ---------- 頁面背景：天空 + 點點 ---------- */
html, body {
  background-color: var(--sky) !important;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.55) 2px, transparent 2.5px),
    linear-gradient(180deg, #a9dcff 0%, #d7f0ff 70%, #e9f8ff 100%) !important;
  background-size: 28px 28px, 100% 100% !important;
  background-attachment: fixed !important;
  color: var(--text);
  font-family: var(--font-body) !important;
}

::selection { background: var(--c-sun); color: var(--ink); }

* { scrollbar-width: thin; scrollbar-color: var(--ink-soft) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--ink-soft); border-radius: 10px; border: 2px solid var(--paper); }
*::-webkit-scrollbar-track { background: transparent; }

/* ==========================================================
   基礎元件
   ========================================================== */

/* ---------- 面板 ---------- */
.nx-panel {
  --accent: var(--c-sky);
  position: relative;
  color: var(--text);
  background:
    linear-gradient(var(--accent), var(--accent)) top / 100% 10px no-repeat,
    var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: 0 8px 0 var(--ink), 0 20px 40px rgba(29, 35, 64, 0.3);
}

.nx-pop { animation: nx-pop .45s var(--nx-ease) both; }
@keyframes nx-pop {
  0% { opacity: 0; transform: translateY(30px) scale(.9); }
  100% { opacity: 1; transform: none; }
}

/* ---------- 遮罩 ---------- */
.nx-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  /* 部分視窗渲染在 .canvas-wrap 內，而它在選關時設為 pointer-events:none，這裡必須恢復可點擊 */
  pointer-events: auto;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background: rgba(29, 35, 64, 0.55);
  animation: nx-fade .2s ease both;
}
@keyframes nx-fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- 標題（彩色名牌） ---------- */
.nx-title {
  --accent: inherit;
  display: inline-block;
  margin: 0;
  padding: .18em .7em .22em;
  font-family: var(--font-body);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: .02em;
  color: var(--ink);
  background: var(--accent, var(--c-sun));
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-1.5deg);
}
.nx-title--accent { /* 與 .nx-title 相同，保留類別名稱相容 */ }

/* 小標籤（欄位名稱等） */
.nx-eyebrow,
.nx-label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}
.nx-sub { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text-dim); }
.nx-sub b, .nx-sub strong { color: var(--ink); }
.nx-mute { font-size: 13px; color: var(--text-mute); }

.nx-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  margin: 6px 0 20px;
}
.nx-header__icon {
  font-size: 46px;
  line-height: 1;
  animation: nx-bob 1.8s ease-in-out infinite;
}
@keyframes nx-bob { 50% { transform: translateY(-6px) rotate(-4deg); } }

/* ---------- 按鈕（立體果凍） ---------- */
.nx-btn {
  --accent: var(--c-sky);
  --shade: color-mix(in srgb, var(--accent) 62%, var(--ink));
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45em;
  min-height: 42px;
  padding: .6em 1.25em .55em;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  color: var(--ink);
  background: var(--accent);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: inset 0 -5px 0 var(--shade), inset 0 3px 0 rgba(255, 255, 255, 0.45), 0 var(--lift) 0 var(--ink);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.nx-btn:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); box-shadow: inset 0 -5px 0 var(--shade), inset 0 3px 0 rgba(255, 255, 255, 0.45), 0 calc(var(--lift) + 1px) 0 var(--ink); }
.nx-btn:active:not(:disabled) { transform: translateY(var(--lift)); box-shadow: inset 0 -2px 0 var(--shade), inset 0 3px 0 rgba(255, 255, 255, 0.35), 0 0 0 var(--ink); }
.nx-btn:focus-visible { outline: 3px solid var(--c-blue); outline-offset: 4px; }
.nx-btn:disabled,
.nx-btn[aria-disabled="true"] { filter: grayscale(.9) opacity(.6); cursor: not-allowed; }

/* 次要按鈕：白底 + 彩色字框 */
.nx-btn--ghost {
  background: var(--white);
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--accent) 35%, var(--white)), 0 var(--lift) 0 var(--ink);
}
.nx-btn--ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 18%, var(--white)); box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--accent) 45%, var(--white)), 0 calc(var(--lift) + 1px) 0 var(--ink); }
.nx-btn--ghost:active:not(:disabled) { box-shadow: 0 0 0 var(--ink); }

.nx-btn--sm { --lift: 4px; min-height: 36px; padding: .5em .95em .45em; font-size: 14px; border-radius: var(--r-sm); }
.nx-btn--lg { --lift: 6px; min-height: 56px; padding: .7em 1.8em .65em; font-size: 20px; border-radius: 18px; }
.nx-btn--block { display: flex; width: 100%; }
.nx-btn--icon { padding: 0; width: 40px; min-width: 40px; }
.nx-btn .nx-k {
  padding: 2px 6px;
  font-family: var(--font-round);
  font-size: .7em;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 6px;
}
.nx-btn--pulse { animation: nx-wiggle 2.4s ease-in-out infinite; }
@keyframes nx-wiggle {
  0%, 80%, 100% { transform: none; }
  84% { transform: rotate(-3deg) scale(1.04); }
  88% { transform: rotate(3deg) scale(1.04); }
  92% { transform: rotate(-2deg); }
}

.nx-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }
.nx-actions--stack { flex-direction: column; align-items: stretch; }

/* ---------- 標籤 ---------- */
.nx-chip {
  --accent: var(--c-sky);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
  color: var(--ink);
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 2px 0 var(--ink);
}

.nx-kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 6px 2px;
  font-family: var(--font-round);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--ink);
}

/* ---------- 數據方塊 ---------- */
.nx-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.nx-stat {
  --accent: var(--c-sky);
  padding: 10px 8px 9px;
  text-align: center;
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--accent) 40%, var(--white)), 0 4px 0 var(--ink);
}
.nx-stat__icon { font-size: 20px; line-height: 1.2; }
.nx-stat__value { font-family: var(--font-round); font-size: 26px; font-weight: 700; color: var(--ink); }
.nx-stat__label { font-size: 12px; font-weight: 700; color: var(--text-dim); }

/* ---------- 提示框 ---------- */
.nx-callout {
  --accent: var(--c-sun);
  margin-bottom: 18px;
  padding: 12px 16px;
  text-align: center;
  color: var(--ink);
  background: color-mix(in srgb, var(--accent) 22%, var(--white));
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
}
.nx-callout strong,
.nx-callout__title { display: block; font-weight: 900; margin-bottom: 4px; }
.nx-callout p { margin: 0; color: var(--ink-soft); font-size: 14px; }

/* ---------- 輸入框 ---------- */
.nx-input,
.nx-panel input[type="text"],
.nx-panel input[type="number"],
.nx-panel input[type="password"],
.nx-panel input[type="email"],
.nx-panel select,
.nx-panel textarea {
  width: 100%;
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: inset 0 3px 0 rgba(29, 35, 64, 0.08);
  outline: none;
  transition: box-shadow .15s;
}
.nx-input:focus,
.nx-panel input:focus,
.nx-panel select:focus,
.nx-panel textarea:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-sky) 45%, transparent); }

/* ---------- 分頁 ---------- */
.nx-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  background: var(--paper-2);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
}
.nx-tab {
  flex: 1;
  padding: 9px 12px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 900;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.nx-tab:hover { color: var(--ink); }
.nx-tab.is-active { color: var(--ink); background: var(--c-sun); box-shadow: 0 0 0 2px var(--ink), 0 3px 0 2px var(--ink); }

/* ---------- 關閉按鈕 ---------- */
.nx-close {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  font-family: var(--font-round);
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  background: var(--c-red);
  border: var(--bw) solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--c-red) 60%, var(--ink)), 0 4px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s;
}
.nx-close:hover { transform: rotate(90deg) scale(1.05); }
.nx-close:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }

/* ---------- 進度條 ---------- */
.nx-progress {
  position: relative;
  height: 20px;
  padding: 3px;
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}
.nx-progress__bar {
  height: 100%;
  min-width: 8px;
  background: var(--c-grass);
  border-radius: 999px;
  box-shadow: inset 0 -4px 0 color-mix(in srgb, var(--c-grass) 60%, var(--ink)), inset 0 3px 0 rgba(255, 255, 255, 0.5);
  transition: width .3s ease;
}

/* ---------- 清單 ---------- */
.nx-list { display: flex; flex-direction: column; gap: 8px; }
.nx-row {
  --accent: var(--c-sky);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: 0 3px 0 var(--ink);
  transition: transform .12s;
}
.nx-row:hover { transform: translateY(-2px); }
.nx-row.is-me { background: color-mix(in srgb, var(--c-sun) 35%, var(--white)); }

.nx-divider { height: 0; margin: 16px 0; border: 0; border-top: 3px dashed rgba(29, 35, 64, 0.2); }

/* ==========================================================
   舊類別（.modal / .card / .btn / .choice / .hint）
   ========================================================== */
.modal {
  background: rgba(29, 35, 64, 0.55) !important;
  animation: nx-fade .2s ease both;
}

.card {
  --accent: var(--c-sky);
  position: relative;
  color: var(--text);
  background:
    linear-gradient(var(--accent), var(--accent)) top / 100% 10px no-repeat,
    var(--paper) !important;
  border: 4px solid var(--ink) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: 0 8px 0 var(--ink), 0 20px 40px rgba(29, 35, 64, 0.3) !important;
  padding: clamp(20px, 4vw, 30px) !important;
  animation: nx-pop .45s var(--nx-ease) both;
}
.card h2, .card h3 { font-family: var(--font-body); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 900;
  color: var(--ink);
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-sm);
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.choice {
  position: relative;
  padding: 14px 18px 14px 54px !important;
  font-family: var(--font-body);
  font-size: 17px !important;
  font-weight: 700;
  text-align: left;
  color: var(--ink) !important;
  background: var(--white) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s !important;
}
.choice:hover:not(:disabled) { background: color-mix(in srgb, var(--c-sun) 30%, var(--white)) !important; transform: translateY(-2px) !important; box-shadow: 0 6px 0 var(--ink); }
.choice:active:not(:disabled) { transform: translateY(4px) !important; box-shadow: 0 0 0 var(--ink); }

.hint { color: var(--text-mute) !important; }

/* ==========================================================
   遊戲頁面版面
   ========================================================== */
.nx-game {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(8px, 2vw, 24px) 22px;
  overflow: auto;
}

/* ---------- 頂部工具列 ---------- */
.nx-topbar {
  position: relative;
  z-index: 100;
  width: 100%;
  max-width: 1920px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: var(--r-lg);
  box-shadow: 0 6px 0 var(--ink);
}
.nx-topbar__left,
.nx-topbar__right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.nx-topbar__right { justify-content: flex-end; }

.nx-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  line-height: 1;
  transform: rotate(-2deg);
}
.nx-brand__en {
  font-family: var(--font-round);
  font-size: clamp(22px, 2.6vw, 30px);
  font-weight: 700;
  letter-spacing: .02em;
}
.nx-brand__zh {
  padding: 4px 10px 6px;
  font-family: var(--font-body);
  font-size: clamp(15px, 1.6vw, 19px);
  font-weight: 900;
  color: var(--ink);
  background: var(--c-sun);
  border: var(--bw) solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 3px 0 var(--ink);
}

.nx-keys {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
}
.nx-keys > span { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 聲音：工具列的靜音鈕＋音量面板 ---------- */
.nx-sound { position: relative; display: inline-flex; align-items: center; gap: 6px; }
.nx-sound__caret { font-size: .8em; transition: transform .15s; }
.nx-sound__open.is-open .nx-sound__caret { transform: rotate(180deg); }
.nx-sound__panel {
  position: absolute;
  top: calc(100% + 14px);
  right: 0;
  z-index: 200;
  width: min(300px, calc(100vw - 24px));
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-width: 3px;
  box-shadow: 0 5px 0 var(--ink), 0 14px 30px rgba(29, 35, 64, 0.25);
  animation: nx-pop .25s var(--nx-ease) both;
}
.nx-sound__head { display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 900; }
.nx-sound__x {
  width: 28px; height: 28px; padding: 0; flex: none;
  font-weight: 900; line-height: 1; color: var(--ink);
  background: var(--white); border: var(--bw) solid var(--ink); border-radius: 50%;
  cursor: pointer;
}
.nx-sound__x:hover { background: #ffe066; }

/* 開關 */
.nx-sound__switch {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px;
  font: inherit; font-weight: 900; color: var(--ink); text-align: left;
  background: var(--white); border: var(--bw) solid var(--ink); border-radius: var(--r-md);
  box-shadow: 0 3px 0 var(--ink);
  cursor: pointer;
}
.nx-sound__switch:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.nx-sound__switch:focus-visible { outline: 3px solid var(--c-blue); outline-offset: 3px; }
.nx-sound__switch-label { flex: 1; }
.nx-sound__track {
  position: relative; width: 46px; height: 26px; flex: none;
  background: #d9dbe6; border: var(--bw) solid var(--ink); border-radius: 999px;
  transition: background .15s;
}
.nx-sound__thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: var(--white); border: 2px solid var(--ink); border-radius: 50%;
  transition: transform .18s var(--nx-ease);
}
.nx-sound__switch.is-on .nx-sound__track { background: var(--c-grass); }
.nx-sound__switch.is-on .nx-sound__thumb { transform: translateX(20px); }
.nx-sound__state { width: 1.2em; font-size: 14px; }

/* 滑桿 */
.nx-sound__sliders { display: flex; flex-direction: column; gap: 10px; transition: opacity .15s; }
.nx-sound__sliders.is-muted { opacity: .5; }
.nx-sound__row { display: grid; grid-template-columns: 1fr 44px; grid-template-areas: "name value" "range range"; align-items: center; row-gap: 4px; cursor: pointer; }
.nx-sound__name { grid-area: name; font-size: 14px; font-weight: 700; }
.nx-sound__value { grid-area: value; font-family: var(--font-round); font-size: 14px; font-weight: 600; text-align: right; color: var(--text-dim); }
.nx-sound__row input[type="range"] {
  grid-area: range;
  width: 100%; height: 22px; margin: 0;
  background: transparent;
  -webkit-appearance: none; appearance: none;
  cursor: pointer;
}
.nx-sound__row input[type="range"]::-webkit-slider-runnable-track {
  height: 12px;
  background: linear-gradient(var(--c-grape), var(--c-grape)) 0 0 / var(--fill, 50%) 100% no-repeat, var(--white);
  border: 2px solid var(--ink); border-radius: 999px;
}
.nx-sound__row input[type="range"]::-moz-range-track { height: 8px; background: var(--white); border: 2px solid var(--ink); border-radius: 999px; }
.nx-sound__row input[type="range"]::-moz-range-progress { height: 8px; background: var(--c-grape); border: 2px solid var(--ink); border-radius: 999px; }
.nx-sound__row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -7px;
  background: var(--c-sun); border: var(--bw) solid var(--ink); border-radius: 50%;
  box-shadow: 0 2px 0 var(--ink);
}
.nx-sound__row input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--c-sun); border: var(--bw) solid var(--ink); border-radius: 50%;
  box-shadow: 0 2px 0 var(--ink);
}
.nx-sound__row input[type="range"]:focus-visible { outline: 3px solid var(--c-blue); outline-offset: 2px; border-radius: 999px; }

.nx-sound__foot { display: flex; align-items: center; gap: 8px; padding-top: 10px; border-top: 2px dashed rgba(29, 35, 64, 0.2); }
.nx-sound__foot .nx-mute { flex: 1; font-size: 12px; font-weight: 700; }
/* 窄螢幕：工具列會換行，面板改成固定在畫面上方置中，不會超出左邊 */
@media (max-width: 767px) {
  .nx-sound__panel { position: fixed; top: 72px; left: 12px; right: 12px; width: auto; max-width: 340px; margin: 0 auto; }
}

/* ---------- 遊戲畫布外框 ---------- */
.canvas-wrap {
  border: 5px solid var(--ink) !important;
  border-radius: 20px !important;
  box-shadow: 0 8px 0 var(--ink), 0 24px 50px rgba(29, 35, 64, 0.3) !important;
}

.nx-footer-hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 92%;
  margin: 0;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.5;
  color: var(--ink-soft);
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
  box-shadow: 0 4px 0 var(--ink);
}
.nx-footer-hint .nx-eyebrow {
  padding: 2px 10px;
  color: var(--ink);
  background: var(--c-sun);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.nx-footer-keys { display: none; align-items: center; gap: 5px; margin-left: 6px; padding-left: 12px; border-left: 3px dashed rgba(29, 35, 64, 0.2); white-space: nowrap; }
@media (max-width: 1500px) {
  .nx-keys { display: none; }
  .nx-footer-keys { display: inline-flex; }
}

/* ---------- 載入畫面 ---------- */
.nx-loader {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: grid;
  place-items: center;
  background:
    radial-gradient(rgba(255, 255, 255, 0.55) 2px, transparent 2.5px) 0 0 / 28px 28px,
    linear-gradient(180deg, #8fd0fb, #d7f0ff);
}
.nx-loader__box { width: min(420px, 86vw); text-align: center; }
.nx-loader__logo {
  font-family: var(--font-round);
  font-size: clamp(48px, 11vw, 80px);
  font-weight: 700;
  line-height: 1;
  transform: rotate(-3deg);
  animation: nx-bob 1.6s ease-in-out infinite;
}
.nx-loader__zh {
  display: inline-block;
  margin: 14px 0 26px;
  padding: 4px 16px 6px;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: .2em;
  color: var(--ink);
  background: var(--c-sun);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.nx-loader__status {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-soft);
}
.nx-loader__status b { font-family: var(--font-round); color: var(--ink); }

/* ---------- 玩家 HUD（右上角使用者按鈕） ---------- */
.nx-game .game-player-hud {
  background: var(--white) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
  box-shadow: 0 4px 0 var(--ink) !important;
  -webkit-backdrop-filter: none !important;
          backdrop-filter: none !important;
}
.nx-game .game-player-hud:hover { transform: translateY(-1px); background: color-mix(in srgb, var(--c-sun) 25%, var(--white)) !important; }
.nx-game .game-user-info-button { padding: 5px 12px 5px 6px; gap: 10px; }
.nx-game .game-user-info-button:hover { transform: none; }
.nx-game .game-user-avatar { width: 36px; height: 36px; border: 2px solid var(--ink) !important; box-shadow: none; }
.nx-game .game-user-name { color: var(--ink) !important; font-size: 14px !important; font-weight: 900; text-shadow: none; }
.nx-game .game-user-role { font-size: 11px !important; font-weight: 700; color: #2f8a12 !important; }
.nx-game .game-user-role.guest { color: #b07800 !important; }
.nx-game .game-user-role::before { box-shadow: none; }
.nx-game .dropdown-arrow { color: var(--ink); }

.user-dropdown-menu,
.game-dropdown-menu {
  background: var(--paper) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
  box-shadow: 0 6px 0 var(--ink), 0 16px 30px rgba(29, 35, 64, 0.25) !important;
  -webkit-backdrop-filter: none !important;
          backdrop-filter: none !important;
}
.dropdown-item { font-family: var(--font-body); font-size: 14px !important; font-weight: 700 !important; color: var(--ink) !important; }
.dropdown-item:hover { background: color-mix(in srgb, var(--c-sun) 40%, var(--white)) !important; padding-left: inherit; }
.dropdown-item.logout-item:hover { background: color-mix(in srgb, var(--c-red) 25%, var(--white)) !important; color: #b3261e !important; }
.dropdown-divider { height: 0 !important; background: none !important; border-top: 2px dashed rgba(29, 35, 64, 0.2); }

/* ---------- 行動裝置按鍵 ---------- */
.mobile-btn {
  background: var(--white) !important;
  border: 4px solid var(--ink) !important;
  border-radius: 50% !important;
  box-shadow: inset 0 -6px 0 #d7dbe9, 0 6px 0 var(--ink) !important;
  -webkit-backdrop-filter: none !important;
          backdrop-filter: none !important;
  opacity: .92;
}
.mobile-btn::before { display: none; }
.mobile-btn:active { transform: translateY(6px) !important; box-shadow: inset 0 -2px 0 #d7dbe9, 0 0 0 var(--ink) !important; }
.mobile-btn.jump-btn { background: var(--c-sun) !important; box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--c-sun) 60%, var(--ink)), 0 6px 0 var(--ink) !important; }
.mobile-btn.jump-btn .label { color: var(--ink); text-shadow: none; font-weight: 900; }

/* Four touch actions fit without overlapping movement and interaction. */
@media (max-width: 1023px), (max-height: 599px) {
  .mobile-controls-left, .mobile-controls-right { display: flex; align-items: center; gap: 8px; bottom: 1.5%; }
  .mobile-controls-left { left: 1.5%; }
  .mobile-controls-right { right: 1.5%; }
  .mobile-btn, .mobile-btn.jump-btn {
    width: clamp(48px, 12vw, 72px) !important;
    height: clamp(48px, 12vw, 72px) !important;
    flex: 0 0 auto; flex-direction: column; gap: 2px;
    font-size: 26px !important;
  }
  .mobile-btn .label, .mobile-btn.jump-btn .label { font-size: 12px !important; color: var(--ink); font-weight: 900; }
}

/* ==========================================================
   答題
   ========================================================== */
.nx-quiz-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin: 6px 0 16px;
  border-bottom: 3px dashed rgba(29, 35, 64, 0.18);
}
.nx-quiz-q {
  margin: 0 0 18px;
  font-size: clamp(22px, 4.6vw, 30px);
  font-weight: 900;
  line-height: 1.4;
  text-align: center;
  color: var(--ink);
}
.nx-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 12px;
}
.choice[data-key]::before {
  content: attr(data-key);
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  font-family: var(--font-round);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  background: var(--c-sky);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.nx-choice-grid .choice:nth-child(2)::before { background: var(--c-pink); }
.nx-choice-grid .choice:nth-child(3)::before { background: var(--c-grass); }
.nx-choice-grid .choice:nth-child(4)::before { background: var(--c-sun); }

/* 難度卡 */
.nx-diff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr));
  gap: 14px;
}
.nx-diff {
  --accent: var(--c-grass);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px 18px;
  text-align: left;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: 18px;
  box-shadow: inset 0 -8px 0 color-mix(in srgb, var(--accent) 45%, var(--white)), 0 5px 0 var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.nx-diff:hover { transform: translateY(-3px) rotate(-1deg); box-shadow: inset 0 -8px 0 color-mix(in srgb, var(--accent) 55%, var(--white)), 0 8px 0 var(--ink); }
.nx-diff:active { transform: translateY(5px); box-shadow: inset 0 -8px 0 color-mix(in srgb, var(--accent) 55%, var(--white)), 0 0 0 var(--ink); }
.nx-diff__tag {
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink);
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.nx-diff__name { font-size: 30px; font-weight: 900; line-height: 1.15; }
.nx-diff__theme { font-size: 14px; font-weight: 700; color: var(--text-dim); }
.nx-diff__reward {
  margin-top: 4px;
  padding-top: 8px;
  width: 100%;
  font-size: 14px;
  font-weight: 900;
  border-top: 2px dashed rgba(29, 35, 64, 0.2);
}

/* 答題回饋 */
.nx-feedback__mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 10px;
  font-family: var(--font-round);
  font-size: 44px;
  font-weight: 700;
  color: var(--white);
  background: var(--accent);
  border: 4px solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 -6px 0 color-mix(in srgb, var(--accent) 60%, var(--ink)), 0 5px 0 var(--ink);
  text-shadow: 0 3px 0 rgba(29, 35, 64, 0.35);
  animation: nx-mark-in .5s var(--nx-ease) both;
}
@keyframes nx-mark-in { 0% { transform: scale(0) rotate(-30deg); } 100% { transform: none; } }
.nx-feedback.is-wrong { animation: nx-pop .45s var(--nx-ease) both, nx-shake .4s .15s ease both; }
@keyframes nx-shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.nx-answer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
  padding: 12px;
  background: color-mix(in srgb, var(--c-grass) 25%, var(--white));
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
}
.nx-answer__label { font-size: 13px; font-weight: 700; color: var(--text-dim); }
.nx-answer__text { font-family: var(--font-round); font-size: 28px; font-weight: 700; color: var(--ink); }

/* ==========================================================
   關卡選擇
   ========================================================== */
.nx-stage-select {
  width: min(980px, 95vw);
  max-height: calc(100vh - 24px);
  padding: clamp(14px, 2.4vh, 28px) clamp(10px, 2vw, 24px) clamp(10px, 2vh, 20px);
  display: flex;
  flex-direction: column;
  overflow: visible; /* the close button sits on the corner; the body below scrolls */
}
.nx-stage-select__body { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; width: 100%; }
.nx-stage-select__head { margin-bottom: clamp(4px, 1vh, 12px); }
.nx-stage-select__title { font-size: clamp(24px, 4.4vh, 38px) !important; }
.nx-stage-select__meta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 14px; margin-top: 6px; }
.nx-stage-select__meta .nx-seed-total, .nx-stage-select__meta .nx-daily { margin-top: 0; }
.nx-stage-select__hint { margin: clamp(6px, 1vh, 12px) 0 0; text-align: center; font-size: 13px; }
.nx-stage-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 8px; }
.nx-stage-tab {
  padding: 4px 12px; font-weight: 900; font-size: 14px; color: var(--ink); background: var(--white);
  border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink); cursor: pointer;
}
.nx-stage-tab small { font-size: 12px; color: var(--text-dim); }
.nx-stage-tab.is-active { background: var(--c-sky); color: var(--white); }
.nx-stage-tab.is-active small { color: var(--white); }
.nx-stage-map__nodes { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 0; }
.nx-stage-select__tools { position: absolute; top: 18px; left: 18px; display: flex; gap: 8px; z-index: 2; }
.nx-stage-track { display: flex; align-items: center; justify-content: center; gap: clamp(8px, 2vw, 22px); width: 100%; }
.nx-stage-track__cards { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 2vw, 22px); padding: 14px 6px 20px; }

.nx-stage-card {
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ink);
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 20px;
  box-shadow: 0 6px 0 var(--ink);
  cursor: pointer;
  user-select: none;
  transition: transform .25s var(--nx-ease);
}
.nx-stage-card.is-empty { width: clamp(110px, 18vw, 170px); height: 1px; border: 0; box-shadow: none; background: none; pointer-events: none; }
.nx-stage-card.is-side { width: clamp(110px, 18vw, 170px); padding: 14px 10px 16px; opacity: .8; }
.nx-stage-track__cards > .nx-stage-card.is-side:first-child { transform: rotate(-5deg) scale(.92); }
.nx-stage-track__cards > .nx-stage-card.is-side:last-child  { transform: rotate(5deg) scale(.92); }
.nx-stage-card.is-side:hover { opacity: 1; }
.nx-stage-card.is-center {
  width: clamp(210px, 32vw, 290px);
  padding: 0 18px 22px;
  overflow: hidden;
  background:
    linear-gradient(var(--c-sky), var(--c-sky)) top / 100% 120px no-repeat,
    var(--white);
  animation: nx-pop .4s var(--nx-ease) both;
}
.nx-stage-card.is-center:hover { transform: translateY(-4px) rotate(-1deg); }

.nx-stage-card__label { font-size: 13px; font-weight: 900; color: var(--text-dim); }
.is-center .nx-stage-card__label {
  margin-top: 14px;
  padding: 2px 12px;
  color: var(--ink);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.nx-stage-card__no {
  font-family: var(--font-round);
  font-size: clamp(40px, 6vw, 56px);
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
}
.is-center .nx-stage-card__no {
  font-size: clamp(76px, 11vw, 104px);
  margin: 2px 0 6px;
  color: var(--white);
  text-shadow:
    -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink),
    0 -3px 0 var(--ink), 0 3px 0 var(--ink), -3px 0 0 var(--ink), 3px 0 0 var(--ink),
    0 7px 0 var(--ink);
}
.nx-stage-card__name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 900;
}
.is-center .nx-stage-card__name { margin-top: 8px; font-size: clamp(17px, 2.4vw, 21px); }
.nx-stage-card__best {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 4px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  background: var(--paper-2);
  border: 2px solid var(--ink);
  border-radius: 999px;
}
.nx-stage-card__best b { font-family: var(--font-round); font-size: 20px; font-weight: 700; color: var(--ink); }
.nx-stage-card__best b.is-none { color: var(--text-mute); }
.nx-stage-card__go { margin-top: 14px; }

.nx-arrow {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: clamp(44px, 6vw, 56px);
  height: clamp(44px, 6vw, 56px);
  font-size: clamp(16px, 2.4vw, 20px);
  color: var(--ink);
  background: var(--c-sun);
  border: var(--bw) solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--c-sun) 60%, var(--ink)), 0 4px 0 var(--ink);
  cursor: pointer;
}
.nx-arrow:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.nx-arrow:disabled { opacity: .35; cursor: not-allowed; }

.nx-dots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.nx-dot {
  width: 14px;
  height: 14px;
  padding: 0;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  transition: all .2s;
}
.nx-dot.is-active { width: 34px; border-radius: 999px; background: var(--c-sun); }

.nx-stage-no {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  font-family: var(--font-round);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  background: var(--accent, var(--c-sky));
  border: 2px solid var(--ink);
  border-radius: 50%;
}

@media (max-width: 600px) {
  .nx-stage-card.is-side, .nx-stage-card.is-empty { display: none; }
}

/* 世界地圖選關：關卡特色、字母、種子、上鎖 */
.nx-seed-total {
  display: inline-block; margin-top: 6px; padding: 3px 14px; font-weight: 900; font-size: 15px;
  background: #d8f5c8; border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink);
}
.nx-key-total { background: #ffe9a8; }
.nx-stage-card__key { margin-top: 6px; }
.nx-daily { margin-top: 6px; font-weight: 900; font-size: 14px; color: var(--ink-soft); }
.nx-stage-card__chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.nx-chip--hook { --accent: var(--c-sun); }
.nx-chip--easy { --accent: #b6ec98; }
.nx-chip--medium { --accent: #ffd38a; }
.nx-chip--hard { --accent: #ffadad; }
.nx-stage-card__letters { display: flex; justify-content: center; gap: 4px; margin-top: 10px; }
.nx-stage-card__letters b {
  width: 28px; height: 30px; display: grid; place-items: center; font-family: var(--font-round); font-size: 18px;
  color: var(--text-mute); background: var(--paper-2); border: 2px solid var(--ink); border-radius: 7px;
}
.nx-stage-card__letters b.is-found { color: var(--ink); background: var(--c-sun); }
.nx-stage-card__progress { display: flex; justify-content: center; gap: 12px; margin-top: 8px; font-weight: 900; font-size: 15px; color: var(--ink); }
.nx-stage-card__progress span:first-child { color: #e0a100; letter-spacing: 2px; }
.nx-stage-card__lock { margin-top: 10px; font-weight: 900; font-size: 14px; color: var(--ink-soft); }
.nx-stage-card.is-locked { filter: saturate(.35); }
.nx-stage-card.is-locked.is-center { filter: none; background: #eceaf5; }
.nx-stage-card.is-cleared .nx-stage-card__no::after { content: '✓'; margin-left: 4px; font-size: .4em; vertical-align: super; color: #3aa655; }
.nx-stage-map { margin-top: clamp(6px, 1.2vh, 14px); max-width: 100%; }
.nx-stage-map__path { width: clamp(6px, 1.4vw, 16px); height: 4px; background: repeating-linear-gradient(90deg, var(--ink) 0 4px, transparent 4px 7px); }
.nx-stage-map__node {
  position: relative; min-width: 46px; height: 34px; padding: 0 8px; font-family: var(--font-round); font-weight: 700; font-size: 14px;
  color: var(--ink); background: var(--white); border: 2px solid var(--ink); border-radius: 999px; box-shadow: 0 2px 0 var(--ink); cursor: pointer;
}
.nx-stage-map__node.is-cleared { background: #c9f0b3; }
.nx-stage-map__node.is-locked { background: #e3e1ec; color: var(--text-mute); }
.nx-stage-map__node.is-active { background: var(--c-sun); transform: translateY(-2px); }
.nx-stage-map__node i { position: absolute; top: -9px; right: -6px; font-style: normal; font-size: 12px; color: #fff; background: #3aa655; border: 2px solid var(--ink); border-radius: 50%; width: 18px; height: 18px; display: grid; place-items: center; }

/* ==========================================================
   登入 / 註冊視窗
   ========================================================== */
.auth-modal { background: rgba(29, 35, 64, 0.55) !important; -webkit-backdrop-filter: none; backdrop-filter: none; }
.auth-card { --accent: var(--c-sky); width: min(440px, 92vw) !important; max-width: none !important; overflow: visible !important; }
.auth-header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px 0 18px !important;
  padding-bottom: 0;
  border-bottom: 0 !important;
}
.auth-header h2 {
  margin: 0 !important;
  padding: 4px 18px 6px;
  font-family: var(--font-body) !important;
  font-size: 22px !important;
  font-weight: 900 !important;
  color: var(--ink) !important;
  background: var(--c-sun);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  transform: rotate(-1.5deg);
  -webkit-text-fill-color: currentColor;
}
.auth-card .close-btn {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 42px;
  height: 42px;
  padding: 0 !important;
  font-size: 16px !important;
  font-weight: 700;
  color: var(--white) !important;
  background: var(--c-red) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: 50% !important;
  box-shadow: 0 4px 0 var(--ink) !important;
  cursor: pointer;
}
.form-group label { font-family: var(--font-body); font-size: 14px !important; font-weight: 900 !important; color: var(--ink) !important; letter-spacing: 0; text-transform: none; }
.form-group input {
  font-family: var(--font-body) !important;
  font-size: 16px !important;
  font-weight: 700;
  color: var(--ink) !important;
  background: var(--white) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
}
.form-group input:focus { box-shadow: 0 0 0 4px color-mix(in srgb, var(--c-sky) 45%, transparent) !important; }
.error-message { color: #b3261e !important; background: color-mix(in srgb, var(--c-red) 18%, var(--white)) !important; border: 2px solid var(--ink) !important; border-radius: var(--r-sm) !important; font-weight: 700; }
.error-message.is-notice { color: var(--ink) !important; background: color-mix(in srgb, var(--c-sun) 35%, var(--white)) !important; }
.submit-btn,
.btn-force-login {
  font-family: var(--font-body) !important;
  font-size: 18px !important;
  font-weight: 900 !important;
  color: var(--ink) !important;
  background: var(--c-grass) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
  box-shadow: inset 0 -5px 0 color-mix(in srgb, var(--c-grass) 62%, var(--ink)), 0 5px 0 var(--ink) !important;
}
.submit-btn:active:not(:disabled),
.btn-force-login:active { transform: translateY(5px); box-shadow: none !important; }
.auth-switch, .auth-switch p { color: var(--text-dim) !important; border-top-color: rgba(29, 35, 64, 0.15) !important; font-weight: 700; }
.auth-switch button { color: #1d6fd6 !important; font-weight: 900 !important; }
.guest-mode { border-top-color: rgba(29, 35, 64, 0.15) !important; }
.guest-btn,
.btn-cancel {
  font-family: var(--font-body) !important;
  font-weight: 900 !important;
  color: var(--ink) !important;
  background: var(--white) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
  box-shadow: 0 4px 0 var(--ink) !important;
}
.device-conflict-warning { background: color-mix(in srgb, var(--c-sun) 25%, var(--white)) !important; border: var(--bw) solid var(--ink) !important; border-radius: var(--r-md) !important; color: var(--ink) !important; }
.device-conflict-warning h3 { color: var(--ink) !important; }
.session-info { background: var(--white) !important; border-radius: var(--r-sm) !important; color: var(--ink-soft) !important; }

/* 地圖查看器 */
.nx-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: var(--r-sm);
}
.nx-legend__item { display: inline-flex; align-items: center; gap: 6px; }
.nx-legend__item i { display: inline-block; flex-shrink: 0; }
.nx-map-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; margin-top: 12px; font-size: 14px; font-weight: 700; color: var(--ink-soft); }
.nx-map-stats b { font-family: var(--font-round); color: var(--ink); margin-left: 4px; }

/* ==========================================================
   多人模式
   ========================================================== */
.nx-mp-player {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: var(--r-md);
}
.nx-mp-player__avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  font-size: 22px;
  background: var(--c-pink);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.nx-mp-player__name { font-size: 18px; font-weight: 900; }

.nx-mp-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.nx-mp-field__row { display: flex; gap: 8px; }
.nx-mp-field__row input { flex: 1; min-width: 0; font-family: var(--font-round) !important; }
.nx-mp-field select.nx-input { cursor: pointer; }

.nx-mp-roomid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: var(--white);
  border: 2px dashed var(--ink);
  border-radius: var(--r-md);
}
.nx-mp-roomid b { font-family: var(--font-round); font-size: 20px; font-weight: 700; color: var(--ink); word-break: break-all; }

.nx-mp-host {
  position: fixed;
  top: 160px;
  right: 18px;
  z-index: 10002;
  width: min(340px, 92vw);
  max-height: calc(100dvh - 180px);
  overflow-y: auto;
  padding: 20px 16px 16px;
}
.nx-mp-error { color: #9c2333; background: #fff0f1; padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.nx-mp-roomid b { user-select: all; }
@media (max-height: 600px) { .nx-mp-host { top: 12px; max-height: calc(100dvh - 24px); } }
.nx-mp-host__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.nx-mp-host__title { font-size: 19px; font-weight: 900; }
.nx-mp-players { margin-bottom: 14px; }
.nx-mp-players .nx-list { max-height: 190px; overflow-y: auto; padding: 2px 2px 6px; }

.nx-mp-dock {
  --accent: var(--c-sky);
  position: fixed;
  right: 18px;
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 180px;
  max-width: 280px;
  padding: 7px 14px 7px 8px;
  font-family: var(--font-body);
  text-align: left;
  color: var(--ink);
  background: var(--paper);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
  cursor: pointer;
}
.nx-mp-dock:active { transform: translateY(4px); box-shadow: none; }
.nx-mp-dock--status { top: 170px; }
.nx-mp-dock--host { top: 240px; z-index: 999; }
.nx-mp-dock__icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 16px;
  background: var(--accent);
  border: 2px solid var(--ink);
  border-radius: 50%;
}
.nx-mp-dock__body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.nx-mp-dock__body b { font-size: 15px; font-weight: 900; }
.nx-mp-dock__body small { font-size: 12px; font-weight: 700; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nx-mp-dock__caret { color: var(--ink-soft); }

.nx-mp-status { position: fixed; top: 170px; right: 18px; z-index: 10001; width: min(300px, 90vw); padding: 20px 14px 14px; }
.nx-mp-status__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 12px;
  padding: 0 0 10px;
  font-family: var(--font-body);
  font-size: 17px;
  font-weight: 900;
  color: var(--ink);
  background: none;
  border: 0;
  border-bottom: 2px dashed rgba(29, 35, 64, 0.2);
  cursor: pointer;
}
.nx-mp-goal { margin-bottom: 12px; }
.nx-mp-goal__row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.nx-mp-goal__row b { font-family: var(--font-round); font-size: 22px; font-weight: 700; }

/* 倒數 */
.nx-countdown { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.nx-countdown__ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(46vmin, 380px);
  height: min(46vmin, 380px);
  margin: calc(min(46vmin, 380px) / -2) 0 0 calc(min(46vmin, 380px) / -2);
  background: var(--accent);
  border: 6px solid var(--ink);
  border-radius: 50%;
  box-shadow: 0 10px 0 var(--ink);
  animation: nx-pop .35s var(--nx-ease) both;
}
.nx-countdown__num {
  position: relative;
  font-family: var(--font-round);
  font-size: clamp(120px, 26vw, 240px);
  font-weight: 700;
  line-height: 1;
  color: var(--white);
  text-shadow:
    -5px -5px 0 var(--ink), 5px -5px 0 var(--ink), -5px 5px 0 var(--ink), 5px 5px 0 var(--ink),
    0 -5px 0 var(--ink), 0 5px 0 var(--ink), -5px 0 0 var(--ink), 5px 0 0 var(--ink),
    0 12px 0 var(--ink);
  animation: nx-count-in .5s var(--nx-ease) both;
}
.nx-countdown__num.is-start { font-size: clamp(64px, 14vw, 140px); }
@keyframes nx-count-in { 0% { transform: scale(2.4) rotate(-10deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.nx-countdown__sub {
  position: relative;
  margin-top: 40px;
  padding: 6px 18px 8px;
  font-size: clamp(16px, 3vw, 22px);
  font-weight: 900;
  color: var(--ink);
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}

/* 計時賽 */
.nx-race-timer {
  position: absolute;
  top: 10px;
  left: 50%;
  z-index: 999;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 18px;
  pointer-events: none;
  background: var(--white);
  border: var(--bw) solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 4px 0 var(--ink);
}
.nx-race-timer b { font-family: var(--font-round); font-size: clamp(18px, 4vw, 28px); font-weight: 700; color: var(--ink); }

.nx-race { width: min(560px, 94vw); max-height: 90vh; overflow-y: auto; padding: clamp(24px, 5vw, 34px) clamp(18px, 4vw, 30px); display: flex; flex-direction: column; }
.nx-race-me {
  --medal: var(--c-sky);
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--medal) 35%, var(--white));
  border: var(--bw) solid var(--ink);
  border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink);
}
.nx-race-me.rank-1 { --medal: #ffd23f; }
.nx-race-me.rank-2 { --medal: #cfd6e6; }
.nx-race-me.rank-3 { --medal: #f0a46a; }
.nx-race-me__rank { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.nx-race-me__rank span { font-size: 12px; font-weight: 900; color: var(--ink-soft); }
.nx-race-me__rank b {
  font-family: var(--font-round);
  font-size: clamp(46px, 10vw, 62px);
  font-weight: 700;
  color: var(--white);
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 6px 0 var(--ink);
}
.nx-race-me__info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nx-race-me__info b { font-family: var(--font-round); font-size: clamp(24px, 5vw, 32px); font-weight: 700; }
.nx-race-me__medal { font-size: clamp(36px, 8vw, 50px); }

.nx-race-row.rank-1 { background: color-mix(in srgb, #ffd23f 35%, var(--white)); }
.nx-race-row.rank-2 { background: color-mix(in srgb, #cfd6e6 45%, var(--white)); }
.nx-race-row.rank-3 { background: color-mix(in srgb, #f0a46a 30%, var(--white)); }
.nx-race-row.is-me { outline: 3px solid var(--c-blue); outline-offset: 2px; }
.nx-race-row__rank { min-width: 36px; text-align: center; font-family: var(--font-round); font-size: 20px; font-weight: 700; }
.nx-race-row__name { flex: 1; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nx-race-row__time { font-family: var(--font-round); font-size: 17px; font-weight: 700; }
.nx-race-row__time.is-dnf { color: var(--text-mute); font-family: var(--font-body); }

/* 網路監控 */
.nx-netstats {
  font-family: var(--font-round) !important;
  color: var(--ink) !important;
  background: var(--white) !important;
  border: var(--bw) solid var(--ink) !important;
  border-radius: var(--r-md) !important;
  box-shadow: 0 4px 0 var(--ink) !important;
}
.nx-netstats * { color: inherit; }
.nx-netstats button { font-family: var(--font-round); color: var(--ink) !important; }

/* ---------- 減少動態 ---------- */
@media (prefers-reduced-motion: reduce) {
  .nx-pop, .card, .nx-overlay, .modal, .nx-header__icon, .nx-loader__logo, .nx-btn--pulse { animation: none !important; }
}

/* ---------- 手機 ---------- */
@media (max-width: 767px) {
  .nx-game { padding: 8px 8px 12px; gap: 12px; }
  .nx-topbar { padding: 8px 10px; gap: 8px; border-width: 3px; }
  .nx-keys, .nx-footer-keys { display: none !important; }
  .nx-btn { font-size: 14px; padding: .5em .9em .45em; min-height: 36px; }
  .nx-btn--lg { font-size: 17px; }
  .nx-close { top: -10px; right: -10px; }
}

/* 強調色工具類放最後，才能覆蓋各元件的預設 --accent */
.nx-a-cyan    { --accent: var(--c-sky); }
.nx-a-magenta { --accent: var(--c-pink); }
.nx-a-lime    { --accent: var(--c-grass); }
.nx-a-amber   { --accent: var(--c-sun); }
.nx-a-red     { --accent: var(--c-red); }
.nx-a-violet  { --accent: var(--c-grape); }
.nx-a-blue    { --accent: var(--c-blue); }

/* 成就橫幅：畫面上方滑入，學習類藍綠、遊戲類金色 */
.nx-achievement{position:fixed;top:14px;left:50%;z-index:9999;display:flex;align-items:center;gap:14px;min-width:min(420px,92vw);max-width:92vw;
  padding:12px 20px 12px 14px;border:3px solid var(--ink);border-radius:20px;box-shadow:0 6px 0 var(--ink),0 14px 30px rgba(29,35,64,.35);
  transform:translateX(-50%);animation:nxAchIn .45s cubic-bezier(.2,1.4,.4,1) both,nxAchOut .4s ease-in 3.2s forwards;pointer-events:none;overflow:hidden}
.nx-achievement--game{background:linear-gradient(135deg,#fff3c4,#ffd166 55%,#ffb703)}
.nx-achievement--learn{background:linear-gradient(135deg,#e0fbff,#8ee6f2 55%,#4cc9f0)}
.nx-achievement::after{content:"";position:absolute;top:0;left:-60%;width:40%;height:100%;background:linear-gradient(100deg,transparent,rgba(255,255,255,.75),transparent);animation:nxAchShine 1.4s .35s ease-out}
.nx-achievement__icon{font-size:38px;width:58px;height:58px;display:grid;place-items:center;border-radius:50%;background:#fff;border:3px solid var(--ink);flex:none}
.nx-achievement__tag{font-size:13px;font-weight:900;letter-spacing:.06em;color:var(--ink-soft)}
.nx-achievement__title{font-size:22px;font-weight:900;color:var(--ink);line-height:1.15}
.nx-achievement__desc{font-size:14px;font-weight:700;color:var(--ink-soft)}
@keyframes nxAchIn{from{transform:translate(-50%,-140%) scale(.9);opacity:0}to{transform:translate(-50%,0) scale(1);opacity:1}}
@keyframes nxAchOut{to{transform:translate(-50%,-140%);opacity:0}}
@keyframes nxAchShine{to{left:120%}}
@media (prefers-reduced-motion:reduce){.nx-achievement,.nx-achievement::after{animation:none}}
/* 題目視窗的關閉鈕 */
.nx-quiz-head{position:relative;padding-right:52px}
.nx-quiz-close{position:absolute;top:50%;right:0;transform:translateY(-50%);width:40px;height:40px;border-radius:50%;border:3px solid var(--ink);background:#fff;color:var(--ink);font-size:20px;font-weight:900;cursor:pointer;box-shadow:0 3px 0 var(--ink)}
.nx-quiz-close:hover{background:#ffe066}

/* AI 夥伴對話框（AI 夥伴模式，畫布右下角、道具欄上方） */
/* AI 夥伴對話框：放在遊戲畫面左下（往右跑時是身後），半透明；不在打字時變淡，滑鼠移上去或打字時才清楚 */
.ai-chat{--accent:var(--c-sky);position:absolute;left:16px;bottom:16px;width:min(360px,calc(100% - 32px));max-height:calc(100% - 150px);padding:16px 12px 10px;display:flex;flex-direction:column;gap:7px;z-index:20;
  background:linear-gradient(var(--accent),var(--accent)) top/100% 8px no-repeat,rgba(255,250,240,.86);backdrop-filter:blur(3px);box-shadow:0 5px 0 var(--ink),0 14px 30px rgba(29,35,64,.25);
  animation:ai-chat-in .3s var(--nx-ease) both;transition:opacity .2s}
@keyframes ai-chat-in{from{transform:translateY(24px) scale(.95)}to{transform:none}}
.ai-chat:not(:focus-within):not(:hover){opacity:.7}
/* 遊戲中（沒在打字、滑鼠不在上面）：收成只看最近幾句；按鈕與輸入框收起來（仍可聚焦，Enter 一按就展開） */
.ai-chat__presets,.ai-chat__form{max-height:120px;transition:max-height .18s,opacity .18s}
.ai-chat:not(:focus-within):not(:hover) .ai-chat__presets,.ai-chat:not(:focus-within):not(:hover) .ai-chat__form{max-height:0;opacity:0;overflow:hidden;margin-top:-7px}
.ai-chat:not(:focus-within):not(:hover) .ai-chat__log{max-height:128px}
.ai-chat__head{display:flex;align-items:center;gap:8px;font-weight:900;color:var(--ink)}
.ai-chat__mode{margin-left:auto;font-size:12px;font-weight:700;color:var(--text-dim);white-space:nowrap}
.ai-chat__mode .nx-kbd{font-size:11px;padding:0 5px}
.ai-chat:focus-within .ai-chat__mode--game,.ai-chat:not(:focus-within) .ai-chat__mode--typing{display:none}
.ai-chat__close{width:28px;height:28px;flex:none;border-radius:50%;border:3px solid var(--ink);background:#fff;color:var(--ink);font-weight:900;cursor:pointer;line-height:1}
.ai-chat__close:hover{background:#ffe066}
.ai-chat__log{display:flex;flex-direction:column;gap:6px;min-height:60px;max-height:min(34vh,280px);overflow-y:auto;overscroll-behavior:contain;padding-right:4px;scrollbar-width:thin}
.ai-chat__hint{color:var(--text-dim);font-size:13px}
.ai-chat__msg{max-width:88%;padding:6px 10px;border:2px solid var(--ink);border-radius:12px;font-size:14px;line-height:1.45;word-break:break-word}
.ai-chat__msg--user{align-self:flex-end;background:var(--c-sun)}
.ai-chat__msg--assistant{align-self:flex-start;background:#d9f7ff}
.ai-chat__msg--thinking{color:var(--text-dim);font-style:italic}
.ai-chat__unseen{align-self:center;margin-top:-4px;padding:2px 12px;border:2px solid var(--ink);border-radius:999px;background:var(--c-sun);color:var(--ink);font:inherit;font-size:12px;font-weight:800;cursor:pointer}
.ai-chat__presets{display:flex;flex-wrap:wrap;gap:5px}
.ai-chat__preset{padding:3px 9px;border:2px solid var(--ink);border-radius:999px;background:#fff;color:var(--ink);font:inherit;font-size:12px;font-weight:700;cursor:pointer;line-height:1.4}
.ai-chat__preset:hover:not(:disabled){background:#ffe066}
.ai-chat__preset:disabled{opacity:.5;cursor:default}
.ai-chat__form{display:flex;gap:8px}
.ai-chat__form .nx-input{flex:1;min-width:0}

/* 過關視窗：放在遊戲畫面裡，必須塞得下（太矮時可以捲動） */
.modal:has(> .nx-finish) { padding: 8px; }
.nx-finish {
  width: min(480px, 94%) !important; max-height: calc(100% - 8px); overflow-y: auto; text-align: center;
  padding: clamp(12px, 2.2vw, 20px) !important; display: flex; flex-direction: column; gap: 8px;
}
.nx-finish__title { margin: 0; font-size: clamp(20px, 3.6vw, 26px) !important; }
.nx-finish__top { display: flex; gap: 10px; align-items: stretch; }
.nx-finish__time, .nx-finish__stars {
  flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 4px 10px;
  background: var(--white); border: 3px solid var(--ink); border-radius: 14px;
}
.nx-finish__time b { font-family: var(--font-round); font-size: clamp(20px, 3.4vw, 26px); line-height: 1.1; color: var(--ink); }
.nx-finish__time span { font-size: 12px; font-weight: 700; color: var(--text-dim); }
.nx-finish__stars { font-size: clamp(20px, 3.4vw, 26px); letter-spacing: 3px; color: #e0a100; background: #fff3cf; }
.nx-finish__goals {
  list-style: none; margin: 0; padding: 6px 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px;
  text-align: left; font-size: 13px; font-weight: 700; color: var(--text-dim); background: #fff8e6; border: 2px solid rgba(29,35,64,.18); border-radius: 12px;
}
.nx-finish__goals li.is-ok { color: var(--ink); }
.nx-finish__word { padding: 6px 12px; background: #e3f6d6; border: 3px solid var(--ink); border-radius: 14px; font-size: 14px; font-weight: 700; }
.nx-finish__word .nx-mute { font-size: 13px; }
.nx-finish__letters { font-family: var(--font-round); font-size: clamp(18px, 3vw, 22px); letter-spacing: 5px; font-weight: 900; color: var(--ink); }
.nx-finish__actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.nx-finish__actions .nx-btn { flex: 1 1 120px; }
.nx-finish__actions .nx-finish__next { flex: 1 1 100%; }
@media (max-width: 420px) { .nx-finish__goals { grid-template-columns: 1fr; } }

/* 選關面板在矮螢幕：放在檔案最後，才能蓋過上面的卡片基本樣式 */
/* short screens: a smaller centre card so the whole panel fits */
@media (max-height: 860px) {
  .nx-stage-track__cards { padding: 8px 6px 12px; }
  .nx-stage-card.is-center { background: linear-gradient(var(--c-sky), var(--c-sky)) top / 100% 92px no-repeat, var(--white); padding-bottom: 14px; }
  .is-center .nx-stage-card__no { font-size: clamp(52px, 8vh, 76px); margin: 0 0 4px; }
  .is-center .nx-stage-card__name { margin-top: 4px; }
  .nx-stage-card__go { margin-top: 8px; }
  .nx-stage-card__best { margin-top: 4px; }
}
/* very short windows (a laptop with the browser bars, ~534px): everything on one screen */
@media (max-height: 620px) {
  .nx-stage-select__title { font-size: 22px !important; padding: 2px 16px !important; }
  .nx-stage-card.is-center { width: clamp(200px, 28vw, 250px); background: linear-gradient(var(--c-sky), var(--c-sky)) top / 100% 66px no-repeat, var(--white); padding: 0 12px 10px; }
  .is-center .nx-stage-card__label { margin-top: 8px; }
  .is-center .nx-stage-card__no { font-size: 40px; margin: 0; }
  .is-center .nx-stage-card__name { margin-top: 2px; font-size: 16px; }
  .nx-stage-card.is-side { padding: 8px 8px 10px; }
  .nx-stage-card__no { font-size: 34px; }
  .nx-stage-track__cards { padding: 4px 6px 8px; }
  .nx-stage-card__letters { margin-top: 4px; }
  .nx-stage-card__chips, .nx-stage-card__progress { margin-top: 4px; }
  .nx-stage-select__hint { display: none; }
  .nx-stage-select { padding: 10px 12px 8px; }
  .nx-stage-select__head { margin-bottom: 0; }
  .nx-stage-select__meta { margin-top: 2px; }
  .nx-stage-card { gap: 2px; }
  .nx-stage-map { margin-top: 2px; }
  .nx-stage-tabs { margin-bottom: 4px; }
  .nx-stage-tab { padding: 2px 10px; font-size: 13px; }
}
