/* The House -- Dark theme (terrarium aesthetic) */

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

body {
  background: #0a0a0a;
  color: #e0e0e0;
  font-family: monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 16px;
}

h1 {
  font-size: 14px;
  font-weight: normal;
  color: #555;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

#hud {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
  height: 18px;
}

#canvas-wrap {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: crosshair;
  image-rendering: auto;
}

#ui-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 10;
}

/* Info panel */
.info-panel {
  position: absolute;
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 10px 14px;
  font-family: monospace;
  font-size: 12px;
  color: #ccc;
  pointer-events: auto;
  min-width: 160px;
  z-index: 11;
}

.info-emoji {
  font-size: 28px;
  margin-bottom: 4px;
}

.info-name {
  font-size: 14px;
  color: #e0e0e0;
  font-weight: bold;
  margin-bottom: 2px;
}

.info-type {
  color: #888;
  margin-bottom: 6px;
}

.info-row {
  margin-bottom: 2px;
}

.info-row span {
  color: #666;
}

.info-action {
  margin-top: 8px;
  color: #c66;
  cursor: pointer;
}

.info-action:hover {
  color: #f88;
}

.info-hint {
  margin-top: 6px;
  font-style: italic;
  color: #555;
  font-size: 11px;
}

/* Emoji picker */
.emoji-picker {
  position: absolute;
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid #333;
  border-radius: 4px;
  padding: 8px;
  pointer-events: auto;
  z-index: 11;
}

.picker-title {
  font-family: monospace;
  font-size: 11px;
  color: #666;
  margin-bottom: 6px;
  text-align: center;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 4px;
}

.picker-cell {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: #111;
  border: 1px solid #222;
  border-radius: 3px;
  cursor: pointer;
}

.picker-cell:hover {
  background: #1a1a2a;
  border-color: #444;
}

/* Room navigation (single-room mobile mode) */
#room-nav {
  display: none; /* shown via JS when mode=single */
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}

#nav-label {
  font-family: monospace;
  font-size: 13px;
  color: #888;
  min-width: 100px;
  text-align: center;
}

.nav-btn {
  width: 44px;
  height: 44px;
  background: #111;
  color: #ccc;
  border: 1px solid #333;
  border-radius: 4px;
  font-family: monospace;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover:not(:disabled) {
  background: #1a1a2a;
  border-color: #555;
}

.nav-btn:disabled {
  color: #333;
  cursor: default;
  border-color: #1a1a1a;
}

/* Naming modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 24px 32px;
  text-align: center;
  font-family: monospace;
  min-width: 220px;
}

.modal-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.modal-label {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
}

.modal-input {
  display: block;
  width: 100%;
  background: #111;
  border: 1px solid #444;
  border-radius: 4px;
  color: #e0e0e0;
  font-family: monospace;
  font-size: 16px;
  padding: 8px 10px;
  text-align: center;
  outline: none;
  margin-bottom: 12px;
}

.modal-input:focus {
  border-color: #666;
}

.modal-btn {
  background: #222;
  border: 1px solid #444;
  border-radius: 4px;
  color: #ccc;
  font-family: monospace;
  font-size: 14px;
  padding: 6px 24px;
  cursor: pointer;
}

.modal-btn:hover {
  background: #2a2a3a;
  border-color: #666;
}

/* Creature modal */
.creature-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.creature-modal {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 20px 24px;
  font-family: monospace;
  min-width: 240px;
  max-width: 320px;
}

.creature-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.creature-modal-emoji {
  font-size: 36px;
  line-height: 1;
}

.creature-modal-name {
  font-size: 16px;
  color: #e0e0e0;
  font-weight: bold;
}

.creature-modal-species {
  font-size: 11px;
  color: #555;
  margin-top: 2px;
}

.creature-modal-rename {
  font-size: 11px;
  color: #c66;
  cursor: pointer;
  margin-left: 8px;
}

.creature-modal-rename:hover {
  color: #f88;
}

.creature-modal-divider {
  border: none;
  border-top: 1px solid #222;
  margin: 10px 0;
}

.creature-modal-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  margin-bottom: 4px;
}

.creature-modal-row-label {
  color: #555;
}

.creature-modal-row-value {
  color: #ccc;
}

.drive-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}

.drive-label {
  color: #555;
  width: 60px;
  flex-shrink: 0;
}

.drive-track {
  flex: 1;
  height: 6px;
  background: #222;
  border-radius: 3px;
  overflow: hidden;
}

.drive-fill {
  height: 100%;
  border-radius: 3px;
}

.creature-modal-personality .creature-modal-row-value {
  color: #a8a;
  font-style: italic;
}

.creature-modal-fav-label {
  font-size: 11px;
  color: #555;
  margin-bottom: 4px;
}

