:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --surface-hover: #2d3142;
  --text: #c0caf5;
  --text-dim: #9aa5ce;
  --text-disabled: #5c6370;
  --accent: #7aa2f7;
  --accent-hover: #89b4fa;
  --success: #9ece6a;
  --error: #f7768e;
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  --breakpoint-mobile: 767px;
  /* Desktop RPG layout */
  --game-width: 1200px;
  --game-height: 900px;
  --sidebar-left-width: 150px; /* 75% of original 200px */
  --sidebar-right-width: 220px;
  --layout-border: 1px solid rgba(192, 202, 245, 0.12);
  --layout-border-accent: 1px solid rgba(122, 162, 247, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  cursor: default !important;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 1rem 0.5rem 4rem;
}

/* Desktop-oriented fixed-width game container (LORD / classic browser RPG style) */
.game-wrapper {
  width: 100%;
  max-width: var(--game-width);
  margin: 0 auto;
  min-height: 0;
}

.game-container {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}

/* When in realm: horizontal 3-column layout */
.game-container.realm-active {
  display: grid;
  grid-template-columns: var(--sidebar-left-width) 1fr var(--sidebar-right-width);
  grid-template-areas: "sidebar-left main-wrap sidebar-right";
  gap: 0;
  height: var(--game-height);
  background: var(--surface);
  border: var(--layout-border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Bottom banner region */
.bottom-banner {
  display: none;
  flex-shrink: 0;
  border-top: var(--layout-border);
  background: rgba(0, 0, 0, 0.35);
  width: 100%;
}

.game-container.banner-active .bottom-banner {
  display: flex;
  align-items: stretch;
}

.game-container:not(.banner-active) .bottom-banner {
  display: none;
}

/* by-the-tree-footer as direct child of bottom-banner:
   banner provides the border/bg; footer owns its own padding and fills the row */
.bottom-banner > .by-the-tree-footer {
  background: none;
  border-top: none;
  flex: 1 1 auto;
  min-width: 0;
}

.bottom-banner > .by-the-tree-footer:not(.hidden) {
  display: flex;
  align-items: center;
}

/* dynamic message slot — takes no space when empty */
.bottom-banner-messages {
  flex: 0 0 auto;
}

/* prevent individual buttons from breaking mid-label */
.bottom-banner .by-the-tree-nav-choice {
  white-space: nowrap;
}

.game-container.realm-active .sidebar-left {
  grid-area: sidebar-left;
  display: flex;
  flex-direction: column;
}

.game-container.realm-active .main-wrap {
  grid-area: main-wrap;
  min-width: 0;
  overflow: hidden;
  border-left: var(--layout-border);
  border-right: var(--layout-border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.game-container.realm-active .main-wrap > main.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* Ensure the single visible realm view fills the main area (fixes blank center for gossiper, bartender, drunk, etc.) */
.game-container.realm-active .main-wrap > main.main > .view:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.game-container.realm-active .main-wrap > main.main > .view.realm-poker {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.game-container.realm-active .sidebar-right {
  grid-area: sidebar-right;
  display: flex;
  flex-direction: column;
}

/* Views in realmViewsHideSidebar (e.g. inventory): hide shared right sidebar, main to the edge */
.game-container.realm-active.inventory-active {
  grid-template-columns: var(--sidebar-left-width) 1fr;
  grid-template-areas: "sidebar-left main-wrap";
}
.game-container.realm-active.inventory-active .sidebar-right {
  display: none;
}
.game-container.realm-active.inventory-active .main-wrap {
  border-right: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.game-container.realm-active.inventory-active .main-wrap > main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.inventory-active .main-wrap > main > #inventory-view,
.game-container.realm-active.inventory-active .main-wrap > main > #realm-level-up-view,
.game-container.realm-active.inventory-active .main-wrap > main > #soulscape-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* By the tree: static footer at bottom of main-wrap (like sidebar, always visible on subpages) */
.game-container.by-the-tree-active .main-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.game-container.by-the-tree-active .main-wrap > main.main {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.game-container.by-the-tree-active .main-wrap > #bottom-banner {
  flex-shrink: 0;
}
.game-container.by-the-tree-active .main-wrap > main.main > #realm-cauldron-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.by-the-tree-active .main-wrap > main.main > #soulscape-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.realm-soulscape .realm-soulscape-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(26, 27, 38, 0.97) 0%, rgba(36, 40, 59, 0.95) 50%, rgba(26, 27, 38, 0.98) 100%);
  border: 1px solid rgba(122, 162, 247, 0.2);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 4px 24px rgba(0, 0, 0, 0.4);
  padding: 0.65rem 0.75rem;
  overflow-y: auto;
}

.realm-soulscape .realm-soulscape-header {
  flex-shrink: 0;
  text-align: center;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(192, 202, 245, 0.12);
}

.realm-soulscape .realm-soulscape-body {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 0.75rem;
  padding: 0.25rem 0.1rem 0.1rem;
}

.realm-soulscape-left {
  flex: 0.55;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.realm-soulscape-right {
  flex: 0.45;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  background: radial-gradient(circle at top left, rgba(90, 108, 191, 0.25), rgba(13, 18, 35, 0.9));
  border: 1px solid rgba(122, 162, 247, 0.25);
  box-shadow: inset 0 0 0 1px rgba(10, 14, 23, 0.9);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.realm-soulscape-options {
  flex: 1;
  min-height: 0;
  margin-top: 0.25rem;
  padding-right: 0.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow-y: auto;
}

.soulscape-option-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 0.4rem 0.55rem;
  border-radius: 7px;
  background: rgba(10, 13, 24, 0.9);
  border: 1px solid rgba(69, 86, 138, 0.8);
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
  max-width: 18rem;   /* or any width you like */
  width: 100%;        /* can drop this if you want them to be only as wide as text */
}

.soulscape-option-card h3 {
  margin: 0 0 0.15rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.soulscape-option-card p {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.25;
  color: var(--text-dim);
}

.soulscape-option-card:hover {
  background: rgba(19, 26, 48, 0.95);
  border-color: rgba(129, 161, 193, 0.95);
  transform: translateY(-1px);
}

.soulscape-option-card:focus-visible {
  outline: 2px solid rgba(129, 161, 193, 0.95);
  outline-offset: 2px;
}

.soulscape-option-card.soulscape-option-selected {
  background: linear-gradient(135deg, rgba(63, 81, 181, 0.9), rgba(30, 41, 82, 0.9));
  border-color: rgba(195, 232, 255, 0.95);
}

.soulscape-option-card.soulscape-option-selected p {
  color: rgba(226, 232, 255, 0.95);
}

.soulscape-detail-placeholder {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.soulscape-detail-name {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.soulscape-detail-description {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.soulscape-stats-panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.soulscape-stats-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}

.soulscape-stats-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.soulscape-stats-list {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.soulscape-stat-row {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text);
}

.soulscape-stat-label {
  min-width: 3.2rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.soulscape-stat-values {
  flex: 1;
  text-align: left;
  white-space: nowrap;
}

.soulscape-stat-delta-positive {
  color: #9ece6a;
  font-weight: 600;
}

.soulscape-stat-delta-negative {
  color: #f7768e;
  font-weight: 600;
}

.soulscape-build-summary {
  padding: 0.6rem 0.8rem;
  color: #cdd6f4;
  line-height: 1.7;
  font-size: 0.92rem;
}

.soulscape-flavor-text {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.soulscape-option-card[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 100%;
  top: 0.2rem;
  margin-left: 0.5rem;
  z-index: 10;
  max-width: 220px;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  background: rgba(10, 10, 20, 0.96);
  border-radius: 6px;
  border: 1px solid rgba(122, 162, 247, 0.7);
  white-space: normal;
  pointer-events: none;
}

.soulscape-option-card[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 0.6rem;
  border-width: 6px;
  border-style: solid;
  border-color: transparent rgba(122, 162, 247, 0.7) transparent transparent;
}

.realm-soulscape-subtitle {
  position: relative;
}

.realm-soulscape-subtitle[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 100%;
  margin-top: 0.35rem;
  z-index: 10;
  max-width: 260px;
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--text);
  background: rgba(10, 10, 20, 0.96);
  border-radius: 6px;
  border: 1px solid rgba(122, 162, 247, 0.7);
  white-space: normal;
  pointer-events: none;
}

.realm-soulscape-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.45rem;
}

.soulscape-confirm[disabled] {
  opacity: 0.55;
  cursor: default;
}

@media (max-width: 900px) {
  .realm-soulscape .realm-soulscape-body {
    flex-direction: column;
  }

  .realm-soulscape-right {
    margin-top: 0.35rem;
  }

  .realm-soulscape-options {
    max-height: 10rem;
  }
}

.by-the-tree-footer {
  display: none;
  background: rgba(0, 0, 0, 0.35);
  border-top: var(--layout-border);
  padding: 0.6rem 1rem;
}
.by-the-tree-footer:not(.hidden) {
  display: block;
}
.by-the-tree-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  max-width: 52rem;
  margin: 0 auto;
}
.by-the-tree-footer-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}
.by-the-tree-footer-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.by-the-tree-footer .by-the-tree-nav-choice {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.by-the-tree-footer .by-the-tree-nav-choice:hover {
  color: var(--accent, #7dcfff);
  border-color: rgba(122, 162, 247, 0.4);
  background: rgba(122, 162, 247, 0.08);
}
.by-the-tree-footer .by-the-tree-nav-leave {
  margin-left: auto;
}

/* Generic action-bar pattern — reusable for any bottom-banner view */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  width: 100%;
}

.action-bar-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
}

.action-bar-right {
  display: flex;
  align-items: center;
  margin-left: auto;
  gap: 0.75rem;
}

/* ActionBar action states — layered on top of base button style */
.action-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(40%);
}

.action-highlight {
  border-color: rgba(120, 180, 255, 0.5);
  box-shadow: 0 0 5px rgba(120, 180, 255, 0.25);
}

.action-danger {
  border-color: rgba(255, 110, 110, 0.5);
}

/* Shop view: fill height so menu choices sit at bottom, item lists scroll */
.game-container.realm-active.shop-active .main-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.game-container.realm-active.shop-active .main-wrap > main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.shop-active .main-wrap > main > #realm-shop-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.game-container.realm-active.shop-active .realm-shop .realm-shop-title,
.game-container.realm-active.shop-active .realm-shop .shop-portrait-wrap,
.game-container.realm-active.shop-active .realm-shop .shop-merchant-line,
.game-container.realm-active.shop-active .realm-shop .realm-sep {
  flex-shrink: 0;
}
.game-container.realm-active.shop-active .realm-shop #shop-message,
.game-container.realm-active.shop-active .realm-shop .shop-confirm-actions {
  flex-shrink: 0;
}
.game-container.realm-active.blacksmith-active .main-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.game-container.realm-active.blacksmith-active .main-wrap > main {
  flex: 1;
  min-height: 0;
  display: flex;
}
.game-container.realm-active.blacksmith-active .main-wrap > main > #realm-blacksmith-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.cauldron-active .main-wrap > main > #realm-cauldron-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* NPC view fixed-header elements must not shrink */
.realm-bartender .bartender-banner,
.realm-bartender .bartender-intro,
.realm-bartender .bartender-portrait-wrap,
.realm-bartender .realm-sep { flex-shrink: 0; }

.realm-drunk .drunk-banner,
.realm-drunk .drunk-intro,
.realm-drunk .drunk-portrait-wrap,
.realm-drunk .realm-sep { flex-shrink: 0; }

.realm-gossiper .gossiper-banner,
.realm-gossiper .gossiper-intro,
.realm-gossiper .gossiper-portrait-wrap,
.realm-gossiper .realm-sep { flex-shrink: 0; }

/* Gossiper chat block fills remaining height and scrolls */
.realm-gossiper .gossiper-chat-block {
  flex: 1 1 0%;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
/* Left sidebar: navigation (Tavern, Forest, Market, Arena, Inventory) */
.sidebar-left {
  display: none;
  background: rgba(0, 0, 0, 0.25);
  padding: 1rem 0.75rem;
  border-right: var(--layout-border);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.sidebar-nav-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0 0.25rem;
  border-bottom: var(--layout-border);
  padding-bottom: 0.5rem;
}

.sidebar-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.sidebar-nav-list li {
  margin: 0;
}

.sidebar-nav-list li:last-child {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: var(--layout-border);
}

.sidebar-nav-btn {
  display: block;
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.35rem;
  text-align: left;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.sidebar-nav-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
  border-color: rgba(122, 162, 247, 0.3);
}

.sidebar-nav-btn[data-logout="1"] {
  margin-top: 0.25rem;
  background: rgba(0, 0, 0, 0.35);
  border-color: rgba(247, 118, 142, 0.5);
  color: var(--error);
}

.sidebar-nav-btn[data-logout="1"]:hover {
  background: rgba(247, 118, 142, 0.15);
  border-color: var(--error);
  color: #fff;
}

.sidebar-nav-btn:focus {
  outline: none;
  border-color: var(--accent);
}

.sidebar-inbox-badge {
  margin-left: 0.2rem;
  font-weight: 600;
  color: var(--accent);
}

.sidebar-inbox-btn.has-unread {
  animation: sidebar-inbox-glow 1.5s ease-in-out infinite alternate;
  border-color: rgba(255, 193, 7, 0.6);
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
}

@keyframes sidebar-inbox-glow {
  from {
    box-shadow: 0 0 4px rgba(255, 193, 7, 0.4);
  }
  to {
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.7);
  }
}

.inbox-description {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.inbox-list-wrap {
  margin-bottom: 1rem;
}

.inbox-thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.inbox-thread-item {
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--layout-border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.inbox-thread-item:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.inbox-thread-item.has-unread {
  border-left: 3px solid #ffc107;
}

.inbox-thread-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.inbox-thread-preview {
  font-size: 0.95rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.inbox-empty {
  padding: 1.5rem;
  text-align: center;
}

.inbox-compose-wrap {
  margin-bottom: 1rem;
}

.inbox-compose-toggle {
  margin-bottom: 0.5rem;
}

.inbox-compose-form label {
  display: block;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.inbox-send-to-wrap {
  position: relative;
  margin-bottom: 0.5rem;
}

.inbox-send-to-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--layout-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.inbox-send-to-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  max-height: 180px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--layout-border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.inbox-send-to-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--layout-border);
}

.inbox-send-to-option:last-child {
  border-bottom: none;
}

.inbox-send-to-option:hover {
  background: var(--surface-hover);
}

.inbox-compose-message {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid var(--layout-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

.inbox-thread-reply-wrap,
.inbox-dm-reply-wrap {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--layout-border);
}

.inbox-thread-reply-wrap label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.inbox-thread-reply-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.95rem;
  border: 1px solid var(--layout-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

.inbox-conversation-wrap {
  margin-top: 1rem;
}

.inbox-conversation-header {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.inbox-conversation-title {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.inbox-conversation-messages {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 400px;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.inbox-msg {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  max-width: 85%;
}

.inbox-msg.player {
  align-self: flex-start;
  background: rgba(122, 162, 247, 0.2);
  border: 1px solid rgba(122, 162, 247, 0.4);
}

.inbox-msg.admin {
  align-self: flex-end;
  background: rgba(255, 193, 7, 0.15);
  border: 1px solid rgba(255, 193, 7, 0.4);
}

.inbox-msg-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.inbox-msg-body {
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.inbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.inbox-overlay-card {
  background: var(--surface);
  border: 1px solid var(--layout-border);
  border-radius: 6px;
  padding: 1.25rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 18px 45px rgba(0, 0, 0, 0.7);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.inbox-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.inbox-overlay-header .card-title {
  margin: 0;
}

.inbox-close-btn {
  flex-shrink: 0;
}

.feedback-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.feedback-popup-card {
  background: #111;
  border-radius: 4px;
  padding: 1.5rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 18px 45px rgba(0, 0, 0, 0.8);
  max-width: 480px;
  width: 100%;
}

.feedback-popup-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.feedback-popup-subtitle {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.8);
}

.feedback-popup-types {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.feedback-type-option {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.feedback-message-label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

.feedback-message-input {
  width: 100%;
  min-height: 4rem;
  background: #050608;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8f8f8;
  padding: 0.5rem;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
}

.feedback-message-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.feedback-popup-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.realm-tip-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.realm-tip-popup-card {
  background: #111;
  border-radius: 4px;
  padding: 1.5rem;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 18px 45px rgba(0, 0, 0, 0.8);
  max-width: 480px;
  width: 100%;
}

.realm-tip-popup-title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.realm-tip-popup-intro {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
}

.realm-tip-browser-tip {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.35;
}

.realm-tip-dont-show {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  cursor: pointer;
  margin-bottom: 0.75rem;
}

.realm-tip-popup-actions {
  margin-top: 0.25rem;
  display: flex;
  justify-content: flex-end;
}

.admin-feedback-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.admin-feedback-filters label {
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.admin-feedback-filters select {
  background: #050608;
  color: #f8f8f8;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
}

.admin-feedback-list {
  max-height: 640px;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
}

.admin-feedback-item {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.35rem;
}

.admin-feedback-item:last-child {
  border-bottom: none;
}

.admin-feedback-meta {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.25rem;
}

.admin-feedback-type {
  font-weight: 600;
}

.admin-feedback-status {
  font-weight: 600;
}

.admin-feedback-message {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.admin-feedback-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.admin-feedback-actions .btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  min-height: auto;
  line-height: 1.2;
}

.admin-feedback-replies {
  margin: 0.75rem 0;
  padding: 0.5rem 0;
  border-top: 1px solid var(--layout-border);
}

.admin-feedback-replies-title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.admin-feedback-reply {
  margin-bottom: 0.5rem;
  padding: 0.5rem;
  background: rgba(255, 193, 7, 0.08);
  border-left: 3px solid rgba(255, 193, 7, 0.5);
  border-radius: 4px;
}

.admin-feedback-reply-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.admin-feedback-reply-message {
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-feedback-reply-form {
  margin: 0.75rem 0;
}

.admin-feedback-reply-form label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
}

.admin-feedback-reply-input {
  width: 100%;
  max-width: 480px;
  padding: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  border: 1px solid var(--layout-border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
}

.admin-feedback-reply-btn {
  font-size: 0.85rem;
}

.admin-feedback-status-new .admin-feedback-status {
  color: var(--accent);
}

.admin-feedback-status-done .admin-feedback-status {
  color: #9ae6b4;
}

.admin-feedback-status-rejected .admin-feedback-status {
  color: var(--error);
}

.admin-feedback-status-reviewed .admin-feedback-status {
  color: #f6e05e;
}

.admin-feedback-check-wrap {
  flex-shrink: 0;
  margin-right: 0.25rem;
  display: inline-flex;
  align-items: center;
}

.admin-feedback-check-wrap input {
  margin: 0;
  cursor: pointer;
}

.admin-feedback-item-body {
  flex: 1 1 auto;
  min-width: 0;
}

.admin-feedback-bottom-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.admin-feedback-confirm {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
}

.admin-feedback-confirm-msg {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

/* Right sidebar: character stats */
.sidebar-right {
  display: none;
  background: rgba(0, 0, 0, 0.2);
  padding: 1rem 0.75rem;
  border-left: var(--layout-border);
}

.sidebar-stats-panel {
  position: sticky;
  top: 1rem;
}

.sidebar-stats-title {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 0 0.25rem;
  border-bottom: var(--layout-border);
  padding-bottom: 0.5rem;
}
.sidebar-char-name {
  margin: 0.35rem 0 0.75rem;
  font-size: 1.0rem;
  color: var(--text);
  text-align: left;
}

.sidebar-gold-under-name {
  margin: 0 0 0.25rem;
  font-size: 0.9rem;
}

.sidebar-spacer {
  margin: 0.5rem 0;
  min-height: 0.25rem;
  line-height: 0;
}

.sidebar-char-meta {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: left;
}

.sidebar-stats .realm-stat {
  margin-bottom: 0.2rem;
  font-size: 0.9rem;
}

.sidebar-stats-sep {
  margin: 0.4rem 0;
  border: 0;
  border-top: 1px solid var(--text-muted, rgba(255, 255, 255, 0.3));
}

.sidebar-stats .realm-stat-label {
  min-width: 4.5rem;
}

.sidebar-stats .realm-stat-value {
  min-width: auto;
}

.sidebar-stats .realm-stat-sublist {
  margin-left: 0.5rem;
  margin-top: 0.15rem;
  margin-bottom: 0.2rem;
}
.sidebar-stats .realm-stat-sublist .realm-stat-sub {
  margin-bottom: 0.1rem;
  font-size: 0.85rem;
}

.sidebar-equipment {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px dashed rgba(192, 202, 245, 0.25);
}

.sidebar-music {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(192, 202, 245, 0.18);
  font-size: 0.8rem;
}

/* Music controls are shown only when a realm/in-game view is active.
   Login/menu/etc. keep the music block hidden. */
.sidebar-music {
  display: none;
}

#game-container.realm-active .sidebar-music {
  display: block;
}

.sidebar-music-title {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.sidebar-music-track {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-music-controls {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.sidebar-music-btn {
  flex: 0 0 auto;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-family: inherit;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sidebar-music-btn:hover {
  color: var(--accent);
  border-color: rgba(122, 162, 247, 0.4);
  background: rgba(122, 162, 247, 0.08);
}

.sidebar-music-volume-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sidebar-music-volume-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.sidebar-music-volume {
  flex: 1;
  appearance: none;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

.sidebar-music-volume::-webkit-slider-thumb {
  appearance: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.sidebar-music-volume::-moz-range-thumb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
}
/* Section headings: EQUIPMENT and ARMOR – same style (bold, larger, light blue) */
.sidebar-equipment-heading {
  margin: 0.5rem 0 0.35rem;
  font-size: 0.9rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7aa2f7;
}
.sidebar-equipment-heading:first-child {
  margin-top: 0;
}
.sidebar-equipment-label {
  margin: 0.25rem 0 0.1rem;
  font-size: 0.85rem;
  color: var(--text);
}
.sidebar-equipment-item {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}
/* Separator before Weapon (at bottom) */
.sidebar-equipment-weapon-sep {
  margin: 0.5rem 0 0.35rem;
  min-height: 0.5rem;
  border-top: 1px solid rgba(192, 202, 245, 0.2);
}

.main-wrap {
  padding: 1.25rem 1.5rem;
  background: var(--bg);
}

.header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding: 0 0.5rem;
}

.title {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--text-dim);
}

.main {
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* Menu view: fixed pixel dimensions (no %) */
#menu-view {
  position: static;
  width: 520px;
  min-height: 823px;
  padding: 24px;
  box-sizing: border-box;
}

.card-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.intro-quote {
  margin: 1rem 0;
  padding: 0.75rem 1rem 0.75rem 1.25rem;
  border-left: 3px solid var(--accent, #7dcfff);
  background: var(--bg-soft, rgba(0, 0, 0, 0.15));
  border-radius: 0  var(--radius) var(--radius) 0;
}
.intro-quote .intro-quote-title { margin: 0 0 0.35rem; font-weight: 600; color: var(--text); }
.intro-quote .intro-quote-text { margin: 0; font-size: 0.95rem; line-height: 1.5; color: var(--text-dim); }

.hint {
  margin: 0 0 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* Purge notice info box — menu view only; fixed pixel dimensions (static) */
#menu-view #menu-purge-notice.menu-purge-info {
  position: static;
  width: 464px;
  min-height: 75px;
  margin: 0 0 20px;
  padding: 14px 16px;
  box-sizing: border-box;
  background: rgba(122, 162, 247, 0.1);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
.menu-purge-info.hidden {
  display: none !important;
}
.menu-purge-info-label {
  display: block;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.menu-purge-info-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}

.create-disclaimer {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--layout-border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.45;
}

.create-accept-wrap {
  margin-bottom: 1rem;
}
.create-accept-label {
  color: var(--text);
}
.create-accept-hint {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--text-error, #c45c5c);
}
.create-accept-hint.hidden {
  display: none !important;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#menu-view .menu-actions {
  gap: 0.75rem;
}

.btn {
  padding: 0.65rem 1rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-hover);
  color: var(--text);
}

.btn-secondary:hover {
  background: #363b52;
}

/* Sign in with Google: placeholder button styled per Google design guidelines */
.google-btn-wrap {
  margin-top: 0.5rem;
  width: 100%;
}
.menu-actions .google-btn-wrap {
  margin-top: 0;
}
.btn-google {
  margin-top: 0;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.65rem 1.25rem 0.65rem 12px;
  min-height: 0;
  height: auto;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 4px;
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  font-weight: 500;
  font-size: 1rem;
  line-height: 1.25;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s;
}
.btn-google .btn-google-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
}
.btn-google .btn-google-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}
.btn-google .btn-google-text {
  white-space: nowrap;
}
.btn-google:hover {
  background: #f7f8f8;
  border-color: #dadce0;
}
.btn-google:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* Custom tooltip with 0ms delay (native title cannot be delayed) */
.btn-google[data-tooltip] {
  position: relative;
}
.btn-google[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 6px;
  padding: 6px 10px;
  background: #1f1f1f;
  color: #fff;
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  border-radius: 4px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.12s ease 0ms, visibility 0ms linear 0ms;
}
.btn-google[data-tooltip]:hover::after,
.btn-google[data-tooltip]:focus::after {
  opacity: 1;
  visibility: visible;
  transition-delay: 0ms;
}

.btn-danger {
  color: #f7768e;
  border: 1px solid rgba(247, 118, 142, 0.4);
}
.btn-danger:hover {
  background: rgba(247, 118, 142, 0.15);
}
.logged-in-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-outline:hover {
  background: rgba(122, 162, 247, 0.15);
}

.hidden {
  display: none !important;
}

.view.hidden {
  display: none !important;
}

.form label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid var(--surface-hover);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

.form input:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.form-actions .btn {
  flex: 1;
}

.message {
  margin-top: 1rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.message.error {
  background: rgba(247, 118, 142, 0.15);
  color: var(--error);
}

.message.success {
  background: rgba(158, 206, 106, 0.15);
  color: var(--success);
}

.footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: var(--bg);
  padding: 0.5rem 1rem 0.75rem;
  z-index: 1;
}

.footer p {
  margin: 0;
}
.footer-version {
  margin-top: 0.25rem;
  font-size: 0.7rem;
  opacity: 0.85;
}

.admin-center-title {
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.admin-as {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.admin-hr {
  border: none;
  border-top: 1px solid var(--surface-hover);
  margin: 0.5rem 0 1rem;
}

.admin-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.admin-list li {
  margin-bottom: 0.35rem;
}

.admin-list .btn-link {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 0.25rem 0;
  font-size: 1rem;
  text-align: left;
}

.admin-list .btn-link:hover {
  text-decoration: underline;
}

.admin-account-row {
  margin-bottom: 0.5rem;
}

.admin-account-meta {
  font-size: 0.8rem;
  color: var(--muted, #666);
  margin-top: 0.2rem;
  margin-left: 0.25rem;
}

.admin-account-online {
  color: #9ece6a;
}

.admin-account-offline {
  color: var(--muted, #666);
}

.admin-account-last {
  color: var(--muted, #888);
}

.admin-account-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent, #7aa2f7);
  margin-left: 0.25rem;
}

.admin-char-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.admin-char-row .admin-char-delete {
  flex-shrink: 0;
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
}

.admin-delete-account-btn {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.form-inline {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

.form-inline input {
  flex: 1;
  margin-bottom: 0;
}

.admin-edit-form .edit-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.4rem;
}

.admin-edit-form .edit-row label {
  width: 5rem;
  margin: 0;
  flex-shrink: 0;
}

.admin-edit-form .edit-row input {
  width: 5rem;
  margin: 0;
}

.admin-edit-form .edit-row input + input {
  margin-left: 0.25rem;
}

.admin-edit-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  column-gap: 1.25rem;
  row-gap: 0.3rem;
}

.admin-edit-form-grid .edit-row {
  margin-bottom: 0;
}

.admin-edit-form-grid .edit-row-wide {
  grid-column: span 2;
}

/* Admin edit: same width as game (tavern view) so the whole page matches the game layout */
.game-wrapper.admin-edit-wide {
  max-width: var(--game-width);
  min-width: var(--game-width);
  width: var(--game-width);
}
.admin-edit-view-wide {
  max-width: 100%;
  width: 100%;
}
.admin-edit-view-wide .admin-edit-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
.admin-edit-view-wide .admin-edit-left {
  position: sticky;
  top: 1rem;
}
.admin-edit-view-wide .admin-edit-left .admin-gear-title {
  margin-bottom: 0.5rem;
}
.admin-edit-view-wide .admin-edit-kills-list {
  min-height: 12rem;
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(247, 118, 142, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.admin-edit-view-wide .admin-edit-kills-list .realm-inventory-kill-header {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin: 0.4rem 0 0.15rem;
}
.admin-edit-view-wide .admin-edit-kills-list .realm-inventory-kill-row {
  font-size: 0.85rem;
  margin: 0.15em 0;
  line-height: 1.35;
  padding: 0;
}
.admin-edit-view-wide .admin-edit-kills-list .realm-inventory-kill-row .realm-inventory-label {
  color: var(--text);
}
.admin-edit-view-wide .admin-edit-kills-list .realm-inventory-kill-stars {
  color: #e0af68;
  font-size: 0.9em;
  letter-spacing: 0.02em;
}
.admin-edit-view-wide .admin-edit-right .admin-gear-title {
  margin-bottom: 0.6rem;
}

.admin-gear-wrap {
  margin-bottom: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface-hover);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
}

.admin-gear-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.6rem 0;
}

.admin-gear-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.admin-playtime {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.admin-gear-item {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.65rem;
  background: rgba(0,0,0,0.2);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}

.admin-gear-slot {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.admin-gear-name {
  font-weight: 500;
  color: var(--text);
}

.admin-gear-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.admin-gear-stat {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
}

.admin-gear-stat.realm-attack {
  background: rgba(122, 162, 247, 0.2);
  color: #7aa2f7;
}

.admin-gear-stat.realm-defense {
  background: rgba(247, 118, 142, 0.2);
  color: #f7768e;
}

.hub-list {
  margin-bottom: 1rem;
}
.hub-list .knight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.hub-list .knight-row .btn {
  flex-shrink: 0;
}

.knight-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.knight-card {
  background: var(--surface-hover);
  border-radius: var(--radius);
  padding: 0.75rem;
  border: 1px solid rgba(255,255,255,0.06);
}
.knight-card-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(122, 162, 247, 0.25);
}
.knight-card-name {
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--accent);
}
.knight-card-stats {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  line-height: 1.35;
}
.knight-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}
.knight-card-actions .knight-card-enter {
  flex: 1;
  min-width: 0;
}
.knight-card-actions .knight-card-remove {
  flex: 0 0 auto;
}
.knight-card-enter {
  width: 100%;
  margin-top: 0.25rem;
}

.hub-header { font-size: 1rem; }
.hub-exp { margin: 0.25rem 0; color: var(--text-dim); font-size: 0.9rem; }
.hub-stats { margin: 0.5rem 0; max-width: 20rem; }
.hub-stats .hub-stat {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0.35rem 0;
  font-size: 0.95rem;
}
.hub-stat-label {
  flex-shrink: 0;
  width: 6.5rem;
  color: var(--text-dim);
}
.hub-stat-value {
  text-align: right;
  width: 10rem;
  flex-shrink: 0;
}
.hub-hp .hub-stat-value,
.hub-hp .hub-stat-value span { color: #f7768e; }
.hub-stamina .hub-stat-value,
.hub-stamina .hub-stat-value span { color: #9ece6a; }
.hub-gold .hub-stat-value { color: #e0af68; }
.hub-weapon .hub-stat-label,
.hub-body .hub-stat-label,
.hub-helmet .hub-stat-label,
.hub-legs .hub-stat-label,
.hub-boots .hub-stat-label,
.hub-gloves .hub-stat-label { color: var(--accent); }
.hub-weapon .hub-stat-value,
.hub-body .hub-stat-value,
.hub-helmet .hub-stat-value,
.hub-legs .hub-stat-value,
.hub-boots .hub-stat-value,
.hub-gloves .hub-stat-value { color: var(--text); }
.hub-playtime .hub-stat-label { color: var(--text-dim); }
.hub-stat-sublist {
  margin-left: 0.75rem;
  margin-top: 0.15rem;
  margin-bottom: 0.25rem;
}
.hub-stat-sublist .hub-stat-sub {
  margin: 0.1rem 0;
  font-size: 0.9em;
}
.hub-menu { margin-top: 0.5rem; }
.hub-menu .hub-menu-sep { margin-top: 1.25rem; }
#hub-enter-realm.hub-action-selected {
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 0 0 1px var(--accent), 0 0 14px rgba(122, 162, 247, 0.5), 0 0 24px rgba(122, 162, 247, 0.25);
}
.hub-confirm {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--surface-hover);
  border-radius: var(--radius);
  border: 1px solid var(--accent);
}
.hub-confirm-msg { margin: 0 0 0.75rem; font-size: 0.95rem; color: var(--text); }
.hub-confirm .form-actions { margin-top: 0; }

/* Realm (Tavern) screen – terminal-style game UI */
.realm-online-bar {
  font-size: 0.8rem;
  color: var(--muted, #888);
  margin: 0 0 0.5rem;
}
.realm-online-bar .realm-online-you {
  color: #9ece6a;
  font-weight: bold;
}

.realm-screen {
  background: var(--bg);
  color: var(--text);
  padding: 1rem 0;
  max-width: 100%;
  margin: 0;
  min-height: 22em;
}

/* Realm main hub: no scrollbar; portrait shrinks so title + menu + image fit */
#realm-main-view {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
#realm-main-view .tavern-portrait-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#realm-main-view .realm-title-block.realm-main-title-block {
  flex-shrink: 0;
}
#realm-main-view .tavern-portrait-wrap .tavern-portrait {
  max-height: 100%;
  width: auto;
  object-fit: contain;
}
#realm-main-view .realm-sep,
#realm-main-view .realm-weather,
#realm-main-view .realm-menu {
  flex-shrink: 0;
}
#realm-main-view #realm-main-message {
  flex-shrink: 0;
}
.realm-title-block {
  text-align: center;
  margin: 0 0 0.5rem;
}
.realm-title-block .realm-title {
  display: block;
  font-family: 'Press Start 2P', monospace;
  font-size: 3rem;
  color: #f7768e;
  margin: 0;
  letter-spacing: 0.02em;
}
.realm-title-block .realm-subtitle {
  display: block;
  font-size: 0.85rem;
  color: var(--text);
  margin: 0.25rem 0 0;
}
.realm-main-title-block .realm-main-title-line1 {
  font-size: 1.35rem;
  margin: 0;
}
.realm-main-title-block .realm-main-title-line2 {
  display: block;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.65rem;
  color: var(--text);
  margin: 0.35rem 0 0;
  line-height: 1.5;
}
.realm-screen .tavern-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-screen .tavern-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
#realm-main-portrait {
  opacity: 0;
  transition: opacity 0.2s ease-out;
}
#realm-main-portrait.realm-portrait-ready {
  opacity: 1;
}
.realm-sep {
  border: none;
  border-top: 1px dashed #f7768e;
  margin: 0.5rem 0;
  opacity: 0.9;
}
.realm-welcome {
  display: none;
}
.realm-lvl { color: #7dcfff; }
.realm-weather {
  margin: 0.25rem 0;
  font-size: 0.95rem;
  color: var(--accent);
  font-weight: 600;
}
.realm-location {
  display: none;
}

/* Weather variants */
.realm-weather-normal,
.realm-weather-rain {
  /* Calm night / Steady rain: white text */
  color: var(--text);
}
.realm-weather-heavy_thunderstorm {
  color: #7dcfff;
}
.realm-weather-acid_rain {
  color: #9ece6a;
}
.realm-weather-blood_moon {
  color: #f7768e;
}
.realm-weather-toxic_fog {
  color: #bb9af7;
}
.realm-weather-winter_blizzard {
  color: #a9b1d6;
}
.realm-stats {
  margin: 0.5rem 0;
  font-size: 0.95rem;
  line-height: 1.25;
}
.realm-stat {
  margin: 0;
  line-height: 1.3;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
}
.realm-stat-label {
  flex-shrink: 0;
}
.realm-stat-value {
  text-align: right;
  min-width: 8rem;
  flex-shrink: 0;
}
.realm-hp { color: #9ece6a; }
.realm-stamina { color: #9ece6a; }
.realm-gold { color: #e0af68; }
.realm-attack { color: #7aa2f7; }
.realm-defense { color: #f7768e; }
.realm-crit { color: #bb9af7; }
.realm-stat-sublist .realm-stat-sub .realm-stat-value.realm-attack { color: #7aa2f7; }
.realm-menu {
  margin: 0.75rem 0;
  font-size: 0.95rem;
  line-height: 1.7;
}
.realm-menu p { margin: 0.35rem 0; }
.realm-menu-choice.realm-menu-gap {
  margin: 0;
  padding: 0;
  height: 1.7em;
  min-height: 1.7em;
  line-height: 0;
  overflow: hidden;
  cursor: default;
  pointer-events: none;
}
.realm-menu-choice { cursor: pointer; }
.realm-menu-choice:hover { color: var(--accent, #7dcfff); }
/* Main menu semantic colors (places, rest, venture) */
#realm-main-menu .realm-menu-choice.realm-menu-place { color: #e0af68; }
#realm-main-menu .realm-menu-choice.realm-menu-place:hover { color: #e0c090; }
#realm-main-menu .realm-menu-choice.realm-menu-rest { color: #9ece6a; }
#realm-main-menu .realm-menu-choice.realm-menu-rest:hover { color: #b4e08a; }
#realm-main-menu .realm-menu-choice.realm-menu-venture { color: #7dcfff; }
#realm-main-menu .realm-menu-choice.realm-menu-venture:hover { color: #a5d8ff; }
.realm-locked { color: #f7768e; }
.realm-menu-forest-hint {
  margin: 0.25em 0 0 0;
  padding: 0;
  font-size: 0.9em;
  color: var(--text-muted, #a9b1d6);
}
.realm-menu-level-up-link {
  color: #7dcfff;
  text-decoration: none;
}
.realm-menu-level-up-link:hover {
  text-decoration: underline;
  color: #a5d8ff;
}
.realm-menu-choice-disabled {
  opacity: 0.5;
  pointer-events: none;
  filter: grayscale(0.5);
}
.realm-option-detail { color: #7dcfff; }

/* Soulscape (level-up / tier choices) — fits inside .main-wrap (636×898) */
.realm-level-up.realm-screen {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.realm-level-up .realm-level-up-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, rgba(26, 27, 38, 0.97) 0%, rgba(36, 40, 59, 0.95) 50%, rgba(26, 27, 38, 0.98) 100%);
  border: 1px solid rgba(122, 162, 247, 0.2);
  border-radius: 10px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03), 0 4px 24px rgba(0, 0, 0, 0.4);
  padding: 0.65rem 0.75rem;
  overflow-y: auto;
}

.realm-level-up .realm-level-up-header {
  flex-shrink: 0;
  text-align: center;
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid rgba(192, 202, 245, 0.12);
}

.realm-level-up .realm-level-up-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: var(--accent);
  margin: 0 0 0.2rem;
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(122, 162, 247, 0.35);
}

.realm-level-up .realm-level-up-subtitle {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.3;
}

.realm-level-up .realm-level-up-grid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 1.25rem auto 0.4rem;
  max-width: 560px;
  width: 100%;
}

.realm-level-up .realm-level-up-row {
  display: grid;
  gap: 0.35rem;
}

.realm-level-up .realm-level-up-perks-row {
  grid-template-columns: 1fr 1fr 1fr;
}

.realm-level-up .realm-level-up-lower-row {
  grid-template-columns: 1fr 1fr;
}

.realm-level-up .realm-level-up-section {
  border-radius: 6px;
  padding: 0.5rem 0.6rem;
  min-height: 18rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.realm-level-up .realm-level-up-section-perk {
  background: linear-gradient(180deg, rgba(122, 162, 247, 0.1) 0%, rgba(122, 162, 247, 0.04) 100%);
  border: 1px solid rgba(122, 162, 247, 0.3);
  box-shadow: 0 1px 0 rgba(122, 162, 247, 0.08);
}

.realm-level-up .realm-level-up-section-perk .realm-level-up-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #7aa2f7;
  margin: 0 0 0.2rem;
  padding-bottom: 0.15rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(122, 162, 247, 0.35);
}

.realm-level-up .realm-level-up-section-trait {
  background: linear-gradient(180deg, rgba(224, 175, 104, 0.12) 0%, rgba(224, 175, 104, 0.04) 100%);
  border: 1px solid rgba(224, 175, 104, 0.35);
  box-shadow: 0 1px 0 rgba(224, 175, 104, 0.08);
}

.realm-level-up .realm-level-up-section-trait .realm-level-up-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #e0af68;
  margin: 0 0 0.2rem;
  padding-bottom: 0.15rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(224, 175, 104, 0.4);
}

.realm-level-up .realm-level-up-section-active {
  background: linear-gradient(180deg, rgba(158, 206, 106, 0.1) 0%, rgba(158, 206, 106, 0.04) 100%);
  border: 1px solid rgba(158, 206, 106, 0.35);
  box-shadow: 0 1px 0 rgba(158, 206, 106, 0.08);
}

.realm-level-up .realm-level-up-section-active .realm-level-up-section-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #9ece6a;
  margin: 0 0 0.2rem;
  padding-bottom: 0.15rem;
  letter-spacing: 0.05em;
  border-bottom: 1px solid rgba(158, 206, 106, 0.4);
}

.realm-level-up .realm-level-up-choices {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.realm-level-up .realm-level-up-option {
  padding: 0.35rem 0.5rem;
  font-size: 0.75rem;
  border-radius: 4px;
  min-height: 2.5rem;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
  filter: grayscale(1);
  opacity: 0.8;
  background: transparent;
  border: 1px solid transparent;
}

.realm-level-up .realm-level-up-option:hover {
  opacity: 1;
  background: rgba(192, 202, 245, 0.08);
  filter: grayscale(0.4);
}

.realm-level-up .realm-level-up-section-perk .realm-level-up-option.realm-level-up-option-selected {
  filter: none;
  opacity: 1;
  background: rgba(122, 162, 247, 0.2);
  border-color: rgba(122, 162, 247, 0.5);
  box-shadow: 0 0 0 1px rgba(122, 162, 247, 0.25);
  color: var(--text);
}

.realm-level-up .realm-level-up-section-trait .realm-level-up-option.realm-level-up-option-selected {
  filter: none;
  opacity: 1;
  background: rgba(224, 175, 104, 0.2);
  border-color: rgba(224, 175, 104, 0.5);
  box-shadow: 0 0 0 1px rgba(224, 175, 104, 0.25);
  color: var(--text);
}

.realm-level-up .realm-level-up-section-active .realm-level-up-option.realm-level-up-option-selected {
  filter: none;
  opacity: 1;
  background: rgba(158, 206, 106, 0.2);
  border-color: rgba(158, 206, 106, 0.5);
  box-shadow: 0 0 0 1px rgba(158, 206, 106, 0.25);
  color: var(--text);
}

.realm-level-up .realm-level-up-option .realm-level-up-option-name {
  display: block;
  font-weight: 600;
  color: inherit;
  font-size: 0.78rem;
  line-height: 1.25;
}

.realm-level-up .realm-level-up-option .realm-level-up-option-desc {
  display: block;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.08rem;
  line-height: 1.2;
}

.realm-level-up .realm-level-up-option.realm-level-up-option-placeholder {
  min-height: 2.5rem;
  visibility: hidden;
  pointer-events: none;
  padding: 0.35rem 0.5rem;
  margin: 0;
}

.realm-level-up .realm-level-up-option.realm-level-up-option-readonly {
  cursor: default;
}

.realm-level-up .realm-level-up-selections {
  flex-shrink: 0;
  margin-bottom: 0.35rem;
  min-height: 1.2rem;
  max-width: 560px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.realm-level-up .realm-level-up-summary {
  font-size: 0.88rem;
  color: var(--text-dim);
  margin: 0;
  line-height: 1.4;
}

.realm-level-up .realm-level-up-summary.realm-level-up-confirmed {
  color: #9ece6a;
}

.realm-level-up .realm-level-up-actions-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  max-width: 560px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.realm-level-up .realm-level-up-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.realm-level-up .realm-level-up-info-box {
  flex: none;
  width: 25rem;
  height: 5rem;
  min-width: 25rem;
  min-height: 5rem;
  max-width: 25rem;
  max-height: 5rem;
  padding: 0.5rem 0.65rem;
  background: rgba(36, 40, 59, 0.8);
  border: 1px solid rgba(122, 162, 247, 0.25);
  border-radius: 6px;
  font-size: 0.85rem;
  line-height: 1.45;
  overflow: auto;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

.realm-level-up .realm-level-up-info-placeholder {
  color: var(--text-dim);
  margin: 0;
  font-style: italic;
  font-size: 0.85rem;
}

.realm-level-up .realm-level-up-info-content .realm-level-up-info-desc {
  color: var(--text);
  margin: 0 0 0.15rem;
  font-size: 0.85rem;
}

.realm-level-up .realm-level-up-info-content .realm-level-up-info-flavor {
  color: var(--text-dim);
  font-style: italic;
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.35;
}

.realm-level-up .realm-level-up-confirm {
  padding: 0.45rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: linear-gradient(180deg, #9ece6a 0%, #8bc34a 100%);
  color: #1a1b26;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.realm-level-up .realm-level-up-confirm:hover {
  filter: brightness(1.12);
}

.realm-level-up .realm-level-up-reset-build {
  padding: 0.45rem 0.75rem;
  font-size: 0.88rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(122, 162, 247, 0.4);
  border-radius: 6px;
  cursor: pointer;
}

.realm-level-up .realm-level-up-reset-build:hover {
  background: rgba(122, 162, 247, 0.12);
}

.realm-level-up .realm-level-up-reset-build:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.realm-level-up .realm-level-up-reset-build:disabled:hover {
  background: var(--surface);
}

.realm-level-up #realm-level-up-message {
  flex-shrink: 0;
  font-size: 0.88rem;
  margin: 0 auto 0.25rem;
  max-width: 560px;
  width: 100%;
}

.realm-level-up .realm-level-up-footer {
  flex-shrink: 0;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(192, 202, 245, 0.1);
  text-align: left;
}

.realm-level-up .realm-level-up-back {
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0;
  display: inline-block;
}

.realm-level-up .realm-level-up-back:hover {
  color: var(--accent);
}

.realm-level-up .realm-level-up-option.realm-level-up-option-preview {
  cursor: default;
  filter: grayscale(0.6);
  opacity: 0.9;
}

.realm-level-up .realm-level-up-option.realm-level-up-option-preview:hover {
  background: transparent;
  filter: grayscale(0.6);
}

.realm-level-up .realm-level-up-preview-note {
  font-style: italic;
  color: var(--text-dim);
}

@media (max-width: 640px) {
  .realm-level-up .realm-level-up-perks-row {
    grid-template-columns: 1fr;
  }
  .realm-level-up .realm-level-up-lower-row {
    grid-template-columns: 1fr;
  }
}

/* Gambling */
.realm-gambling .gambling-title {
  text-align: center;
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: #e0af68;
}
.realm-gambling .gambling-player-line {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.95rem;
}
.realm-gambling .gambling-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-gambling .gambling-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-gambling .gambling-sep {
  border: none;
  border-top: 1px dashed rgba(224, 175, 104, 0.75);
  margin: 0.5rem 0 0.75rem;
}
.realm-gambling .gambling-menu {
  font-size: 0.95rem;
  line-height: 1.7;
}
.realm-gambling .gambling-menu-choice {
  margin: 0.2rem 0;
  cursor: pointer;
}
.realm-gambling .gambling-menu-choice:hover {
  color: #e0af68;
}
.realm-gambling .gambling-menu-choice-return {
  margin-top: 2em;
}
.realm-gambling .gambling-message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
/* Shop */
.realm-shop .realm-shop-title {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: #9ece6a;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}
.realm-shop .shop-merchant-line {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.realm-shop .shop-merchant-quote,
.realm-shop #shop-category-choices .shop-merchant-quote {
  color: #6eb3f7;
  font-style: italic;
}
.realm-shop #shop-player-gold,
.realm-gambling #gambling-gold {
  color: #e0af68;
}
.realm-shop .realm-shop-stats {
  margin-top: 0.25rem;
}
.realm-shop .shop-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-shop .shop-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-shop .shop-step.hidden {
  display: none;
}
/* Shop fill-height layout: choices at bottom (when shop-active) */
.game-container.realm-active.shop-active .realm-shop #shop-list {
  flex: 1 1 0%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.shop-active .realm-shop .shop-step {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.shop-active .realm-shop .shop-choices {
  margin-top: auto;
  padding-bottom: 0.25rem;
}
.game-container.realm-active.shop-active .realm-shop #shop-step-category .shop-choices,
.game-container.realm-active.shop-active .realm-shop #shop-step-armor .shop-choices,
.game-container.realm-active.shop-active .realm-shop #shop-step-weapons-tier .shop-choices {
  margin-top: 0;
  padding-bottom: 0.5rem;
}
.game-container.realm-active.shop-active .realm-shop .shop-leave-box {
  margin-top: auto;
  flex-shrink: 0;
  align-self: flex-start;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--layout-border, rgba(192, 202, 245, 0.25));
  border-radius: var(--radius, 4px);
  background: var(--surface, rgba(26, 27, 38, 0.6));
}
.realm-shop .shop-leave-box .shop-leave {
  margin: 0;
}
.game-container.realm-active.shop-active .realm-shop #shop-step-items #shop-items-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  align-self: stretch;
}
.game-container.realm-active.shop-active .realm-shop .shop-back-box {
  margin-top: auto;
  flex-shrink: 0;
  align-self: flex-start;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--layout-border, rgba(192, 202, 245, 0.25));
  border-radius: var(--radius, 4px);
  background: var(--surface, rgba(26, 27, 38, 0.6));
}
.realm-shop .shop-back-box .shop-choice-back {
  margin: 0;
}
.realm-shop .shop-choices {
  margin-top: 0.5rem;
}
.realm-shop .shop-choice {
  margin: 0.2rem 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.realm-shop .shop-choice:hover {
  color: var(--accent, #7dcfff);
}
.realm-shop .shop-choice-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.realm-shop .shop-choice-disabled:hover {
  color: inherit;
}
.realm-shop .shop-coming-soon {
  font-size: 0.85em;
  color: var(--text-dim);
  font-style: italic;
}
.realm-shop .shop-choice-back {
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
  color: var(--text-dim);
}
.realm-shop .shop-section-category.hidden {
  display: none;
}
.realm-shop .shop-sections {
  margin-top: 0.5rem;
  display: block;
}
.realm-shop .shop-section {
  margin-bottom: 0.5rem;
  min-width: 0;
  max-width: 100%;
}
.realm-shop .shop-section-title {
  font-weight: bold;
  font-size: 0.95rem;
  margin: 0.25rem 0;
}
.realm-shop #shop-armor-tier-choices {
  margin-top: 0.5rem;
}
.realm-shop #shop-weapons-list,
.realm-shop #shop-armors-list,
.realm-shop #shop-armor-helmet-list,
.realm-shop #shop-armor-legs-list,
.realm-shop #shop-armor-boots-list,
.realm-shop #shop-armor-gloves-list {
  margin: 0;
  min-width: 0;
}
.realm-shop #shop-weapons-list {
  overflow-x: auto;
  max-width: 100%;
}
.realm-shop .shop-weapons-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  table-layout: fixed;
}
.realm-shop .shop-weapons-table thead th {
  text-align: left;
  font-weight: bold;
  color: var(--accent, #7dcfff);
  padding: 0.15rem 0.25rem 0.2rem 0;
}
.realm-shop .shop-weapons-table .shop-weapons-th-name { width: 45%; }
.realm-shop .shop-weapons-table .shop-weapons-th-stats { width: 35%; }
.realm-shop .shop-weapons-table .shop-weapons-th-price { width: 20%; }
.realm-shop .shop-weapons-table tbody td {
  padding: 0.15rem 0.25rem 0.15rem 0;
  vertical-align: top;
  white-space: nowrap;
}
.realm-shop .shop-weapons-table .shop-weapons-td-price {
  text-align: right;
}
.realm-shop .shop-weapons-table .shop-stat-atk {
  color: #7aa2f7;
}
.realm-shop .shop-weapons-table .shop-stat-crit {
  color: #bb9af7;
}
.realm-shop .shop-weapons-table .shop-stat-def {
  color: #f7768e;
}
.realm-shop .shop-weapons-table .shop-price {
  color: #e0af68;
}
.realm-shop .shop-weapons-table tbody tr.shop-item {
  cursor: pointer;
}
.realm-shop .shop-weapons-table tbody tr.shop-item:hover {
  color: var(--accent, #7dcfff);
}
.realm-shop .shop-weapons-table tbody tr.shop-item-locked {
  opacity: 0.5;
  color: var(--text-dim);
  cursor: not-allowed;
}
.realm-shop .shop-weapons-table tbody tr.shop-item-locked:hover {
  color: var(--text-dim);
}
.realm-shop .shop-item {
  margin: 0.15rem 0;
  cursor: pointer;
  font-size: 0.95rem;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.realm-shop .shop-item:hover {
  color: var(--accent, #7dcfff);
}
.realm-shop .shop-item-locked {
  opacity: 0.5;
  color: var(--text-disabled);
  cursor: not-allowed;
}
.realm-shop .shop-item-locked:hover {
  color: var(--text-disabled);
}
.realm-shop .shop-choice.shop-item-locked {
  color: var(--text-disabled);
  opacity: 0.8;
  cursor: not-allowed;
}
.realm-shop .shop-choice.shop-item-locked:hover {
  color: var(--text-disabled);
}
.realm-shop .shop-tier-columns {
  margin: 0.1rem 0 0.2rem 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
}
.realm-shop .shop-tier-header {
  margin: 0.5rem 0 0.2rem 0;
  font-weight: bold;
  font-size: 0.9rem;
  color: var(--accent, #7dcfff);
  cursor: default;
}
.realm-shop .shop-leave {
  grid-column: 1 / -1;
  margin-top: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.realm-shop .shop-leave:hover {
  color: var(--accent, #7dcfff);
}

/* Blacksmith – same look and feel as shop */
.realm-blacksmith .realm-blacksmith-title {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: #e0af68;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}
.realm-blacksmith .blacksmith-line {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
}
.realm-blacksmith .shop-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-blacksmith .shop-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.game-container.realm-active.blacksmith-active .realm-blacksmith #blacksmith-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.realm-blacksmith .shop-choices {
  margin-top: 0.5rem;
}
.realm-blacksmith .shop-choice {
  margin: 0.2rem 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.realm-blacksmith .shop-choice:hover {
  color: var(--accent, #7dcfff);
}
.realm-blacksmith .shop-choice-back {
  margin-top: 0.5rem;
}
.realm-blacksmith .realm-blacksmith-repair-info {
  margin: 0.2rem 0;
  font-size: 0.95rem;
  color: var(--text-muted, rgba(205, 214, 244, 0.7));
}
.realm-blacksmith .shop-leave-box {
  margin-top: auto;
  flex-shrink: 0;
  align-self: flex-start;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--layout-border, rgba(192, 202, 245, 0.25));
  border-radius: var(--radius, 4px);
  background: var(--surface, rgba(26, 27, 38, 0.6));
}
.realm-blacksmith .shop-leave-box .shop-leave {
  margin: 0;
}
.realm-blacksmith .shop-leave {
  margin-top: 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.realm-blacksmith .shop-leave:hover {
  color: var(--accent, #7dcfff);
}
.realm-blacksmith .blacksmith-message {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  min-height: 1.2em;
}
.realm-blacksmith .blacksmith-message.error {
  color: #f7768e;
}
.realm-blacksmith .blacksmith-message.success {
  color: #9ece6a;
}

/* Cauldron – brew phials by the tree */
.realm-cauldron {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.75rem 1rem;
}
.realm-cauldron .realm-cauldron-title {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 0.9rem;
  color: #e0af68;
  margin: 0 0 0.25rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.realm-cauldron .realm-cauldron-intro {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
  flex-shrink: 0;
}
.realm-cauldron .cauldron-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 0.5rem;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 0;
}
.realm-cauldron .cauldron-portrait-wrap-bg {
  width: 100%;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
  aspect-ratio: 5/3;
  background-color: transparent;
  background-image: url('images/cauldron.jpg');
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
.realm-cauldron .cauldron-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
}
.realm-cauldron .realm-cauldron-choice {
  margin: 0 0 0.25rem;
  cursor: pointer;
  color: var(--text);
}
.realm-cauldron .realm-cauldron-choice:hover {
  color: var(--accent, #7dcfff);
}
.realm-cauldron .realm-sep {
  flex-shrink: 0;
}
.realm-cauldron .realm-cauldron-content {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1rem;
  margin-top: 0.35rem;
}
.realm-cauldron .realm-cauldron-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.realm-cauldron .realm-cauldron-column-phials {
  max-width: 52%;
}
.realm-cauldron .realm-cauldron-block-title {
  font-size: 0.85rem;
  color: var(--text);
  margin: 0 0 0.25rem;
  font-weight: 600;
  flex-shrink: 0;
}
.realm-cauldron .realm-cauldron-bottles {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.realm-cauldron .realm-cauldron-ingredients-list {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.realm-cauldron .realm-cauldron-ingredient-row {
  display: flex;
  align-items: baseline;
  font-size: 0.8rem;
  margin: 0.25rem 0;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(192, 202, 245, 0.08);
  color: var(--text-dim);
}
.realm-cauldron .realm-cauldron-ingredient-name {
  flex: 0 0 calc(11em + 5ch);
  min-width: 0;
  cursor: help;
}
/* Ensure ingredient colors show (override any inherit) */
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-moonwell_water { color: #7dcfff; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-raw_moonwell_water { color: var(--text-dim); }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-sun_herb { color: #9ece6a; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-moonpetal { color: #bb9af7; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-iron_dust { color: #a9b1d6; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-crystal_shard { color: #73daca; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-blood_moss { color: #f7768e; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-honey { color: #e0af68; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-spirit_essence { color: #c0caf5; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-shadow_silk { color: #565f89; }
.realm-cauldron .realm-cauldron-ingredient-name.ingredient-color-venom_sac { color: #ff9e64; }
.realm-cauldron .realm-cauldron-ingredient-have {
  flex-shrink: 0;
  margin-right: 0.25rem;
  color: var(--text-dim);
}
.realm-cauldron .realm-cauldron-ingredient-count {
  flex-shrink: 0;
  min-width: 2ch;
  text-align: right;
  color: var(--text);
}
.realm-cauldron .realm-cauldron-ingredient-base {
  flex-direction: column;
  align-items: stretch;
}
.realm-cauldron .realm-cauldron-ingredient-base-line {
  display: flex;
  align-items: baseline;
}
.realm-cauldron .realm-cauldron-ingredient-sub-row {
  display: flex;
  align-items: baseline;
  margin-top: 0.15rem;
  padding-left: 0.5rem;
}
.realm-cauldron .realm-cauldron-ingredient-base .realm-cauldron-ingredient-base-line .realm-cauldron-ingredient-name {
  font-weight: 600;
}
.realm-cauldron .realm-cauldron-ingredient-base .realm-cauldron-ingredient-base-line .realm-cauldron-ingredient-have,
.realm-cauldron .realm-cauldron-ingredient-base .realm-cauldron-ingredient-base-line .realm-cauldron-ingredient-count {
  color: var(--text-dim);
  font-weight: 400;
}
.realm-cauldron .realm-cauldron-ingredient-base .realm-cauldron-ingredient-have,
.realm-cauldron .realm-cauldron-ingredient-base .realm-cauldron-ingredient-count {
  color: var(--text-dim);
  font-weight: 400;
}
.realm-cauldron .realm-cauldron-bottle {
  margin: 0.35rem 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--layout-border, rgba(192, 202, 245, 0.2));
  border-radius: var(--radius, 4px);
  background: var(--surface, rgba(26, 27, 38, 0.4));
  cursor: pointer;
}
.realm-cauldron .realm-cauldron-bottle:hover {
  border-color: rgba(224, 175, 104, 0.5);
  background: rgba(26, 27, 38, 0.65);
}
.realm-cauldron .realm-cauldron-bottle-name {
  margin: 0 0 0.15rem;
  font-size: 0.9rem;
  color: #e0af68;
}
.realm-cauldron .realm-cauldron-bottle-needs {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.realm-cauldron .realm-cauldron-mats {
  font-style: italic;
  color: var(--text-dim);
}
.realm-cauldron .realm-cauldron-footer {
  flex-shrink: 0;
  margin-top: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
/* By the tree nav in Cauldron/Level-up uses same styles as inventory – see .realm-inventory .realm-inventory-menu below */
.realm-cauldron .cauldron-message {
  font-size: 0.85rem;
  min-height: 1.2em;
  color: var(--text-dim);
}
.realm-cauldron .cauldron-message.error {
  color: #f7768e;
}
.realm-cauldron .cauldron-message.success {
  color: #9ece6a;
}

/* Custom ingredient tooltip (short delay, no browser default) */
.cauldron-tooltip {
  position: fixed;
  z-index: 10000;
  max-width: 280px;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  line-height: 1.35;
  color: var(--text, #c0caf5);
  background: var(--surface, rgba(26, 27, 38, 0.98));
  border: 1px solid rgba(192, 202, 245, 0.25);
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}
.cauldron-tooltip.hidden {
  display: none !important;
}
.cauldron-tooltip .cauldron-tooltip-source {
  color: var(--text-dim);
  font-style: italic;
}

/* Ingredient colors – use .ingredient-color-{id} game-wide whenever an ingredient name is shown */
.ingredient-color-moonwell_water { color: #7dcfff; }
.ingredient-color-raw_moonwell_water { color: var(--text-dim); }
.ingredient-color-sun_herb { color: #9ece6a; }
.ingredient-color-moonpetal { color: #bb9af7; }
.ingredient-color-iron_dust { color: #a9b1d6; }
.ingredient-color-crystal_shard { color: #73daca; }
.ingredient-color-blood_moss { color: #f7768e; }
.ingredient-color-honey { color: #e0af68; }
.ingredient-color-spirit_essence { color: #c0caf5; }
.ingredient-color-shadow_silk { color: #565f89; }
.ingredient-color-venom_sac { color: #ff9e64; }

/* Inventory – character sheet styling */
.realm-inventory {
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, rgba(26, 27, 38, 0.97) 0%, var(--bg) 100%);
}
.realm-inventory .realm-inventory-inner {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  max-width: 52rem;
  margin: 0 auto;
  width: 100%;
}
.realm-inventory .realm-inventory-title {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 1.8rem;
  color: #f7768e;
  margin: 0 0 1rem;
  letter-spacing: 0.15em;
  text-shadow: 0 0 20px rgba(247, 118, 142, 0.25);
}
.realm-inventory .realm-inventory-title::after {
  content: '';
  display: block;
  width: 4rem;
  height: 2px;
  margin: 0.5rem auto 0;
  background: linear-gradient(90deg, transparent, rgba(247, 118, 142, 0.5), transparent);
  border-radius: 1px;
}
.realm-inventory .realm-inventory-header {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  margin-bottom: 1rem;
  min-height: 9rem;
  width: 100%;
  padding: 0.6rem 0.9rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.realm-inventory .realm-inventory-header-left {
  flex: 0 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  padding-right: 0;
}
.realm-inventory .realm-inventory-identity {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}
.realm-inventory .realm-inventory-identity .realm-inventory-title-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}
.realm-inventory .realm-inventory-identity .realm-inventory-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.realm-inventory .realm-inventory-meta-block {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem 0.7rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 6px;
  border-left: 3px solid rgba(224, 175, 104, 0.55);
  width: fit-content;
}
.realm-inventory .realm-inventory-meta-row {
  margin: 0;
  font-size: 0.9rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.realm-inventory .realm-inventory-meta-row .realm-inventory-meta-label {
  flex: 0 0 auto;
  color: var(--text-dim);
  font-weight: 600;
  min-width: 2.5em;
}
.realm-inventory .realm-inventory-meta-row .realm-inventory-value.realm-gold {
  color: #e0af68;
  font-weight: 600;
}
.realm-inventory .realm-inventory-exp-sep {
  opacity: 0.7;
  margin: 0 0.1rem;
}
.realm-inventory .realm-inventory-header .realm-inventory-portrait-wrap {
  flex: 1 1 auto;
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  padding-left: 0;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
  max-width: 72%;
}
.realm-inventory .realm-inventory-header .realm-inventory-portrait {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  flex-shrink: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.realm-inventory .realm-inventory-main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.realm-inventory .realm-inventory-bottom-row {
  display: flex;
  gap: 0;
  align-items: stretch;
  margin: 0.5rem 0;
  max-width: 100%;
  min-width: 0;
  flex: 1;
  min-height: 0;
}
.realm-inventory .realm-inventory-left-column {
  flex: 0 0 33%;
  min-width: 0;
  max-width: 33%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding-right: 1rem;
}
.realm-inventory .realm-inventory-bottom-sep {
  width: 1px;
  min-width: 1px;
  background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.1), transparent);
  flex-shrink: 0;
  align-self: stretch;
}
.realm-inventory .realm-inventory-stats-wrap {
  flex: 0 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.realm-inventory .realm-inventory-stats-wrap .realm-inventory-block-title {
  margin-bottom: 0.15rem;
}
.realm-inventory .realm-inventory-block-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  opacity: 0.95;
}
.realm-inventory .realm-inventory-stats {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(158, 206, 106, 0.5);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.realm-inventory .realm-inventory-stat {
  margin: 0.28rem 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.9rem;
  gap: 0.75rem;
}
.realm-inventory .realm-inventory-stat-main .realm-inventory-label {
  font-weight: bold;
}
.realm-inventory .realm-inventory-defense-sublist {
  margin-left: 1rem;
  margin-top: 0.2rem;
  margin-bottom: 0.2rem;
  padding-left: 0.25rem;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
}
.realm-inventory .realm-inventory-stat-sub {
  margin: 0.12rem 0;
  font-size: 0.88em;
}
.realm-inventory .realm-inventory-stored-wrap {
  flex: 0 0 auto;
  min-width: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.realm-inventory .realm-inventory-stored-wrap .realm-inventory-block-title {
  margin-bottom: 0.15rem;
}
.realm-inventory .realm-inventory-stored-list {
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  max-height: 6em;
  overflow-y: auto;
}
.realm-inventory .realm-inventory-stored-list .realm-inventory-stat {
  margin: 0.15rem 0;
  font-size: 0.9em;
}
.realm-inventory .realm-inventory-stored-empty {
  color: rgba(255, 255, 255, 0.5);
  font-style: italic;
}
.realm-inventory .realm-inventory-stored-hint {
  font-size: 0.75em;
  color: rgba(255, 255, 255, 0.45);
  margin: 0;
}

.realm-inventory .realm-inventory-equipment-wrap {
  flex: 1;
  min-width: 0;
  padding-left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.realm-inventory .realm-inventory-equipment-wrap .realm-inventory-block-title {
  margin-bottom: 0.15rem;
}
.realm-inventory .realm-inventory-equipment {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(122, 162, 247, 0.4);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.realm-inventory .realm-inventory-equipment-sep {
  height: 1px;
  margin: 0.5rem 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
  border: none;
}
.realm-inventory .realm-inventory-stat-right {
  justify-content: flex-end;
}
.realm-inventory .realm-inventory-label {
  color: var(--text);
  font-weight: 500;
}
.realm-inventory .realm-inventory-value {
  color: var(--text);
}
.realm-inventory .realm-inventory-value.realm-hp { color: #9ece6a; }
.realm-inventory .realm-inventory-value.realm-stamina { color: #9ece6a; }
.realm-inventory .realm-inventory-value.realm-gold { color: #e0af68; }
.realm-inventory .realm-inventory-value.realm-attack { color: #7aa2f7; }
.realm-inventory .realm-inventory-value.realm-defense { color: #f7768e; }

/* Durability on equipment (By the tree): default, yellow ≤50%, red ≤25% */
.realm-inventory .realm-inventory-durability {
  color: var(--text);
}
.realm-inventory .realm-inventory-durability.realm-inventory-durability-low {
  color: #e0af68;
}
.realm-inventory .realm-inventory-durability.realm-inventory-durability-critical {
  color: #f7768e;
}

.realm-inventory .realm-inventory-reduced {
  color: #e0af68;
  font-style: italic;
}

/* Kills subpage */
.realm-inventory .realm-inventory-kills-subpage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0.5rem 0;
}
.realm-inventory .realm-inventory-kills-subpage.hidden {
  display: none;
}
.realm-inventory .realm-inventory-kills-subpage-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.realm-inventory .realm-inventory-kills-subpage-content .realm-inventory-block-title {
  margin-bottom: 0.15rem;
}
.realm-inventory .realm-inventory-kills-subpage-content .realm-inventory-kills-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(247, 118, 142, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.realm-inventory .realm-inventory-items-subpage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0.5rem 0;
}
.realm-inventory .realm-inventory-items-subpage.hidden {
  display: none;
}
.realm-inventory .realm-inventory-items-subpage-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.realm-inventory .realm-inventory-items-subpage-content .realm-inventory-block-title {
  margin-bottom: 0.15rem;
}
.realm-inventory .realm-inventory-items-subpage-content .realm-inventory-meta-row {
  margin: 0.2rem 0;
}
.realm-inventory .realm-inventory-items-subpage-content .realm-inventory-items-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.28);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(224, 175, 104, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.realm-inventory .realm-inventory-items-subpage-content .realm-inventory-stored-hint {
  margin-top: 0.25rem;
}

.realm-inventory .realm-inventory-kill-header {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
  margin: 0.4rem 0 0.15rem;
}
.realm-inventory .realm-inventory-kill-row {
  font-size: 0.85rem;
  margin: 0.15em 0;
  line-height: 1.35;
  padding: 0;
}
.realm-inventory .realm-inventory-kill-row .realm-inventory-label {
  color: var(--text);
}
.realm-inventory .realm-inventory-kill-stars {
  color: #e0af68;
  font-size: 0.9em;
  letter-spacing: 0.02em;
}

/* Inventory menu – pill buttons (legacy; By the tree nav is now in static footer #by-the-tree-footer) */
.realm-inventory .realm-inventory-menu {
  margin: 0;
  padding-top: 1rem;
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}
.realm-inventory .realm-inventory-choice,
.realm-inventory .realm-inventory-return {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.realm-inventory .realm-inventory-choice:hover,
.realm-inventory .realm-inventory-return:hover {
  color: var(--accent, #7dcfff);
  border-color: rgba(122, 162, 247, 0.4);
  background: rgba(122, 162, 247, 0.08);
}
.realm-inventory .realm-inventory-return {
  margin-left: 0;
}

/* Legacy / unused inventory rules kept for compatibility */
.realm-inventory .realm-inventory-kills-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding-left: 0;
  padding-right: 0;
  min-height: 0;
}
.realm-inventory .realm-inventory-kills-wrap .realm-inventory-kills {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.realm-inventory .realm-inventory-kills-wrap .realm-inventory-kills .realm-inventory-block-title { margin: 0; }
.realm-inventory .realm-inventory-kills { margin-top: 0.75rem; padding-top: 0.5rem; border-top: 1px solid rgba(255, 255, 255, 0.12); }
.realm-inventory .realm-inventory-kills-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  margin-top: 0;
}
.realm-inventory .realm-inventory-gold-box {
  padding: 0.35rem 0.6rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  font-size: 0.9rem;
  align-self: flex-start;
}
.realm-inventory .realm-inventory-gold-box .realm-inventory-value.realm-gold { font-weight: 600; }

.realm-inventory .form-actions {
  margin-top: 0.75rem;
}
.shop-message {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
.shop-message.error {
  color: #f7768e;
}
.shop-message.success {
  color: #9ece6a;
}
.shop-empty {
  margin: 0.2rem 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Dice table – uusi banneri ja 2D-nopat */
.realm-dice .dice-title-frame {
  text-align: center;
  margin-bottom: 0.75rem;
}
.realm-dice .dice-banner-line {
  color: #e0af68;
  font-size: 0.85rem;
  font-family: ui-monospace, monospace;
  letter-spacing: 0.05em;
}
.realm-dice .dice-banner-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
  margin: 0.2rem 0;
  letter-spacing: 0.08em;
}
.realm-dice .dice-banner-bottom {
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}
.realm-dice .dice-table {
  margin: 0.5rem 0;
  padding: 1rem 0.75rem;
  border: 3px solid rgba(160, 160, 175, 0.6);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  height: 11rem;
  min-height: 11rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.realm-dice .dice-roll-area {
  text-align: center;
  transform-origin: center center;
  transition: none;
}
/* 3D dice */
.realm-dice .dice-3d-wrap {
  display: flex;
  gap: 28px;
  align-items: center;
  justify-content: center;
  perspective: 600px;
}
.realm-dice .die-scene {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  position: relative;
  transform: rotateX(-20deg);
  transform-style: preserve-3d;
}
.realm-dice .die-scene::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 10px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.45) 0%, transparent 70%);
  border-radius: 50%;
}
.realm-dice .die {
  width: 72px;
  height: 72px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(0deg) rotateY(0deg);
}
.realm-dice .die-face {
  position: absolute;
  width: 72px;
  height: 72px;
  background: linear-gradient(145deg, #faf6ee 0%, #ede8dc 100%);
  border: 1.5px solid #c0a880;
  border-radius: 12px;
  box-shadow:
    inset 0 1px 3px rgba(255,255,255,0.8),
    inset 0 -2px 4px rgba(0,0,0,0.12);
  backface-visibility: hidden;
  box-sizing: border-box;
}
.realm-dice .face-front  { transform: translateZ(36px); }
.realm-dice .face-back   { transform: rotateY(180deg) translateZ(36px); }
.realm-dice .face-right  { transform: rotateY(90deg) translateZ(36px); }
.realm-dice .face-left   { transform: rotateY(-90deg) translateZ(36px); }
.realm-dice .face-top    { transform: rotateX(90deg) translateZ(36px); }
.realm-dice .face-bottom { transform: rotateX(-90deg) translateZ(36px); }
.realm-dice .die-pips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  width: 100%;
  height: 100%;
  padding: 9px;
  box-sizing: border-box;
}
.realm-dice .die-pips span {
  display: block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin: auto;
  background: transparent;
  box-shadow: none;
}
/* pip patterns — 3×3 grid, positions 1-9 left-to-right, top-to-bottom */
.realm-dice .pips-1 span:nth-child(5) { background: #2c1a0a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.realm-dice .pips-2 span:nth-child(3),
.realm-dice .pips-2 span:nth-child(7) { background: #2c1a0a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.realm-dice .pips-3 span:nth-child(3),
.realm-dice .pips-3 span:nth-child(5),
.realm-dice .pips-3 span:nth-child(7) { background: #2c1a0a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.realm-dice .pips-4 span:nth-child(1),
.realm-dice .pips-4 span:nth-child(3),
.realm-dice .pips-4 span:nth-child(7),
.realm-dice .pips-4 span:nth-child(9) { background: #2c1a0a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.realm-dice .pips-5 span:nth-child(1),
.realm-dice .pips-5 span:nth-child(3),
.realm-dice .pips-5 span:nth-child(5),
.realm-dice .pips-5 span:nth-child(7),
.realm-dice .pips-5 span:nth-child(9) { background: #2c1a0a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
.realm-dice .pips-6 span:nth-child(1),
.realm-dice .pips-6 span:nth-child(3),
.realm-dice .pips-6 span:nth-child(4),
.realm-dice .pips-6 span:nth-child(6),
.realm-dice .pips-6 span:nth-child(7),
.realm-dice .pips-6 span:nth-child(9) { background: #2c1a0a; box-shadow: inset 0 1px 2px rgba(0,0,0,0.4); }
@keyframes die-tumble {
  0%   { transform: rotateX(0deg)   rotateY(0deg)   rotateZ(0deg); }
  20%  { transform: rotateX(144deg) rotateY(72deg)  rotateZ(36deg); }
  40%  { transform: rotateX(72deg)  rotateY(216deg) rotateZ(108deg); }
  60%  { transform: rotateX(216deg) rotateY(144deg) rotateZ(180deg); }
  80%  { transform: rotateX(288deg) rotateY(288deg) rotateZ(252deg); }
  100% { transform: rotateX(360deg) rotateY(360deg) rotateZ(360deg); }
}
.realm-dice .die.die-rolling {
  animation: die-tumble 0.5s linear infinite;
  transition: none !important;
}
.realm-dice .dice-player {
  margin: 0.25rem 0;
  font-size: 0.95rem;
  font-weight: bold;
}
.realm-dice .dice-player #dice-player-gold { color: #e0af68; }
.realm-dice .dice-rules-title {
  font-weight: bold;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.95rem;
}
.realm-dice .dice-rule { margin: 0.2rem 0; font-size: 0.95rem; }
.realm-dice .dice-win { color: #9ece6a; }
.realm-dice .dice-jackpot { color: #9ece6a; font-weight: bold; }
.realm-dice .dice-bet-line {
  margin-top: 0.75rem;
  font-size: 1rem;
  min-height: 1.4em;
}
.realm-dice .dice-prompt { color: var(--text); }
.realm-dice .dice-bet-input { color: var(--text); }
.realm-dice .dice-cursor {
  color: var(--text);
  animation: dice-blink 1s step-end infinite;
}
@keyframes dice-blink {
  50% { opacity: 0; }
}
.realm-dice .dice-message {
  margin-top: 0.5rem;
  font-size: 0.95rem;
}
.realm-dice .dice-message.error { color: #f7768e; }
.realm-dice .dice-message.success { color: #9ece6a; }
.realm-dice .dice-result { margin-top: 0.75rem; }
.realm-dice .dice-result-line { margin: 0.25rem 0; }
.realm-dice .dice-result-line .dice-win { color: #9ece6a; }
.realm-dice .dice-result-line .dice-jackpot-result { color: #9ece6a; }
.realm-dice .dice-result-line .dice-jackpot-bold { font-weight: bold; color: #9ece6a; }
.realm-dice .dice-result-line .dice-lost { color: #f7768e; }
.realm-dice .dice-again { margin-top: 0.5rem; font-size: 0.95rem; color: var(--text-dim); }

/* Blackjack */
.realm-blackjack .bj-banner {
  text-align: center;
  font-size: 0.9rem;
  font-weight: bold;
  color: #9ece6a;
  margin-bottom: 0.75rem;
  letter-spacing: 0.04em;
}
.realm-blackjack .bj-table {
  margin: 0.5rem 0;
  padding: 1rem 0.75rem;
  border: 3px solid rgba(160, 160, 175, 0.6);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.realm-blackjack .bj-cards-wrap {
  text-align: center;
  min-height: 11rem;
}
.realm-blackjack .bj-table-divider {
  height: 2px;
  margin: 0.6rem 0.5rem;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 15%, rgba(255, 255, 255, 0.5) 50%, rgba(255, 255, 255, 0.4) 85%, transparent 100%);
  border-radius: 1px;
}
.realm-blackjack .bj-cards-row {
  margin-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 82px;
}
.realm-blackjack .bj-card {
  display: inline-block;
}
.realm-blackjack .bj-card .playing-card {
  animation: bj-card-bounce 0.4s ease-out;
}
@keyframes bj-card-bounce {
  0% { transform: scale(0.9); opacity: 0.5; }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}
.realm-blackjack .bj-card-flip-reveal {
  animation: bj-card-flip-reveal 0.6s ease-in-out forwards;
}
@keyframes bj-card-flip-reveal {
  0% { transform: scaleX(1); }
  45% { transform: scaleX(0.02); }
  55% { transform: scaleX(0.02); }
  100% { transform: scaleX(1); }
}
.realm-blackjack .bj-line { height: 2px; margin: 0.5rem 0; }
.realm-blackjack .bj-line-green { background: #9ece6a; }
.realm-blackjack .bj-player { font-weight: bold; margin: 0.25rem 0; font-size: 0.95rem; }
.realm-blackjack .bj-player #bj-player-gold { color: #e0af68; }
.realm-blackjack .bj-player #bj-player-gold.bj-gold-update {
  animation: bj-gold-update 0.7s ease-out;
}
.realm-blackjack .bj-player #bj-player-gold.bj-gold-update-win {
  animation: bj-gold-update-win 0.7s ease-out;
}
.realm-blackjack .bj-player #bj-player-gold.bj-gold-update-lose {
  animation: bj-gold-update-lose 0.7s ease-out;
}
@keyframes bj-gold-update {
  0% { color: #e0af68; transform: scale(1.15); }
  100% { color: #e0af68; transform: scale(1); }
}
@keyframes bj-gold-update-win {
  0% { color: #fff; transform: scale(1.15); }
  40% { color: #fff; }
  100% { color: #e0af68; transform: scale(1); }
}
@keyframes bj-gold-update-lose {
  0% { color: #f7768e; transform: scale(1.15); }
  40% { color: #f7768e; }
  100% { color: #e0af68; transform: scale(1); }
}
.realm-blackjack .bj-bet-block { margin-top: 0.75rem; }
.realm-blackjack .bj-option { margin: 0.25rem 0; }
.realm-blackjack .bj-prompt { margin: 0.35rem 0; }
.realm-blackjack .bj-bet-input { color: var(--text); }
.realm-blackjack .bj-game-block .bj-dealer-line { color: #7dcfff; margin: 0.25rem 0; }
.realm-blackjack .bj-game-block .bj-your-line { font-weight: bold; margin: 0.25rem 0; }
.realm-blackjack .bj-action-prompt { margin-top: 0.5rem; }
.realm-blackjack .bj-result-block { margin-top: 0.75rem; }
.realm-blackjack .bj-result-text { margin: 0.25rem 0; }
.realm-blackjack .bj-result-text.bj-win { color: #9ece6a; }
.realm-blackjack .bj-result-text.bj-lose { color: #f7768e; }
.realm-blackjack .bj-result-text.bj-push { color: #e0af68; }
.realm-blackjack .bj-again { margin-top: 0.5rem; font-size: 0.95rem; color: var(--text-dim); }
.realm-blackjack .dice-cursor { animation: dice-blink 1s step-end infinite; }

/* Texas Hold'em */
.realm-poker {
  position: relative;
  min-height: 100%;
}
.realm-poker .poker-table-wrap {
  margin: 0.25rem 0 0;
  padding: 0.75rem 1rem 1rem;
  border: 1px dashed rgba(224, 175, 104, 0.5);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.2);
  min-width: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.realm-poker .poker-community-wrap {
  text-align: center;
  margin-bottom: 0.75rem;
}
.realm-poker .poker-street {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0 0 0.25rem;
}
.realm-poker .poker-community {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin: 0.25rem 0;
}
.realm-poker .poker-card {
  display: inline-block;
  padding: 0.2rem 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  font-size: 0.9rem;
  font-family: monospace;
}
.realm-poker .poker-pot {
  margin: 0.25rem 0;
  font-weight: bold;
}
.realm-poker .poker-pot .realm-gold { color: #e0af68; }
.realm-poker .poker-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
  min-height: 2rem;
}
.realm-poker .poker-players-empty { color: var(--text-dim); font-style: italic; margin: 0.5rem 0; }
.realm-poker .poker-player {
  padding: 0.35rem 0.6rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}
.realm-poker .poker-player-active {
  border-color: #9ece6a;
  box-shadow: 0 0 8px rgba(158, 206, 106, 0.3);
}
.realm-poker .poker-player-me { color: #7dcfff; }
.realm-poker .poker-player-folded { opacity: 0.6; color: var(--text-dim); }
.realm-poker .poker-player-name { display: block; font-weight: bold; }
.realm-poker .poker-player-stack { display: block; }
.realm-poker .poker-player-bet { display: block; font-size: 0.85rem; color: var(--text-dim); }
.realm-poker .poker-player-cards { display: block; font-family: monospace; font-size: 0.85rem; margin-top: 0.2rem; }
.realm-poker .poker-log-and-board {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0.5rem 0;
  min-width: 0;
}
.realm-poker .poker-log-wrap {
  width: 28.8%;
  min-width: 16.2rem;
  min-height: 12.6rem;
  max-height: 100%;
  overflow: hidden;
  padding: 0.5rem 0.6rem;
  border: 1px solid rgba(224, 175, 104, 0.4);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 2px 8px rgba(0, 0, 0, 0.3);
}
.realm-poker .poker-dealer-board {
  width: 375px;
  min-width: 375px;
  height: 128px;
  min-height: 128px;
  max-height: 128px;
  padding: 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  box-sizing: border-box;
}
.realm-poker .poker-dealer-board .poker-dealer-cards-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 0.2rem;
  flex: 1;
  min-height: 0;
  align-items: center;
}
.realm-poker .poker-dealer-board .bj-card-ascii {
  font-size: 0.6rem;
  line-height: 1.15;
}
.realm-poker .poker-dealer-board .bj-card {
  padding: 0.15rem;
}
.realm-poker .poker-dealer-pot {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.realm-poker .poker-dealer-pot .realm-gold { color: #e0af68; }
.realm-poker .poker-log-title { font-size: 0.8rem; color: var(--text-dim); margin: 0 0 0.25rem; }
.realm-poker .poker-log {
  min-height: 11.25rem;
  overflow-y: auto;
  overflow-x: hidden;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.realm-poker .poker-log-line {
  margin: 0.15rem 0;
  word-break: break-word;
  flex-shrink: 0;
}
.realm-poker .poker-log-separator {
  height: 0;
  border: none;
  border-top: 1px solid rgba(224, 175, 104, 0.35);
  margin: 0.4rem 0;
}
.realm-poker .poker-turn-timer-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.35rem 0 0.25rem;
  font-size: 0.9rem;
}
.realm-poker .poker-turn-timer-label {
  color: var(--text-dim);
}
.realm-poker .poker-turn-timer {
  font-weight: bold;
  color: #9ece6a;
  min-width: 1.8em;
  text-align: center;
}
.realm-poker .poker-turn-timer-unit {
  color: var(--text-dim);
  font-size: 0.85em;
}
.realm-poker .poker-player-slot-wrap .poker-slot-turn-indicator {
  font-size: 0.95rem;
  font-weight: bold;
  margin-bottom: 0.35rem;
  min-height: 1.35em;
  color: var(--text);
  text-align: center;
}
.realm-poker .poker-player-slot-wrap .poker-slot-turn-indicator.poker-slot-turn-indicator-empty {
  visibility: hidden;
  margin-bottom: 0.35rem;
  min-height: 1.35em;
}
.realm-poker .poker-player-slot-wrap .poker-slot-turn-indicator.poker-turn-thinking {
  color: var(--text-dim);
}
.realm-poker .poker-player-slot-wrap .poker-slot-turn-indicator .poker-thinking-char {
  display: inline-block;
  min-width: 1ch;
  font-family: monospace;
  text-align: center;
}
.realm-poker .poker-players {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
  margin-top: 0.5rem;
  min-width: 0;
}
.realm-poker .poker-player-slot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  min-height: 0;
}
.realm-poker .poker-player-slot-wrap .poker-player-slot-footer {
  margin-top: 0.25rem;
  width: 100%;
}
.realm-poker .poker-player-slot {
  width: 160px;
  min-width: 160px;
  max-width: 160px;
  height: 128px;
  min-height: 128px;
  max-height: 128px;
  padding: 0.4rem 0.35rem;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}
.realm-poker .poker-player-slot .poker-player-cards-row {
  margin-top: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  flex: 1;
  min-height: 0;
  align-items: center;
}
.realm-poker .poker-player-slot-footer {
  margin-top: 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.05rem;
  font-size: 0.8rem;
}
.realm-poker .poker-player-slot-footer .poker-player-name { font-weight: bold; }
.realm-poker .poker-player-slot-footer .poker-player-chips {
  color: var(--realm-gold, #e0af68);
  font-weight: 600;
  margin-right: 0.35em;
}
.realm-poker .poker-player-slot-footer .poker-player-bet { font-size: 0.75rem; color: var(--text-dim); }
.realm-poker .poker-player-slot.poker-player-slot-in-hand {
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}
.realm-poker .poker-player-slot.poker-player-slot-in-hand .poker-player-cards-row {
  flex: 1;
  margin-top: 0;
}
.realm-poker .poker-player-empty-slot {
  color: var(--text-dim);
  font-style: italic;
}
.realm-poker .poker-player-empty-inner,
.realm-poker .poker-player-slot-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}
.realm-poker .poker-add-ai-btn {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
}
.realm-poker .poker-remove-ai-btn {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
}
.realm-poker .poker-start-btn {
  font-size: 0.75rem;
  padding: 0.2rem 0.7rem;
}
.realm-poker .poker-waiting-others {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-style: italic;
}
.realm-poker .poker-start-btn-alone,
.realm-poker .poker-start-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  background: var(--bg-dim, rgba(255, 255, 255, 0.1));
  color: var(--text-dim);
}
.realm-poker .poker-player {
  border-color: rgba(224, 175, 104, 0.7);
}
.realm-poker .poker-player-active {
  box-shadow: 0 0 8px rgba(158, 206, 106, 0.55);
}
.realm-poker .poker-player-folded {
  opacity: 0.6;
}
.realm-poker .poker-player-me .poker-player-name {
  color: #7aa2f7;
}
.realm-poker .poker-player-name {
  display: block;
  font-weight: bold;
}
.realm-poker .poker-player-stack {
  display: inline-block;
  margin-top: 0.15rem;
}
.realm-poker .poker-player-bet {
  display: inline-block;
  margin-left: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}
.realm-poker .poker-player-cards-row {
  margin-top: 0.3rem;
  display: flex;
  gap: 0.3rem;
}
.realm-poker .bj-card {
  display: inline-block;
  padding: 0.2rem;
  border: 1px dashed rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
}
.realm-poker .bj-card-ascii {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--text);
  white-space: pre;
  font-family: ui-monospace, monospace;
}
.realm-poker .bj-card-face-down .bj-card-ascii {
  color: rgba(255, 255, 255, 0.6);
  filter: contrast(0.7);
}
.realm-poker .card-container {
  display: flex;
  flex-direction: row;
  gap: 10px;
  flex-wrap: wrap;
}
.realm-poker .playing-card,
.realm-blackjack .playing-card {
  width: 56px;
  height: 82px;
  background: #faf6f0;
  border: 1px solid #b8a898;
  border-radius: 6px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.7);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  user-select: none;
  box-sizing: border-box;
}
.realm-poker .pc-corner,
.realm-blackjack .pc-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.realm-poker .pc-tl, .realm-blackjack .pc-tl { top: 4px; left: 5px; }
.realm-poker .pc-br, .realm-blackjack .pc-br { bottom: 4px; right: 5px; transform: rotate(180deg); }
.realm-poker .pc-rank,
.realm-blackjack .pc-rank {
  font-size: 0.8rem;
  font-weight: bold;
  font-family: Georgia, 'Times New Roman', serif;
  line-height: 1;
  display: block;
}
.realm-poker .pc-suit-sm,
.realm-blackjack .pc-suit-sm {
  font-size: 0.55rem;
  line-height: 1;
  display: block;
  margin-top: 1px;
}
.realm-poker .pc-center,
.realm-blackjack .pc-center {
  font-size: 1.65rem;
  line-height: 1;
}
.realm-poker .suit-h, .realm-blackjack .suit-h { color: #cc1a00; }
.realm-poker .suit-d, .realm-blackjack .suit-d { color: #cc1a00; }
.realm-poker .suit-s, .realm-blackjack .suit-s { color: #1a1a22; }
.realm-poker .suit-c, .realm-blackjack .suit-c { color: #1a1a22; }
.realm-poker .card-face-down,
.realm-blackjack .card-face-down {
  background: #1e3058;
  border-color: #2a3d6a;
}
.realm-poker .pc-back-inner,
.realm-blackjack .pc-back-inner {
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  border-radius: 3px;
  background: repeating-linear-gradient(
    45deg,
    #243a6a 0px,
    #243a6a 4px,
    #1a2f58 4px,
    #1a2f58 8px
  );
  border: 1px solid #2e4880;
}
@keyframes poker-deal-flip {
  0% {
    opacity: 0;
    transform: perspective(400px) rotateY(90deg) scale(0.8);
  }
  100% {
    opacity: 1;
    transform: perspective(400px) rotateY(0deg) scale(1);
  }
}
.realm-poker .animate-flip {
  animation: poker-deal-flip 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  opacity: 0;
}
.realm-poker .poker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0 0;
}
.realm-poker .poker-actions .poker-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.realm-poker .poker-message { margin-top: 0.5rem; font-size: 0.9rem; }
.realm-poker .poker-message.error { color: #f7768e; }
.realm-poker #poker-gold,
.realm-poker #poker-stack { color: #e0af68; }
.realm-poker .poker-lobby {
  margin: 0.5rem 0;
  padding: 0.75rem;
  border: 1px dashed rgba(224, 175, 104, 0.4);
  border-radius: 4px;
}
.realm-poker .poker-lobby-title { font-weight: bold; margin: 0 0 0.5rem; }
.realm-poker .poker-tables-list { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 0.5rem 0; }
.realm-poker .poker-table-card {
  padding: 0.6rem 0.9rem;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  min-width: 10rem;
}
.realm-poker .poker-table-card .poker-table-name { font-weight: bold; margin-bottom: 0.25rem; }
.realm-poker .poker-table-card .poker-table-status { font-size: 0.9rem; color: var(--text-dim); margin: 0.2rem 0; }
.realm-poker .poker-table-card .poker-table-players { margin: 0.25rem 0; }
.realm-poker .poker-table-card.poker-table-empty .poker-table-status { color: var(--text-dim); }
.realm-poker .poker-table-card.poker-table-waiting .poker-table-status { color: #e0af68; }
.realm-poker .poker-table-card.poker-table-in-progress .poker-table-status { color: #9ece6a; }
.realm-poker .poker-lobby-hint { font-size: 0.85rem; color: var(--text-dim); margin-top: 0.5rem; }
.realm-poker .poker-lobby {
  display: flex;
  flex-direction: column;
}
.realm-poker .poker-lobby-leave-box {
  margin-top: auto;
  flex-shrink: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--layout-border, rgba(192, 202, 245, 0.25));
  border-radius: 4px;
  align-self: flex-start;
}
.realm-poker .poker-lobby-leave-box .poker-lobby-exit {
  margin: 0;
  cursor: pointer;
}
.realm-poker .poker-game-panel {
  position: relative;
  margin: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.realm-poker .poker-table-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-bottom: 0;
}
.realm-poker .poker-actions-leave-wrap {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}
.realm-poker #poker-leave {
  align-self: flex-start;
  padding: 0.25rem 0.5rem;
  font-size: 0.65rem;
}
.realm-poker .poker-ready-wrap { margin: 0.5rem 0; }

.realm-poker .poker-showdown-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
  border-radius: 6px;
}
.realm-poker .poker-showdown-overlay.hidden { display: none; }
.realm-poker .poker-showdown-overlay-text {
  margin: 0;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: bold;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Rest */
.realm-rest .realm-rest-title { text-align: center; margin-bottom: 1rem; font-size: 1rem; }
.realm-rest .realm-rest-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0 0 0.75rem;
  max-width: 100%;
  min-width: 0;
}
.realm-rest .realm-rest-portrait {
  width: 100%;
  max-width: 480px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-rest .realm-rest-narrative {
  white-space: pre-wrap;
  line-height: 1.5;
  margin-bottom: 1rem;
  min-height: 4em;
}
.realm-rest .realm-rest-return { font-size: 0.9rem; color: var(--text-dim); margin-top: 0.75rem; }
.realm-rest .realm-main-rest-sleep-wrap { margin: 1rem 0; }
.realm-rest .realm-main-rest-sleep-location {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  line-height: 1.4;
}
.realm-rest #realm-main-rest-narrative-sleep {
  margin-top: 1rem;
  min-height: 3em;
}
.realm-rest .realm-rest-choice { margin-top: 1rem; }
.realm-rest .realm-rest-choice-prompt { margin-bottom: 0.75rem; font-size: 0.9rem; }
.realm-rest .realm-rest-choice-keys { margin: 0.25rem 0; font-size: 0.95rem; color: var(--text); }
.realm-rest .realm-rest-choice-key {
  margin: 0.2rem 0;
  cursor: pointer;
}
.realm-rest .realm-rest-choice-key:hover {
  color: var(--accent);
}

/* Bartender */
.realm-bartender .bartender-banner {
  text-align: center;
  font-weight: bold;
  color: #e0af68;
  margin-bottom: 0.5rem;
}
.realm-bartender .bartender-intro {
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.realm-bartender .bartender-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-bartender .bartender-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-bartender .bartender-chat-block { margin-top: 0.5rem; }
.realm-bartender .bartender-label { font-weight: bold; margin: 0 0 0.25rem; color: var(--text); }
.realm-bartender .bartender-message {
  margin: 0 0 0.75rem;
  color: #e0af68;
  white-space: pre-wrap;
  line-height: 1.4;
  min-height: 6.5rem;
}
.realm-bartender .bartender-options-label { font-weight: bold; margin: 0 0 0.35rem; color: #7dcfff; }
.realm-bartender .bartender-options { margin-bottom: 0.5rem; }
.realm-bartender .bartender-options p { margin: 0.25rem 0; }
/* Shared busy/loading state for options (bartender, drunk, etc.) */
.realm-options-busy { opacity: 0.5; pointer-events: none; }
.realm-bartender .bartender-option-0 { margin-top: 0.5rem; color: var(--text); font-size: 0.95rem; cursor: pointer; }
.realm-bartender .bartender-done-block { margin-top: 0.75rem; }
.realm-bartender .bartender-done-message { margin: 0 0 0.5rem; white-space: pre-wrap; line-height: 1.4; }
.realm-bartender .bartender-done-message.bartender-reward { color: #9ece6a; }
.realm-bartender .bartender-done-prompt { color: var(--text-dim); font-size: 0.95rem; }

/* Drunk */
.realm-drunk .drunk-banner {
  text-align: center;
  font-weight: bold;
  color: #c0a060;
  margin-bottom: 0.5rem;
}
.realm-drunk .drunk-intro {
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.realm-drunk .drunk-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-drunk .drunk-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-drunk .drunk-chat-block { margin-top: 0.5rem; }
.realm-drunk .drunk-label { font-weight: bold; margin: 0 0 0.25rem; color: var(--text); }
.realm-drunk .drunk-message {
  margin: 0 0 0.75rem;
  color: #7dcfff;
  font-style: italic;
  white-space: pre-wrap;
  line-height: 1.4;
  min-height: 6.5rem;
}
.realm-drunk .drunk-message .drunk-hic {
  color: #a5d6ff;
  font-style: italic;
}
.realm-drunk .drunk-done-narrative {
  margin: 0.5rem 0 0;
  color: var(--text-dim);
  font-style: normal;
}
.realm-drunk .drunk-options-label { font-weight: bold; margin: 0 0 0.35rem; color: #7dcfff; }
.realm-drunk .drunk-options { margin-bottom: 0.5rem; }
.realm-drunk .drunk-options p { margin: 0.25rem 0; }
.realm-drunk .drunk-option-cost { color: #e0af68; }
.realm-drunk .drunk-option-0 { margin-top: 0.5rem; color: var(--text); font-size: 0.95rem; cursor: pointer; }
.realm-drunk .drunk-done-block { margin-top: 0.75rem; }
.realm-drunk .drunk-done-message { margin: 0 0 0.5rem; white-space: pre-wrap; line-height: 1.4; }
.realm-drunk .drunk-reveal-message { margin: 0.5rem 0 0; color: #9ece6a; font-style: italic; white-space: pre-wrap; line-height: 1.4; }
.realm-drunk .drunk-done-prompt { color: var(--text-dim); font-size: 0.95rem; }

/* Town Gossiper */
.realm-gossiper .gossiper-banner {
  text-align: center;
  font-weight: bold;
  color: #c0a060;
  margin-bottom: 0.5rem;
}
.realm-gossiper .gossiper-intro {
  color: var(--text-dim);
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.realm-gossiper .gossiper-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-gossiper .gossiper-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-gossiper .gossiper-chat-block { margin-top: 0.5rem; }
.realm-gossiper .gossiper-label { font-weight: bold; margin: 0 0 0.25rem; color: var(--text); }
.realm-gossiper .gossiper-message {
  margin: 0 0 0.75rem;
  color: var(--text);
  font-style: normal;
  white-space: pre-wrap;
  line-height: 1.4;
  min-height: 4rem;
}
.realm-gossiper .gossiper-message .gossiper-speech {
  color: #7dcfff;
  font-style: italic;
}
.realm-gossiper .gossiper-timer { color: var(--text-dim); font-size: 0.85rem; margin: 0 0 0.5rem; font-style: italic; min-height: 1.1rem; }
.realm-gossiper .gossiper-done-prompt { color: var(--text-dim); font-size: 0.95rem; }

/* Forest – THE GREAT FOREST */
.realm-forest #forest-content {
  min-height: 15em;
}
.game-container.realm-active.forest-active .main-wrap {
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.forest-active .main-wrap > main {
  flex: 1;
  min-height: 0;
  margin-bottom: 0;
}
.game-container.realm-active.forest-active .main-wrap > main > #realm-forest-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}
.game-container.realm-active.forest-active .realm-forest #forest-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.game-container.realm-active.forest-active .realm-forest #forest-content .forest-content-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.game-container.realm-active.forest-active .realm-forest #forest-content > .forest-moonblight-footer {
  flex-shrink: 0;
}
.game-container.realm-active.forest-active .realm-forest #forest-combat-block {
  flex: 1;
  min-height: 0;
}
.realm-forest .realm-forest-title {
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 1rem;
  color: #9ece6a;
  margin: 0 0 0.5rem;
  letter-spacing: 0.02em;
}
.realm-forest .realm-forest-player-line {
  margin: 0.25rem 0;
  font-size: 0.95rem;
  color: var(--text);
  text-align: right;
}
.realm-forest .realm-forest-player-line .realm-lvl { color: #7dcfff; }
.realm-forest .realm-forest-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-forest .realm-forest-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-forest .realm-forest-portrait.forest-boss-portrait {
  animation: forest-boss-portrait-glow 2s ease-in-out infinite alternate;
  border: 2px solid rgba(180, 100, 180, 0.6);
}
@keyframes forest-boss-portrait-glow {
  from {
    box-shadow: 0 0 16px rgba(180, 100, 180, 0.35), 0 0 12px rgba(0, 0, 0, 0.6);
    border-color: rgba(180, 100, 180, 0.4);
  }
  to {
    box-shadow: 0 0 28px rgba(180, 100, 180, 0.65), 0 0 12px rgba(0, 0, 0, 0.6);
    border-color: rgba(180, 100, 180, 0.75);
  }
}
/* Tier 1.2 (mad woodland): gray-green, darker/unstable */
.realm-forest .realm-forest-portrait.forest-portrait-tier-12 {
  filter: saturate(0.85) sepia(0.08) hue-rotate(-15deg);
  border: 2px solid rgba(80, 100, 80, 0.5);
  box-shadow: 0 0 14px rgba(60, 80, 60, 0.4), 0 0 12px rgba(0, 0, 0, 0.6);
}
/* Tier 1.3 (Moonblight-tainted): cold blue/silver-moon, clearly different from boss purple */
.realm-forest .realm-forest-portrait.forest-portrait-tier-13 {
  filter: saturate(0.9) hue-rotate(-10deg) brightness(0.95);
  border: 2px solid rgba(120, 160, 200, 0.5);
  box-shadow: 0 0 18px rgba(100, 140, 180, 0.45), 0 0 12px rgba(0, 0, 0, 0.6);
}
.realm-forest .forest-boss-dialogue {
  margin: 0.4rem 0;
  padding: 0.35rem 0.5rem;
  font-style: italic;
  color: #c0a0e0;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.35;
  max-width: 100%;
  word-wrap: break-word;
}
.realm-forest .realm-forest-stats {
  margin: 0.5rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  max-width: 22em;
}
.realm-forest .realm-forest-stat {
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.realm-forest .realm-forest-label {
  color: var(--text);
}
.realm-forest .realm-forest-value {
  text-align: right;
  color: var(--text);
}
.realm-forest .realm-forest-value.realm-hp { color: #9ece6a; }
.realm-forest .realm-forest-value.realm-stamina { color: #9ece6a; }
.realm-forest .realm-forest-value.realm-gold { color: #e0af68; }
.realm-forest .realm-forest-sep {
  margin: 0.5rem 0;
}
.realm-death .realm-death-portrait-wrap {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0 0.5rem;
  max-width: 100%;
  min-width: 0;
}
.realm-death .realm-death-portrait-wrap .realm-forest-portrait {
  width: 100%;
  max-width: 500px;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
  display: block;
  object-fit: contain;
}
.realm-forest .realm-forest-menu {
  margin: 0.75rem 0;
  font-size: 0.95rem;
  line-height: 1.7;
}
.realm-forest .realm-forest-menu p,
.realm-forest .realm-forest-menu button {
  display: block;
  width: 100%;
  margin: 0.35rem 0;
  background: transparent;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}
.realm-forest .realm-forest-biome-unlocked.realm-biome-green { color: #9ece6a; }
.realm-forest .realm-forest-biome-unlocked.realm-biome-cyan { color: #7dcfff; }
.realm-forest .realm-forest-biome-unlocked.realm-biome-magenta { color: #bb9af7; }
.realm-forest .realm-forest-biome-unlocked.realm-biome-gray { color: #a9b1d6; }
.realm-forest .realm-forest-biome-unlocked.realm-biome-red { color: #f7768e; }
.realm-forest .realm-forest-biome-locked {
  color: var(--text-disabled);
  opacity: 0.85;
}
.realm-forest .forest-biome-tier-disabled {
  color: var(--text-dim, #565f89);
  opacity: 0.8;
  cursor: not-allowed;
  position: relative;
}
.realm-forest .forest-biome-tier-disabled:hover::after {
  content: 'Reject';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  padding: 0.15rem 0.4rem;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--text-dim);
  border-radius: 3px;
  color: var(--text-dim);
  pointer-events: none;
}
.realm-forest .forest-biome-current {
  font-weight: bold;
  text-decoration: underline;
}
.realm-forest .forest-sub-area-item {
  margin-bottom: 0.75rem;
  cursor: default;
}
.realm-forest .forest-sub-area-item .realm-forest-biome-unlocked,
.realm-forest .forest-sub-area-item .realm-forest-biome-locked,
.realm-forest .forest-sub-area-item .forest-sub-area-name {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.35rem 0;
  text-align: left;
}
.realm-forest .forest-sub-area-name,
.realm-forest .forest-sub-area-desc {
  cursor: default;
  pointer-events: none;
  text-decoration: none;
}
.realm-forest .forest-sub-area-desc {
  margin: 0.15rem 0 0 0.5rem;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--text-dim);
}
.realm-forest .forest-sub-area-item.forest-sub-area-locked .forest-sub-area-name {
  color: #6b8f71;
}
.realm-forest .forest-sub-area-item.forest-sub-area-locked .forest-sub-area-desc {
  color: #7a7a8a;
}
.realm-forest .forest-challenge-boss-btn {
  display: block;
  width: 100%;
  margin: 0.5rem 0 0 0;
  text-align: left;
  background: transparent;
  border: none;
  padding: 0.35rem 0;
  font: inherit;
  cursor: pointer;
  color: #9ece6a;
}
.realm-forest .forest-challenge-boss-btn:disabled,
.realm-forest .forest-challenge-boss-btn.forest-challenge-boss-disabled {
  cursor: not-allowed;
  color: var(--text-dim);
}
.realm-forest .forest-moonblight-footer {
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 0 0 6px 6px;
}
.realm-forest .forest-moonblight-footer.hidden {
  display: none;
}
.realm-forest .forest-moonblight-footer .by-the-tree-footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem 0.5rem;
}
.realm-forest .forest-moonblight-footer .forest-moonblight-footer-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
}
.realm-forest .forest-moonblight-footer .forest-area-btn,
.realm-forest .forest-moonblight-footer .forest-moonblight-back {
  margin: 0;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.realm-forest .forest-moonblight-footer .forest-area-btn:hover,
.realm-forest .forest-moonblight-footer .forest-moonblight-back:hover {
  color: var(--accent, #7dcfff);
  border-color: rgba(122, 162, 247, 0.4);
  background: rgba(122, 162, 247, 0.08);
}
.realm-forest .forest-moonblight-footer .forest-area-btn.forest-area-btn-locked,
.realm-forest .forest-moonblight-footer .forest-area-btn:disabled {
  cursor: default;
  pointer-events: none;
  color: #5a5a6a;
  opacity: 0.75;
}
.realm-forest .forest-moonblight-footer .forest-area-btn.forest-area-btn-locked:hover,
.realm-forest .forest-moonblight-footer .forest-area-btn:disabled:hover {
  color: #5a5a6a;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
}
.realm-forest .forest-search-text {
  color: #9ece6a;
  margin: 0.5rem 0;
}
.realm-forest .forest-message-text {
  margin: 0.5rem 0;
  white-space: pre-line;
}
.realm-forest #forest-message-block.forest-message-boss-catch .forest-message-text {
  color: #c0a0e0;
}
.realm-forest .forest-death-fatal {
  color: #f7768e;
  font-weight: bold;
}
.realm-forest .forest-message-text.death-intro,
.realm-forest .forest-combat-result-text.death-intro {
  text-align: center;
  font-weight: bold;
}
.realm-forest .forest-message-prompt {
  margin-top: 0.5rem;
  color: var(--text-dim);
}
.realm-forest #forest-message-block.forest-gate-popup {
  position: absolute;
  top: calc(50% + 50px);
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 480px;
  width: 90%;
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.9);
  border-radius: 6px;
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.75);
  z-index: 5;
}
.realm-forest #forest-message-block.forest-gate-popup .forest-message-text {
  font-size: 0.95rem;
}
.realm-forest #forest-message-block.forest-gate-popup .forest-message-prompt {
  text-align: right;
}
.realm-forest .forest-death-scenario-text {
  margin: 0.5rem 0;
  white-space: pre-line;
}
.realm-forest .forest-death-scenario-prompt {
  margin-top: 0.5rem;
  color: var(--text-dim);
}
.realm-forest .forest-event-continue-wrap {
  margin-top: 0.75rem;
}
.realm-forest .forest-event-continue-wrap .forest-event-continue {
  margin-bottom: 0.5rem;
}
.realm-forest .forest-encounter-title {
  font-weight: bold;
  color: #f7768e;
  margin: 0.5rem 0;
}
.realm-forest .forest-encounter-msg {
  margin: 0.5rem 0;
  white-space: pre-wrap;
}
.realm-forest .forest-encounter-monster {
  margin: 0.5rem 0;
  color: #7dcfff;
}
.realm-forest .forest-monster-stars {
  color: #e6c200;
}
.realm-forest .forest-encounter-prompt {
  margin-top: 0.75rem;
}
.realm-forest .forest-encounter-choice {
  margin: 0.25rem 0;
  color: var(--text);
  font-size: 0.95rem;
}
.realm-forest .forest-combat-title {
  font-weight: bold;
  margin: 0.5rem 0;
}
.realm-forest .forest-combat-stats {
  margin: 0.5rem 0;
  font-size: 0.9rem;
}
.realm-forest .forest-combat-stats-header {
  text-align: center;
  color: #f7768e;
}
.realm-forest .forest-combat-stats-header .forest-monster-stars {
  color: #e6c200;
}
.realm-forest .forest-monster-stars-violet,
.realm-forest .forest-combat-stats-header.forest-combat-boss-header .forest-monster-stars {
  color: #a855f7;
  text-shadow: 0 0 6px rgba(168, 85, 247, 0.6);
}
.realm-forest .forest-combat-stats-header.forest-combat-boss-header {
  color: #c0a0e0;
  text-shadow: 0 0 8px rgba(180, 100, 180, 0.6);
  margin: 0 0 0.4rem;
  font-size: 1.05rem;
  text-transform: uppercase;
}
.realm-forest .forest-combat-stats-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
  flex-wrap: wrap;
}
.realm-forest .forest-combat-you .forest-combat-label { color: #7dcfff; }
.realm-forest .forest-combat-foe .forest-combat-label { color: #f7768e; }
.realm-forest .forest-combat-atk { color: #bb9af7; margin-right: 0.25rem; }
.realm-forest .forest-combat-def { color: #7dcfff; }
.realm-forest .forest-combat-hp-wrap {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}
.realm-forest .forest-combat-hp-bar {
  width: 120px;
  height: 10px;
  background: repeating-linear-gradient(
    90deg,
    #3b4252 0,
    #3b4252 2px,
    #2e3440 2px,
    #2e3440 4px
  );
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}
.realm-forest .forest-combat-hp-fill {
  height: 100%;
  background: #f7768e;
  border-radius: 0 2px 2px 0;
  transition: width 0.2s ease;
}
.realm-forest .forest-combat-hp-num {
  width: 5em;
  min-width: 5em;
  font-size: 0.85rem;
  color: var(--text);
  text-align: right;
}
.realm-forest #forest-combat-block {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  padding-bottom: 3.5rem;
}
.realm-forest #forest-combat-block .forest-combat-log {
  flex: 0 0 auto;
  height: 10.5em;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}
.realm-forest .forest-combat-log .forest-log-slot {
  margin: 0;
  padding: 0.1em 0;
  min-height: 1.25em;
  line-height: 1.25;
  color: var(--text);
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}
.realm-forest .forest-log-slot.forest-log-windup,
.realm-forest .forest-log-slot.forest-log-enemy-windup {
  color: #9ece6a;
  font-style: italic;
}
.realm-forest .forest-log-slot.forest-log-hit,
.realm-forest .forest-log-slot.forest-log-enemy-hit {
  color: #f7768e;
}
.realm-forest .forest-log-slot.forest-log-crit {
  color: #e0af68;
  font-weight: bold;
}
.realm-forest .forest-log-slot.forest-log-absorbed {
  color: var(--text-dim);
  font-style: italic;
}
.realm-forest .forest-log-slot.forest-log-miss {
  color: var(--text-dim);
}
.realm-forest .forest-log-slot.forest-log-enemy-miss {
  color: #7dcfff;
}
.realm-forest .forest-log-slot.forest-log-boss {
  color: #c0a0e0;
  font-style: italic;
}
.realm-forest .forest-log-slot.forest-log-boss-skill {
  font-weight: bold;
}
.realm-forest .forest-log-slot.forest-log-sep {
  width: 100%;
  margin: 0.35em 0;
  padding: 0;
  border: none;
  border-top: 1px solid #555;
  background: none;
  font-size: 0;
  line-height: 0;
  min-height: 0;
  color: transparent;
}
.realm-forest .forest-combat-result {
  margin-top: 0.75rem;
  display: none;
}
.realm-forest .forest-combat-result-popup {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}
.realm-forest .forest-combat-result-popup.hidden {
  display: none;
}
.realm-forest .forest-combat-result-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}
.realm-forest .forest-combat-result-popup-card {
  position: relative;
  width: 100%;
  max-width: 22rem;
  padding: 1.5rem 1.75rem;
  background: linear-gradient(160deg, #1e2030 0%, #16161e 100%);
  border: 1px solid rgba(192, 202, 245, 0.2);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3), 0 12px 32px rgba(0, 0, 0, 0.5), 0 0 40px rgba(125, 207, 255, 0.08);
  text-align: center;
}
.realm-forest .forest-combat-result-popup-title {
  margin: 0 0 1rem;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #9ece6a;
  text-transform: uppercase;
  line-height: 1.3;
}
.realm-forest .forest-combat-result-popup-title.slain {
  color: #f7768e;
  letter-spacing: 0.08em;
}
.realm-forest .forest-combat-result-popup-title.fled {
  color: #e0af68;
  font-size: 1.2rem;
  text-transform: none;
}
.realm-forest .forest-combat-result-popup-body {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
}
.realm-forest .forest-combat-result-popup-xp {
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: #7dcfff;
}
.realm-forest .forest-combat-result-popup-xp:empty {
  display: none;
}
.realm-forest .forest-combat-result-popup-loot {
  margin: 0 0 0.5rem;
  color: var(--text);
}
.realm-forest .forest-combat-result-popup-loot:empty {
  display: none;
}
.realm-forest .forest-combat-result-popup-loot .realm-gold {
  color: #e0af68;
}
.realm-forest .forest-combat-result-popup-level {
  margin: 0;
  font-weight: 700;
  color: #9ece6a;
}
.realm-forest .forest-combat-result-popup-level:empty {
  display: none;
}
.realm-forest .forest-combat-result-popup-prompt {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
}
.realm-forest .forest-combat-result-banner {
  font-weight: bold;
  color: #9ece6a;
  text-align: left;
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}
.realm-forest .forest-combat-result-banner.slain {
  color: #f7768e;
  letter-spacing: 0.05em;
}
.realm-forest .forest-combat-result-text {
  margin: 0.5rem 0;
  white-space: pre-wrap;
}
.realm-forest .forest-combat-result-prompt {
  margin-top: 0.5rem;
  color: var(--text-dim);
}
.realm-forest .forest-combat-prompt {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}
.realm-forest .forest-combat-actions-box {
  margin: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--layout-border, rgba(192, 202, 245, 0.25));
  border-radius: var(--radius, 4px) var(--radius, 4px) 0 0;
  background: var(--surface, rgba(26, 27, 38, 0.6));
}
.realm-forest .forest-combat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.realm-forest .forest-combat-btn {
  margin: 0;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface, #1a1b26);
  border: 1px solid #3b4252;
  border-radius: var(--radius, 4px);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.realm-forest .forest-combat-btn:hover {
  color: var(--accent, #7dcfff);
  border-color: var(--accent, #7dcfff);
}
/* Default choice (Enter = Attack): subtle glow so it reads as selected */
.realm-forest .forest-combat-btn.forest-combat-btn-default {
  box-shadow: 0 0 10px rgba(125, 207, 255, 0.35), 0 0 4px rgba(125, 207, 255, 0.2);
  border-color: rgba(125, 207, 255, 0.5);
}
.realm-forest .forest-combat-btn.forest-combat-btn-default:hover {
  box-shadow: 0 0 14px rgba(125, 207, 255, 0.5), 0 0 6px rgba(125, 207, 255, 0.3);
  border-color: var(--accent, #7dcfff);
}
.realm-forest .forest-combat-btn.forest-combat-btn-default.forest-combat-choice-disabled {
  box-shadow: 0 0 6px rgba(125, 207, 255, 0.2);
}
.realm-forest .forest-combat-btn.forest-combat-choice-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.realm-forest .forest-combat-btn.forest-combat-choice-disabled:hover {
  color: var(--text);
  border-color: #3b4252;
}
.realm-forest .forest-combat-btn-autofight {
  background: rgba(158, 206, 106, 0.15);
  border-color: #9ece6a;
  color: #9ece6a;
}
.realm-forest .forest-combat-btn-autofight:hover {
  background: rgba(158, 206, 106, 0.25);
  color: #9ece6a;
  border-color: #9ece6a;
}
.realm-forest .forest-combat-btn-autofight.forest-combat-btn-autofight-on {
  background: #e0af68;
  border-color: #e0af68;
  color: #1a1b26;
}
.realm-forest .forest-combat-btn-autofight.forest-combat-btn-autofight-on:hover {
  background: #c9a05a;
  border-color: #c9a05a;
  color: #1a1b26;
}
.realm-forest .forest-log-slot.forest-log-dots {
  color: #c0a0e0;
  font-style: italic;
}
.realm-forest .forest-combat-choice.forest-combat-choice-disabled {
  color: var(--text-dim);
  cursor: default;
  pointer-events: none;
}
.realm-forest .forest-combat-choice.forest-combat-choice-disabled:hover {
  color: var(--text-dim);
}
.realm-forest .forest-combat-skill-popup {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  border-radius: 0;
}
.realm-forest .forest-combat-skill-popup.hidden {
  display: none;
}
.realm-forest .forest-combat-skill-popup-inner {
  background: var(--surface);
  border: 2px solid #9ece6a;
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  max-width: 90%;
  text-align: center;
}
.realm-forest .forest-combat-skill-popup-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: #9ece6a;
  margin: 0 0 0.5rem;
}
.realm-forest .forest-combat-skill-popup-cost {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin: 0 0 0.35rem;
}
.realm-forest .forest-combat-skill-popup-desc {
  font-size: 0.9rem;
  color: var(--text);
  margin: 0;
}
.realm-forest .forest-combat-skills-popup-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
}
.realm-forest .forest-combat-skills-popup-overlay.hidden {
  display: none;
}
.realm-forest .forest-combat-skills-popup-inner {
  margin: 1rem;
  padding: 1.25rem 1.5rem;
  border: 2px solid rgba(122, 162, 247, 0.5);
  border-radius: var(--radius);
  background: var(--surface);
  max-width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}
.realm-forest .forest-combat-skills-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 0.5rem;
}
.realm-forest .forest-combat-skills-list {
  margin-bottom: 0.5rem;
}
.realm-forest .forest-combat-skills-empty {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.realm-forest .forest-combat-skill-choice {
  margin: 0.2rem 0;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}
.realm-forest .forest-combat-skill-choice:hover {
  color: var(--accent);
}
.realm-forest .forest-combat-skill-choice.forest-combat-skill-choice-disabled {
  color: var(--text-dim);
  cursor: default;
}
.realm-forest .forest-combat-skills-back {
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
  margin: 0;
}
.realm-forest .forest-combat-skills-back:hover {
  color: var(--accent);
}

/* Items popup – centered on screen */
.realm-forest .forest-combat-items-popup-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 110;
}
.realm-forest .forest-combat-items-popup-overlay.hidden {
  display: none;
}
.realm-forest .forest-combat-items-popup-inner {
  margin: 1rem;
  padding: 1.5rem 2rem;
  border: 2px solid rgba(122, 162, 247, 0.5);
  border-radius: var(--radius);
  background: var(--surface);
  min-width: 18rem;
  max-width: 90%;
}
.realm-forest .forest-combat-items-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 1rem;
  text-align: center;
}
.realm-forest .forest-combat-items-list {
  margin-bottom: 1rem;
}
.realm-forest .forest-combat-item-choice {
  margin: 0.35rem 0;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
.realm-forest .forest-combat-item-choice:hover {
  color: var(--accent);
  background: rgba(122, 162, 247, 0.12);
}
.realm-forest .forest-combat-item-choice.forest-combat-item-choice-disabled {
  color: var(--text-dim);
  cursor: default;
}
.realm-forest .forest-combat-item-choice.forest-combat-item-choice-disabled:hover {
  background: transparent;
  color: var(--text-dim);
}
.realm-forest .forest-combat-items-back {
  font-size: 0.9rem;
  color: var(--text-dim);
  cursor: pointer;
  margin: 0;
  text-align: center;
}
.realm-forest .forest-combat-items-back:hover {
  color: var(--accent);
}

.realm-forest .forest-event-title {
  font-weight: bold;
  color: #e0af68;
  margin: 0.5rem 0;
}
.realm-forest .forest-event-msg {
  margin: 0.5rem 0;
}
.realm-forest .forest-event-result { margin: 0.5rem 0; color: #9ece6a; }
.realm-forest .forest-event-prompt { margin-top: 0.75rem; }
.realm-forest .forest-event-choice {
  margin: 0.25rem 0;
  color: var(--text);
  font-size: 0.95rem;
}
.realm-forest .forest-event-continue { margin-top: 0.5rem; color: var(--text-dim); }

/* Forest Riddle Troll – fixed green box, same margin on all sides including bottom */
.realm-forest #forest-riddle-block {
  margin: 0.5rem 0;
}
.realm-forest .forest-riddle-troll-box {
  border: 3px solid #4a7c59;
  border-radius: 6px;
  padding: 1rem;
  margin: 0.5rem;
  height: 22rem;
  min-height: 22rem;
  max-height: 22rem;
  box-sizing: border-box;
  overflow-y: auto;
  background: rgba(42, 52, 42, 0.4);
  box-shadow: inset 0 0 12px rgba(74, 124, 89, 0.2);
}
.realm-forest .forest-riddle-portrait-wrap {
  text-align: center;
  margin-bottom: 0.75rem;
}
.realm-forest .forest-riddle-portrait {
  max-width: 100%;
  width: 280px;
  height: auto;
  border-radius: 4px;
  border: 2px solid #4a7c59;
}
.realm-forest .forest-riddle-troll-label {
  font-weight: bold;
  color: #9ece6a;
  margin: 0.25rem 0 0.15rem;
}
.realm-forest .forest-riddle-troll-msg {
  margin: 0.35rem 0 0.5rem;
  white-space: pre-wrap;
  color: #7aa2f7;
  font-weight: bold;
}
.realm-forest .forest-riddle-troll-gotyou {
  margin: 0.25rem 0 0.75rem;
  white-space: pre-wrap;
  color: #e0af68;
  font-style: italic;
}
.realm-forest .forest-riddle-question-label {
  font-weight: bold;
  color: var(--text-dim);
  margin: 0.5rem 0 0.2rem;
}
.realm-forest .forest-riddle-question {
  margin: 0.25rem 0 0.5rem;
  color: #e0af68;
  font-style: italic;
  white-space: pre-wrap;
}
.realm-forest .forest-riddle-options-label {
  margin: 0.5rem 0 0.25rem;
  color: var(--text);
}
.realm-forest .forest-riddle-wrong-banner {
  margin: 0.5rem 0 0.25rem;
  color: #f7768e;
  font-weight: bold;
  font-size: 1.1rem;
}
.realm-forest .forest-riddle-options { margin-top: 0.5rem; }
.realm-forest .forest-riddle-choice {
  margin: 0.3rem 0;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.25rem 0;
}
.realm-forest .forest-riddle-choice:hover { color: #9ece6a; }
.realm-forest .forest-riddle-result-wrap {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 2px solid #4a7c59;
  border-radius: 4px;
  background: rgba(42, 52, 42, 0.3);
}
.realm-forest .forest-riddle-result-msg { white-space: pre-wrap; margin: 0 0 0.5rem; }
.realm-forest .forest-riddle-result-prompt { color: var(--text-dim); }

/* ========== Responsive: mobiili vs desktop ========== */

/* Small screens: single column, touch-friendly, sidebars stack or hide */
@media (max-width: 767px) {
  .admin-edit-view-wide .admin-edit-layout {
    grid-template-columns: 1fr;
  }
  .admin-edit-view-wide .admin-edit-left,
  .admin-edit-view-wide .admin-edit-right {
    position: static;
  }
  .game-wrapper {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  body {
    padding-bottom: max(4rem, calc(env(safe-area-inset-bottom) + 3rem));
  }
  .game-container.realm-active {
    grid-template-columns: 1fr;
    grid-template-areas: "main-wrap";
    min-height: 0;
  }
  .game-container.realm-active .sidebar-left,
  .game-container.realm-active .sidebar-right {
    display: none;
  }
  .main-wrap {
    padding: 1rem max(1rem, env(safe-area-inset-right));
  }
  .footer {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  }
  .btn {
    min-height: 44px;
    padding: 0.75rem 1rem;
  }
  .realm-menu-choice,
  .realm-forest .realm-forest-menu p,
  .realm-forest .realm-forest-menu button,
  .realm-gambling .gambling-menu-choice,
  .forest-encounter-choice,
  .forest-riddle-choice {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0.25rem 0;
  }
  .realm-screen {
    padding-left: 0;
    padding-right: 0;
  }
  .card {
    padding: 1.25rem;
  }
  .realm-main-title-block .realm-main-title-line1 { font-size: 1.15rem; }
  .realm-main-title-block .realm-main-title-line2 { font-size: 0.6rem; }
  .realm-title-block .realm-title { font-size: 2.25rem; }
}

/* Desktop: fixed-width RPG layout, sidebars visible when in realm */
@media (min-width: 768px) {
  .game-wrapper {
    max-width: min(var(--game-width), 92vw);
  }
  body {
    align-items: flex-start;
    padding-top: 1.5rem;
    padding-bottom: 5rem;
  }
  .main-wrap {
    padding: 1.5rem 2rem;
  }
  .card {
    padding: 1.75rem;
    max-width: 520px;
    margin: 0 auto;
  }
  /* Admin edit view must use full width like tavern, not the default card width */
  .game-wrapper.admin-edit-wide #admin-edit-view.card {
    max-width: none;
    width: 100%;
    margin: 0;
  }
  .card-title {
    font-size: 1.25rem;
  }
  .realm-screen {
    padding: 1rem 0;
  }
  .realm-title-block .realm-title {
    font-size: 3.25rem;
  }
  .realm-main-title-block .realm-main-title-line1 {
    font-size: 1.5rem;
  }
  .realm-main-title-block .realm-main-title-line2 {
    font-size: 0.7rem;
  }
}

/* Wide desktop: use full target width */
@media (min-width: 1320px) {
  .game-wrapper {
    max-width: var(--game-width);
  }
}

/* Realms down – shown when server is unreachable on load or after Try again */
.realms-down-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  padding: 1rem;
}
.realms-down-overlay.hidden {
  display: none !important;
}
.realms-down-card {
  background: var(--surface);
  border: var(--layout-border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  max-width: 420px;
  text-align: center;
}
.realms-down-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--accent);
}
.realms-down-message {
  margin: 0 0 1.25rem;
  color: var(--text);
  line-height: 1.5;
}
.realms-down-card .btn {
  margin: 0;
}

/* Restart server popup – shown to all logged-in users when admin restarts */
.restart-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  padding: 1rem;
}
.restart-popup-overlay.hidden {
  display: none !important;
}
.restart-popup-card {
  background: var(--surface);
  border: var(--layout-border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  max-width: 420px;
  text-align: center;
}
.restart-popup-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  color: var(--accent);
}
.restart-popup-title:empty {
  display: none;
  margin: 0;
}
.restart-popup-message {
  margin: 0 0 1.25rem;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-line;
}
.restart-popup-message .restart-popup-prefix {
  font-style: italic;
  color: var(--text-dim);
}
.restart-popup-card .btn {
  margin: 0;
}

/* Admin wipe data popup */
.admin-wipe-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  padding: 1rem;
}
.admin-wipe-popup-overlay.hidden {
  display: none !important;
}
.admin-wipe-popup-card {
  background: var(--surface);
  border: var(--layout-border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  max-width: 480px;
  width: 100%;
}
.admin-wipe-popup-title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--accent);
}
.admin-wipe-popup-intro {
  margin: 0 0 1rem;
  color: var(--text);
  font-size: 0.9rem;
}
.admin-wipe-option {
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--layout-border);
}
.admin-wipe-option-desc {
  margin: 0 0 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.4;
}
.admin-wipe-option-actions {
  display: flex;
  gap: 0.5rem;
}
.admin-wipe-option-actions .btn {
  margin: 0;
}
.admin-wipe-popup-message {
  margin: 0 0 1rem;
  font-size: 0.9rem;
}
.admin-wipe-popup-footer {
  margin-top: 0.5rem;
}
.admin-wipe-popup-footer .btn {
  margin: 0;
}

/* Sidebar backup popup (same UX as admin backup progress) */
.sidebar-backup-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  padding: 1rem;
}
.sidebar-backup-popup-overlay.hidden {
  display: none !important;
}
.sidebar-backup-popup-card {
  background: var(--surface);
  border: var(--layout-border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem 2rem;
  max-width: 420px;
  width: 100%;
}
.sidebar-backup-popup-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  color: var(--accent);
}
.sidebar-backup-popup-progress {
  padding: 0.75rem;
  background: var(--bg-secondary, rgba(0, 0, 0, 0.2));
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow-y: auto;
  color: var(--text);
  margin-bottom: 1rem;
}
.sidebar-backup-popup-footer {
  margin-top: 0;
}
.sidebar-backup-popup-footer .btn {
  margin: 0;
}
.sidebar-backup-popup-footer .btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.admin-broadcast-panel {
  margin-top: 1rem;
}

.admin-restart-panel {
  margin-top: 1rem;
}

.admin-restart-panel .admin-restart-timer-input {
  width: 5rem;
  margin-right: 0.5rem;
}

.admin-restart-actions {
  margin-top: 0.75rem;
}

.admin-restart-countdown-wrap {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-restart-countdown {
  font-weight: 600;
  color: var(--accent);
}

.admin-backup-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}
.admin-backup-label {
  flex: 0 0 auto;
  color: var(--text);
}
.admin-backup-input {
  flex: 0 1 12rem;
  min-width: 8rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
}
.admin-backup-progress {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--bg-secondary, rgba(0,0,0,0.2));
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow-y: auto;
  color: var(--text);
}

/* Level-up congratulations popup */
.level-up-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 1rem;
}
.level-up-popup-overlay.hidden {
  display: none !important;
}
.level-up-popup-card {
  background: var(--surface);
  border: var(--layout-border-accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 1.25rem 1.75rem;
  max-width: 360px;
  width: 100%;
  text-align: center;
}
.level-up-popup-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.level-up-popup-message {
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
}
.admin-backup-progress.hidden {
  display: none;
}
