.rise3d {
  box-sizing: border-box;
  --r3-paper: rgba(34, 31, 26, 0.96);
  --r3-ink: #f2e8d2;
  --r3-muted: #c3b79d;
  --r3-gold: #e4bf70;
  --r3-line: #625640;
  --r3-control: #413a2d;
  color: var(--r3-ink);
}
.rise3d .r3-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: var(--r3-ink);
  font: 14px/1.45 system-ui, sans-serif;
}
.rise3d [hidden] {
  display: none !important;
}
.rise3d button,
.rise3d input,
.rise3d select,
.rise3d textarea {
  font: inherit;
  border: 1px solid var(--r3-line);
  border-radius: 6px;
  min-height: 36px;
  background: var(--r3-control);
  color: var(--r3-ink);
  padding: 7px 10px;
  box-shadow: none;
}
.rise3d button {
  cursor: pointer;
  transition: background var(--dur-fast, 0.12s);
}
.rise3d button:hover {
  background: #5d4d32;
  border-color: var(--r3-gold);
}
.rise3d button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.rise3d :focus-visible {
  outline: 2px solid var(--r3-gold);
  outline-offset: 3px;
}
.rise3d h1,
.rise3d h2,
.rise3d h3 {
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--r3-ink);
  text-wrap: balance;
  line-height: 1.2;
}
.rise3d h1 {
  font-size: 32px;
  margin: 12px 0;
}
.rise3d h2 {
  font-size: 24px;
  margin: 0;
}
.rise3d h3 {
  font-size: 19px;
  margin: 18px 0 10px;
}
.rise3d p {
  overflow-wrap: anywhere;
}
.rise3d .r3-muted,
.rise3d small {
  color: var(--r3-muted);
}
.rise3d .r3-hud,
.rise3d .r3-nav,
.rise3d .r3-panel,
.rise3d .r3-selection,
.rise3d .r3-queue,
.rise3d .r3-minimap,
.rise3d .r3-guide,
.rise3d .r3-founding {
  pointer-events: auto;
  background: var(--r3-paper);
  border: 1px solid var(--r3-line);
  border-radius: 8px;
  box-shadow: var(--shadow-md, 0 4px 12px #0005);
}
.rise3d .r3-hud {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 24px;
  padding: 12px 18px;
  align-items: center;
}
.rise3d .r3-resource {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0 12px;
  flex: 1;
  min-width: 0;
}
.rise3d .r3-resource-name {
  color: var(--r3-gold);
}
.rise3d .r3-resource strong {
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.rise3d .r3-resource small,
.rise3d .r3-resource progress {
  grid-column: 1/-1;
}
.rise3d progress {
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 6px;
  overflow: hidden;
  accent-color: var(--r3-gold);
  background: var(--r3-control);
}
.rise3d progress::-webkit-progress-bar {
  background: var(--r3-control);
}
.rise3d progress::-webkit-progress-value {
  background: var(--r3-gold);
}
.rise3d progress::-moz-progress-bar {
  background: var(--r3-gold);
}
.rise3d .r3-stats {
  min-width: 170px;
  font-size: 12px;
}
.rise3d .r3-nav {
  position: absolute;
  top: 104px;
  left: 12px;
  display: flex;
  gap: 5px;
  padding: 6px;
  max-width: calc(100% - 24px);
  overflow-x: auto;
}
.rise3d .r3-nav button {
  white-space: nowrap;
}
.rise3d .r3-panel {
  position: absolute;
  right: 12px;
  top: 160px;
  bottom: 16px;
  width: min(480px, calc(100% - 24px));
  padding: 20px;
  overflow: auto;
  overscroll-behavior: contain;
}
.rise3d .r3-panel-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.rise3d .r3-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 3px 0;
}
.rise3d .r3-line > span:last-child {
  text-align: right;
  overflow-wrap: anywhere;
  min-width: 0;
}
.rise3d .r3-selection {
  position: absolute;
  left: 226px;
  bottom: 16px;
  width: 320px;
  max-width: calc(100% - 250px);
  padding: 16px;
  max-height: calc(100% - 180px);
  overflow: auto;
}
.rise3d .r3-selection button,
.rise3d .r3-row button {
  margin: 6px 6px 0 0;
}
.rise3d .r3-queue {
  position: absolute;
  left: 12px;
  top: 160px;
  width: 200px;
  padding: 12px;
  max-height: calc(100% - 410px);
  overflow: auto;
  font-size: 12px;
}
.rise3d .r3-task {
  padding: 8px 0;
  border-bottom: 1px solid var(--r3-line);
  display: grid;
  gap: 6px;
}
.rise3d .r3-countdown {
  font-variant-numeric: tabular-nums;
  color: var(--r3-gold);
}
.rise3d .r3-commander {
  padding-top: 12px;
}
.rise3d summary {
  cursor: pointer;
  min-height: 30px;
}
.rise3d .r3-minimap {
  position: absolute;
  bottom: 16px;
  left: 12px;
  width: 268px;
  padding: 5px;
}
.rise3d .r3-minimap canvas {
  display: block;
  width: 256px;
  height: 256px;
  border-radius: 6px;
  cursor: crosshair;
}
.rise3d .r3-minimap small {
  display: block;
  text-align: center;
  font-size: 10px;
}
.rise3d .r3-guide {
  position: absolute;
  right: 12px;
  bottom: var(--r3-bottom, 16px);
  width: 260px;
  padding: 12px;
  font-size: 12px;
}
.rise3d .r3-panel:not([hidden]) ~ .r3-guide {
  display: none;
}
.rise3d .r3-guide ol {
  padding-left: 20px;
}
.rise3d .r3-guide li {
  margin: 5px 0;
}
.rise3d .r3-complete {
  color: var(--r3-gold);
}
.rise3d .r3-field {
  display: grid;
  gap: 5px;
  margin: 12px 0;
}
.rise3d input[type='checkbox'] {
  min-height: 20px;
  width: 20px;
  accent-color: var(--r3-gold);
}
.rise3d .r3-troop-input {
  display: grid;
  grid-template-columns: 1fr 1fr 70px;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
}
.rise3d .r3-troop-input input {
  width: 100%;
  min-width: 0;
  accent-color: var(--r3-gold);
}
.rise3d .r3-building-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.rise3d .r3-building-grid button {
  font-size: 12px;
  padding: 7px 4px;
}
.rise3d .r3-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--r3-line);
}
.rise3d .r3-row h3 {
  margin-top: 0;
}
.rise3d .r3-table-wrap {
  overflow-x: auto;
  margin: 12px 0;
}
.rise3d table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
.rise3d th,
.rise3d td {
  text-align: left;
  padding: 8px 5px;
  border-bottom: 1px solid var(--r3-line);
  vertical-align: top;
}
.rise3d th {
  color: var(--r3-muted);
  font-weight: 500;
}
.rise3d .r3-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.rise3d .r3-report {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  margin: 8px 0;
}
.rise3d .r3-unread {
  border-left: 3px solid var(--r3-gold);
}
.rise3d .r3-color {
  display: inline-block;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  vertical-align: middle;
  margin-left: 8px;
}
.rise3d .r3-confirm {
  position: sticky;
  bottom: 0;
  background: var(--r3-paper);
  padding: 14px;
  border: 1px solid var(--r3-gold);
  border-radius: 8px;
}
.rise3d .r3-confirm button {
  margin-right: 8px;
}
.rise3d .r3-tabs {
  display: flex;
  gap: 6px;
}
.rise3d .r3-tabs [aria-pressed='true'] {
  color: var(--r3-gold);
  border-color: var(--r3-gold);
}
.rise3d .r3-chat-log {
  height: min(50vh, 420px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px 0;
}
.rise3d .r3-message {
  padding: 8px 0;
  border-bottom: 1px solid var(--r3-line);
  overflow-wrap: anywhere;
}
.rise3d .r3-message time {
  float: right;
  font-size: 11px;
}
.rise3d .r3-message p {
  margin: 4px 0;
  white-space: pre-wrap;
}
.rise3d .r3-chat-form {
  display: flex;
  gap: 6px;
}
.rise3d .r3-chat-form input {
  min-width: 0;
  flex: 1;
}
.rise3d .r3-toasts {
  position: absolute;
  top: 160px;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, 80%);
  display: grid;
  gap: 8px;
  z-index: 8;
}
.rise3d .r3-toast {
  padding: 12px 16px;
  background: var(--r3-paper);
  color: var(--r3-ink);
  border-left: 3px solid var(--r3-gold);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
}
.rise3d .r3-founding {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  padding: 28px;
}
.rise3d .r3-crest {
  display: block;
  width: 48px;
  height: 48px;
  color: var(--r3-gold);
}
.rise3d .r3-loading {
  position: absolute;
  inset: 0;
  background: #201e19ed;
  display: grid;
  place-items: center;
  pointer-events: auto;
  z-index: 20;
  transition: opacity var(--dur-panel, 0.24s);
}
.rise3d .r3-loading-card {
  width: min(420px, calc(100% - 32px));
  padding: 32px;
}
.rise3d .r3-loading-card progress {
  height: 8px;
}
.rise3d .r3-loaded {
  opacity: 0;
  pointer-events: none;
}

