/* Cozy Pixel-Art Game Style System */
:root {
  --primary-color: #07070a;
  --panel-bg: #1c1d24;
  --panel-border: #4d4f5c;
  --accent-color: #ffe066;
  --text-color: #f1f2f6;
  --green: #2ecc71;
  --red: #e74c3c;
  --blue: #3498db;
  --font-pixel: 'Press Start 2P', monospace;
  --font-terminal: 'VT323', monospace;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  margin: 0;
  padding: 0;
  background-color: #050508;
  color: var(--text-color);
  font-family: var(--font-pixel);
  font-size: 10px;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
}

/* App & Game Container */
#app {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 960px;
  height: 100%;
  max-height: 540px;
  aspect-ratio: 16 / 9;
  background-color: #2c3e50;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
  border: 4px solid #111;
  display: flex;
  justify-content: center;
  align-items: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT Screen Filter */
#crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.3s;
}

#game-wrapper.crt-effect::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: radial-gradient(circle, rgba(0,0,0,0) 60%, rgba(0,0,0,0.5) 100%);
  pointer-events: none;
  z-index: 101;
}

#game-wrapper:not(.crt-effect) #crt-overlay {
  opacity: 0;
}
#game-wrapper:not(.crt-effect)::after {
  display: none !important;
}

/* Pixel UI Panels */
.pixel-panel {
  position: absolute;
  background-color: var(--panel-bg);
  border: 4px solid #fff;
  border-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='M2 2h2v2H2zm2-2h4v2H4zm4 2h2v2H8zm2 2h2v4h-2zm-2 4h2v2H8zm-4 2h4v-2H4zm-2-2h2v2H2zm-2-2h2v-4H0zm2-2h8v8H2z' fill='%23ffffff'/%3E%3C/svg%3E") 4 repeat;
  box-shadow: 0 6px 0 rgba(0,0,0,0.4);
  padding: 12px;
  color: var(--text-color);
  z-index: 10;
  box-sizing: border-box;
}

.pixel-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--panel-border);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.pixel-panel-header h3 {
  margin: 0;
  font-size: 11px;
  color: var(--accent-color);
  letter-spacing: 1px;
}

/* Pixel Buttons */
.pixel-btn {
  background-color: #2b2d35;
  color: var(--text-color);
  font-family: var(--font-pixel);
  font-size: 8px;
  padding: 6px 10px;
  border: 2px solid #fff;
  cursor: pointer;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.pixel-btn:hover {
  background-color: var(--accent-color);
  color: #111;
  border-color: #ffe066;
}

.pixel-btn:active {
  transform: translateY(2px);
}

.pixel-btn-close {
  background: var(--red);
  color: white;
  border: 2px solid #fff;
  font-family: var(--font-pixel);
  font-size: 8px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  outline: none;
}

.pixel-btn-close:hover {
  background: #ff6b6b;
}

/* Dialog Box */
#dialog-box {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 700px;
  min-height: 80px;
  display: flex;
  gap: 16px;
  align-items: center;
  z-index: 50;
  transition: opacity 0.2s;
}

.dialog-speaker-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background-color: #111;
  border: 2px solid var(--panel-border);
  image-rendering: pixelated;
}

.dialog-content {
  flex-grow: 1;
  position: relative;
}

#dialog-speaker-name {
  margin: 0 0 6px 0;
  font-size: 9px;
  color: var(--accent-color);
}

#dialog-text {
  margin: 0;
  font-size: 13px;
  font-family: var(--font-terminal);
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.dialog-arrow {
  position: absolute;
  right: 0;
  bottom: -4px;
  font-size: 8px;
  animation: bounce 0.6s infinite alternate;
  color: var(--accent-color);
}

/* Options/Settings bar */
#options-bar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  z-index: 90;
}

/* Help Panel Overlay */
#help-overlay {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80%;
  max-width: 450px;
  z-index: 95;
}

.pixel-panel-content {
  font-family: var(--font-terminal);
  font-size: 14px;
  line-height: 1.4;
}