.creature-modal-fav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.creature-modal-fav-item {
  font-size: 12px;
  color: #ccc;
  background: #222;
  padding: 2px 8px;
  border-radius: 3px;
}

/* Interests in creature modal */
.creature-modal-interests {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.creature-modal-interest-item {
  font-size: 11px;
  color: #ca8;
  background: #1a1a0a;
  border: 1px solid #332a1a;
  padding: 2px 8px;
  border-radius: 3px;
}

.interest-strength {
  color: #665;
  font-size: 10px;
}

/* Journal in creature modal */
.creature-modal-journal {
  margin-bottom: 4px;
}

.journal-entry {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  font-size: 11px;
  line-height: 1.3;
}

.journal-time {
  color: #444;
  flex-shrink: 0;
  font-size: 10px;
}

.journal-text {
  color: #998;
  font-style: italic;
}

/* Drives HUD (main view) */
#drives-hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  max-width: 400px;
  width: 100%;
  margin: 10px auto 0;
  font-family: monospace;
  font-size: 11px;
}

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

.dhud-label {
  color: #555;
  width: 56px;
  flex-shrink: 0;
}

.dhud-track {
  flex: 1;
  height: 4px;
  background: #222;
  border-radius: 2px;
  overflow: hidden;
}

.dhud-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.dhud-fill[data-drive="hunger"]   { background: #c66; }
.dhud-fill[data-drive="curiosity"]{ background: #6ac; }
.dhud-fill[data-drive="comfort"]  { background: #a6c; }
.dhud-fill[data-drive="energy"]   { background: #ca6; }

/* Care bar (main view) */
#care-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  max-width: 400px;
  width: 100%;
  margin: 8px auto 0;
}

.care-main-btn {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #aaa;
  font-family: monospace;
  font-size: 12px;
  padding: 8px 0;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.care-main-btn:hover {
  background: #222;
  border-color: #555;
  color: #ddd;
}

.care-main-btn:active {
  background: #2a2a3a;
}

.creature-modal-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: #444;
  font-style: italic;
}

/* Activity log */
.log-toggle-btn {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #888;
  font-family: monospace;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  z-index: 20;
}

.log-toggle-btn:hover {
  background: #222;
  border-color: #555;
  color: #ccc;
}

.log-panel {
  position: fixed;
  bottom: 40px;
  right: 12px;
  width: 280px;
  max-height: 60vh;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  font-family: monospace;
  font-size: 11px;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #222;
  color: #666;
  flex-shrink: 0;
}

.log-close-btn {
  background: none;
  border: none;
  color: #555;
  font-family: monospace;
  font-size: 12px;
  cursor: pointer;
  padding: 0 4px;
}

.log-close-btn:hover {
  color: #ccc;
}

.log-list {
  overflow-y: auto;
  padding: 4px 0;
  flex: 1;
}

.log-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  line-height: 1.4;
}

.log-time {
  color: #444;
  flex-shrink: 0;
  font-size: 10px;
}

.log-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.log-text {
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Playdate button */
.playdate-btn {
  background: #1a2a1a;
  border: 1px solid #3a5a3a;
  border-radius: 4px;
  color: #6a8;
  font-family: monospace;
  font-size: 12px;
  padding: 8px 24px;
  cursor: pointer;
  margin-top: 10px;
  transition: background 0.15s, border-color 0.15s;
}

.playdate-btn:hover {
  background: #2a3a2a;
  border-color: #5a7a5a;
  color: #8ca;
}

/* Playdate HUD */
.playdate-hud {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 500px;
  width: 100%;
  margin: 10px auto 0;
  font-family: monospace;
  font-size: 12px;
  color: #888;
  padding: 8px 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.playdate-location {
  color: #6a8;
  font-weight: bold;
}

.playdate-guest-info {
  color: #888;
}

.playdate-guest-name {
  color: #6a8;
}

.playdate-timer {
  color: #555;
  min-width: 40px;
  text-align: center;
}

.playdate-end-btn {
  background: #2a1a1a;
  border: 1px solid #5a3a3a;
  border-radius: 4px;
  color: #c88;
  font-family: monospace;
  font-size: 11px;
  padding: 4px 12px;
  cursor: pointer;
}

.playdate-end-btn:hover {
  background: #3a2a2a;
  border-color: #7a4a4a;
  color: #eaa;
}

/* Location picker */
.location-picker {
  min-width: 260px;
}

.location-grid {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  justify-content: center;
}

.location-option {
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 12px 16px;
  cursor: pointer;
  text-align: center;
  font-family: monospace;
  color: #ccc;
  transition: background 0.15s, border-color 0.15s;
}

.location-option:hover {
  background: #1a2a1a;
  border-color: #5a7a5a;
}

.location-emoji {
  display: block;
  font-size: 28px;
  margin-bottom: 4px;
}

.location-name {
  font-size: 11px;
  color: #888;
}

/* Invite / share-back modal */
.invite-box, .shareback-box {
  min-width: 300px;
  max-width: 90vw;
}

.invite-link, .shareback-link {
  font-size: 11px !important;
  text-align: left !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invite-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

/* Guest badge */
.guest-badge {
  font-size: 10px;
  color: #1a1a1a;
  background: #6a8;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 8px;
  vertical-align: middle;
}

.guest-modal {
  border-color: #3a5a3a;
}

/* Session code modal */
.session-box, .join-box {
  min-width: 280px;
  max-width: 90vw;
}

.session-code {
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 6px;
  color: #6a8;
  padding: 12px 0 8px;
  text-align: center;
}

.session-link {
  font-size: 11px !important;
  text-align: left !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-status {
  font-size: 11px;
  color: #555;
  margin-bottom: 10px;
  text-align: center;
}

.session-status.connected {
  color: #6a8;
}

/* Connection banner */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 6px 12px;
  font-family: monospace;
  font-size: 12px;
  text-align: center;
  z-index: 200;
  background: #2a1a1a;
  color: #c88;
  border-bottom: 1px solid #5a3a3a;
}

.connection-banner.reconnected {
  background: #1a2a1a;
  color: #6a8;
  border-bottom-color: #3a5a3a;
}

/* Playdate offline label */
.playdate-btn .offline-label {
  font-size: 10px;
  color: #666;
  margin-left: 4px;
}

/* Settings button */
.settings-toggle-btn {
  position: fixed;
  bottom: 12px;
  left: 12px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: #888;
  font-family: monospace;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  z-index: 20;
}

.settings-toggle-btn:hover {
  background: #222;
  border-color: #555;
  color: #ccc;
}

/* Settings modal */
.settings-box {
  min-width: 300px;
  max-width: 90vw;
  text-align: left;
}

.settings-section {
  margin-bottom: 12px;
}

.settings-label {
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
}

.settings-hint {
  color: #444;
  font-size: 10px;
}

.settings-toggle-row {
  display: flex;
  gap: 4px;
}

.settings-toggle {
  flex: 1;
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  color: #888;
  font-family: monospace;
  font-size: 12px;
  padding: 6px 0;
  cursor: pointer;
}

.settings-toggle.active {
  background: #1a2a1a;
  border-color: #3a5a3a;
  color: #6a8;
}

.settings-toggle:hover:not(.active) {
  background: #1a1a2a;
  border-color: #444;
}

.settings-key-row {
  display: flex;
  gap: 4px;
}

.settings-key {
  flex: 1;
  text-align: left !important;
  font-size: 12px !important;
  margin-bottom: 0 !important;
}

.settings-eye {
  background: #111;
  border: 1px solid #333;
  border-radius: 4px;
  color: #888;
  font-family: monospace;
  font-size: 10px;
  padding: 0 8px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-eye:hover {
  background: #1a1a2a;
  border-color: #444;
}

.settings-model {
  text-align: left !important;
  font-size: 12px !important;
}

.settings-slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-slider {
  flex: 1;
  accent-color: #6a8;
}

.settings-slider-val {
  font-size: 12px;
  color: #888;
  min-width: 50px;
  text-align: right;
}

.settings-test-btn {
  font-size: 11px !important;
  padding: 4px 12px !important;
}

.settings-test-result {
  font-size: 11px;
  color: #888;
  margin-left: 8px;
}

.settings-usage-text {
  font-size: 11px;
  color: #888;
}

.settings-explain {
  font-size: 10px;
  color: #444;
  line-height: 1.4;
}

.settings-mode-row {
  margin-bottom: 4px;
}

.settings-builtin-info {
  margin-bottom: 8px;
}

.settings-builtin-info .settings-explain {
  color: #6a8;
  font-size: 11px;
}

.settings-custom-section {
  border-top: 1px solid #222;
  padding-top: 8px;
}

.settings-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 4px;
}

/* Mobile adjustments */
@media (max-width: 600px) {
  body {
    padding: 8px;
  }

  #canvas-wrap {
    width: 100%;
  }

  #drives-hud {
    max-width: 100%;
  }

  #care-bar {
    max-width: 100%;
  }

  .picker-grid {
    grid-template-columns: repeat(3, 52px);
    gap: 6px;
  }

  .picker-cell {
    width: 52px;
    height: 52px;
    font-size: 28px;
  }

  .info-panel {
    max-width: 80vw;
  }

  .playdate-hud {
    max-width: 100%;
    font-size: 11px;
    gap: 8px;
  }

  .location-grid {
    flex-direction: column;
  }

  .location-option {
    padding: 10px 12px;
  }

  .invite-box, .shareback-box {
    min-width: auto;
    width: 90vw;
  }

  .session-box, .join-box {
    min-width: auto;
    width: 90vw;
  }

  .session-code {
    font-size: 24px;
    letter-spacing: 4px;
  }
}