.rise3d.is-mobile button,
.rise3d.is-mobile input,
.rise3d.is-mobile select {
  min-height: 40px;
}

.rise3d.is-mobile .r3-guide {
  bottom: var(--r3-bottom, 62px);
  right: 6px;
  width: 190px;
  max-height: 28%;
  overflow: auto;
}

.rise3d.is-mobile .r3-troop-input {
  grid-template-columns: 1fr 1fr 64px;
  gap: 6px;
  font-size: 12px;
}
.rise3d.is-mobile summary {
  min-height: 40px;
}
@media (prefers-reduced-motion: reduce) {
  .rise3d *,
  .rise3d *::before,
  .rise3d *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
.rise3d {
  position: fixed;
  inset: 0;
  z-index: 10000;
  overflow: hidden;
  background: #b8ced5;
  isolation: isolate;
}
.rise3d .rise3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline-offset: -4px;
}
.rise3d .rise3d-labels,
.rise3d .rise3d-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.rise3d .rise3d-label {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  font: 12px/1.4 system-ui, sans-serif;
  color: #fff4d8;
  background: #201d18e6;
  border: 1px solid var(--r3-line);
  border-radius: 6px;
  padding: 3px 7px;
  pointer-events: none;
}
.rise3d .rise3d-label.own {
  border-color: var(--r3-gold);
}
.rise3d .rise3d-label.building {
  color: var(--r3-gold);
}
.rise3d .rise3d-fatal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 24px);
  background: var(--r3-paper);
  padding: 24px;
  border-radius: 8px;
  color: var(--r3-ink);
}

/* Compact mobile navigation and guide */
.rise3d .r3-nav-short {
  display: none;
}

.rise3d.is-mobile .r3-guide.r3-guide-collapsed {
  width: auto;
  padding: 0;
  max-height: none;
}
.rise3d.is-mobile .r3-guide-collapsed summary {
  padding: 6px 10px;
  min-height: 40px;
  box-sizing: border-box;
  list-style: none;
}
.rise3d.is-mobile .r3-guide-collapsed summary::-webkit-details-marker {
  display: none;
}
.rise3d.is-mobile .r3-guide-collapsed > button {
  display: none;
}
.rise3d .r3-report small {
  flex-shrink: 0;
}

