:root {
  --bg: #0b0614;
  --panel: rgba(16, 14, 38, 0.9);
  --line: rgba(148, 163, 184, 0.45);
  --text: #f8fafc;
  --muted: #a8a3b8;
  --accent: #f97316;
  --accent2: #facc15;
  --good: #4ade80;
  --danger: #f43f5e;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; }
body { font-family: 'Kanit', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; touch-action: none; }
button, input { font: inherit; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; display: grid; place-items: center; }
#stage { position: relative; width: min(100vw, 177.78vh); aspect-ratio: 16 / 9; background: #000; }
#stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#gl { image-rendering: pixelated; }
#hud { pointer-events: none; }

/* ---------- title ---------- */
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center; overflow-y: auto; padding: 16px;
  background: radial-gradient(ellipse at 50% 20%, rgba(30, 58, 138, 0.45), rgba(8, 4, 20, 0.93) 70%);
}
.menu-card {
  width: min(780px, 100%); padding: 22px 26px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(71, 85, 105, 0.35), rgba(15, 12, 35, 0.92) 30%), var(--panel);
  border: 2px solid var(--line);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.logo { text-align: center; line-height: 1; margin-bottom: 8px; }
.logo .jp { font-weight: 800; font-size: 22px; letter-spacing: 8px; color: #fde68a; text-shadow: 0 2px 0 #7c2d12; }
.logo .en {
  font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: clamp(28px, 6vw, 50px); letter-spacing: 1px;
  background: linear-gradient(180deg, #fff 0%, #fdba74 45%, #ea580c 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 3px 0 #431407);
}
.logo .en span { background: linear-gradient(180deg, #e0f2fe, #38bdf8 50%, #1d4ed8); -webkit-background-clip: text; background-clip: text; }
.logo .online { font-family: 'Orbitron', sans-serif; font-size: 12px; letter-spacing: 4px; color: #93c5fd; margin-top: 6px; }
.story { text-align: center; margin: 4px 0 14px; color: var(--muted); font-size: 14px; }

.field { display: block; font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.field input, .join input {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16); color: var(--text); outline: none;
}
.field input:focus, .join input:focus, #chatInput:focus { border-color: var(--accent); }
.section-label { font-size: 13px; color: var(--muted); margin: 4px 0 6px; }

.kemo { display: flex; align-items: center; gap: 10px; margin: 4px 0 8px; }
.kemo canvas { width: 48px; height: 48px; border-radius: 8px; border: 2px solid #0d5b4a; }
.kemo .bubble { background: linear-gradient(180deg, #6d6fc9, #23255e); border: 1px solid #c3cadb; padding: 6px 12px; border-radius: 8px; font-size: 14px; }

.pilots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.pilot {
  padding: 8px; border-radius: 12px; cursor: pointer; text-align: center; transition: transform .12s, border-color .12s;
  background: rgba(255, 255, 255, 0.04); border: 2px solid rgba(255, 255, 255, 0.1);
}
.pilot:hover { transform: translateY(-2px); }
.pilot.sel { border-color: var(--pc); background: rgba(255, 255, 255, 0.09); box-shadow: 0 0 22px -6px var(--pc); }
.pilot canvas { width: 76px; height: 76px; border-radius: 8px; border: 2px solid #0d5b4a; }
.pilot .pn { font-weight: 600; font-size: 16px; }
.pilot .mn { font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: 13px; color: var(--pc); }
.pilot .pd { font-size: 11.5px; color: #d4d0e0; margin-top: 3px; line-height: 1.35; min-height: 30px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hangar-link { grid-column: 1 / -1; display: block; text-align: center; padding: 9px; border-radius: 10px; border: 1px dashed rgba(125, 211, 252, 0.6); color: #7dd3fc; text-decoration: none; font-weight: 600; }
.hangar-link:hover { background: rgba(125, 211, 252, 0.1); }
.actions .wide { grid-column: 1 / -1; padding: 14px; font-size: 18px; }

button {
  padding: 10px 16px; border-radius: 10px; cursor: pointer; color: var(--text); font-weight: 600;
  background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.18); transition: filter .12s, transform .06s;
}
button:hover { filter: brightness(1.2); }
button:active { transform: translateY(1px); }
button.primary { background: linear-gradient(180deg, #fb923c, #c2410c); border-color: #fdba74; color: #fff; text-shadow: 0 1px 0 #7c2d12; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 13px; }
button.wide { width: 100%; margin-top: 8px; }

.help { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; margin-top: 14px; font-size: 12.5px; color: var(--muted); }
kbd {
  display: inline-block; min-width: 22px; padding: 1px 5px; border-radius: 5px; text-align: center;
  background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); border-bottom-width: 2px; font-family: inherit; font-size: 12px; color: var(--text);
}
.status { text-align: center; margin-top: 10px; font-size: 13px; color: var(--muted); }
.status.ok { color: var(--good); }
.status.bad { color: var(--danger); }

/* ---------- room panel ---------- */
.panel {
  position: absolute; right: 16px; top: 60px; width: 290px; padding: 14px; border-radius: 14px;
  background: var(--panel); border: 2px solid var(--line); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.rp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.rp-head b { font-family: 'Orbitron', sans-serif; font-size: 22px; color: var(--accent2); letter-spacing: 3px; }
#rpPlayers { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 6px; }
#rpPlayers li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(255, 255, 255, 0.05); font-size: 14px; }
#rpPlayers .chip { width: 12px; height: 12px; border-radius: 3px; flex: none; }
#rpPlayers .pm { margin-left: auto; font-family: 'Orbitron', sans-serif; font-size: 11px; color: var(--muted); }
.pilot-mini { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pilot-mini button { padding: 6px 0; font-size: 12px; border-width: 2px; line-height: 1.2; }
.pilot-mini button small { display: block; font-family: 'Orbitron', sans-serif; font-size: 9px; color: var(--muted); }
.pilot-mini button.sel { border-color: var(--pc); box-shadow: 0 0 12px -3px var(--pc); }
.muted { color: var(--muted); font-size: 13px; margin: 8px 0 0; text-align: center; }

/* ---------- chat ---------- */
/* chat: top-left of the game view, under the party strip; input only shows while typing (Enter) */
#chat { position: absolute; left: 1%; top: 8.5%; width: min(340px, 34%); pointer-events: none; }
#chatLog { display: flex; flex-direction: column; gap: 1px; font-size: 12px; text-shadow: 0 1px 2px #000, 0 0 4px #000; }
#chatLog div { animation: fadeout 10s forwards; }
#chatLog .sys { color: var(--accent2); }
#chatLog b { color: #fdba74; font-weight: 600; }
#chatInput {
  pointer-events: auto; width: 100%; margin-top: 4px; padding: 5px 9px; border-radius: 6px; font-size: 12px;
  background: rgba(4, 12, 26, 0.85); border: 1px solid rgba(56, 232, 255, 0.6); color: var(--text); outline: none;
  opacity: 0; height: 0; padding-top: 0; padding-bottom: 0; border-width: 0;
}
#chatInput:focus { opacity: 1; height: auto; padding-top: 5px; padding-bottom: 5px; border-width: 1px; }
@keyframes fadeout { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

#corner { position: absolute; right: 12px; top: 44px; display: flex; gap: 6px; }
body:not(.inroom) #corner { top: auto; bottom: 12px; }
button.icon { width: 36px; height: 36px; padding: 0; font-size: 16px; background: rgba(0, 0, 0, 0.45); }

#toast {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 10px;
  background: rgba(190, 18, 60, 0.92); font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; }

/* ---------- touch ---------- */
#touch { display: none; position: absolute; inset: auto 0 0 0; justify-content: space-between; align-items: flex-end; padding: 0 max(12px, env(safe-area-inset-right)) max(130px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); pointer-events: none; }
body.touch.inroom #touch { display: flex; }
#touch .pad { pointer-events: auto; }
#touch .pad.left { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
#touch .pad.left .up { grid-area: 1 / 2; } #touch .pad.left .lt { grid-area: 2 / 1; } #touch .pad.left .rt { grid-area: 2 / 3; } #touch .pad.left .dn { grid-area: 3 / 2; }
#touch .pad.right { display: grid; grid-template-columns: repeat(3, 62px); gap: 8px; align-items: end; }
#touch button {
  width: 56px; height: 56px; border-radius: 50%; font-size: 15px; padding: 0; user-select: none; -webkit-user-select: none;
  background: rgba(255, 255, 255, 0.12); border: 2px solid rgba(255, 255, 255, 0.25);
}
#touch .pad.right button { width: 62px; height: 62px; }
#touch .pad.right .sm { height: 40px; border-radius: 12px; font-size: 12px; }
#touch .pad.right .big { background: rgba(249, 115, 22, 0.35); }
#touch button.on { background: rgba(251, 146, 60, 0.6); }
body.touch #chat { display: none !important; }
body.shopping #roomPanel, body.shopping #touch { display: none !important; }
#touch #tShop { visibility: hidden; }
body.intown #touch #tShop { visibility: visible; }

#rotate { display: none; position: absolute; top: 16px; left: 50%; transform: translateX(-50%); padding: 8px 14px; border-radius: 10px; background: rgba(0, 0, 0, 0.6); font-size: 14px; white-space: nowrap; }
@media (orientation: portrait) { body.touch.inroom #rotate { display: block; } }

@media (max-width: 720px) {
  .pilots { grid-template-columns: repeat(2, 1fr); }
  .actions { grid-template-columns: 1fr; }
  .panel { right: 8px; left: 8px; width: auto; top: auto; bottom: 8px; }
  .menu-card { padding: 16px 14px; }
}

/* ---------- town shop / status window ---------- */
#shop { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(2, 6, 16, 0.55); backdrop-filter: blur(2px); --sc: #38e8ff; z-index: 5; }
.shop-win {
  width: min(900px, 96vw); height: min(600px, 96vh); overflow: hidden; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px;
  background: linear-gradient(180deg, rgba(8, 24, 44, 0.96), rgba(3, 10, 22, 0.97)); color: #e6fbff;
  border: 1px solid color-mix(in srgb, var(--sc) 70%, transparent); border-radius: 4px;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
  box-shadow: 0 0 40px -10px var(--sc), inset 0 0 60px rgba(56, 232, 255, 0.06);
  background-image: repeating-linear-gradient(0deg, rgba(56, 232, 255, 0.035) 0 1px, transparent 1px 3px), linear-gradient(180deg, rgba(8, 24, 44, 0.96), rgba(3, 10, 22, 0.97));
}
.shop-head { display: flex; align-items: center; gap: 12px; }
.shop-face { width: 64px; height: 64px; flex: none; clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); border: 2px solid var(--sc); background: #0b1220; }
.shop-title { flex: 1; min-width: 0; }
.shop-name { font-family: 'Orbitron', 'Kanit', sans-serif; font-weight: 700; font-size: 17px; letter-spacing: 1.5px; color: var(--sc); text-shadow: 0 0 10px var(--sc); }
.shop-hello { font-size: 13.5px; color: #cbeff7; margin-top: 2px; }
.shop-mec { display: flex; align-items: baseline; gap: 6px; padding: 6px 12px; border: 1px solid rgba(255, 176, 32, 0.6); background: rgba(255, 176, 32, 0.08); }
.shop-mec small { font-size: 11px; color: #fcd889; }
.shop-mec b { font-family: 'Orbitron', sans-serif; font-size: 20px; color: #ffb020; text-shadow: 0 0 8px rgba(255, 176, 32, 0.7); }
.shop-close { width: 34px; height: 34px; padding: 0; background: rgba(255, 59, 92, 0.12); border-color: rgba(255, 59, 92, 0.6); }
.shop-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.shop-tabs button { padding: 5px 10px; font-family: 'Orbitron', sans-serif; font-size: 11px; letter-spacing: 1px; border-radius: 2px; background: rgba(56, 232, 255, 0.06); border-color: rgba(56, 232, 255, 0.3); color: #9fdcea; }
.shop-tabs button.on { background: rgba(56, 232, 255, 0.2); border-color: #38e8ff; color: #fff; box-shadow: 0 0 10px -2px #38e8ff; }
.shop-load { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.shop-load .cell { padding: 4px 6px; background: rgba(56, 232, 255, 0.05); border-left: 2px solid rgba(56, 232, 255, 0.5); min-width: 0; }
.shop-load .cell small { display: block; font-family: 'Orbitron', sans-serif; font-size: 8.5px; letter-spacing: 1px; color: #6fb7c7; }
.shop-load .cell span { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shop-load .cell.empty span { color: #64748b; }
.shop-load .cell.items span { font-family: 'Orbitron', sans-serif; font-size: 9.5px; }
.shop-body { display: grid; grid-template-columns: 1.15fr 1fr; grid-template-rows: minmax(0, 1fr); gap: 10px; min-height: 0; flex: 1; }
.shop-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; border: 1px solid rgba(56, 232, 255, 0.18); }
.shop-list li { display: flex; align-items: center; gap: 8px; padding: 7px 10px; cursor: pointer; font-size: 14px; border-bottom: 1px solid rgba(56, 232, 255, 0.08); }
.shop-list li:hover { background: rgba(56, 232, 255, 0.07); }
.shop-list li.sel { background: linear-gradient(90deg, color-mix(in srgb, var(--sc) 30%, transparent), transparent); box-shadow: inset 3px 0 0 var(--sc); }
.shop-list li.empty { color: #64748b; cursor: default; }
.shop-list .nm { flex: 1; }
.shop-list .tg { font-size: 10.5px; padding: 1px 6px; border: 1px solid; border-radius: 2px; }
.shop-list .tg.eq { color: #3dff9a; border-color: rgba(61, 255, 154, 0.6); }
.shop-list .tg.own { color: #7dd3fc; border-color: rgba(125, 211, 252, 0.5); }
.shop-list .pr { font-family: 'Orbitron', sans-serif; font-size: 12px; color: #ffb020; min-width: 64px; text-align: right; }
.shop-list .pr.poor { color: #ff5c7a; opacity: 0.8; }
.shop-detail { padding: 10px 12px; border: 1px solid rgba(56, 232, 255, 0.18); background: rgba(56, 232, 255, 0.03); display: flex; flex-direction: column; gap: 6px; min-height: 0; overflow-y: auto; }
.shop-detail .dn { font-size: 20px; font-weight: 600; color: #fff; text-shadow: 0 0 10px var(--sc); }
.shop-detail .dt { font-size: 13px; color: #a5d8e4; }
.shop-detail .dt.small { font-size: 11.5px; color: #7fa7b3; }
.shop-detail .stats { display: grid; gap: 5px; margin: 4px 0; }
.shop-detail .st { display: grid; grid-template-columns: 78px 1fr 64px 14px; align-items: center; gap: 8px; font-size: 12.5px; }
.shop-detail .sl { color: #9fdcea; }
.shop-detail .bar { height: 8px; background: rgba(56, 232, 255, 0.1); clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%); }
.shop-detail .bar i { display: block; height: 100%; background: linear-gradient(90deg, #38e8ff, var(--sc)); box-shadow: 0 0 8px var(--sc); }
.shop-detail .sv { font-family: 'Orbitron', sans-serif; font-size: 11.5px; text-align: right; }
.shop-detail .cmp { font-size: 11px; }
.shop-detail .cmp.good { color: #3dff9a; }
.shop-detail .cmp.bad { color: #ff5c7a; }
.shop-detail .acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 6px; }
.shop-detail .acts button { padding: 7px 12px; font-size: 13px; border-radius: 2px; background: rgba(56, 232, 255, 0.08); border-color: rgba(56, 232, 255, 0.45); }
.shop-detail .acts button.primary { background: linear-gradient(180deg, color-mix(in srgb, var(--sc) 55%, #000), color-mix(in srgb, var(--sc) 25%, #000)); border-color: var(--sc); text-shadow: none; }
.shop-detail .acts button.on { color: #3dff9a; border-color: rgba(61, 255, 154, 0.6); }
.shop-detail .acts button:disabled { opacity: 0.4; cursor: default; filter: none; transform: none; }
.shop-foot { font-size: 11.5px; color: #6fb7c7; text-align: center; }
@media (max-width: 720px) {
  .shop-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 40%) minmax(0, 1fr); } /* list on top, details below, both scroll inside */
  .shop-load { grid-template-columns: repeat(3, 1fr); }
}
.shop-list .th { width: 52px; height: 30px; flex: none; display: grid; place-items: center; }
.shop-list .th img { max-width: 100%; max-height: 100%; filter: drop-shadow(0 0 3px rgba(56, 232, 255, 0.35)); }
.shop-detail .art {
  height: 150px; display: grid; place-items: center; margin: -2px 0 2px;
  background: radial-gradient(ellipse at 50% 60%, color-mix(in srgb, var(--sc) 22%, transparent), transparent 70%),
    repeating-linear-gradient(90deg, rgba(56, 232, 255, 0.06) 0 1px, transparent 1px 16px),
    repeating-linear-gradient(0deg, rgba(56, 232, 255, 0.06) 0 1px, transparent 1px 16px);
  border: 1px solid rgba(56, 232, 255, 0.15);
}
.shop-detail .art img { max-width: 94%; max-height: 140px; filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 8px color-mix(in srgb, var(--sc) 45%, transparent)); animation: artIn .25s ease-out; }
@keyframes artIn { from { opacity: 0; transform: translateX(-12px) scale(0.96); } }

/* ---------- title screen ---------- */
#title { position: fixed; inset: 0; z-index: 50; overflow: hidden; background: #05020c; cursor: pointer; user-select: none; -webkit-user-select: none; }
#title .t-bg {
  position: absolute; inset: -3%; background: url('/art/title/keyart.webp') center 38% / cover no-repeat;
  opacity: 0; transform: scale(1.12); filter: saturate(1.1) brightness(0.55);
  transition: opacity 1.4s ease, transform 2.2s cubic-bezier(.2,.7,.2,1), filter 1.4s ease;
}
#title.in .t-bg { opacity: 1; transform: scale(1.02); filter: saturate(1.12) brightness(1); animation: tDrift 26s ease-in-out 2.2s infinite alternate; }
@keyframes tDrift { to { transform: scale(1.08) translate(-1%, -1%); } }
#title .t-shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5, 2, 12, 0.72) 0%, rgba(5, 2, 12, 0.15) 34%, rgba(5, 2, 12, 0) 55%, rgba(5, 2, 12, 0.55) 78%, rgba(5, 2, 12, 0.92) 100%),
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(5, 2, 12, 0.6) 100%);
}
#title .t-embers { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#title .t-scan { position: absolute; inset: 0; pointer-events: none; opacity: 0.18; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0 1px, transparent 1px 3px); }

#title .t-logo { position: absolute; left: 0; right: 0; top: 4.5vh; text-align: center; line-height: 0.9; opacity: 0; transform: scale(1.8); filter: blur(12px); }
#title.in .t-logo { animation: tSlam .55s cubic-bezier(.2,1.4,.4,1) .45s forwards; }
@keyframes tSlam { to { opacity: 1; transform: scale(1); filter: blur(0); } }
#title .t-jp { display: inline-flex; gap: 0.35em; margin-bottom: 0.6vh; }
#title .t-jp span {
  display: grid; place-items: center; width: clamp(26px, 3.6vw, 48px); aspect-ratio: 1; font-family: 'Kanit', serif; font-weight: 800;
  font-size: clamp(16px, 2.4vw, 32px); color: #fff; background: linear-gradient(180deg, #ef4444, #991b1b);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%); text-shadow: 0 2px 0 #450a0a;
}
#title .t-ride {
  display: inline-block; font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: clamp(20px, 3.4vw, 46px); letter-spacing: 0.32em; padding: 0.12em 0.5em 0.12em 0.82em;
  color: #fff7ed; background: linear-gradient(90deg, transparent, rgba(234, 88, 12, 0.92) 12%, rgba(194, 65, 12, 0.92) 88%, transparent);
  transform: skewX(-14deg); text-shadow: 0 2px 0 #431407, 0 0 14px rgba(253, 186, 116, 0.8);
}
#title .t-guy {
  position: relative; font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: clamp(46px, 10.5vw, 150px); letter-spacing: 0.02em; margin-top: 0.05em;
  background: linear-gradient(180deg, #ffffff 0%, #dbeafe 30%, #60a5fa 52%, #1d4ed8 70%, #93c5fd 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-stroke: clamp(1.5px, 0.25vw, 3px) #0b1b4d;
  filter: drop-shadow(0 0.06em 0 #0a1238) drop-shadow(0 0 0.25em rgba(56, 189, 248, 0.55));
}
#title .t-guy::after { /* moving shine */
  content: attr(data-text); position: absolute; inset: 0; -webkit-text-stroke: 0; color: transparent;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.95) 50%, transparent 60%) no-repeat;
  background-size: 250% 100%; background-position: 150% 0; -webkit-background-clip: text; background-clip: text;
  animation: tShine 4.5s ease-in-out 1.4s infinite;
}
@keyframes tShine { 0% { background-position: 150% 0; } 35%, 100% { background-position: -60% 0; } }
#title .t-sub { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 1.2vh; font-family: 'Orbitron', sans-serif; font-weight: 700; font-size: clamp(10px, 1.3vw, 16px); letter-spacing: 0.4em; color: #bae6fd; text-shadow: 0 0 10px rgba(56, 189, 248, 0.9), 0 2px 2px #000; }
#title .t-sub i { display: block; width: clamp(30px, 8vw, 120px); height: 2px; background: linear-gradient(90deg, transparent, #38bdf8); }
#title .t-sub i:last-child { transform: scaleX(-1); }

#title .t-bottom { position: absolute; left: 0; right: 0; bottom: 11vh; text-align: center; opacity: 0; transition: opacity .6s ease 1.1s; }
#title.in .t-bottom { opacity: 1; }
#title .t-press {
  display: inline-block; font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: clamp(20px, 3vw, 38px); letter-spacing: 0.3em; padding-left: 0.3em;
  color: #fde047; text-shadow: 0 0 12px rgba(250, 204, 21, 0.9), 0 3px 0 #713f12; animation: tBlink 1.1s steps(1) infinite;
}
@keyframes tBlink { 50% { opacity: 0.15; } }
#title .t-hint { margin-top: 6px; font-size: clamp(12px, 1.3vw, 15px); color: #e2e8f0; text-shadow: 0 1px 3px #000; }
#title .t-foot { position: absolute; left: 16px; right: 16px; bottom: 12px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-family: 'Orbitron', 'Kanit', sans-serif; font-size: 11px; letter-spacing: 0.12em; color: rgba(226, 232, 240, 0.6); }
#title #tOnline.ok { color: #4ade80; text-shadow: 0 0 8px rgba(74, 222, 128, 0.6); }
#title #tOnline.bad { color: #f43f5e; }
#title .t-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#title.go .t-press { animation: tBlink .08s steps(1) infinite; }
#title.go .t-flash { animation: tFlash .9s ease-out forwards; }
@keyframes tFlash { 0% { opacity: 0; } 30% { opacity: 0.95; } 100% { opacity: 0; } }
#title.out { transition: opacity .7s ease; opacity: 0; pointer-events: none; }
@media (orientation: portrait) {
  #title .t-bg { background-position: 42% center; }
  #title .t-logo { top: 7vh; }
}
.menu-card.enter { animation: cardIn .6s cubic-bezier(.2,1.2,.4,1) both; }
@keyframes cardIn { from { opacity: 0; transform: translateY(24px) scale(0.96); } }

/* ---------- save record / sign-in ---------- */
.record { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: -2px 0 10px; padding: 8px 10px; border-radius: 10px; background: rgba(56, 232, 255, 0.06); border: 1px solid rgba(56, 232, 255, 0.25); }
.record .rec-info { flex: 1; min-width: 180px; display: flex; flex-direction: column; line-height: 1.3; }
.record .rec-info b { font-size: 13.5px; color: #bae6fd; font-weight: 600; }
.record .rec-info span { font-family: 'Orbitron', 'Kanit', sans-serif; font-size: 12px; color: #fcd34d; letter-spacing: 0.5px; }
.record.reg { border-color: rgba(74, 222, 128, 0.5); background: rgba(74, 222, 128, 0.07); }
.record.reg .rec-info b { color: #86efac; }
.record.temp { border-color: rgba(251, 191, 36, 0.5); }
.record .rec-actions { display: flex; gap: 6px; }
.authbox { margin: -4px 0 12px; padding: 10px; border-radius: 10px; background: rgba(8, 20, 38, 0.9); border: 1px solid rgba(56, 232, 255, 0.45); display: grid; gap: 8px; }
.authbox .auth-title { font-weight: 600; font-size: 14px; color: #e0f2fe; }
.authbox .auth-row { display: flex; gap: 8px; flex-wrap: wrap; }
.authbox input { flex: 1; min-width: 140px; padding: 8px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(255, 255, 255, 0.16); color: var(--text); outline: none; }
.authbox input:focus { border-color: #38bdf8; }
.authbox .auth-note { font-size: 12px; color: var(--muted); }
#name:disabled { opacity: 0.75; border-color: rgba(74, 222, 128, 0.5); }
#toast.ok { background: rgba(21, 128, 61, 0.92); }

/* pilots not open yet: shown, but greyed out and not selectable */
.pilot.locked { cursor: not-allowed; filter: grayscale(1) brightness(0.55); opacity: 0.7; }
.pilot.locked:hover { transform: none; }
.pilot.locked .pd { color: #fde68a; font-weight: 600; }

/* ---------- world map (painted desert + area nodes) ---------- */
#worldmap { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(2, 6, 16, 0.6); backdrop-filter: blur(2px); z-index: 6; }
.wm-win {
  width: min(1000px, 96vw); max-height: 96vh; display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; color: #fff7e6;
  background: linear-gradient(180deg, rgba(40, 24, 10, 0.97), rgba(18, 10, 4, 0.98)); border: 1px solid #f5b85a; border-radius: 4px;
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px); box-shadow: 0 0 40px -10px #f59e0b;
}
.wm-head { display: flex; align-items: baseline; gap: 12px; }
.wm-head b { font-family: 'Orbitron', sans-serif; font-size: 18px; letter-spacing: 3px; color: #facc15; text-shadow: 0 0 10px rgba(250, 204, 21, 0.6); }
.wm-head span { flex: 1; font-size: 13px; color: #fcd9a0; }
.wm-x { padding: 2px 10px; min-width: 0; }
.wm-map { position: relative; aspect-ratio: 16 / 9; width: 100%; max-height: 62vh; margin: 0 auto; overflow: hidden; border: 1px solid rgba(245, 184, 90, 0.5); }
.wm-map img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.wm-map svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.wm-map line { stroke-width: 0.6; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.wm-map line.on { stroke: #fff2c2; stroke-width: 4; stroke-dasharray: 10 7; filter: drop-shadow(0 0 3px #000); animation: wmTrail 1s linear infinite; }
.wm-map line.off { stroke: rgba(40, 20, 10, 0.55); stroke-width: 3; stroke-dasharray: 4 8; }
@keyframes wmTrail { to { stroke-dashoffset: -17; } }
.wm-node {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: 0; padding: 0; min-width: 0; cursor: pointer; box-shadow: none; transition: none;
}
.wm-node:active { transform: translate(-50%, -50%); } /* the global button press-dip would shove the pin off the cursor */
.wm-map { cursor: pointer; touch-action: manipulation; }
.wm-node .pin {
  width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; font: 700 15px 'Orbitron', sans-serif; color: #fff;
  background: radial-gradient(circle at 35% 30%, #fb923c, #9a3412); border: 2px solid #fff3d6; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}
.wm-node .lbl { font-size: 12px; font-weight: 600; white-space: nowrap; padding: 1px 7px; border-radius: 3px; background: rgba(20, 10, 4, 0.78); color: #ffe7b8; }
.wm-node.done .pin { background: radial-gradient(circle at 35% 30%, #4ade80, #166534); }
.wm-node.locked .pin { background: radial-gradient(circle at 35% 30%, #78716c, #292524); border-color: #a8a29e; font-size: 13px; }
.wm-node.locked .lbl { color: #a8a29e; }
.wm-node.town .pin { background: radial-gradient(circle at 35% 30%, #38bdf8, #075985); font-size: 16px; }
.wm-node.open .pin { animation: wmPulse 1.2s ease-in-out infinite; }
.wm-node.sel .pin { outline: 3px solid #facc15; outline-offset: 3px; transform: scale(1.15); }
.wm-node.sel .lbl { background: #facc15; color: #1c1004; }
@keyframes wmPulse { 50% { box-shadow: 0 0 0 7px rgba(251, 146, 60, 0.35), 0 2px 6px rgba(0, 0, 0, 0.6); } }
.wm-info { display: flex; gap: 12px; align-items: center; }
.wm-desc { flex: 1; min-width: 0; }
.wm-desc .nm { font-size: 18px; font-weight: 700; color: #ffd27a; }
.wm-desc em { font-style: normal; font-size: 12px; padding: 1px 8px; border-radius: 3px; margin-left: 6px; vertical-align: 2px; }
.wm-desc em.ok { background: #166534; color: #dcfce7; }
.wm-desc em.new { background: #c2410c; color: #fff; }
.wm-desc em.lock { background: #44403c; color: #d6d3d1; }
.wm-desc .tx { font-size: 13.5px; color: #fbe6c4; margin-top: 2px; }
.wm-desc .tx.small { font-size: 12.5px; color: #e7c79a; }
.wm-desc .tx b { color: #fca5a5; }
.wm-acts { display: flex; gap: 8px; flex: none; }
.wm-acts button { font-size: 16px; padding: 10px 18px; }
.wm-acts button:disabled { opacity: 0.45; filter: grayscale(1); cursor: not-allowed; }
.wm-foot { font-size: 11.5px; color: #c9a877; text-align: center; }
body.touch .wm-foot { display: none; }
@media (max-width: 700px) {
  .wm-win { padding: 8px; gap: 6px; }
  .wm-head span { display: none; }
  .wm-node .pin { width: 26px; height: 26px; font-size: 12px; }
  .wm-node .lbl { font-size: 10px; padding: 0 4px; }
  .wm-info { flex-direction: column; align-items: stretch; }
  .wm-acts button { flex: 1; padding: 8px; }
}
