/* CSS Variables - RuneScape-style Medieval Palette */
:root {
  --bg: #2a1f0f;
  --fg: #e8dcc4;
  --dim: #9a8a73;
  --accent: #d4af37;
  --accent-secondary: #4a9d96;
  --accent-secondary-soft: rgba(74, 157, 150, 0.4);
  --terminal-bg: #2f2115;
  --terminal-border: #60472f;
  --terminal-alt: rgba(74, 157, 150, 0.08);
  --whisper-glow: rgba(92, 228, 255, 0.5);
  
  /* Layout sizing rules */
  --layout-max-width: 1600px;
  --layout-min-width: 800px;
  --sidebar-width: clamp(280px, 25vw, 400px);
  --terminal-min-width: 400px;
  --gap: 16px;
  --padding: 16px;
}

/* Base Styles */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Layout */
.wrap {
  height: 100vh;
  max-width: 100%;
  margin: 0 0 24px 0;
  padding: var(--padding);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  align-items: center;
}

.title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: var(--layout-max-width);
  margin-bottom: 12px;
  box-sizing: border-box;
}

h1 {
  margin: 0;
  font-size: clamp(18px, 1.5vw, 24px);
  flex-shrink: 0;
  text-align: left;
  line-height: 1.2;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.online-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(74, 157, 150, 0.15);
  border: 1px solid rgba(74, 157, 150, 0.35);
  border-radius: 999px;
  font-size: 12px;
  color: rgba(198, 236, 230, 0.92);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

.online-indicator .status-icon {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.online-indicator .status-text {
  letter-spacing: 0.02em;
}

.hiscores-button {
  padding: 8px 16px;
  background: #4a3420;
  color: var(--fg);
  border: 1px solid #6b5a4a;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  flex-shrink: 0;
}

.hiscores-button:hover {
  background: #5c4a35;
  border-color: var(--accent);
  filter: brightness(1.1);
}

.hiscores-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hiscores-button .hiscores-icon {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
  display: block;
}

/* Hiscores tab buttons */
.hiscores-tab-button {
  transition: all 0.2s;
}

.hiscores-tab-button:hover:not(.active) {
  background: rgba(212, 175, 55, 0.15) !important;
  color: var(--fg) !important;
}

.main-layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  grid-template-rows: 1fr;
  gap: var(--gap);
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
  max-width: var(--layout-max-width);
  min-width: var(--layout-min-width);
  box-sizing: border-box;
  align-items: start;
}

.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* Terminal Section */
.terminal-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.terminal-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Status Panel */
.status-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  min-height: 0;
  height: 100%;
  width: 100%;
}

.status-panel > div {
  padding: 12px;
  background: #3d2914;
  border-radius: 8px;
  border: 1px solid #5c4a35;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

#minimap {
  flex: 0 1 20%;
  min-height: 0;
  max-height: 200px;
}

#ground-items-panel {
  flex: 0 1 auto;
  min-height: 0;
  max-height: 150px;
  display: flex;
  flex-direction: column;
}

#ground-items-panel h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--accent);
  font-weight: bold;
}

#ground-items-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 110px;
  max-height: 110px;
  background: #2a1f0f;
  border: 1px solid #5c4a35;
  border-radius: 4px;
  padding: 4px;
  font-size: 11px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
  align-content: start;
}

.ground-item-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 6px 8px;
  border: 1px solid rgba(92, 74, 53, 0.5);
  border-radius: 6px;
  background: rgba(92, 74, 53, 0.18);
  backdrop-filter: blur(1px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.ground-item-group-header {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--fg);
  text-transform: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ground-item-group-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 6px;
}

#ground-items-content:empty::before {
  content: 'The ground is empty.';
  color: var(--dim);
  font-style: italic;
  display: block;
  padding: 8px;
  text-align: center;
  grid-column: 1 / -1; /* Span both columns */
}

/* Ground item row styling */
.ground-item-row {
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.ground-item-row:hover {
  background-color: rgba(212, 175, 55, 0.08);
}

/* Ground item sprite styling */
.ground-item-sprite {
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}

/* Animation for new items appearing */
@keyframes groundItemAppear {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.95);
  }
  50% {
    transform: translateY(2px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Pulse animation for new items */
@keyframes groundItemPulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(212, 175, 55, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0);
  }
}

#inventory-skills {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: visible; /* Allow item gain animations to overflow */
  position: relative;
  z-index: 1;
}

