:root {
  --ink: #1a0b33;
  --ink-2: #2b1352;
  --pink: #ff4fa3;
  --gold: #ffc933;
  --cyan: #2ef2d0;
  --header-h: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 20%, #4b1d7a 0%, var(--ink) 70%);
  color: #fff;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

#rtd-header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  background: rgba(16, 6, 34, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 5;
}

.rtd-brand { display: flex; align-items: center; gap: 8px; font-weight: 900; font-style: italic; font-size: 20px; letter-spacing: 0.5px; white-space: nowrap; }
.rtd-brand-icon { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; }
.rtd-loader-logo { width: min(560px, 82vw); height: auto; margin-bottom: 6px; filter: drop-shadow(0 10px 30px rgba(0, 0, 0, 0.45)); animation: rtd-logo-in 0.6s cubic-bezier(.2, 1.4, .4, 1) both, rtd-logo-bob 3.2s ease-in-out 0.6s infinite; }
@keyframes rtd-logo-in { from { transform: scale(0.7) rotate(-4deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes rtd-logo-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.rtd-run { color: #fff; }
.rtd-degen { color: var(--gold); text-shadow: 0 2px 0 #7a3b00; }

#rtd-links { margin-left: auto; display: flex; gap: 8px; }

.rtd-link {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.4px;
  text-decoration: none;
  color: #fff;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.rtd-link:hover { transform: translateY(-1px) scale(1.03); filter: brightness(1.1); }
.rtd-link.buy { background: linear-gradient(180deg, #34d77a, #1fae5c); }
.rtd-link.x { background: #000; border: 1px solid rgba(255, 255, 255, 0.25); }
.rtd-link.site { background: linear-gradient(180deg, #9b6bff, #7444f0); }
.rtd-link.ca { background: rgba(255, 255, 255, 0.08); border: 1px dashed rgba(255, 216, 74, 0.7); color: var(--gold); cursor: pointer; font-family: inherit; }
.rtd-link-icon { width: 18px; height: 18px; margin-right: 7px; border-radius: 4px; object-fit: contain; }

.rtd-icon-btn {
  width: 34px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
}
#rtd-links:empty + .rtd-icon-btn { margin-left: auto; }

#rtd-stage {
  position: relative;
  width: 100%;
  height: calc(100% - var(--header-h));
  background: var(--ink);
}
#rtd-stage:fullscreen { height: 100%; }

#unity-canvas { width: 100%; height: 100%; display: block; background: var(--ink); outline: none; }

#rtd-loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 35%, #5a2190 0%, var(--ink) 72%);
  transition: opacity 0.5s ease;
}
#rtd-loader.done { opacity: 0; pointer-events: none; }

.rtd-loader-title {
  text-align: center;
  font-weight: 900;
  font-style: italic;
  line-height: 0.95;
  transform: rotate(-3deg);
}
.rtd-loader-title .rtd-run { font-size: clamp(32px, 6vw, 64px); }
.rtd-loader-title .rtd-degen { font-size: clamp(56px, 11vw, 120px); }

.rtd-bar {
  width: min(460px, 80vw);
  height: 16px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
#rtd-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--gold));
  transition: width 0.2s ease;
}
#rtd-percent { font-weight: 800; font-size: 18px; color: var(--gold); }
#rtd-tip { font-size: 15px; opacity: 0.85; text-align: center; padding: 0 20px; }

#rtd-warning { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 10; width: min(640px, 92vw); }
.rtd-msg { padding: 10px 14px; margin-bottom: 8px; border-radius: 10px; font-size: 14px; }
.rtd-msg.warn { background: rgba(255, 201, 51, 0.95); color: #2a1800; }
.rtd-msg.error { background: rgba(255, 71, 87, 0.95); color: #fff; }

@media (max-width: 560px) {
  .rtd-brand { font-size: 16px; }
  .rtd-link { padding: 0 10px; font-size: 12px; }
}

/* ---- wallet chooser + name dialog (TemplateData/rtd-wallet.js) ---- */
.rtdw-backdrop { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; background: rgba(10, 3, 24, 0.66); backdrop-filter: blur(3px); }
.rtdw-modal { width: min(420px, calc(100vw - 32px)); background: linear-gradient(180deg, #2f1660, #1c0b3c); border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 18px; padding: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55); animation: rtdw-pop 0.16s ease-out; }
@keyframes rtdw-pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.rtdw-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.rtdw-title { font-weight: 900; font-style: italic; font-size: 20px; letter-spacing: 0.6px; }
.rtdw-close { width: 32px; height: 32px; border-radius: 10px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.06); color: #fff; font-size: 20px; cursor: pointer; }
.rtdw-list { display: flex; flex-direction: column; gap: 8px; }
.rtdw-wallet { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.12); background: rgba(255, 255, 255, 0.06); color: #fff; font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; transition: background 0.12s, transform 0.08s; }
.rtdw-wallet:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-1px); }
.rtdw-wallet:disabled { opacity: 0.75; cursor: wait; }
.rtdw-icon { width: 34px; height: 34px; border-radius: 9px; flex: 0 0 34px; }
.rtdw-icon-fallback { display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, #9b6bff, #7444f0); font-weight: 900; }
.rtdw-name { flex: 1; text-align: left; }
.rtdw-tag { font-size: 12px; font-weight: 700; color: var(--cyan); }
.rtdw-install .rtdw-tag { color: var(--gold); }
.rtdw-empty, .rtdw-sub { font-size: 14px; opacity: 0.85; margin: 2px 0 8px; }
.rtdw-note { font-size: 12px; opacity: 0.65; margin-top: 12px; text-align: center; }
.rtdw-input { width: 100%; height: 46px; border-radius: 12px; border: 2px solid rgba(255, 201, 51, 0.55); background: rgba(0, 0, 0, 0.3); color: #fff; font: inherit; font-size: 20px; font-weight: 800; padding: 0 14px; outline: none; }
.rtdw-input:focus { border-color: var(--gold); }
.rtdw-error { min-height: 18px; font-size: 13px; color: var(--pink); margin: 6px 2px; }
.rtdw-row { display: flex; gap: 8px; }
.rtdw-btn { flex: 1; height: 44px; border-radius: 12px; border: none; background: linear-gradient(180deg, #ff6ab4, #ff2f8f); color: #fff; font: inherit; font-weight: 900; letter-spacing: 0.4px; cursor: pointer; }
.rtdw-btn-ghost { background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.2); font-weight: 700; font-size: 12px; }