/* Windowed / minimized modes: the realm floats over disdroc instead of covering it. */
.rise3d .rise3d-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 50; height: 36px;
  display: flex; align-items: center; gap: 4px; padding: 0 6px 0 10px;
  background: rgba(32, 29, 24, 0.88); color: var(--r3-ink); border: 1px solid var(--r3-line); border-radius: 8px;
  cursor: grab; touch-action: none; user-select: none;
}
.rise3d .rise3d-bar-title { font: 600 12px/1 system-ui, sans-serif; color: var(--r3-gold); margin-right: auto; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.rise3d .rise3d-bar button.rise3d-bar-btn { min-height: 30px; width: 32px; padding: 0; line-height: 1; font-size: 13px; flex-shrink: 0; }
.rise3d.windowed {
  inset: auto 16px 16px auto;
  width: min(960px, calc(100vw - 32px)); height: min(640px, calc(100vh - 32px));
  border: 1px solid var(--r3-line); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  z-index: 900;
}
.rise3d .rise3d-ui, .rise3d .rise3d-labels { top: 36px; }
.rise3d .rise3d-canvas { position: absolute; top: 36px; height: calc(100% - 36px); }
.rise3d *, .rise3d *::before, .rise3d *::after { box-sizing: border-box; }
.rise3d .r3-ui { container-type: inline-size; }
.rise3d .r3-panel { z-index: 6; }
.rise3d .r3-panel-header h2 { min-width: 0; overflow-wrap: anywhere; }
.rise3d .r3-panel-header button { flex-shrink: 0; }
.rise3d .r3-field input { width: 100%; min-width: 0; }
.rise3d .rise3d-label { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.rise3d .rise3d-label.mine { border-color: var(--r3-gold); }
.rise3d .r3-chat-log { height: min(240px, 30vh); }
.rise3d .r3-report { flex-wrap: wrap; overflow-wrap: anywhere; }
.rise3d .r3-queue { max-height: calc(100% - 180px); }
.rise3d .r3-queue:has(~ .r3-minimap:not([hidden])) { max-height: calc(100% - 454px); }
.rise3d .r3-panel:not([hidden]) ~ .r3-minimap { display: none; }
.rise3d .r3-ui:has(.r3-founding:not([hidden])) .r3-guide,
.rise3d .r3-ui:has(.r3-founding:not([hidden])) .r3-minimap { display: none; }
.rise3d .r3-ui:has(.r3-panel:not([hidden])) .r3-selection { display: none; }
.rise3d .r3-ui:has(.r3-selection:not([hidden])) .r3-guide { display: none; }
body.theme-light .rise3d {
  --r3-paper: var(--bg-2); --r3-ink: var(--text-bright); --r3-muted: var(--muted);
  --r3-gold: #775411; --r3-line: var(--border-strong); --r3-control: var(--bg-3);
}
body.theme-light .rise3d button:hover { background: var(--bg-4); }
body.theme-light .rise3d .rise3d-bar { background: var(--r3-paper); }
body.theme-light .rise3d .r3-loading { background: var(--bg-2); }
@container (max-width: 800px) {
  .rise3d .r3-hud { gap: 8px; padding: 8px; flex-wrap: wrap; }
  .rise3d .r3-stats { display: flex; width: 100%; gap: 12px; min-width: 0; justify-content: space-between; }
  .rise3d .r3-resource { font-size: 11px; gap: 0 4px; }
  .rise3d .r3-nav { top: auto; bottom: 6px; left: 6px; right: 6px; z-index: 7; }
  .rise3d .r3-nav button { min-width: 40px; flex: 1; padding: 4px; font-size: 10px; }
  .rise3d .r3-nav-full { display: none; }
  .rise3d .r3-nav-short { display: block; }
  .rise3d .r3-panel { top: 116px; bottom: 62px; left: 6px; right: 6px; width: auto; padding: 14px; }
  .rise3d .r3-selection { left: 6px; right: 6px; bottom: 62px; width: auto; max-width: none; max-height: calc(100% - 180px); z-index: 5; }
  .rise3d .r3-guide { bottom: var(--r3-bottom, 62px); max-height: 28%; overflow: auto; }
  .rise3d .r3-minimap { bottom: 62px; }
  .rise3d .r3-queue { top: 116px; max-height: 22%; }
}
.rise3d.windowed .rise3d-bar { display: flex; }
.rise3d.windowed.mini { width: 220px; height: 40px; }
.rise3d.windowed.mini .rise3d-canvas, .rise3d.windowed.mini .rise3d-ui, .rise3d.windowed.mini .rise3d-labels { display: none; }
@media (max-width: 800px) {
  .rise3d.windowed { inset: auto 0 0 0; width: 100%; height: 55vh; border-radius: 12px 12px 0 0; }
  .rise3d.windowed.mini { width: 100%; }
}

/* rise2-ui: treasury, command dock and parchment panels. */
.rise3d {
  --r3-success: #a7c68a;
  --r3-danger: #f0a08b;
  --r3-warning: #edc679;
  --r3-bottom: 94px;
  --r3-panel-top: 164px;
}
.rise3d .r3-icon { width: 22px; height: 22px; flex: 0 0 auto; vertical-align: middle; }
.rise3d button { transition: background 120ms, transform 120ms, color 120ms; }
.rise3d button:not(:disabled):active { transform: translateY(1px); }
.rise3d .r3-primary { background: #b89452; color: #211d16; font-weight: 650; border-color: #d9b76c; }
.rise3d .r3-primary:hover { background: #d9b76c; color: #211d16; }
.rise3d .r3-hud {
  left: 12px; right: auto; top: 12px; width: max-content; max-width: calc(100% - 24px);
  gap: 0; padding: 5px 6px; flex-wrap: nowrap; align-items: center;
  box-shadow: 0 5px 18px #17120d30;
}
.rise3d button.r3-resource {
  position: relative; display: grid; grid-template-columns: 24px 62px; grid-template-rows: 25px 4px;
  gap: 1px 8px; padding: 4px 12px; flex: 0 0 auto; min-height: 40px; border: 0; border-radius: 6px;
  background: transparent; overflow: visible; text-align: left;
}
.rise3d .r3-resource > .r3-icon { grid-row: 1 / 3; align-self: center; color: var(--r3-gold); }
.rise3d .r3-resource strong { text-align: left; font-size: 15px; font-variant-numeric: tabular-nums; transition: color 160ms; }
.rise3d .r3-resource progress { grid-column: 2; height: 3px; width: 62px; align-self: end; }
.rise3d .r3-resource.r3-gain strong { color: var(--r3-success); }
.rise3d .r3-resource.r3-spend strong { color: var(--r3-danger); }
.rise3d .r3-resource-tip {
  display: none; position: absolute; top: calc(100% + 12px); left: 0; z-index: 14;
  width: 246px; padding: 12px; border-radius: 8px; border: 1px solid var(--r3-line);
  background: var(--r3-paper); color: var(--r3-ink); box-shadow: 0 6px 20px #17120d40;
  font-size: 12px; line-height: 1.8; white-space: pre-line; pointer-events: none;
}
.rise3d .r3-resource:focus-visible .r3-resource-tip,
.rise3d .r3-resource[aria-expanded='true'] .r3-resource-tip { display: block; }
.rise3d .r3-resource:nth-child(4) .r3-resource-tip { left: auto; right: 0; }
.rise3d .r3-hud { z-index: 12; }
.rise3d .r3-stats { display: flex; gap: 6px; min-width: 0; width: auto; padding-left: 8px; font-size: 12px; }
.rise3d .r3-stat { display: flex; align-items: center; gap: 7px; padding: 5px 8px; background: var(--r3-control); border-radius: 6px; }
.rise3d .r3-stat .r3-icon { width: 19px; height: 19px; color: var(--r3-gold); }
.rise3d .r3-stat strong { font-weight: 550; font-variant-numeric: tabular-nums; }
.rise3d .r3-unprotected { color: var(--r3-danger); }
.rise3d .r3-sound { border: 0; background: transparent; min-height: 36px; padding: 5px; }
.rise3d .r3-nav {
  top: auto; bottom: max(12px, env(safe-area-inset-bottom)); left: 50%; right: auto; transform: translateX(-50%);
  display: flex; width: max-content; max-width: calc(100% - 24px); gap: 2px; padding: 5px;
  overflow: visible; z-index: 10; border-top-color: var(--r3-gold); box-shadow: 0 8px 24px #17120d50;
}
.rise3d .r3-nav button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; min-width: 72px; min-height: 60px; padding: 6px 10px; font-size: 11px;
  background: transparent; border-color: transparent; color: var(--r3-muted); flex: 0 0 auto;
}
.rise3d .r3-nav button:hover { color: var(--r3-ink); background: var(--r3-control); }
.rise3d .r3-nav button[aria-pressed='true'] { color: var(--r3-gold); background: var(--r3-control); border-bottom-color: var(--r3-gold); }
.rise3d .r3-nav .r3-nav-short { display: none; }
.rise3d .r3-nav-more, .rise3d .r3-nav-menu { display: contents; }
.rise3d .r3-nav-more > summary { display: none; }
.rise3d .r3-badge {
  position: absolute; right: 5px; top: 2px; min-width: 18px; height: 18px; padding: 0 3px;
  border-radius: 6px; background: #a54632; color: #fff3dd; font-size: 10px; font-weight: 700; line-height: 18px;
}
.rise3d .r3-badge.r3-attention { background: var(--r3-gold); color: var(--r3-paper); }
.rise3d .r3-panel {
  top: var(--r3-panel-top); bottom: var(--r3-bottom); right: 12px; left: auto; width: min(480px, calc(100% - 24px));
  padding: 0 22px 22px; border-top-color: var(--r3-gold); scrollbar-width: thin;
  animation: r3-panel-in 160ms ease-out; scroll-padding-top: 78px;
}
.rise3d .r3-panel-header { gap: 10px; margin-bottom: 18px; }
.rise3d .r3-panel > .r3-panel-header {
  position: sticky; top: 0; padding: 18px 0 14px; background: var(--r3-paper); z-index: 2; border-bottom: 1px solid var(--r3-line);
}
.rise3d .r3-panel-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rise3d .r3-panel-title .r3-icon { color: var(--r3-gold); width: 26px; height: 26px; }
.rise3d .r3-panel h2 { font-size: 26px; }
.rise3d .r3-panel .r3-line { padding: 5px 0; }
.rise3d .r3-line .r3-icon { width: 17px; height: 17px; margin-right: 7px; color: var(--r3-gold); }
.rise3d .r3-building-grid { gap: 3px; margin: 0 -5px 22px; }
.rise3d .r3-building-grid button {
  position: relative; display: grid; justify-items: center; gap: 5px; padding: 10px 4px; border-color: transparent;
  background: transparent; min-width: 0; white-space: normal; line-height: 1.2;
}
.rise3d .r3-building-grid button .r3-icon { width: 28px; height: 28px; color: var(--r3-gold); }
.rise3d .r3-building-grid button[aria-pressed='true'] { background: var(--r3-control); border-color: var(--r3-gold); }
.rise3d .r3-building-grid .r3-upgrade-ready::after { content: '↑'; position: absolute; top: 5px; right: 7px; color: var(--r3-success); font-size: 14px; }
.rise3d .r3-cost { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 12px 0; font-size: 12px; }
.rise3d .r3-cost-values { display: flex; flex-wrap: wrap; gap: 8px 12px; justify-content: flex-end; }
.rise3d .r3-cost-item { display: inline-flex; align-items: center; gap: 5px; font-variant-numeric: tabular-nums; }
.rise3d .r3-cost-item .r3-icon { width: 17px; height: 17px; color: var(--r3-gold); }
.rise3d .r3-cost-item.r3-short, .rise3d .r3-cost-item.r3-short .r3-icon { color: var(--r3-danger); }
.rise3d .r3-counters { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--r3-muted); margin: 12px 0; }
.rise3d .r3-counters > span { display: inline-flex; gap: 5px; align-items: center; }
.rise3d .r3-counters .r3-icon { width: 18px; height: 18px; }
.rise3d .r3-queue, .rise3d .r3-queue:has(~ .r3-minimap:not([hidden])) {
  top: 82px; width: 204px; padding: 0 12px 10px; max-height: calc(100% - 186px); background: var(--r3-paper);
  scrollbar-width: thin; overflow: auto;
}
.rise3d .r3-queue:has(~ .r3-minimap:not([hidden])) { max-height: calc(100% - 476px); }
.rise3d .r3-queue-heading { font-size: 16px; margin: 12px 0 4px; }
.rise3d .r3-task { grid-template-columns: 1fr auto; gap: 4px; padding: 10px 0; border-bottom: 0; }
.rise3d .r3-task progress { grid-column: 1 / -1; height: 3px; }
.rise3d .r3-task > button:not(.r3-order-jump) { grid-column: 1 / -1; font-size: 11px; min-height: 28px; padding: 3px; }
.rise3d .r3-order-jump { display: flex; gap: 7px; align-items: center; min-height: 30px; background: transparent; border: 0; padding: 0; text-align: left; font-size: 11px; }
.rise3d .r3-order-jump .r3-icon { width: 18px; height: 18px; color: var(--r3-gold); }
.rise3d .r3-task .r3-countdown { align-self: center; font-size: 11px; }
.rise3d .r3-commander { padding: 10px 0 0; }
.rise3d .r3-commander > summary { display: flex; align-items: center; gap: 12px; padding: 2px 0; list-style: none; }
.rise3d .r3-commander > summary::-webkit-details-marker { display: none; }
.rise3d .r3-commander-caption { display: grid; gap: 1px; }
.rise3d .r3-commander-caption strong { font: 18px Georgia, serif; }
.rise3d .r3-commander-caption small { font-size: 10px; }
.rise3d .r3-portrait {
  --r3-banner: #8d5335; display: grid; place-items: center; position: relative; width: 52px; height: 62px; flex: 0 0 auto;
  color: #f3deb0; border: 2px solid var(--r3-gold); border-radius: 8px; background: var(--r3-banner);
}
.rise3d .r3-portrait::after { content: ''; position: absolute; bottom: -2px; left: -2px; height: 3px; width: var(--r3-xp); background: var(--r3-success); border-radius: 6px; }
.rise3d .r3-portrait .r3-icon { width: 34px; height: 34px; }
.rise3d .r3-portrait-level { position: absolute; right: -5px; bottom: -5px; background: var(--r3-paper); border: 1px solid var(--r3-gold); border-radius: 6px; padding: 0 4px; font-size: 11px; color: var(--r3-gold); }
.rise3d .r3-idle-builder { display: flex; align-items: center; gap: 8px; width: 100%; background: transparent; border: 1px dashed var(--r3-line); color: var(--r3-gold); font-size: 12px; padding: 7px; margin: 8px 0; }
.rise3d .r3-idle-builder small { margin-left: auto; }
.rise3d .r3-idle-training { width: 100%; padding: 6px 0; color: var(--r3-muted); }
.rise3d .r3-selection { left: 292px; bottom: var(--r3-bottom); width: 334px; max-width: calc(100% - 314px); max-height: calc(100% - 180px); border-top-color: var(--r3-gold); animation: r3-panel-in 160ms ease-out; }
.rise3d .r3-selection > .r3-panel-header > .r3-icon { width: 28px; height: 28px; color: var(--r3-gold); }
.rise3d .r3-selection h2 { font-size: 23px; flex: 1; }
.rise3d .r3-selection .r3-primary { width: 100%; margin: 14px 0 4px; min-height: 42px; }
.rise3d .r3-selection-estimate { margin: 10px 0; padding: 8px 10px; background: var(--r3-control); border-radius: 6px; font-size: 12px; }
.rise3d .r3-minimap { bottom: var(--r3-bottom); }
.rise3d .r3-battle-heading { display: flex; align-items: center; gap: 12px; padding: 16px 0; font-size: 25px; }
.rise3d .r3-victory { color: var(--r3-success); }
.rise3d .r3-defeat { color: var(--r3-danger); }
.rise3d .r3-own-row { background: var(--r3-control); color: var(--r3-gold); font-weight: 650; }
.rise3d .r3-tabs { margin-bottom: 12px; border-bottom: 1px solid var(--r3-line); }
.rise3d .r3-tabs button { border: 0; background: transparent; border-bottom: 2px solid transparent; border-radius: 6px 6px 0 0; }
.rise3d .r3-tabs button[aria-pressed='true'] { border-bottom-color: var(--r3-gold); }
.rise3d .r3-toasts {
  top: 74px; right: 12px; left: auto; transform: none; width: min(480px, calc(100% - 250px));
  max-height: 80px; overflow: auto; gap: 4px; scrollbar-width: thin; z-index: 9;
}
.rise3d .r3-toast { padding: 8px 12px; font-size: 12px; line-height: 1.4; animation: r3-notice-in 140ms ease-out; box-shadow: 0 3px 12px #17120d30; }
.rise3d .r3-toast-success { border-left-color: var(--r3-success); }
.rise3d .r3-toast-error { border-left-color: var(--r3-danger); }
.rise3d .r3-toast-warning { border-left-color: var(--r3-warning); }
.rise3d .r3-chat-form { position: sticky; bottom: -22px; background: var(--r3-paper); padding: 10px 0; }
body.theme-light .rise3d { --r3-success: #3b641e; --r3-danger: #a42c20; --r3-warning: #8a5d0a; }
body.theme-light .rise3d .r3-primary { background: #886524; border-color: #886524; color: #fff5df; }
body.theme-light .rise3d .r3-primary:hover { background: #6a4c19; }
@keyframes r3-panel-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes r3-notice-in { from { opacity: 0; } to { opacity: 1; } }
@container (max-width: 800px) {
  .rise3d .r3-hud { left: 6px; right: 6px; top: 6px; width: auto; max-width: none; padding: 5px; flex-wrap: wrap; }
  .rise3d button.r3-resource { flex: 1; grid-template-columns: 22px minmax(0, 1fr); gap: 1px 5px; padding: 3px 5px; font-size: 12px; }
  .rise3d .r3-resource strong { font-size: 13px; }
  .rise3d .r3-resource progress { width: 100%; }
  .rise3d .r3-resource-tip { width: 215px; }
  .rise3d .r3-resource:nth-child(n + 3) .r3-resource-tip { left: auto; right: 0; }
  .rise3d .r3-stats { width: 100%; justify-content: flex-start; padding: 4px 0 0; gap: 5px; font-size: 11px; }
  .rise3d .r3-stat { padding: 3px 7px; }
  .rise3d .r3-sound { margin-left: auto; min-height: 28px; padding: 1px 5px; }
  .rise3d .r3-nav { left: 6px; right: 6px; transform: none; width: auto; max-width: none; bottom: max(6px, env(safe-area-inset-bottom)); gap: 2px; padding: 4px; overflow: visible; }
  .rise3d .r3-nav > button, .rise3d .r3-nav-more { flex: 1 1 0; min-width: 0; }
  .rise3d .r3-nav button { min-width: 0; min-height: 58px; padding: 5px 1px; font-size: 10px; }
  .rise3d .r3-nav button .r3-nav-full { display: none; }
  .rise3d .r3-nav button .r3-nav-short { display: block; white-space: normal; }
  .rise3d .r3-nav-more { display: block; position: relative; }
  .rise3d .r3-nav-more > summary { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 58px; gap: 4px; font-size: 10px; list-style: none; cursor: pointer; color: var(--r3-muted); border-radius: 6px; }
  .rise3d .r3-nav-more > summary::-webkit-details-marker { display: none; }
  .rise3d .r3-nav-more[open] > summary { background: var(--r3-control); color: var(--r3-gold); }
  .rise3d .r3-nav-menu { display: none; position: absolute; right: 0; bottom: 70px; width: 232px; padding: 6px; background: var(--r3-paper); border: 1px solid var(--r3-line); border-radius: 8px; box-shadow: 0 6px 20px #17120d40; }
  .rise3d .r3-nav-more[open] .r3-nav-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
  .rise3d .r3-nav-menu button { min-height: 64px; }
  .rise3d .r3-nav-menu button .r3-nav-full { display: block; white-space: normal; }
  .rise3d .r3-nav-menu button .r3-nav-short { display: none; }
  .rise3d .r3-panel { top: 184px; bottom: var(--r3-bottom); left: 6px; right: 6px; width: auto; padding: 0 16px 16px; border-radius: 12px 12px 8px 8px; }
  .rise3d .r3-panel h2 { font-size: 24px; }
  .rise3d .r3-panel > .r3-panel-header { padding-top: 14px; }
  .rise3d .r3-selection { left: 6px; right: 6px; bottom: var(--r3-bottom); width: auto; max-width: none; max-height: calc(100% - 196px); }
  .rise3d .r3-queue, .rise3d .r3-queue:has(~ .r3-minimap:not([hidden])) { left: 6px; top: 104px; width: 170px; padding: 0 8px 8px; max-height: 30%; }
  .rise3d .r3-commander > summary { gap: 8px; }
  .rise3d .r3-portrait { width: 38px; height: 44px; }
  .rise3d .r3-portrait .r3-icon { width: 25px; height: 25px; }
  .rise3d .r3-commander-caption strong { font-size: 15px; }
  .rise3d .r3-idle-builder { font-size: 11px; gap: 4px; padding: 5px; }
  .rise3d .r3-minimap { bottom: var(--r3-bottom); left: 6px; width: 166px; padding: 5px; }
  .rise3d .r3-minimap canvas { width: 154px; height: 154px; }
  .rise3d .r3-ui:has(.r3-selection:not([hidden])) .r3-minimap { display: none; }
  .rise3d .r3-toasts { top: 94px; right: 6px; left: auto; width: calc(100% - 192px); max-height: 80px; }
  .rise3d .r3-chat-form { bottom: -16px; }
  .rise3d .r3-building-grid { margin-bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .rise3d *, .rise3d *::before, .rise3d *::after { animation: none !important; transition: none !important; }
}
.rise3d .r3-portrait-level { display: grid; place-items: center; width: 30px; height: 30px; right: -8px; bottom: -6px; padding: 0; border: 0; border-radius: 6px; }
.rise3d .r3-portrait-level svg { position: absolute; inset: 0; width: 30px; height: 30px; }
.rise3d .r3-xp-track { stroke: var(--r3-line); }
.rise3d .r3-xp-ring { stroke: var(--r3-gold); }
.rise3d .r3-portrait::after { display: none; }
@container (max-width: 800px) {
  .rise3d button.r3-sound { min-height: 28px; }
  .rise3d .r3-stat { min-height: 28px; }
  .rise3d .r3-queue { top: 98px; }
  .rise3d .r3-queue:has(~ .r3-minimap:not([hidden])) { top: 98px; }
  .rise3d .r3-nav button { font-size: 10px; }
  .rise3d .r3-toasts { top: 94px; }
}
.rise3d .r3-building-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rise3d .r3-building-grid button { padding: 7px 3px; gap: 3px; font-size: 11px; }
.rise3d .r3-building-grid button .r3-icon { width: 24px; height: 24px; }
@container (max-width: 800px) {
  .rise3d .r3-building-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rise3d .r3-building-grid button { grid-template-columns: 22px minmax(0, 1fr); grid-template-rows: auto auto; justify-items: start; align-items: center; gap: 2px 6px; padding: 9px 6px; font-size: 11px; text-align: left; }
  .rise3d .r3-building-grid button .r3-icon { grid-row: 1 / 3; width: 22px; height: 22px; }
  .rise3d .r3-building-grid button small { grid-column: 2; font-size: 10px; }
  .rise3d .r3-building-grid .r3-upgrade-ready::after { right: 3px; top: 2px; font-size: 11px; }
}
@container (max-width: 800px) {
  .rise3d .r3-queue, .rise3d .r3-queue:has(~ .r3-minimap:not([hidden])) {
    width: calc(100% - 12px); max-height: 80px; min-height: 76px; display: flex; gap: 12px; padding: 7px 8px; overflow: auto;
  }
  .rise3d .r3-queue-heading { display: none; }
  .rise3d .r3-commander { flex: 0 0 138px; padding: 0; }
  .rise3d .r3-commander > summary { min-height: 58px; }
  .rise3d .r3-order-list { display: flex; gap: 12px; flex: 1; align-items: center; overflow-x: auto; scrollbar-width: thin; }
  .rise3d .r3-task { flex: 0 0 145px; padding: 0; }
  .rise3d .r3-idle-builder { flex: 0 0 152px; width: auto; min-height: 42px; margin: 0; }
  .rise3d .r3-idle-training { flex: 0 0 104px; }
  .rise3d .r3-order-jump { font-size: 11px; }
  .rise3d .r3-toasts { top: auto; bottom: 82px; right: 6px; width: calc(100% - 12px); max-height: 76px; }
  .rise3d .r3-ui:has(.r3-toast) > :is(.r3-panel, .r3-selection, .r3-minimap, .r3-guide) { --r3-bottom: 170px; }
}
.rise3d .r3-panel.r3-closing { animation: r3-panel-out 140ms ease-in forwards; pointer-events: none; }
@keyframes r3-panel-out { to { opacity: 0; transform: translateY(5px); } }

@media (hover: hover) {
  .rise3d .r3-resource:hover .r3-resource-tip { display: block; }
}
.rise3d .r3-toasts:has(.r3-toast) { pointer-events: auto; overscroll-behavior: contain; }
.rise3d .r3-panel[data-view='chat']:not([hidden]) { display: flex; flex-direction: column; overflow: hidden; }
.rise3d .r3-panel[data-view='chat'] > .r3-panel-header,
.rise3d .r3-panel[data-view='chat'] > .r3-tabs { flex-shrink: 0; }
.rise3d .r3-panel[data-view='chat'] .r3-chat-log { flex: 1; min-height: 0; height: auto; }
.rise3d .r3-panel[data-view='chat'] .r3-chat-form { position: static; flex-shrink: 0; padding: 10px 0 0; }
.rise3d .r3-order-list { scrollbar-width: none; }
.rise3d .r3-order-list::-webkit-scrollbar { display: none; }

/* rise2-mobile: the realm gets the viewport; sheets own the scrolling. */
html.rise3d-mobile-playing, html.rise3d-mobile-playing body { overflow: hidden; overscroll-behavior: none; }
.rise3d .r3-sheet-handle, .rise3d .r3-sheet-backdrop,
.rise3d .r3-orders-button, .rise3d .r3-map-button { display: none; }
.rise3d.is-phone:not(.mini) {
  inset: var(--r3-vtop, 0px) 0 auto; width: 100%; height: var(--r3-vh, 100dvh); max-height: 100dvh;
  border: 0; border-radius: 0; z-index: 10000; overscroll-behavior: none;
  --r3-bar: calc(44px + env(safe-area-inset-top));
  --r3-bottom: calc(74px + env(safe-area-inset-bottom));
}
.rise3d.is-phone .rise3d-bar { height: var(--r3-bar, 44px); padding: env(safe-area-inset-top) max(6px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)); border: 0; border-radius: 0; cursor: default; background: var(--r3-paper); }
.rise3d.is-phone .rise3d-bar-title { font-size: 12px; }
.rise3d.is-phone .rise3d-bar button.rise3d-bar-btn { width: 44px; min-height: 44px; font-size: 18px; border: 0; background: transparent; }
.rise3d.is-phone .rise3d-bar button:nth-last-child(2) { display: none; }
.rise3d.is-phone .rise3d-ui, .rise3d.is-phone .rise3d-labels { top: var(--r3-bar, 44px); }
.rise3d.is-phone .rise3d-canvas { top: var(--r3-bar, 44px); height: calc(100% - var(--r3-bar, 44px)); -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.rise3d.is-phone button, .rise3d.is-phone input, .rise3d.is-phone select, .rise3d.is-phone summary { min-height: 44px; }
.rise3d.is-phone input:not([type='range']):not([type='checkbox']), .rise3d.is-phone textarea { font-size: 16px; }
.rise3d.is-phone input[type='checkbox'] { min-height: 24px; width: 24px; }
.rise3d.is-phone label:has(input[type='checkbox']) { min-height: 44px; align-items: center; }
.rise3d.is-phone .r3-hud {
  top: 0; left: env(safe-area-inset-left); right: env(safe-area-inset-right); width: auto; max-width: none;
  height: 44px; padding: 0 8px; gap: 2px; flex-wrap: nowrap; border: 0; border-bottom: 1px solid var(--r3-line); border-radius: 0; box-shadow: none; z-index: 12;
}
.rise3d.is-phone button.r3-resource { flex: 1 1 0; grid-template-columns: 18px minmax(0, 1fr); grid-template-rows: 1fr; align-items: center; gap: 6px; padding: 0 4px; min-width: 0; min-height: 44px; }
.rise3d.is-phone .r3-resource > .r3-icon { width: 18px; height: 18px; grid-row: 1; }
.rise3d.is-phone .r3-resource strong { font-size: 13px; }
.rise3d.is-phone .r3-resource progress, .rise3d.is-phone .r3-stats,
.rise3d.is-phone .r3-resource-tip { display: none !important; }
.rise3d.is-phone .r3-nav {
  bottom: 0; left: 0; right: 0; width: auto; transform: none; max-width: none; gap: 2px;
  padding: 3px max(6px, env(safe-area-inset-right)) calc(3px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  border: 0; border-top: 1px solid var(--r3-line); border-radius: 0; box-shadow: none; z-index: 10;
}
.rise3d.is-phone .r3-nav > button, .rise3d.is-phone .r3-nav-more { flex: 1 1 0; min-width: 0; }
.rise3d.is-phone .r3-nav button { padding: 5px 1px; min-width: 0; min-height: 56px; font-size: 11px; gap: 3px; }
.rise3d.is-phone .r3-nav .r3-icon { width: 23px; height: 23px; }
.rise3d.is-phone .r3-nav button .r3-nav-full { display: none; }
.rise3d.is-phone .r3-nav button .r3-nav-short { display: block; white-space: nowrap; }
.rise3d.is-phone .r3-nav-more { display: block; }
.rise3d.is-phone .r3-nav-more > summary { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 56px; font-size: 11px; gap: 3px; list-style: none; color: var(--r3-muted); }
.rise3d.is-phone .r3-nav-more > summary::-webkit-details-marker { display: none; }
.rise3d.is-phone .r3-nav-menu { display: none !important; }
.rise3d.is-phone .r3-orders-button, .rise3d.is-phone .r3-map-button {
  display: flex; align-items: center; justify-content: center; gap: 6px; position: absolute; top: 52px; z-index: 4;
  background: var(--r3-paper); min-height: 44px; box-shadow: 0 2px 8px #17120d25; font-size: 11px;
}
.rise3d.is-phone .r3-orders-button { left: max(8px, env(safe-area-inset-left)); padding: 4px 10px; }
.rise3d.is-phone .r3-map-button { right: max(8px, env(safe-area-inset-right)); width: 44px; padding: 0; }
.rise3d.is-phone .r3-queue { display: none; }
.rise3d.is-phone .r3-panel .r3-queue {
  display: block; position: static; width: auto; min-height: 0; max-height: none; padding: 0; background: none; border: 0; box-shadow: none; overflow: visible;
}
.rise3d.is-phone .r3-panel .r3-commander { padding: 8px 0 16px; }
.rise3d.is-phone .r3-panel .r3-portrait { width: 48px; height: 56px; }
.rise3d.is-phone .r3-panel .r3-commander-caption strong { font-size: 18px; }
.rise3d.is-phone .r3-panel .r3-order-list { display: block; overflow: visible; }
.rise3d.is-phone .r3-panel .r3-task { padding: 14px 0; border-top: 1px solid var(--r3-line); }
.rise3d.is-phone .r3-panel .r3-idle-builder { width: 100%; margin: 10px 0; }
.rise3d.is-phone .r3-panel .r3-order-jump { min-height: 44px; }
.rise3d.is-phone .r3-panel .r3-speedup-actions button { min-height: 44px; }
.rise3d.is-phone .r3-minimap { display: none; }
.rise3d.is-phone .r3-sheet-backdrop { display: block; position: absolute; inset: 44px 0 0; z-index: 14; border: 0; border-radius: 0; background: #17140d44; padding: 0; }
.rise3d.is-phone .r3-sheet-backdrop:hover { background: #17140d44; }
.rise3d.is-phone .r3-panel {
  top: auto; bottom: 0; left: env(safe-area-inset-left); right: env(safe-area-inset-right); width: auto;
  height: 58%; max-height: 100%; padding: 0 16px calc(18px + env(safe-area-inset-bottom)); border-radius: 12px 12px 0 0;
  background: var(--r3-paper); z-index: 16; overflow: auto; overscroll-behavior: none; scroll-padding-top: 100px;
  animation: r3-sheet-in 180ms cubic-bezier(.22,1,.36,1); --r3-bottom: 0px;
}
.rise3d.is-phone .r3-panel[data-snap='full'], .rise3d.is-phone.keyboard-open .r3-panel { height: 100%; border-radius: 0; }
.rise3d.is-phone .r3-panel.r3-sheet-dragging { animation: none; transition: none; }
.rise3d.is-phone .r3-panel > .r3-panel-header {
  position: sticky; top: 0; padding: 40px 0 8px; margin-bottom: 12px; touch-action: none; user-select: none; min-height: 92px;
}
.rise3d.is-phone .r3-panel h2 { font-size: 23px; }
.rise3d.is-phone .r3-panel .r3-sheet-handle {
  display: block; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 80px; min-height: 44px;
  background: transparent; border: 0; padding: 0;
}
.rise3d.is-phone .r3-sheet-handle::after { content: ''; display: block; width: 34px; height: 4px; margin: auto; border-radius: 6px; background: var(--r3-muted); }
.rise3d.is-phone .r3-panel .r3-sheet-handle:active { transform: translateX(-50%); }
.rise3d.is-phone .r3-treasury-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--r3-line); }
.rise3d.is-phone .r3-treasury-row .r3-icon { color: var(--r3-gold); margin-top: 4px; }
.rise3d.is-phone .r3-treasury-row p { white-space: pre-line; margin: 0; font-size: 13px; line-height: 1.8; }
.rise3d.is-phone .r3-more-list { display: grid; gap: 4px; }
.rise3d.is-phone .r3-more-list button { display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px 4px; background: transparent; border: 0; }
.rise3d.is-phone .r3-more-list .r3-icon { color: var(--r3-gold); }
.rise3d.is-phone .r3-panel .r3-minimap { display: block; position: static; width: 100%; padding: 0; background: none; border: 0; box-shadow: none; }
.rise3d.is-phone .r3-panel .r3-minimap canvas { width: min(100%, calc(var(--r3-vh, 100dvh) - 220px)); height: auto; max-height: none; margin: 0 auto; aspect-ratio: 1; touch-action: manipulation; image-rendering: pixelated; }
.rise3d.is-phone .r3-panel .r3-minimap small { display: none; }
.rise3d.is-phone .r3-panel[data-view='mobile.map'] { display: flex; flex-direction: column; align-items: stretch; }
.rise3d.is-phone .r3-panel[data-view='mobile.map'] .r3-minimap { margin: auto 0; flex: 0 1 auto; min-height: 0; }
.rise3d.is-phone .r3-selection {
  bottom: var(--r3-bottom); left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); width: auto; max-width: none;
  padding: 10px 12px; max-height: min(240px, 36%); z-index: 5;
}
.rise3d.is-phone .r3-selection .r3-panel-header { margin: 0 0 6px; gap: 6px; }
.rise3d.is-phone .r3-selection h2 { font-size: 18px; }
.rise3d.is-phone .r3-selection .r3-panel-header > .r3-icon { width: 22px; height: 22px; }
.rise3d.is-phone .r3-selection .r3-panel-header button { padding: 4px 8px; font-size: 11px; }
.rise3d.is-phone .r3-selection > .r3-line { display: none; }
.rise3d.is-phone .r3-selection .r3-selection-estimate { display: flex; justify-content: space-between; flex-wrap: wrap; margin: 0; padding: 0; background: none; font-size: 11px; }
.rise3d.is-phone .r3-selection .r3-selection-estimate .r3-line { gap: 6px; }
.rise3d.is-phone .r3-selection .r3-primary { margin: 8px 0 0; min-height: 48px; }
.rise3d.is-phone .r3-selection > button:not(.r3-primary) { display: none; }
.rise3d.is-phone .r3-toasts { top: 104px; bottom: auto; left: 8px; right: 8px; width: auto; max-height: 64px; z-index: 20; pointer-events: none; }
.rise3d.is-phone .r3-toasts:has(.r3-toast) { pointer-events: auto; touch-action: pan-y; }
.rise3d.is-phone .r3-ui:has(.r3-panel:not([hidden])) .r3-toasts { top: 8px; }
.rise3d.is-phone .r3-ui:has(.r3-toast) > .r3-panel { max-height: calc(100% - 80px); }
.rise3d.is-phone .r3-ui:has(.r3-toast) > :is(.r3-panel, .r3-selection, .r3-minimap, .r3-guide) { --r3-bottom: calc(74px + env(safe-area-inset-bottom)); }
.rise3d.is-phone .r3-ui:has(.r3-panel:not([hidden])) :is(.r3-orders-button, .r3-map-button) { visibility: hidden; }
.rise3d.is-phone .r3-founding { padding: 22px; max-height: calc(100% - 44px); }
.rise3d.is-phone .r3-founding h1 { font-size: 27px; }
.rise3d.is-phone .r3-ui:has(.r3-founding:not([hidden])) :is(.r3-orders-button, .r3-map-button) { display: none; }
.rise3d.is-phone .r3-panel[data-view='chat'] { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.rise3d.is-phone .r3-chat-form { min-height: 56px; }
.rise3d.is-phone .r3-chat-log { overscroll-behavior: none; }
.rise3d.is-phone.keyboard-open .r3-nav { display: none; }
.rise3d.is-phone.windowed.mini {
  inset: auto max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) auto;
  width: 218px; height: 48px; border-radius: 8px; z-index: 900;
}
.rise3d.is-phone.mini .rise3d-bar { height: 48px; padding: 0 4px 0 10px; border-radius: 8px; }
@keyframes r3-sheet-in { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }

/* A rotated phone retains the shell boundary via max-height: 800px. */
.rise3d.is-landscape-phone .r3-hud { top: 8px; bottom: 8px; left: max(8px, env(safe-area-inset-left)); right: auto; width: 78px; height: auto; flex-direction: column; border: 1px solid var(--r3-line); border-radius: 8px; padding: 4px; justify-content: flex-start; }
.rise3d.is-landscape-phone button.r3-resource { flex: 0 0 44px; width: 100%; grid-template-columns: 18px 1fr; }
.rise3d.is-landscape-phone .r3-nav { top: 8px; bottom: 8px; left: auto; right: max(8px, env(safe-area-inset-right)); width: 70px; flex-direction: column; padding: 3px; border: 1px solid var(--r3-line); border-radius: 8px; }
.rise3d.is-landscape-phone .r3-nav > button, .rise3d.is-landscape-phone .r3-nav-more { flex: 1 1 0; min-height: 0; }
.rise3d.is-landscape-phone .r3-nav button, .rise3d.is-landscape-phone .r3-nav-more > summary { min-height: 48px; }
.rise3d.is-landscape-phone .r3-orders-button { top: 192px; left: max(8px, env(safe-area-inset-left)); width: 78px; font-size: 10px; padding: 4px; gap: 3px; }
.rise3d.is-landscape-phone .r3-orders-button .r3-icon { display: none; }
.rise3d.is-landscape-phone .r3-map-button { top: 244px; right: auto; left: max(25px, env(safe-area-inset-left)); }
.rise3d.is-landscape-phone .r3-selection { left: 98px; right: 90px; bottom: 12px; max-height: 70%; width: min(380px, calc(100% - 188px)); }
.rise3d.is-landscape-phone .r3-panel { left: 98px; right: 88px; height: 80%; }
.rise3d.is-landscape-phone .r3-panel[data-snap='full'], .rise3d.is-landscape-phone.keyboard-open .r3-panel { height: 100%; }
.rise3d.is-landscape-phone .r3-toasts { top: 8px; left: 98px; right: 88px; }

/* Tablet keeps the desktop's map, order column and journal at a calmer scale. */
.rise3d.is-tablet .r3-hud { left: 12px; right: 12px; width: auto; flex-wrap: nowrap; padding: 5px; }
.rise3d.is-tablet button.r3-resource { flex: 1; grid-template-columns: 20px minmax(0, 1fr); min-height: 44px; }
.rise3d.is-tablet .r3-stats { width: auto; padding: 0; flex-shrink: 0; }
.rise3d.is-tablet .r3-nav { left: 50%; right: auto; transform: translateX(-50%); width: max-content; max-width: calc(100% - 24px); }
.rise3d.is-tablet .r3-nav button { min-width: 65px; min-height: 58px; font-size: 10px; }
.rise3d.is-tablet .r3-queue, .rise3d.is-tablet .r3-queue:has(~ .r3-minimap:not([hidden])) { top: 84px; left: 12px; width: 184px; min-height: 0; max-height: calc(100% - 418px); display: block; padding: 0 12px 12px; }
.rise3d.is-tablet .r3-commander { padding: 10px 0 0; }
.rise3d.is-tablet .r3-queue-heading { display: block; }
.rise3d.is-tablet .r3-order-list { display: block; overflow: visible; }
.rise3d.is-tablet .r3-task { padding: 10px 0; }
.rise3d.is-tablet .r3-idle-builder { width: 100%; margin: 8px 0; }
.rise3d.is-tablet .r3-minimap { bottom: var(--r3-bottom); left: 12px; width: 204px; }
.rise3d.is-tablet .r3-minimap canvas { width: 192px; height: 192px; }
.rise3d.is-tablet .r3-panel { left: auto; right: 12px; top: 150px; width: min(430px, calc(100% - 224px)); }
.rise3d.is-tablet .r3-selection { left: 228px; right: auto; width: 310px; max-width: calc(100% - 244px); }
.rise3d.is-tablet .r3-toasts { top: 78px; left: auto; right: 12px; width: calc(100% - 224px); }
.rise3d.is-tablet .r3-nav-more, .rise3d.is-tablet .r3-nav-menu { display: contents; }
.rise3d.is-tablet .r3-nav-more > summary { display: none; }
.rise3d.is-landscape-phone .r3-hud { bottom: auto; height: 184px; }
.rise3d.is-landscape-phone .r3-orders-button { top: 200px; }
.rise3d.is-landscape-phone .r3-map-button { top: 252px; }
.rise3d.is-phone :is(.r3-orders-button, .r3-map-button, .r3-sheet-backdrop) { pointer-events: auto; }
.rise3d.is-tablet :is(button, input, select, summary) { min-height: 44px; }
.rise3d.is-landscape-phone.keyboard-open .r3-panel > .r3-panel-header { padding: 4px 0 6px; min-height: 54px; margin-bottom: 6px; }
.rise3d.is-landscape-phone.keyboard-open .r3-sheet-handle { display: none; }
.rise3d.is-phone .r3-field:has(input[type='checkbox']) { display: flex; justify-content: space-between; gap: 12px; }
.rise3d.is-phone .r3-panel[data-view='march'] form > .r3-primary { width: 100%; min-height: 48px; position: sticky; bottom: 0; margin-top: 10px; }
.rise3d.is-tablet:not(.mini):not(.windowed) { top: var(--r3-vtop, 0px); height: var(--r3-vh, 100dvh); max-height: 100dvh; }
.rise3d.is-tablet.keyboard-open .r3-panel { top: 82px; bottom: 12px; left: 12px; right: 12px; width: auto; }
.rise3d.is-tablet.keyboard-open :is(.r3-nav, .r3-queue, .r3-guide, .r3-minimap) { display: none; }
.rise3d .r3-march-warning { margin: 6px 0 0; padding: 6px 8px; border-left: 3px solid var(--r3-warning); border-radius: 6px; color: var(--r3-warning); font-size: 12px; line-height: 1.35; }

/* rise3-int: eight calm dock destinations; secondary commands share More. */
.rise3d .r3-nav.r3-nav-grouped .r3-nav-more { display: block; position: relative; min-width: 72px; }
.rise3d .r3-nav.r3-nav-grouped .r3-nav-more > summary { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60px; gap: 4px; padding: 6px 10px; font-size: 11px; list-style: none; cursor: pointer; color: var(--r3-muted); border-radius: 6px; }
.rise3d .r3-nav-grouped summary::-webkit-details-marker { display: none; }
.rise3d .r3-nav-grouped .r3-nav-more[open] > summary { color: var(--r3-gold); background: var(--r3-control); }
.rise3d .r3-nav.r3-nav-grouped .r3-nav-menu { display: none; position: absolute; right: 0; bottom: 76px; width: 280px; max-height: min(440px, 65vh); overflow-y: auto; padding: 6px; background: var(--r3-paper); border: 1px solid var(--r3-line); border-radius: 8px; box-shadow: 0 6px 20px #17120d40; }
.rise3d .r3-nav.r3-nav-grouped .r3-nav-more[open] .r3-nav-menu { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.rise3d .r3-nav-grouped .r3-nav-menu button { min-width: 0; white-space: normal; }
.rise3d.is-phone .r3-nav.r3-nav-grouped .r3-nav-more { min-width: 0; }
.rise3d.is-phone .r3-nav.r3-nav-grouped .r3-nav-more > summary { font-size: 10px; padding: 3px; }
.rise3d.is-phone .r3-more-list { grid-template-columns: 1fr 1fr; column-gap: 12px; }
.rise3d.is-phone .r3-more-list button { min-width: 0; gap: 8px; }
@container (max-width: 800px) {
  .rise3d .r3-nav.r3-nav-grouped .r3-nav-more { min-width: 0; }
  .rise3d .r3-nav.r3-nav-grouped .r3-nav-more > summary { padding: 5px 1px; font-size: 10px; }
}

/* Minimap footer and enlarged overlay. */
.rise3d .r3-minimap-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 2px 0 4px; }
.rise3d .r3-minimap-foot small { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--r3-muted); }
.rise3d .r3-minimap-expand { display: grid; place-items: center; width: 26px; height: 26px; min-height: 26px; min-width: 26px; padding: 0; font-size: 15px; line-height: 1; flex-shrink: 0; }
.rise3d .r3-minimap canvas { image-rendering: pixelated; }
.rise3d .r3-minimap.expanded {
  left: 50%; top: 50%; bottom: auto; width: auto; padding: 8px; z-index: 20;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 100vmax #0b090788, 0 18px 48px #0008;
  animation: r3-map-in 160ms ease-out;
}
.rise3d .r3-minimap.expanded canvas { width: var(--r3-map-size, 560px); height: var(--r3-map-size, 560px); }
.rise3d .r3-minimap.expanded .r3-minimap-foot { padding-top: 6px; }
.rise3d .r3-minimap.expanded small { font-size: 12px; }
.rise3d.is-phone .r3-minimap-foot { display: none; }
@keyframes r3-map-in { from { opacity: 0; transform: translate(-50%, -48%) scale(0.97); } }

/* Comfortable compact controls and visible explanations. */
.rise3d .r3-action-help { margin: 0 0 16px; color: var(--r3-muted); font-size: 13px; line-height: 1.55; }
.rise3d .r3-button-help { display: block; font-weight: 400; font-size: 12px; line-height: 1.4; color: var(--r3-muted); white-space: normal; }
.rise3d .r3-nav > button > .r3-button-help { display: none; }
.rise3d .r3-nav-menu button { text-align: left; align-items: flex-start; }
.rise3d .r3-menu-copy { flex: 1; min-width: 0; }
.rise3d .r3-panel-header .r3-panel-title { flex: 1; }
.rise3d .r3-panel-header h2 { overflow-wrap: anywhere; min-width: 0; }
.rise3d .r3-panel-header > button { flex-shrink: 0; }
.rise3d.is-phone .r3-more-list { grid-template-columns: 1fr; }
.rise3d.is-phone .r3-more-list button { min-height: 64px; padding: 10px 4px; }
.rise3d.is-phone .r3-more-list .r3-icon { flex-shrink: 0; }
.rise3d.is-phone :is(button, input:not([type=checkbox]), select, summary) { min-height: 44px; }
.rise3d.is-phone :is(input, textarea, select) { font-size: 16px; }
.rise3d.is-phone .r3-panel { overflow-x: hidden; touch-action: pan-y; scroll-padding-bottom: 72px; }
.rise3d.is-phone .r3-selection { overflow-y: auto; max-height: min(350px, 48%); touch-action: pan-y; }
.rise3d.is-phone .r3-selection > button:not(.r3-primary) { display: inline-flex; align-items: center; margin: 6px 6px 0 0; }
.rise3d.is-phone .r3-selection .r3-panel-header > button { min-height: 44px; }
.rise3d.is-phone .r3-panel .r3-minimap canvas { width: 100%; }
.rise3d.is-phone .r3-panel[data-view='mobile.map'] .r3-minimap { flex-shrink: 0; margin: 0; }
.rise3d.is-phone .r3-panel .r3-minimap-foot { display: none; }
.rise3d.is-phone .r3-panel-header { z-index: 2; }
.rise3d.is-phone .r3-table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
.rise3d.is-phone .r3-building-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rise3d.is-landscape-phone .r3-panel { left: max(8px, env(safe-area-inset-left)); right: max(8px, env(safe-area-inset-right)); height: 100%; }
.rise3d.is-landscape-phone .r3-panel > .r3-panel-header { min-height: 64px; padding: 10px 0 8px; }
.rise3d.is-landscape-phone .r3-sheet-handle { display: none; }
.rise3d.is-landscape-phone .r3-sheet-backdrop { inset: 0; }
.rise3d.is-landscape-phone .r3-ui:has(.r3-panel:not([hidden])) :is(.r3-nav,.r3-hud) { visibility: hidden; }
.rise3d.is-phone .r3-nav-short { overflow-wrap: anywhere; }
.rise3d.is-phone .r3-nav button .r3-nav-short { white-space: normal; line-height: 1.15; }
.rise3d .r3-house-request { display: grid; gap: 6px; padding: 14px 0; border-bottom: 1px solid var(--r3-line); }
.rise3d .r3-house-request .r3-actions { display: flex; gap: 8px; }
.rise3d .r3-house-request .r3-actions button { flex: 1; }
.rise3d .r3-explained { text-align: left; }
.rise3d .r3-explained .r3-button-help { margin-top: 3px; }
.rise3d .r3-minimap canvas, .rise3d .r3-minimap.expanded canvas { height: auto; aspect-ratio: 2 / 1; }
.rise3d.is-phone .r3-panel .r3-minimap canvas { aspect-ratio: 2 / 1; }