#logout-section {
  flex: 0 0 auto;
  padding: 4px;
  background: #3d2914;
  border-radius: 8px;
  border: 1px solid #5c4a35;
  display: flex;
  justify-content: center;
}

.logout-button {
  width: 100%;
  padding: 10px 16px;
  background: #7c4a4a;
  border: 1px solid #5c4a35;
  border-radius: 4px;
  color: var(--fg);
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-button .logout-icon {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
  display: block;
}

.logout-button:hover {
  background: #8d5a5a;
}

.logout-button:active {
  background: #6b3a3a;
}

/* Tab Menu */
.tab-menu {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #5c4a35;
}

.tab-button {
  padding: 6px 12px;
  background: transparent;
  color: var(--dim);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-button .tab-icon {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  display: block;
}

.tab-button .tab-label {
  display: none;
}

.tab-button:hover {
  background: rgba(212, 175, 55, 0.15);
  color: var(--fg);
}

.tab-button.active {
  background: rgba(212, 175, 55, 0.25);
  color: var(--accent);
  border-color: var(--accent);
}

.tab-content {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* Friends list */
#friends-content {
  gap: 4px;
  padding-right: 4px;
}

.friends-empty {
  font-size: 12px;
  color: var(--dim);
  padding: 12px 8px;
  text-align: center;
  border: 1px dashed rgba(92, 74, 53, 0.6);
  border-radius: 6px;
}

.friend-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(34, 25, 21, 0.65);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: 6px;
  color: var(--fg);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.friend-entry.friend-online {
  border-color: rgba(212, 175, 55, 0.5);
}

.friend-entry .friend-name {
  flex: 1;
  text-align: left;
}

.friend-status {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.friend-status.online {
  color: #45df34;
}

.friend-status.offline {
  color: var(--dim);
}

.friend-entry:hover,
.friend-entry:focus {
  outline: none;
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.5);
}

.friend-entry:active {
  background: rgba(212, 175, 55, 0.28);
}

.friends-context-menu {
  position: fixed;
  background: #3d2914;
  border: 1px solid #5c4a35;
  border-radius: 6px;
  padding: 4px;
  z-index: 10002;
  box-shadow: 0 4px 12px rgba(0,0,0,0.45);
  min-width: 140px;
}

.friends-context-menu button {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--fg);
  padding: 6px 10px;
  text-align: left;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
}

.friends-context-menu button:hover {
  background: rgba(212, 175, 55, 0.18);
}

.status-panel h3 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: var(--accent);
  border-bottom: 1px solid #5c4a35;
  padding-bottom: 4px;
  flex-shrink: 0;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.panel-header h3 {
  margin: 0;
}

.world-map-button {
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.world-map-button:hover {
  background: rgba(212, 175, 55, 0.28);
  transform: translateY(-1px);
}

/* Minimap */
#minimap-content {
  position: relative;
  flex: 1;
  min-height: 0;
}

#minimap .current {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--accent);
  font-weight: bold;
  padding: 4px 6px;
  background: rgba(212, 175, 55, 0.25);
  border-radius: 3px;
  border: 1px solid var(--accent);
  white-space: nowrap;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
}

#minimap .current:hover {
  background: rgba(212, 175, 55, 0.35);
}

#minimap .adjacent {
  position: absolute;
  color: var(--dim);
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
  cursor: pointer;
}

#minimap .adjacent.north {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

#minimap .adjacent.south {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

#minimap .adjacent.east {
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

#minimap .adjacent.west {
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

#minimap .adjacent.northeast {
  top: 10px;
  right: 10px;
}

#minimap .adjacent.northwest {
  top: 10px;
  left: 10px;
}

#minimap .adjacent.southeast {
  bottom: 10px;
  right: 10px;
}

#minimap .adjacent.southwest {
  bottom: 10px;
  left: 10px;
}

#minimap .adjacent.up {
  top: 0;
  right: 20%;
}

#minimap .adjacent.down {
  bottom: 0;
  right: 20%;
}

#minimap .direction-label {
  color: #f4a460;
  font-size: 10px;
  display: block;
  margin-bottom: 1px;
}

.minimap-adjacent-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg);
}

/* World Map Window */
.world-map-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
  z-index: 9998;
}

.world-map-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(640px, 80vw, 960px);
  height: clamp(520px, 78vh, 760px);
  background: rgba(24, 16, 8, 0.96);
  border: 2px solid #5c4a35;
  border-radius: 10px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.world-map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(92, 74, 53, 0.6);
  gap: 12px;
}

