:root {
  --bg: #1a1b26;
  --surface: #24283b;
  --surface-hover: #2d3142;
  --text: #c0caf5;
  --text-dim: #9aa5ce;
  --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;
}

.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: auto;
  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;
}
.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 {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 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;
}
.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;
}
.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;
}

/* 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);
}

/* 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: 0.9rem;
  color: var(--text);
  text-align: left;
}

.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);
}
/* 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);
}

.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;
}

.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;
}

.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;
  margin-bottom: 0.75rem;
}

.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: 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-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-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-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-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);
  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;
  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 {
  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-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;
}
.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-dim);
  cursor: not-allowed;
}
.realm-shop .shop-item-locked:hover {
  color: var(--text-dim);
}
.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;
}
.realm-cauldron .realm-cauldron-leave-box {
  padding: 0.4rem 0.6rem;
  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-cauldron .realm-cauldron-leave {
  margin: 0;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--text-dim);
}
.realm-cauldron .realm-cauldron-leave:hover {
  color: var(--accent, #7dcfff);
}
.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: 1;
  min-width: 0;
  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-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-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);
}

/* Inventory menu – pill buttons */
.realm-inventory .realm-inventory-menu {
  margin: 0;
  padding-top: 1rem;
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.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;
}
.realm-dice .dice-ascii {
  margin: 0.5rem auto;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--text);
  white-space: pre;
  font-family: ui-monospace, monospace;
  text-align: center;
}
.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: 4.8rem;
}
.realm-blackjack .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.2);
  animation: bj-card-bounce 0.4s ease-out;
}
.realm-blackjack .bj-card-ascii {
  margin: 0;
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--text);
  white-space: pre;
  font-family: ui-monospace, monospace;
}
@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-face-down .bj-card-ascii {
  color: rgba(255, 255, 255, 0.6);
  filter: contrast(0.7);
}
.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 .ascii-card {
  margin: 0;
  padding: 0.35rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: pre;
  background-color: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
}
.realm-poker .card-red {
  color: #ff4444;
}
.realm-poker .card-black {
  color: #aaaaaa;
}
@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-dim); font-size: 0.95rem; }
.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-dim); font-size: 0.95rem; }
.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; }

/* Forest – THE GREAT FOREST */
.realm-forest #forest-content {
  min-height: 15em;
}
.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-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-dim);
}
.realm-forest .forest-biome-current {
  font-weight: bold;
  text-decoration: underline;
}
.realm-forest .forest-boss-progress {
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--text-dim);
}
.realm-forest .forest-boss-xp-line {
  margin: 0.35rem 0;
  font-size: 0.9rem;
}
.realm-forest .forest-challenge-boss-disabled,
.realm-forest button.forest-challenge-boss-disabled:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
}
.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-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-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-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;
  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-log-sep {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin: 0.4rem 0 0.25rem;
  letter-spacing: 0.02em;
}
.realm-forest .forest-combat-log {
  height: 8em;
  margin: 0.5rem 0;
  font-size: 0.9rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex-shrink: 0;
  overflow: hidden;
}
.realm-forest .forest-log-slot {
  margin: 0;
  min-height: 1.25em;
  line-height: 1.25;
  color: var(--text);
  flex-shrink: 0;
}
.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-sep {
  color: var(--text-dim);
  font-size: 0.85em;
  letter-spacing: 0.02em;
}
.realm-forest .forest-combat-result {
  margin-top: 0.75rem;
}
.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 {
  margin-top: 0.75rem;
}
.realm-forest .forest-combat-choice {
  margin: 0.25rem 0;
  color: var(--text);
  font-size: 0.95rem;
}
.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);
}
.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 – conversation-style box with mossy green borders */
.realm-forest .forest-riddle-troll-box {
  border: 3px solid #4a7c59;
  border-radius: 6px;
  padding: 1rem;
  margin: 0.5rem 0;
  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.75rem;
  white-space: pre-wrap;
  color: var(--text);
}
.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;
}
.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);
  }
}

/* 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-broadcast-panel {
  margin-top: 1rem;
}

.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);
}
.admin-backup-progress.hidden {
  display: none;
}
