@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  overflow: hidden;
  background: #000;
  font-family: 'Press Start 2P', monospace;
  color: #ff981f;
  cursor: default;
}

#viewport {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* Stone border mixin */
.stone-border {
  border: 3px solid #3e3529;
  outline: 2px solid #1a1510;
  box-shadow:
    inset 0 0 0 1px #5a4d3a,
    0 2px 8px rgba(0,0,0,0.6);
}

/* UI Overlay */
#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

#ui-overlay > * {
  pointer-events: auto;
}

/* Top bar */
#top-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 20px;
  background: linear-gradient(180deg, #4a3c28 0%, #3a2e1e 100%);
  border: 3px solid #5a4d3a;
  outline: 2px solid #1a1510;
  padding: 8px 24px;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#site-name {
  font-size: 10px;
  color: #ffcc00;
  text-shadow: 1px 1px 0 #000;
  letter-spacing: 1px;
}

/* Date filter buttons */
#date-filter {
  display: flex;
  gap: 4px;
}

.filter-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 4px 8px;
  background: linear-gradient(180deg, #3a2e1e 0%, #2a2015 100%);
  color: #c0a875;
  border: 2px solid #5a4d3a;
  cursor: pointer;
  text-shadow: 1px 1px 0 #000;
  transition: all 0.15s;
}

.filter-btn:hover {
  background: linear-gradient(180deg, #5a4a32 0%, #4a3c28 100%);
  color: #ffcc00;
}

.filter-btn.active {
  background: linear-gradient(180deg, #6a5a3a 0%, #5a4a30 100%);
  color: #ffcc00;
  border-color: #ffcc00;
  box-shadow: 0 0 6px #ffcc0044;
}

#active-count {
  font-size: 9px;
  color: #00ff00;
  text-shadow: 1px 1px 0 #000;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Event action colors in chat */
.chat-msg .event-name {
  color: #ff9800;
}

.chat-msg .event-scroll { color: #4fc3f7; }
.chat-msg .event-click { color: #ff7043; }
.chat-msg .event-form { color: #ab47bc; }
.chat-msg .event-hover { color: #66bb6a; }

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #00ff00;
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* Timeline */
#timeline-panel {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%);
  width: 480px;
  background: linear-gradient(180deg, #4a3c28 0%, #3a2e1e 100%);
  border: 3px solid #5a4d3a;
  outline: 2px solid #1a1510;
  padding: 6px 12px 8px;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#timeline-dates {
  display: flex;
  justify-content: space-between;
  font-size: 7px;
  color: #c0a875;
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 4px;
}

#timeline-current-label {
  color: #ffcc00;
  font-size: 8px;
}

#timeline-track {
  position: relative;
  height: 10px;
  background: #2a2015;
  border: 2px solid #5a4d3a;
  border-radius: 1px;
  cursor: pointer;
}

#timeline-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff981f, #ffcc00);
  border-radius: 1px;
  transition: width 0.1s linear;
}

#timeline-scrubber {
  position: absolute;
  top: -3px;
  left: 0%;
  width: 8px;
  height: 16px;
  background: #ffcc00;
  border: 2px solid #3e3529;
  border-radius: 2px;
  transform: translateX(-50%);
  cursor: grab;
  box-shadow: 0 0 6px #ffcc0066;
  transition: left 0.1s linear;
}

#timeline-controls {
  display: flex;
  gap: 4px;
  margin-top: 5px;
  justify-content: center;
}

#timeline-controls .filter-btn {
  min-width: 32px;
  font-size: 8px;
}

/* Minimap */
#minimap-frame {
  position: absolute;
  top: 12px;
  right: 12px;
  background: linear-gradient(180deg, #4a3c28 0%, #3a2e1e 100%);
  border: 3px solid #5a4d3a;
  outline: 2px solid #1a1510;
  padding: 4px;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

#minimap {
  display: block;
  image-rendering: pixelated;
}