.world-map-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.world-map-header-actions {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.world-map-close {
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 20px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.world-map-close:hover {
  color: var(--accent);
}

.world-map-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.world-map-button-group {
  display: flex;
  gap: 6px;
}

.world-map-button-group button {
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: var(--accent);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.world-map-button-group button:hover {
  background: rgba(212, 175, 55, 0.25);
}

.world-map-toggle-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.world-map-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--fg);
}

.world-map-toggle input {
  accent-color: var(--accent);
}

.world-map-canvas {
  flex: 1;
  position: relative;
  padding: 12px 14px;
}

.world-map-svg-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.world-map-svg {
  width: 100%;
  height: 100%;
  background: rgba(61, 41, 20, 0.28);
  border: 1px solid rgba(92, 74, 53, 0.5);
  border-radius: 8px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
  cursor: grab;
}

.world-map-svg:active {
  cursor: grabbing;
}

.world-map-link {
  stroke: rgba(212, 175, 55, 0.28);
  stroke-width: 1.5;
  stroke-linecap: round;
}

.world-map-node {
  cursor: pointer;
}

.world-map-node-circle {
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.6));
}

.world-map-node.current-room .world-map-node-circle {
  stroke: var(--accent);
  stroke-width: 3;
}

.world-map-label,
.world-map-resource,
.world-map-object,
.world-map-spawns {
  fill: var(--fg);
  font-size: 10px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.world-map-resource {
  fill: #d4af37;
}

.world-map-spawns {
  fill: #ffb1b1;
}

.world-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 16px;
  font-size: 11px;
  color: var(--dim);
  border-top: 1px solid rgba(92, 74, 53, 0.5);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 16px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.legend-swatch.legend-safe {
  background: #236b46;
}

.legend-swatch.legend-danger {
  background: #7a2c2c;
}

.legend-swatch.legend-town {
  background: #6b5b2a;
}

.legend-swatch.legend-magic {
  background: #3a406b;
}

.legend-icon {
  font-size: 12px;
}

.world-map-node:hover .world-map-node-circle {
  stroke: var(--accent);
  stroke-width: 2;
}

.world-map-exit {
  stroke: rgba(212, 175, 55, 0.4);
  stroke-width: 1;
}

.world-map-exit.active {
  stroke: var(--accent);
  stroke-width: 2;
}

.world-map-exit:hover {
  stroke: var(--accent);
  stroke-width: 2;
}

.world-map-poi {
  pointer-events: none;
}

.world-map-poi-icon {
  font-size: 12px;
}

.world-map-poi-label {
  font-size: 9px;
  fill: var(--fg);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.world-map-npc-spawn {
  fill: #ffb1b1;
}

.world-map-object {
  fill: #9d9dff;
}

/* Inventory & Skills Content */
#inventory-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#skills-content {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

#inventory-content .item {
  color: var(--dim);
  margin: 2px 0;
  font-size: 12px;
}

#inventory-content .item-count {
  color: var(--accent);
}

#inventory-content .item-count.qty-thousands {
  color: #ffffff; /* White for thousands (K) */
}

#inventory-content .item-count.qty-millions {
  color: #9d4edd; /* Purple for millions (M) */
}

#inventory-content .empty {
  color: var(--dim);
  font-style: italic;
  font-size: 12px;
}

#inventory-content .empty-slot {
  color: var(--dim) !important;
  font-style: italic !important;
  opacity: 0.5 !important;
}

#inventory-content .inventory-item.dragging {
  opacity: 0.5;
  transform: scale(0.95);
  transition: opacity 0.2s, transform 0.2s;
}

#inventory-content .inventory-item,
#inventory-content .inventory-slot {
  transition: background-color 0.2s, transform 0.2s;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
}

#inventory-content .drag-over {
  background-color: rgba(212, 175, 55, 0.3);
  border: 1px dashed var(--accent);
}

#skills-content .skill {
  color: var(--dim);
  margin: 0;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(92, 74, 53, 0.3);
}

#skills-content .skill-name {
  color: var(--fg);
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

#skills-content .skill-icon {
  height: 20px;
  width: auto;
  image-rendering: pixelated;
  flex-shrink: 0;
  vertical-align: middle;
}

#skills-content .skill-icon-container {
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-shrink: 0;
}

/* Inline skill icons in terminal */
.skill-icon-inline {
  height: 14px;
  width: auto;
  image-rendering: pixelated;
  vertical-align: middle;
  margin: 0 2px;
  display: inline-block;
}