.pixel-panel-content p {
  margin: 6px 0;
}

/* Home Server Dashboard */
#dashboard-overlay {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  height: 80%;
  max-height: 400px;
  display: flex;
  flex-direction: column;
  z-index: 80;
}

.dashboard-body {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--font-terminal);
}

.system-stats {
  background-color: #111;
  border: 1px solid var(--panel-border);
  padding: 6px 12px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #888;
}

.green-text {
  color: var(--green);
}

.service-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  overflow-y: auto;
}

.service-card {
  padding: 10px;
  border: 2px solid var(--panel-border);
  background-color: #222530;
  display: flex;
  align-items: center;
  text-align: left;
  border-radius: 0;
  color: var(--text-color);
  font-family: var(--font-terminal);
  font-size: 15px;
  gap: 12px;
}

.service-card:hover {
  border-color: var(--green);
  background-color: #1b2f20;
  color: #fff;
}

.service-icon {
  font-size: 20px;
  width: 24px;
  display: inline-block;
  text-align: center;
}

.service-name {
  flex-grow: 1;
  font-weight: bold;
}

.service-status {
  font-size: 11px;
  font-family: var(--font-pixel);
}

.service-status.online {
  color: var(--green);
}

.terminal-footer {
  background-color: #0c0d12;
  border-top: 2px solid var(--panel-border);
  margin-top: 12px;
  padding: 6px;
  color: #888;
  font-size: 13px;
}

.blink-cursor {
  margin: 0;
  animation: blink 1s step-end infinite;
}

/* Minigames Overlay Layouts */
#dino-game-overlay, #garden-game-overlay {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 450px;
  z-index: 85;
}

.minigame-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background-color: #111;
  padding: 12px;
  border: 2px solid var(--panel-border);
}

#dino-canvas, #garden-canvas {
  background-color: #f7f7f7;
  border: 2px solid var(--panel-border);
  max-width: 100%;
}

#garden-canvas {
  background-color: #87ceeb; /* Blue sky for garden */
}

.minigame-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--accent-color);
}

.minigame-instructions {
  font-family: var(--font-terminal);
  font-size: 13px;
  color: #888;
  text-align: center;
}

.garden-status {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

#water-bar-fill {
  display: inline-block;
  height: 12px;
  width: 100px;
  background-color: var(--blue);
  border: 1px solid #fff;
  transition: width 0.1s linear;
}

.garden-btn-row {
  margin-top: 6px;
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* Mobile Virtual Controls Overlay */
#mobile-controls {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: none; /* Shown via JS/CSS on touch devices */
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 70;
}

#mobile-controls button {
  pointer-events: auto;
  font-family: var(--font-pixel);
  background: rgba(43, 45, 53, 0.7);
  color: #fff;
  border: 3px solid #fff;
  border-radius: 6px;
  touch-action: manipulation;
}

#mobile-controls button:active {
  background: var(--accent-color);
  color: #111;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-row {
  display: flex;
  gap: 16px;
}

.dpad-btn {
  width: 36px;
  height: 36px;
  font-size: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.action-buttons {
  margin-bottom: 8px;
}

.action-btn {
  padding: 12px 18px;
  font-size: 8px;
  height: 48px;
}

/* Animations */
@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-4px); }
}

@keyframes blink {
  from, to { color: transparent }
  50% { color: var(--green); }
}

/* Responsive Scaling Rules */
@media (max-width: 768px) {
  body {
    font-size: 9px;
  }
  #game-wrapper {
    border: none;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    aspect-ratio: auto;
  }
  #dialog-box {
    bottom: 80px; /* Leave space for mobile buttons */
  }
  .service-grid {
    grid-template-columns: 1fr;
  }
}

/* Make sure mobile controls show up if touch-enabled or user is on mobile */
@media (pointer: coarse) {
  #mobile-controls {
    display: flex;
  }
  /* Push options bar down or make it smaller so it doesn't overlap */
  #options-bar button {
    padding: 4px 6px;
    font-size: 7px;
  }
}