#minimap-label {
  text-align: center;
  font-size: 7px;
  color: #c0a875;
  padding: 3px 0 1px;
  text-shadow: 1px 1px 0 #000;
}

/* Stats panel */
#stats-panel {
  position: absolute;
  top: 200px;
  right: 12px;
  width: 176px;
  background: linear-gradient(180deg, #4a3c28 0%, #3a2e1e 100%);
  border: 3px solid #5a4d3a;
  outline: 2px solid #1a1510;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  overflow: hidden;
}

.panel-title {
  background: linear-gradient(180deg, #5a4a32 0%, #4a3c28 100%);
  padding: 6px 10px;
  font-size: 8px;
  color: #ffcc00;
  text-shadow: 1px 1px 0 #000;
  border-bottom: 2px solid #3e3529;
  text-align: center;
  letter-spacing: 1px;
}

#stats-content {
  padding: 6px 8px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 2px;
  font-size: 7px;
  border-bottom: 1px solid #3e352966;
}

.stat-row:last-child {
  border-bottom: none;
}

.stat-label {
  color: #c0a875;
  text-shadow: 1px 1px 0 #000;
}

.stat-value {
  color: #ffffff;
  text-shadow: 1px 1px 0 #000;
}

/* Chat / Activity log */
#chat-log {
  position: absolute;
  bottom: 12px;
  left: 12px;
  width: 320px;
  max-height: 200px;
  background: linear-gradient(180deg, #4a3c28 0%, #3a2e1e 100%);
  border: 3px solid #5a4d3a;
  outline: 2px solid #1a1510;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  overflow: hidden;
}

#chat-messages {
  padding: 6px 8px;
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #5a4d3a #3a2e1e;
}

#chat-messages::-webkit-scrollbar {
  width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
  background: #3a2e1e;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: #5a4d3a;
}

.chat-msg {
  font-size: 7px;
  padding: 3px 0;
  line-height: 1.6;
  border-bottom: 1px solid #3e352933;
  word-break: break-all;
}

.chat-msg:last-child {
  border-bottom: none;
}

.chat-msg .timestamp {
  color: #888;
}

.chat-msg .player-name {
  color: #00ffff;
}

.chat-msg .action {
  color: #c0a875;
}

.chat-msg .page-name {
  color: #ffcc00;
}

/* Room info popup */
#room-info {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 200px;
  background: linear-gradient(180deg, #4a3c28 0%, #3a2e1e 100%);
  border: 3px solid #5a4d3a;
  outline: 2px solid #1a1510;
  border-radius: 2px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  overflow: hidden;
  transition: opacity 0.2s;
}

#room-info.hidden {
  opacity: 0;
  pointer-events: none;
}

#room-info-content {
  padding: 8px;
  font-size: 7px;
  line-height: 1.8;
  color: #c0a875;
}

#room-info-content .info-value {
  color: #fff;
}

/* Loading screen */
#loading-screen {
  position: fixed;
  inset: 0;
  background: #1a1510;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.8s;
}

#loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

#loading-content {
  text-align: center;
}

#loading-title {
  font-size: 24px;
  color: #ffcc00;
  text-shadow: 2px 2px 0 #000, 0 0 20px #ff981f44;
  margin-bottom: 12px;
  letter-spacing: 2px;
}

#loading-subtitle {
  font-size: 9px;
  color: #c0a875;
  text-shadow: 1px 1px 0 #000;
  margin-bottom: 20px;
}

#loading-bar-outer {
  width: 280px;
  height: 16px;
  background: #3a2e1e;
  border: 2px solid #5a4d3a;
  outline: 1px solid #1a1510;
  margin: 0 auto 16px;
}

#loading-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #ff981f 0%, #cc7a18 100%);
  transition: width 0.3s;
}

#loading-tip {
  font-size: 7px;
  color: #888;
  text-shadow: 1px 1px 0 #000;
}

/* Responsive */
@media (max-width: 768px) {
  #chat-log { width: 240px; }
  #minimap-frame { display: none; }
  #stats-panel { width: 140px; }
}