.terminal-fade {
  animation: terminalFade 0.35s ease-in-out;
}

@keyframes terminalFade {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  50% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

#skills-content .skill-level {
  color: var(--dim);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 68px;
  white-space: nowrap;
}

#skills-content .skill-xp-container {
  position: relative;
  display: flex;
  align-items: center;
  text-align: right;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: visible;
  padding-right: 28px;
}

#skills-content .xp-gain {
  position: absolute;
  right: 0;
  bottom: 0;
  color: #45df34;
  font-size: 10px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: none;
  text-shadow: 
    -1px -1px 0 #000000,
    1px -1px 0 rgb(0, 0, 0),
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 -1px 0 #000000,
    0 1px 0 #000000,
    -1px 0 0 #000000,
    1px 0 0 #000000;
  z-index: 2;
}

#skills-content .level-up-gain {
  position: absolute;
  right: 0;
  bottom: -14px;
  color: #b971ff;
  font-size: 10px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: none;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 -1px 0 #000000,
    0 1px 0 #000000,
    -1px 0 0 #000000,
    1px 0 0 #000000;
  z-index: 2;
}

#skills-content .xp-gain-animate {
  animation: xpGainFloat 2s ease-out forwards;
}

#skills-content .level-up-gain-animate {
  animation: xpGainFloat 2s ease-out forwards;
}

@keyframes xpGainFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0);
  }
  15% {
    opacity: 1;
    transform: translateY(-8px) translateX(0);
  }
  85% {
    opacity: 1;
    transform: translateY(-20px) translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-28px) translateX(0);
  }
}

/* Item gain animation next to Inventory button */
.item-gain-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10000; /* Very high z-index to appear above everything */
  overflow: visible;
}

.item-gain {
  position: absolute;
  color: #d4af37; /* Gold */
  font-size: 11px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: none;
  z-index: 10001;
}

.item-gain-animate {
  animation: itemGainFloat 2s ease-out forwards;
}

/* Item slot animation when item appears in empty slot */
#inventory-content .inventory-item.item-new {
  opacity: 0;
  transform: scale(0.8);
}

#inventory-content .inventory-item.item-new-animate {
  animation: itemSlotAppear 0.5s ease-out forwards;
}

@keyframes itemSlotAppear {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes itemGainFloat {
  0% {
    opacity: 0;
    transform: translateY(0) translateX(0);
  }
  15% {
    opacity: 1;
    transform: translateY(-8px) translateX(0);
  }
  85% {
    opacity: 1;
    transform: translateY(-20px) translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-28px) translateX(0);
  }
}

/* Trade window animations */
.trade-item-new {
  opacity: 0;
  transform: scale(0.8);
}

.trade-item-appear {
  animation: tradeItemAppear 0.6s ease-out;
}

@keyframes tradeItemAppear {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Log */
#log {
  white-space: pre-wrap;
  flex: 1;
  min-height: 0;
  padding: 16px;
  background: var(--terminal-bg);
  border-radius: 12px;
  border: 1px solid var(--terminal-border);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.45);
}

#log.log-drop-target {
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.25);
  background: rgba(70, 70, 70, 0.82);
}

#log .log-drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(24, 24, 24, 0.65);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  letter-spacing: 0.08em;
  pointer-events: none;
  text-align: center;
}

/* Log Entries */
.log-entry {
  position: relative;
  padding: 6px 12px;
  margin: 0;
  border-left: 2px solid transparent;
  border-bottom: 1px solid rgba(0, 0, 0, 0.22);
  transition: background 0.2s ease, border-left-color 0.2s ease;
}

.log-entry:last-of-type {
  border-bottom: none;
}

.log-entry--alt {
  background: var(--terminal-alt);
}

.log-entry:not([data-floor-message]):hover {
  background: rgba(212, 175, 55, 0.08);
  border-left-color: rgba(212, 175, 55, 0.6);
}

/* Message Animations */
@keyframes levelUpFloat {
  0% {
    opacity: 0;
    transform: translateY(6px);
  }
  20% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0.15;
    transform: translateY(-6px);
  }
}

@keyframes whisperGlow {
  0%, 100% {
    text-shadow:
      -1px -1px 0 #000000,
      1px -1px 0 #000000,
      -1px 1px 0 #000000,
      1px 1px 0 #000000,
      0 -1px 0 #000000,
      0 1px 0 #000000,
      -1px 0 0 #000000,
      1px 0 0 #000000;
  }
  50% {
    text-shadow:
      0 0 6px var(--whisper-glow),
      0 0 12px rgba(92, 228, 255, 0.55);
  }
}

