/* Premier Nexus: a full-screen client. App rail | active experience | server chat. Hosts the journal and TapuCraft views as they are. */
body:has(.nexus) { overflow: hidden; }
.nexus {
  --nx-bg: #16100d; --nx-rail: #0e0a08; --nx-surface: #1e1612; --nx-raised: #2a1f19; --nx-line: #3a2b22;
  --nx-text: #f5eae1; --nx-muted: #a99383; --nx-accent: #e8a87c; --nx-accent-deep: #c9683a; --nx-green: #5bd16a;
  position: fixed; inset: 0; z-index: 40;
  display: grid; grid-template-columns: 76px minmax(0, 1fr) clamp(320px, 26vw, 400px);
  background: var(--nx-bg); color: var(--nx-text);
  font-family: "Source Sans 3", "Segoe UI", Arial, sans-serif;
}
.nexus *:focus-visible { outline: 2px solid var(--nx-accent); outline-offset: 2px; }

/* Buttons: undo the site-wide button look for Nexus' own controls only (the games keep theirs). */
.nexus-btn, .nexus-rail-item, .nexus .game-chat-form button {
  width: auto; margin: 0; box-shadow: none; transform: none; filter: none; letter-spacing: normal; transition: background .15s, color .15s, transform .1s;
}
.nexus-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 11px 20px;
  border: 1px solid var(--nx-line); border-radius: 10px; background: var(--nx-raised); color: var(--nx-text);
  font: inherit; font-size: .95rem; font-weight: 700; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.nexus-btn:hover { background: #3a2b22; color: #fff; transform: none; box-shadow: none; }
.nexus-btn:active { transform: scale(.97); box-shadow: none; }
.nexus-btn.is-primary { border-color: transparent; background: linear-gradient(180deg, var(--nx-accent), var(--nx-accent-deep)); color: #1a0e08; }
.nexus-btn.is-primary:hover { background: linear-gradient(180deg, #f2b98f, #d47848); color: #1a0e08; }
.nexus-btn:disabled { opacity: .6; cursor: default; pointer-events: none; }
.nexus-gate-fine[data-nexus-join-note]:not(:empty) { color: var(--nx-accent); }

/* Rail */
.nexus-rail { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; min-width: 0; padding: 12px 0; background: var(--nx-rail); border-right: 1px solid var(--nx-line); overflow-x: hidden; overflow-y: auto; }
.nexus-logo { display: grid; place-items: center; width: 50px; height: 50px; margin-bottom: 10px; border-radius: 14px; background: var(--nx-raised); }
.nexus-rail-item {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; width: 62px; padding: 10px 0 8px;
  border: 0; border-radius: 12px; background: transparent; color: var(--nx-muted); font: inherit; font-size: .7rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.nexus-rail-item i { font-size: 1.25rem; }
.nexus-rail-item:hover { background: var(--nx-surface); color: var(--nx-text); }
.nexus-rail-item[aria-current] { background: var(--nx-raised); color: var(--nx-accent); }
.nexus-rail-item[aria-current]::before { content: ""; position: absolute; left: -7px; top: 12px; bottom: 12px; width: 4px; border-radius: 0 4px 4px 0; background: var(--nx-accent); }
.nexus-dot { position: absolute; top: 7px; right: 14px; width: 9px; height: 9px; border-radius: 50%; background: #ff6a4d; box-shadow: 0 0 0 2px var(--nx-rail); }
.nexus-rail-chat, .nexus-lobby-foot { display: none; }
/* Rail = Lobi, TapuCraft, Çark, Oyna (same as the phone tab bar); the single games open from Oyna and the lobby. */
.nexus-rail-item[data-nexus-tab="maze"]:not(.nexus-rail-play), .nexus-rail-item[data-nexus-tab="dodge"]:not(.nexus-rail-play),
.nexus-rail-item[data-nexus-tab="whack"]:not(.nexus-rail-play), .nexus-rail-item[data-nexus-tab="journal"] { display: none; }
.nexus-rail-end { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: auto; }
.nexus-balances { display: flex; flex-direction: column; gap: 4px; width: 68px; min-width: 0; }
.nexus .nexus-balance {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 2px; width: 100%; min-width: 0; box-sizing: border-box;
  min-height: 0; margin: 0; padding: 3px 4px; border: 0; border-radius: 999px; background: var(--nx-raised); box-shadow: none;
  color: var(--nx-text); font-size: 10px; font-weight: 800; letter-spacing: 0; line-height: 1; font-variant-numeric: tabular-nums;
}
.nexus .nexus-balance i,
.nexus .nexus-balance > span[aria-hidden] { flex: none; font-size: 9px; color: var(--nx-accent); }
.nexus .nexus-balance .pcoin-badge-value,
.nexus .nexus-balance > span:last-child {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 10px; line-height: 1; animation: none; text-shadow: none; transform: none;
}
.nexus-balance-name { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.nexus-me img { display: block; border-radius: 10px; image-rendering: pixelated; box-shadow: 0 0 0 2px var(--nx-line); }
.nexus-royal { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; color: #f5c542; font-size: 11px; font-weight: 700; }
.nexus-royal i { font-size: 16px; }
[data-royal] .nexus-me img { box-shadow: 0 0 0 2px #f5c542; }

/* Stage */
.nexus-stage { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: var(--nx-line) transparent; padding: 28px clamp(16px, 3vw, 40px) 40px; }
.nexus-panel[hidden] { display: none; }
.nexus-closed { display: none; min-height: 100%; align-items: center; justify-content: center; }
.nexus[data-gate="closed"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.nexus[data-gate="closed"] .nexus-closed { display: flex; }
.nexus[data-gate="closed"] .nexus-rail,
.nexus[data-gate="closed"] .nexus-chat,
.nexus[data-gate="closed"] .nexus-panel { display: none; }
.nexus-gate { display: none; min-height: 100%; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px; box-sizing: border-box; }
.nexus[data-gate="locked"] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.nexus[data-gate="locked"] .nexus-gate { display: flex; }
.nexus[data-gate="locked"] .nexus-rail,
.nexus[data-gate="locked"] .nexus-chat,
.nexus[data-gate="locked"] .nexus-panel { display: none; }
.nexus-gate-card a { color: var(--nx-accent); font-weight: 700; }
.nexus-gate-card { max-width: 440px; padding: 36px 32px; text-align: center; background: var(--nx-surface); border: 1px solid var(--nx-line); border-radius: 20px; animation: nexus-in .25s ease-out; }
.nexus-gate-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; margin-bottom: 14px; border-radius: 16px; background: var(--nx-raised); color: var(--nx-accent); font-size: 1.4rem; }
.nexus-gate-card h1 { margin: 0 0 8px; font-size: 1.6rem; color: var(--nx-text); }
.nexus-gate-card p { margin: 0 0 20px; color: var(--nx-muted); line-height: 1.5; }
.nexus-gate-card .nexus-gate-fine { margin: 16px 0 0; font-size: .85rem; }
.nexus-panel { max-width: 1180px; margin: 0 auto; animation: nexus-in .25s ease-out; }
@keyframes nexus-in { from { opacity: 0; transform: translateY(6px); } }

/* Lobby */
.nexus-lobby { display: grid; gap: 22px; }
.nexus-hero {
  position: relative; display: flex; align-items: center; gap: 24px; overflow: hidden; padding: clamp(24px, 4vw, 48px);
  border: 1px solid var(--nx-line); border-radius: 20px;
  background: radial-gradient(600px 300px at 85% 30%, rgba(232, 168, 124, .22), transparent 70%), linear-gradient(135deg, #3a1f13 0%, #1e1612 70%);
}
.nexus-hero-text { position: relative; z-index: 1; flex: 1; min-width: 0; }
.nexus-hero h1 { margin: 10px 0 8px; font-size: clamp(1.8rem, 4vw, 2.9rem); line-height: 1.1; letter-spacing: -.02em; color: #fff; }
.nexus-hero p { max-width: 48ch; margin: 0 0 22px; color: #d8c3b4; font-size: 1.05rem; }
.nexus-hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.nexus-hero-actions .nexus-btn { padding: 13px 24px; font-size: 1.02rem; }
.nexus-server { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: rgba(0, 0, 0, .35); color: var(--nx-muted); font-size: .85rem; font-weight: 700; }
.nexus-server i { width: 8px; height: 8px; border-radius: 50%; background: #8a7466; }
.nexus-server.is-online { color: #c9f5cf; }
.nexus-server.is-online i { background: var(--nx-green); box-shadow: 0 0 0 4px rgba(91, 209, 106, .2); animation: nexus-pulse 2s infinite; }
@keyframes nexus-pulse { 50% { box-shadow: 0 0 0 7px rgba(91, 209, 106, 0); } }
/* A small pixel landscape: grass over dirt over stone. */
.nexus-hero-art { display: grid; grid-template-columns: repeat(3, 56px); gap: 4px; transform: rotate(-8deg); flex: none; filter: drop-shadow(0 14px 24px rgba(0, 0, 0, .5)); }
.nexus-hero-art span { aspect-ratio: 1; border-radius: 6px; background: #866043; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, .18); }
.nexus-hero-art span:nth-child(-n+3) { background: linear-gradient(180deg, #6fbf4a 0 34%, #866043 34%); }
.nexus-hero-art span:nth-child(n+7) { background: #7d7d7d; }
.nexus-hero-art span:nth-child(5) { background: #5ad2d8; box-shadow: inset 0 0 0 10px #7d7d7d; }

.nexus-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.nexus-stats div { display: grid; gap: 2px; padding: 16px 18px; border: 1px solid var(--nx-line); border-radius: 14px; background: var(--nx-surface); }
.nexus-stats strong { font-size: 1.5rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nexus-stats span { color: var(--nx-muted); font-size: .85rem; }

.nexus-heading { margin: 6px 0 -6px; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--nx-muted); }
.nexus-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.nexus-tile { position: relative; cursor: pointer; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--nx-line); border-radius: 18px; background: var(--nx-surface); transition: transform .2s, border-color .2s; }
.nexus-tile:hover { transform: translateY(-3px); border-color: #5a4334; }
.nexus-tile-art { display: grid; place-items: center; height: 150px; font-size: 3.6rem; color: rgba(255, 255, 255, .92); text-shadow: 0 6px 18px rgba(0, 0, 0, .35); }
.nexus-tile--journal .nexus-tile-art { background: radial-gradient(circle at 30% 20%, #9bd36e, transparent 60%), linear-gradient(135deg, #3f7d32, #1f4d2a); }
.nexus-tile--tapu .nexus-tile-art { background: radial-gradient(circle at 70% 20%, #7fb3ff, transparent 60%), linear-gradient(135deg, #3a5fb0, #2a2366); }
.nexus-tile--cark .nexus-tile-art { background: radial-gradient(circle at 30% 20%, #f3cfb5, transparent 55%), linear-gradient(135deg, #c45c2c, #6b2e14); }
.nexus-tile--discord .nexus-tile-art { background: radial-gradient(circle at 30% 20%, #c9d1ff, transparent 55%), linear-gradient(135deg, #5865f2, #2c3480); }
.nexus-sheet .spin-wheel-header { display: none; }
.nexus-sheet .spin-wheel-shell { max-width: none; }
.nexus-sheet .spin-wheel-board-wrap { max-width: min(100%, 430px); }
.nexus-tile-body { display: grid; gap: 12px; padding: 18px 20px 20px; }
.nexus-tile h3 { margin: 0; font-size: 1.35rem; color: #fff; }
.nexus-tile p { margin: 0; color: var(--nx-muted); }
.nexus-tile .nexus-btn { justify-self: start; }
/* The whole card is the click target, not just its button. */
.nexus-tile .nexus-btn:not(.is-loading)::after { content: ""; position: absolute; inset: 0; }
.nexus-progress { display: flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--nx-muted); }
.nexus-progress i { width: 34px; height: 8px; border-radius: 4px; background: var(--nx-raised); }
.nexus-progress i.is-done { background: var(--nx-green); }
.nexus-progress span { margin-left: 6px; }
.nexus-avatars { display: flex; align-items: center; font-size: .88rem; color: var(--nx-muted); }
.nexus-avatars img { margin-right: -6px; border-radius: 6px; border: 2px solid var(--nx-surface); image-rendering: pixelated; }
.nexus-avatars span { margin-left: 14px; }

/* Game panels: a slim header, then the game on its own light screen. */
.nexus-game-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.nexus-game-head h2 { margin: 0; font-size: 1.6rem; color: #fff; }
.nexus-game-head p { margin: 2px 0 0; color: var(--nx-muted); }
.nexus-sheet { padding: clamp(12px, 2vw, 22px); border-radius: 18px; background: #f5ede4; color: #2d1810; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.nexus-sheet .journal-intro { display: none; }
.nexus-sheet .journal-shell { padding-bottom: 0; }
.nexus-sheet .card:hover { transform: none; }

/* Chat: dark, like the in-game chat. Overrides the cream home widget it reuses. */
.nexus-chat { display: flex; min-width: 0; min-height: 0; border-left: 1px solid var(--nx-line); background: var(--nx-surface); }
.nexus-chat .game-chat { flex: 1; display: flex; flex-direction: column; min-height: 0; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--nx-text); }
.nexus-chat .game-chat::before, .nexus-chat .game-chat::after { display: none; }
.nexus-chat .game-chat:hover { transform: none; box-shadow: none; }
.nexus-chat .home-widget-head { gap: 10px; margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--nx-line); }
.nexus-chat .home-widget-icon { border: 0; background: var(--nx-raised); color: var(--nx-accent); }
.nexus-chat .home-widget-title { color: #fff; font-size: 1.05rem; }
.nexus-chat .home-widget-body { padding: 18px; color: var(--nx-muted); }
.nexus-chat .home-widget-body a { color: var(--nx-accent); }
.nexus-chat .game-chat-status { padding: 3px 10px; border-radius: 999px; background: rgba(91, 209, 106, .14); color: var(--nx-green); }
.nexus-chat .game-chat--offline .game-chat-status, .nexus-chat .game-chat-status:empty { background: rgba(255, 255, 255, .06); color: var(--nx-muted); }
.nexus-chat .game-chat-status:empty { display: none; }
.nexus-chat .game-chat-players { flex-shrink: 0; margin: 0; padding: 8px 18px; border-bottom: 1px solid var(--nx-line); }
.nexus-chat .game-chat-log { flex: 1; height: auto; min-height: 0; gap: 6px; padding: 14px 18px; border: 0; border-radius: 0; background: transparent; color: var(--nx-text); font-size: .93rem; line-height: 1.45; }
.nexus-chat .game-chat-log:empty::before { color: var(--nx-muted); }
.nexus-chat .game-chat-line { color: var(--nx-text); }
.nexus-chat .game-chat-line time { color: #7d6858; }
.nexus-chat .game-chat-line b { color: var(--nx-accent); }
.nexus-chat .game-chat-line b::after { color: #7d6858; }
.nexus-chat .game-chat-note { margin: 0; padding: 8px 18px 0; color: #ff8a70; }
/* The join gate already offers this; game-chat.js still needs the node. */
.nexus-chat .game-chat-join { display: none; }
.nexus-chat .game-chat-form { gap: 8px; margin: 0; padding: 12px 16px 16px; border-top: 1px solid var(--nx-line); }
.nexus-chat .game-chat-form input { padding: 12px 14px; border: 1px solid var(--nx-line); border-radius: 10px; background: var(--nx-bg); color: var(--nx-text); }
.nexus-chat .game-chat-form input::placeholder { color: #7d6858; }
.nexus-chat .game-chat-form input:focus-visible { border-color: var(--nx-accent); }
.nexus-chat .game-chat-form button { width: 46px; border: 0; border-radius: 10px; background: var(--nx-accent); color: #1a0e08; }
.nexus-chat .game-chat-form button:hover { background: #f2b98f; transform: none; box-shadow: none; }

.nexus-toasts { position: fixed; right: max(24px, env(safe-area-inset-right)); bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 50; display: flex; flex-direction: column; gap: 12px; width: min(420px, calc(100vw - 32px)); pointer-events: none; }
.nexus-toast {
  display: flex; align-items: flex-start; gap: 14px; padding: 20px; border: 1px solid #a76c43; border-left: 4px solid var(--nx-accent); border-radius: 16px;
  background: radial-gradient(ellipse at top left, rgba(232, 168, 124, .16), transparent 75%), #2a1c14;
  color: var(--nx-text); box-shadow: 0 16px 48px rgba(0, 0, 0, .5), 0 0 0 1px rgba(0, 0, 0, .25); pointer-events: auto;
  animation: nexus-toast-in .3s cubic-bezier(.2, .8, .2, 1);
}
.nexus-toast-icon { display: grid; place-items: center; flex: none; width: 40px; height: 40px; border: 1px solid rgba(232, 168, 124, .35); border-radius: 12px; background: rgba(232, 168, 124, .12); color: var(--nx-accent); font-size: 1.4rem; font-weight: 800; }
.nexus-toast-body { flex: 1; min-width: 0; }
.nexus-toast-title { display: block; margin-bottom: 5px; color: #fff5e9; font-size: 1.05rem; line-height: 1.3; }
.nexus-toast-message { display: block; color: #dfcbbc; font-size: .95rem; line-height: 1.5; overflow-wrap: anywhere; }
.nexus .nexus-toast-action, .nexus .nexus-toast-close { width: auto; margin: 0; border: 0; font: inherit; letter-spacing: normal; box-shadow: none; transform: none; filter: none; cursor: pointer; }
.nexus .nexus-toast-action { margin-top: 14px; padding: 9px 14px; border-radius: 8px; background: var(--nx-accent); color: #241308; font-size: .9rem; font-weight: 800; text-align: left; }
.nexus .nexus-toast-action:hover { background: #f6c39b; }
.nexus .nexus-toast-close { display: grid; place-items: center; flex: none; width: 28px; height: 28px; margin: -8px -8px 0 0; padding: 0; border-radius: 7px; background: transparent; color: #c9b1a0; font-size: 1.5rem; line-height: 1; }
.nexus .nexus-toast-close:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.nexus-toast.is-complete { border-color: #729b55; border-left-color: #a7df7c; background: radial-gradient(ellipse at top left, rgba(143, 202, 94, .18), transparent 75%), #20261a; }
.nexus-toast.is-complete .nexus-toast-icon { border-color: rgba(167, 223, 124, .35); background: rgba(167, 223, 124, .12); color: #b8ed8f; }
.nexus-toast-meter { display: flex; align-items: center; gap: 10px; margin: 2px 0 8px; }
.nexus-toast-bar { display: flex; flex: 1; gap: 4px; }
.nexus-toast-bar span { flex: 1; height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .12); }
.nexus-toast-bar .is-on { background: var(--nx-accent); }
.nexus-toast-bar .is-fresh { animation: nexus-seg-pop .6s .25s cubic-bezier(.3, 1.6, .5, 1) both; }
.nexus-toast.is-complete .nexus-toast-bar .is-on { background: #a7df7c; }
.nexus-toast-count { flex: none; color: #fff5e9; font-size: .9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
@keyframes nexus-seg-pop { from { transform: scaleX(0); opacity: .4; } 60% { transform: scaleX(1.08) scaleY(1.6); opacity: 1; box-shadow: 0 0 12px currentColor; } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .nexus-toast-bar .is-fresh { animation: none; } }
@keyframes nexus-toast-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 960px) {
  .nexus-toasts { right: max(16px, env(safe-area-inset-right)); bottom: calc(88px + env(safe-area-inset-bottom)); }
  .nexus-toast { gap: 10px; padding: 16px; }
  .nexus-toast-icon { width: 34px; height: 34px; border-radius: 10px; }
}
/* Phones and narrow windows: the rail becomes a bottom tab bar and the chat a tab. */
/* Site-wide h2/p colors are for light pages; the TapuCraft help dialog is dark. */
.nexus .tapu-help h2, .nexus .tapu-help p { color: inherit; }
@media (max-width: 960px) {
  .nexus { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .nexus-rail { grid-row: 2; flex-direction: row; justify-content: space-around; gap: 0; width: auto; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--nx-line); overflow: visible; }
  .nexus-logo, .nexus-rail-end { display: none; }
  .nexus-rail-chat { display: flex; }
  .nexus-rail-item { flex: 1; width: auto; min-height: 56px; justify-content: center; font-size: .72rem; }
  .nexus-dot { right: calc(50% - 20px); }
  .nexus-lobby-foot { display: flex; gap: 10px; }
  .nexus-lobby-foot .nexus-btn { flex: 1; }
  .nexus-hero { padding: 22px 18px; }
  .nexus-hero-actions .nexus-btn { flex: 1; }
  .nexus-tiles { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .nexus-tile { flex-direction: row; }
  .nexus-tile-art { flex: none; width: 88px; height: auto; font-size: 2rem; }
  .nexus-tile-body { padding: 14px 16px; gap: 8px; min-width: 0; }
  .nexus-tile h3 { font-size: 1.15rem; }
  .nexus-game-head { flex-wrap: wrap; gap: 10px; }
  .nexus-game-head h2 { font-size: 1.3rem; }
  .nexus-chat .game-chat-form input { font-size: 16px; }
  .nexus-rail-item[aria-current]::before { left: 25%; right: 25%; top: -5px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 3px 3px; }
  .nexus-stage, .nexus-chat { grid-row: 1; grid-column: 1; }
  .nexus-stage { padding: 16px 16px 28px; }
  .nexus[data-view="games"] .nexus-chat, .nexus[data-view="chat"] .nexus-stage { display: none; }
  .nexus-chat { border-left: 0; }
  .nexus-hero-art { display: none; }
  .nexus-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nexus-game-head p { display: none; }
  .nexus-sheet { padding: 10px; border-radius: 14px; }
}

.nexus-gate-form { display: grid; gap: 10px; margin: 0 0 4px; text-align: left; }
.nexus-gate-form input:not([type="hidden"]) { width: 100%; box-sizing: border-box; padding: 11px 14px; border-radius: 12px; border: 1px solid var(--nx-line); background: var(--nx-raised); color: var(--nx-text); font: inherit; }
.nexus-gate-form input:focus { outline: 2px solid var(--nx-accent); outline-offset: 1px; }
.nexus-gate-form .nexus-btn { justify-content: center; width: 100%; }

/* Dot-matrix intro. The CSS animation is only a fallback if nexus.js never removes it. */
.nexus-intro { position: fixed; inset: 0; z-index: 9999; background: radial-gradient(ellipse at 50% 45%, #231813 0%, #0e0a08 70%); cursor: default; animation: nexus-intro-out .6s ease 7s forwards; }
.nexus-intro canvas { display: block; width: 100%; height: 100%; }
.nexus-intro.is-leaving { opacity: 0; pointer-events: none; transition: opacity .9s ease .25s; }
@keyframes nexus-intro-out { to { opacity: 0; visibility: hidden; } }
.nexus-intro-gate { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 18px; padding: 24px; overflow-y: auto; text-align: center; animation: nexus-in .6s ease-out; }
.nexus-intro-gate img { border-radius: 18px; box-shadow: 0 0 0 1px var(--nx-line), 0 10px 40px rgba(232, 168, 124, .18); }
.nexus-intro-gate p { max-width: 320px; margin: 0; color: var(--nx-muted); font-size: .9rem; line-height: 1.5; }
.nexus-intro-go { position: relative; flex-shrink: 0; padding: 15px 38px; font-size: 1.1rem; letter-spacing: .02em; box-shadow: 0 0 30px rgba(232, 168, 124, .35); animation: nexus-intro-pulse 2.2s ease-out infinite; }
.nexus-intro-gate.is-playing { justify-content: flex-end; pointer-events: none; }
.nexus-intro-gate.is-playing > :not([data-nexus-intro-status]) { display: none; }
.nexus-intro-gate.is-playing [data-nexus-intro-status] { margin-bottom: 28px; color: var(--nx-accent); font-weight: 700; }
@keyframes nexus-intro-pulse { 0% { box-shadow: 0 0 0 0 rgba(232, 168, 124, .55), 0 0 30px rgba(232, 168, 124, .35); } 70%, 100% { box-shadow: 0 0 0 22px rgba(232, 168, 124, 0), 0 0 30px rgba(232, 168, 124, .35); } }
.nexus-logout { margin: 0; display: contents; }

/* Loading state: join buttons while the request runs (game-chat.js disables them), forms while they submit. */
.nexus-btn.is-loading, .nexus-btn[data-nexus-join]:disabled, .nexus-rail-item.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.nexus-btn.is-loading > *, .nexus-btn[data-nexus-join]:disabled > *, .nexus-rail-item.is-loading > * { visibility: hidden; }
.nexus-btn.is-loading::after, .nexus-btn[data-nexus-join]:disabled::after, .nexus-rail-item.is-loading::after {
  content: ""; box-sizing: border-box; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; transform: none; background: none; z-index: auto; /* reset the header button sweep (style.css .nexus-btn::after) */
  border: 2.5px solid rgba(26, 14, 8, .25); border-top-color: #1a0e08; border-radius: 50%; animation: nexus-spin .7s linear infinite;
}
.nexus-rail-item.is-loading::after { border-color: var(--nx-line); border-top-color: var(--nx-accent); }
@keyframes nexus-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* "What you can do" strip on the join screen: cards rise in one by one, each lit by a sweeping edge. */
.nexus-can-title { margin: 6px 0 -6px; color: var(--nx-accent); font-size: .78rem; font-weight: 700; letter-spacing: .28em; text-transform: uppercase; }
.nexus-can { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; width: min(960px, 100%); margin: 0; padding: 0; list-style: none; }
.nexus-can li { position: relative; overflow: hidden; display: grid; gap: 6px; justify-items: center; padding: 18px 12px 16px; background: rgba(30, 22, 18, .72); border: 1px solid var(--nx-line); border-radius: 16px; backdrop-filter: blur(6px); animation: nexus-in .6s ease-out calc(.35s + var(--i) * .12s) backwards; }
.nexus-can li::after { content: ""; position: absolute; inset: 0 auto 0 -60%; width: 40%; background: linear-gradient(100deg, transparent, rgba(232, 168, 124, .16), transparent); transform: skewX(-18deg); animation: nexus-can-sweep 4.5s ease-in-out calc(1.2s + var(--i) * .5s) infinite; }
.nexus-can i { display: grid; place-items: center; width: 42px; height: 42px; margin-bottom: 4px; color: var(--nx-accent); background: var(--nx-raised); border-radius: 12px; font-size: 1.15rem; box-shadow: 0 0 22px rgba(232, 168, 124, .18); }
.nexus-can strong { font-size: .95rem; }
.nexus-can span { color: var(--nx-muted); font-size: .8rem; line-height: 1.4; }
@keyframes nexus-can-sweep { 0%, 55% { left: -60%; } 100% { left: 130%; } }
@media (max-width: 860px) { .nexus-can { grid-template-columns: repeat(2, minmax(0, 1fr)); } .nexus-can li:last-child { grid-column: 1 / -1; } }

/* "Oyna" menu: positioned by nexus.js (beside the rail, or above the phone tab bar). */
.nexus-play-menu { position: fixed; z-index: 60; display: flex; flex-direction: column; min-width: 180px; padding: 6px; border: 1px solid var(--nx-line); border-radius: 14px; background: var(--nx-surface); box-shadow: 0 16px 48px rgba(0, 0, 0, .5); }
.nexus-play-menu[hidden] { display: none; }
.nexus .nexus-play-menu button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; margin: 0; padding: 0 14px; border: 0; border-radius: 10px; background: transparent; color: var(--nx-text); font: inherit; font-size: 1rem; font-weight: 700; text-align: left; box-shadow: none; transform: none; cursor: pointer; }
.nexus .nexus-play-menu button:hover { background: var(--nx-raised); }
.nexus-play-menu i { width: 1.25em; color: var(--nx-accent); text-align: center; }
.nexus-tile--safir .nexus-tile-art { color: #7cc4ff; }
.nexus-tile--skin .nexus-tile-art { background: radial-gradient(circle at 30% 20%, #f2c7a5, transparent 55%), linear-gradient(135deg, #8d5a3c, #3a2418); }
.nexus-panel[data-nexus-panel="skin"] { display: grid; gap: 16px; }
.nexus-panel[data-nexus-panel="skin"][hidden] { display: none; }
.nexus-sheet.nexus-skin {
  --skin-panel: #17110e; --skin-card: #211814; --skin-soft: #2b201a; --skin-line: #453328;
  container-type: inline-size; padding: 0; overflow: hidden; background: var(--skin-panel); color: var(--nx-text);
  border: 1px solid var(--skin-line); box-shadow: 0 22px 52px rgba(0, 0, 0, .3);
}
.nexus-skin [hidden] { display: none !important; }
.nexus-skin-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px;
  border-bottom: 1px solid var(--skin-line); background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent);
}
.nexus-skin-bar > div:first-child { display: grid; gap: 2px; min-width: 0; }
.nexus-skin-kicker, .nexus-skin-card-head span, .nexus-skin-result > span, .nexus-skin-control-label {
  color: #b6947f; font-size: .68rem; font-weight: 800; letter-spacing: .11em; line-height: 1.2;
}
.nexus-skin-bar strong { overflow: hidden; color: #fff; font-size: 1.04rem; text-overflow: ellipsis; white-space: nowrap; }
.nexus-skin-file-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.nexus-skin-file-actions .nexus-btn { padding: 8px 11px; background: transparent; font-size: .82rem; }
.nexus-skin-file-actions .nexus-btn:hover { background: var(--skin-soft); }
.nexus-skin .nexus-btn { background-image: none; box-shadow: none; filter: none; text-shadow: none; }
.nexus-skin .nexus-btn:hover { background-image: none; box-shadow: none; filter: none; }
.nexus-skin .nexus-btn.is-primary { border-color: #c77950; background: #d88b60; color: #21120b; }
.nexus-skin .nexus-btn.is-primary:hover { border-color: #d58a60; background: #e19a70; color: #21120b; }
.nexus-skin-progress {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0 18px;
  border-bottom: 1px solid var(--skin-line); background: #130e0c; list-style: none;
}
.nexus-skin-progress li { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 9px; min-width: 0; padding: 13px 16px; color: #7e6b60; }
.nexus-skin-progress li:not(:last-child)::after { content: ""; position: absolute; top: 50%; right: -1px; width: 1px; height: 28px; background: var(--skin-line); transform: translateY(-50%); }
.nexus-skin-progress li > span { display: grid; place-items: center; width: 26px; height: 26px; border: 1px solid #4a382e; border-radius: 50%; background: #1c1512; color: #8f796b; font-size: .72rem; font-weight: 900; }
.nexus-skin-progress li > div { display: grid; gap: 2px; min-width: 0; }
.nexus-skin-progress strong { color: #a89385; font-size: .78rem; line-height: 1.2; }
.nexus-skin-progress small { overflow: hidden; font-size: .66rem; line-height: 1.25; text-overflow: ellipsis; white-space: nowrap; }
.nexus-skin-progress li.is-current { color: #cbb6a8; background: rgba(232, 168, 124, .045); }
.nexus-skin-progress li.is-current > span { border-color: #d88b60; background: #d88b60; color: #21120b; box-shadow: 0 0 0 4px rgba(216, 139, 96, .1); }
.nexus-skin-progress li.is-current strong { color: #fff; }
.nexus-skin-progress li.is-done > span { border-color: #4c8656; background: rgba(91, 209, 106, .12); color: #83d68d; }
.nexus-skin-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px; }
.nexus-skin-gallery { grid-column: 1 / -1; }
.nexus-skin-gallery-source { color: #e8a87c; font-size: .78rem; font-weight: 800; white-space: nowrap; }
.nexus-skin-gallery-source:hover { color: #ffd8bc; }
.nexus-skin-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px;
  max-height: 360px; overflow: auto; padding-right: 2px;
}
.nexus-skin-gallery-item { display: grid; gap: 4px; min-width: 0; }
.nexus-skin-gallery-grid .nexus-btn {
  position: relative; display: grid; gap: 4px; width: 100%; min-width: 0; padding: 6px; border-radius: 10px;
  background: #15100d; box-shadow: none; transform: none;
}
.nexus-skin-gallery-grid .nexus-btn::after { display: none; }
.nexus-skin-gallery-grid .nexus-btn:hover,
.nexus-skin-gallery-grid .nexus-btn:focus-visible,
.nexus-skin-gallery-grid .nexus-btn:active { transform: none; box-shadow: none; }
.nexus-skin-gallery-grid .nexus-btn[aria-pressed="true"] { border-color: #d88b60; background: #3b291f; color: #ffd8bc; box-shadow: inset 0 0 0 1px #d88b60; }
.nexus-skin-gallery-grid .nexus-btn[aria-pressed="true"]::before { content: "\2713"; position: absolute; z-index: 2; top: 8px; right: 8px; display: grid; place-items: center; width: 23px; height: 23px; border-radius: 50%; background: #d88b60; color: #21120b; font-size: .75rem; font-weight: 1000; box-shadow: 0 3px 12px rgba(0, 0, 0, .42); }
.nexus-skin-gallery-grid img { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; }
.nexus-skin-gallery-name,
.nexus-skin-gallery-credit { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .68rem; line-height: 1.2; }
.nexus-skin-gallery-name { color: #f8eee7; font-weight: 700; }
.nexus-skin-gallery-credit { color: #b6947f; }
.nexus-skin-gallery-credit:hover { color: #ffd8bc; }
.nexus-skin-gallery-status { margin: 8px 0 0; color: #bba699; font-size: .78rem; line-height: 1.4; }
.nexus-skin-gallery-status:empty { display: none; }
.nexus-skin-gallery-status.is-error { color: #ff9f91; }
.nexus-skin-gallery-status a { color: #e8a87c; }
.nexus-skin-gallery-more { width: min(240px, 100%); margin: 12px auto 0; background: #291f1a; }
.nexus-skin-gallery-more:disabled { cursor: wait; opacity: .68; }
.nexus-skin-card { min-width: 0; padding: 15px; border: 1px solid var(--skin-line); border-radius: 14px; background: var(--skin-card); }
.nexus-skin-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.nexus-skin-card-head > div { display: grid; gap: 3px; min-width: 0; }
.nexus-skin-card-head h3 { margin: 0; color: #fff; font-size: 1.08rem; line-height: 1.2; }
.nexus-skin-model { display: flex; flex-direction: column; }
.nexus-skin-model-badge { padding: 5px 8px; border: 1px solid var(--skin-line); border-radius: 999px; background: var(--skin-soft); white-space: nowrap; }
.nexus-skin-preview {
  position: relative; flex: 1; min-width: 0; min-height: 390px; overflow: hidden; border: 1px solid #39281f; border-radius: 12px;
  background: radial-gradient(circle at 50% 32%, rgba(232, 168, 124, .11), transparent 42%), linear-gradient(180deg, #17100d, #100b09);
}
.nexus-skin-preview::after { content: ""; position: absolute; left: 14%; right: 14%; bottom: 9%; height: 10%; border-radius: 50%; background: rgba(0, 0, 0, .42); filter: blur(12px); pointer-events: none; }
.nexus-skin-preview canvas { position: absolute; z-index: 1; left: 0; top: 0; touch-action: none; cursor: grab; }
.nexus-skin-preview canvas:active { cursor: grabbing; }
.nexus-skin-preview-hint { position: absolute; z-index: 2; left: 50%; bottom: 11px; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; background: rgba(12, 8, 6, .72); color: #bba89b; font-size: .75rem; white-space: nowrap; pointer-events: none; }
.nexus-skin-edit-toggle { width: 100%; margin-top: 10px; background: transparent; }
.nexus-skin-edit-toggle[aria-expanded="true"] { border-color: #b87854; background: rgba(232, 168, 124, .08); color: #ffd8bc; }
.nexus-skin-options { display: grid; align-content: start; gap: 11px; }
.nexus-skin-options .nexus-skin-card-head { margin-bottom: 1px; }
.nexus-skin-fieldset { display: grid; grid-template-columns: 25px minmax(0, 1fr); gap: 9px; padding-bottom: 11px; border-bottom: 1px solid rgba(69, 51, 40, .7); }
.nexus-skin-fieldset > div { min-width: 0; }
.nexus-skin-fieldset strong { color: #f8eee7; font-size: .9rem; }
.nexus-skin-optional { display: inline-block; margin-left: 5px; padding: 2px 6px; border: 1px solid #4d3a2f; border-radius: 999px; color: #aa9385; font-size: .62rem; font-weight: 700; vertical-align: 1px; }
.nexus-skin-step { display: grid; place-items: center; width: 23px; height: 23px; border-radius: 7px; background: rgba(232, 168, 124, .13); color: var(--nx-accent); font-size: .76rem; font-weight: 900; }
.nexus-skin-fieldset p { margin: 2px 0 8px; color: #9f897b; font-size: .76rem; line-height: 1.35; }
.nexus-skin-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 7px; }
.nexus-skin-choice .nexus-btn { width: 100%; min-width: 0; padding: 8px 7px; border-radius: 8px; background: #291f1a; white-space: normal; font-size: .78rem; line-height: 1.2; }
.nexus-skin-choice .nexus-btn small { display: block; color: currentColor; font-size: .68rem; opacity: .66; }
.nexus-skin-choice .nexus-btn[aria-pressed="true"],
.nexus-skin-tools .nexus-btn[aria-pressed="true"] { border-color: #b87854; background: #3b291f; color: #ffd8bc; box-shadow: none; }
.nexus-skin label:not([hidden]) { display: grid; gap: 6px; margin: 9px 0 0; color: #c2aa9b; font: inherit; font-size: .78rem; font-weight: 700; letter-spacing: 0; }
.nexus-skin label > span { color: #846f62; font-size: .72rem; font-weight: 600; }
.nexus-skin input,
.nexus-skin select {
  width: 100%; box-sizing: border-box; margin: 0; padding: 9px 10px; border: 1px solid var(--skin-line); border-radius: 8px;
  background: #17110e; color: var(--nx-text); box-shadow: none; font: inherit; font-size: .86rem;
}
.nexus-skin input:focus, .nexus-skin select:focus { border-color: #b87854; }
.nexus-skin-select-label { margin-top: 7px !important; }
.nexus-skin-ready-note { display: grid; grid-template-columns: 18px 1fr; gap: 8px; padding: 10px; border-radius: 9px; background: rgba(91, 209, 106, .07); color: #b8cdb9; font-size: .76rem; line-height: 1.4; }
.nexus-skin-ready-note i { padding-top: 2px; color: var(--nx-green); }
.nexus-skin-generate { width: 100%; }
.nexus-skin-generate { min-height: 46px; margin-top: 1px; font-weight: 900; }
.nexus-skin-generate[aria-busy="true"] { cursor: wait; }
.nexus-skin-generate.is-loading i { animation: spin .9s linear infinite; }
.nexus-skin-status { min-height: 0; margin: -3px 2px 0 !important; color: #bba699 !important; font-size: .78rem; line-height: 1.4; }
.nexus-skin-status:not(:empty) { min-height: 1.1em; }
.nexus-skin-status.is-error { color: #ff9f91 !important; }
.nexus-skin-result { padding: 13px; border: 1px solid #4c8656; border-radius: 10px; background: linear-gradient(180deg, rgba(91, 209, 106, .08), #15100d 60%); }
.nexus-skin [data-skin-result]:not([hidden]) { display: grid; gap: 8px; }
.nexus-skin-result > span { color: #83d68d; }
.nexus-skin-result p { margin: 0; color: #b8cdb9; font-size: .77rem; line-height: 1.4; }
.nexus-skin-result code { display: block; padding: 9px 10px; border: 1px solid #3d2d24; border-radius: 8px; background: #0e0a08; color: #f9e9dc; user-select: all; overflow-wrap: anywhere; font-size: .76rem; line-height: 1.4; }
.nexus-skin-editor { grid-column: 1 / -1; }
.nexus-skin-editor:not([hidden]) { display: block; }
.nexus-skin-coordinate { align-self: center; max-width: 52%; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.nexus-skin-editor-body { display: grid; grid-template-columns: minmax(300px, 1fr) minmax(220px, 280px); align-items: start; gap: 16px; }
.nexus-skin-map-wrap {
  position: relative; width: min(100%, 480px); aspect-ratio: 1; justify-self: center; overflow: hidden;
  border: 1px solid #6a4c39; border-radius: 10px; background: repeating-conic-gradient(#2c211b 0% 25%, #1c1511 0% 50%) 50% / 20px 20px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, .24);
}
.nexus-skin-texture {
  display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; image-rendering: pixelated;
}
.nexus-skin-guide { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; image-rendering: pixelated; }
.nexus-skin-controls { display: grid; gap: 15px; min-width: 0; }
.nexus-skin-controls > div { display: grid; gap: 7px; }
.nexus-skin-controls p { margin: 0; color: #9f897b; font-size: .77rem; line-height: 1.45; }
.nexus-skin-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.nexus-skin-tools .nexus-btn { width: 100%; min-width: 0; padding: 8px 7px; border-radius: 8px; background: #291f1a; font-size: .76rem; white-space: normal; }
.nexus-skin-history { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px !important; }
.nexus-skin-history .nexus-btn { width: 100%; padding: 8px; font-size: .78rem; }
.nexus-skin-color > span { display: flex; align-items: center; gap: 9px; }
.nexus-skin input[type="color"] { flex: none; width: 48px; height: 40px; padding: 3px; cursor: pointer; }
.nexus-skin-color code { color: #ead8cc; font-size: .84rem; }
.nexus-skin-editor-note { display: grid; grid-template-columns: 16px 1fr; gap: 7px; padding: 10px; border-radius: 9px; background: rgba(232, 168, 124, .07); color: #bda596 !important; }
.nexus-skin-editor-note i { padding-top: 3px; color: var(--nx-accent); }
@container (min-width: 720px) {
  .nexus-skin-grid { grid-template-columns: minmax(300px, 1fr) minmax(270px, 330px); align-items: stretch; }
}
@container (max-width: 719px) {
  .nexus-skin-bar { align-items: flex-start; }
  .nexus-skin-file-actions { max-width: 260px; }
  .nexus-skin-preview { min-height: 340px; }
  .nexus-skin-editor-body { grid-template-columns: minmax(0, 1fr); }
  .nexus-skin-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nexus-skin-editor-note { align-self: end; }
}
@container (max-width: 480px) {
  .nexus-skin-bar { display: grid; }
  .nexus-skin-file-actions { justify-content: flex-start; max-width: none; }
  .nexus-skin-file-actions .nexus-btn { flex: 1; }
  .nexus-skin-card { padding: 12px; }
  .nexus-skin-preview { min-height: 310px; }
  .nexus-skin-editor-body { display: block; }
  .nexus-skin-controls { display: grid; grid-template-columns: 1fr; margin-top: 14px; }
  .nexus-skin-coordinate { display: none; }
  .nexus-skin-progress { padding: 0 7px; }
  .nexus-skin-progress li { grid-template-columns: 1fr; justify-items: center; gap: 5px; padding: 11px 5px; text-align: center; }
  .nexus-skin-progress li > div { justify-items: center; }
  .nexus-skin-progress small { display: none; }
}