@keyframes factionPulse {
  0%, 100% {
    opacity: 0.7;
    letter-spacing: 0.02em;
  }
  50% {
    opacity: 1;
    letter-spacing: 0.08em;
  }
}

/* Message Types */
.sys {
  color: var(--accent-secondary);
}

.sys.italic {
  font-style: italic;
}

.you {
  color: var(--accent);
}

.room {
  color: #f4a460;
}

.success {
  color: #d4af37; /* Gold for success messages */
}

.xp {
  color: rgba(185, 246, 238, 0.9);
}

.equipment {
  color: #6b6b6b; /* Dark grey for equipment actions */
}

.failure {
  color: #c97a5e; /* Brown-red for failure messages */
}

.whisper {
  color: #5ce4ff;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 -1px 0 #000000,
    0 1px 0 #000000,
    -1px 0 0 #000000,
    1px 0 0 #000000;
  animation: whisperGlow 2.3s ease-in-out 1;
}

.faction {
  color: #f7c778;
  animation: factionPulse 1.8s ease-in-out 1;
}

.system.level-up,
.level-up {
  color: #b971ff;
  text-shadow:
    -1px -1px 0 #000000,
    1px -1px 0 #000000,
    -1px 1px 0 #000000,
    1px 1px 0 #000000,
    0 -1px 0 #000000,
    0 1px 0 #000000,
    -1px 0 0 #000000,
    1px 0 0 #000000;
  animation: levelUpFloat 1.6s ease-out 1;
}

/* Player Names & Mentions */
.player-name {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.player-name:hover {
  opacity: 0.8;
}

.player-name.mention {
  color: #f4a460;
}

.player-tooltip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* Ground Item Styling */
.ground-item-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.ground-item-name {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  color: var(--accent);
  transition: color 0.2s;
}

.ground-item-name:hover {
  color: #f4a460; /* Amber on hover */
}

/* Form */
form {
  display: flex;
  gap: 8px;
  flex-shrink: 0;

}

input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  background: #3d2914;
  color: var(--fg);
  border: 1px solid #5c4a35;
}

button {
  padding: 10px 14px;
  border-radius: 10px;
  background: #4a3420;
  color: var(--fg);
  border: 1px solid #6b5a4a;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.1);
}

/* Hint */
.hint {
  color: var(--dim);
  margin-top: 8px;
  flex-shrink: 0;
  font-size: 12px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* Equipment Grid Layout */
.equipment-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
  padding: 4px;
}

.equipment-slot {
  min-height: 50px;
  padding: 6px 8px;
  border-radius: 4px;
  border: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(61, 41, 20, 0.6);
  transition: background-color 0.2s ease, border-color 0.2s ease, border-width 0.2s ease;
}

.equipment-slot-empty {
  opacity: 0.4;
  background: rgba(61, 41, 20, 0.3);
  border: none !important;
  cursor: text;
}

.equipment-slot-empty:hover {
  opacity: 0.7 !important;
  background: rgba(61, 41, 20, 0.5) !important;
}

.equipment-slot.equipment-item {
  background: rgba(212, 175, 55, 0.12);
  border: 2px solid #5c4a35;
  cursor: text;
}

.equipment-slot.equipment-item:hover {
  background: rgba(212, 175, 55, 0.35) !important;
  border-color: #d4af37 !important;
  border-width: 2px !important;
}

.equipment-slot-label {
  font-size: 11px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
  font-weight: bold;
}

.equipment-item-name {
  font-size: 12px;
  color: var(--fg);
  font-weight: 500;
  word-break: break-word;
  line-height: 1.2;
}

.equipment-empty-text {
  font-size: 11px;
  color: var(--dim);
  font-style: italic;
  opacity: 0.6;
}

.equipment-bonuses {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(136, 192, 208, 0.2);
}

.equipment-bonuses-title {
  font-size: 11px;
  font-weight: bold;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.equipment-bonuses-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.equipment-bonuses-category {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.equipment-bonuses-category-title {
  font-size: 10px;
  font-weight: bold;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.equipment-bonus-line {
  font-size: 11px;
  display: flex;
  justify-content: space-between;
  color: var(--fg);
}

.bonus-label {
  color: var(--dim);
}

.bonus-value {
  color: var(--fg);
  font-weight: 500;
}

