/* Lobster House -- Dark terrarium theme, mobile-first */

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #111;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #222;
  --border-subtle: #222;
  --border-medium: #333;
  --border-strong: #444;
  --text-primary: #e0e0e0;
  --text-secondary: #ccc;
  --text-muted: #888;
  --text-dim: #555;
  --text-faint: #444;
  --accent-green: #6a8;
  --accent-green-bg: #1a2a1a;
  --accent-green-border: #3a5a3a;
  --accent-red: #c66;
  --accent-red-hover: #f88;
  --accent-teal: #6cc;
  --accent-amber: #ca8;
  --drive-hunger: #c66;
  --drive-curiosity: #6ac;
  --drive-comfort: #a6c;
  --drive-energy: #ca6;
}

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

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px 8px 80px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}

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

#app-version {
  font-size: 10px;
  color: #333;
  letter-spacing: 0;
}

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

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

/* Status bar */
#status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
  padding: 6px 12px;
  width: 100%;
  max-width: 480px;
  margin-top: 6px;
  background: #111;
  border: 1px solid #222;
  border-radius: 4px;
}

#status-name {
  color: #ccc;
  font-weight: bold;
}

#status-sep, #status-sep2 {
  color: #333;
}

#status-mood {
  color: #6cc;
}

#trial-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
}

#trial-badge.trial-active {
  background: #2a2a1a;
  border: 1px solid #5a5a3a;
  color: #ca8;
}

#trial-badge.trial-warning {
  background: #2a1a1a;
  border: 1px solid #5a3a3a;
  color: #c66;
}

#trial-badge.trial-expired {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #888;
}

/* Trial expired modal */
.trial-expired-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
  animation: modal-overlay-in 0.2s ease;
}

.trial-expired-box {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 24px 28px;
  text-align: center;
  font-family: monospace;
  max-width: 300px;
  animation: modal-scale-in 0.2s ease;
}

.trial-expired-box .modal-label {
  margin-bottom: 8px;
}

.trial-expired-box .modal-btn {
  margin-top: 12px;
}

/* Drives HUD */
#drives-hud {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  max-width: 480px;
  width: 100%;
  margin: 6px 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; }

/* Activity / chat log (inline, scrollable) */
.log-panel {
  width: 100%;
  max-width: 480px;
  max-height: 150px;
  min-height: 60px;
  background: #111;
  border: 1px solid #222;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  margin: 6px auto 0;
  overflow: hidden;
}

.log-list {
  overflow-y: auto;
  padding: 4px 0;
  max-height: 148px;
}

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

/* Care bar (fixed bottom) */
#care-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.care-main-btn {
  background: #111;
  border: none;
  border-right: 1px solid #222;
  color: #aaa;
  font-family: monospace;
  font-size: 13px;
  padding: 14px 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.care-main-btn:last-child {
  border-right: none;
}

.care-main-btn:hover {
  background: #1a1a2a;
  color: #ddd;
}

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

/* Toast notifications */
#toast-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 200;
  padding-top: 8px;
}

.toast {
  background: rgba(26, 42, 26, 0.95);
  border: 1px solid #3a5a3a;
  border-radius: 4px;
  color: #8ca;
  font-family: monospace;
  font-size: 12px;
  padding: 8px 16px;
  margin-bottom: 4px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast-visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-exit {
  opacity: 0;
  transform: translateY(-10px);
}

/* Care button pulse */
.care-btn-pulse {
  animation: care-pulse 0.3s ease;
}

@keyframes care-pulse {
  0% { background: #111; }
  50% { background: #1a2a2a; }
  100% { background: #111; }
}

/* UI overlay */
#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;
  animation: panel-fade-in 0.2s ease;
}

@keyframes panel-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* 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;
  animation: panel-fade-in 0.2s ease;
}

.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, 52px);
  gap: 4px;
}

.picker-cell {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  cursor: pointer;
}

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

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: modal-overlay-in 0.2s ease;
}

.modal-box {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 24px 28px;
  text-align: center;
  font-family: monospace;
  min-width: 220px;
  max-width: 90vw;
  animation: modal-scale-in 0.2s ease;
}

@keyframes modal-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modal-scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

/* Species picker */
.species-picker-box {
  min-width: 280px;
}

.species-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

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

.species-option:hover:not(:disabled) {
  background: #1a2a2a;
  border-color: #5a7a7a;
}

.species-locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.species-emoji {
  display: block;
  font-size: 32px;
  margin-bottom: 4px;
}

.species-name {
  display: block;
  font-size: 13px;
  color: #ccc;
  margin-bottom: 2px;
}

.species-desc {
  display: block;
  font-size: 10px;
  color: #666;
}

/* Creature modal */
.creature-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: modal-overlay-in 0.2s ease;
}

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

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

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

.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; }
.journal-truncated { cursor: pointer; }
.journal-truncated:hover .journal-text { color: #bba; }

.insight-row {
  font-size: 11px;
  color: #998;
  margin-bottom: 3px;
}

.insight-label {
  color: #665;
}

.creature-export-bio-btn {
  font-size: 11px !important;
  padding: 4px 12px !important;
}

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

/* Settings button */
.settings-toggle-btn {
  position: fixed;
  bottom: 52px;
  right: 8px;
  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;
}

/* Cloud save auth section */
.settings-auth-section {
  border-bottom: 1px solid #222;
  padding-bottom: 10px;
  margin-bottom: 12px;
}

.settings-auth-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.settings-auth-name {
  font-size: 12px;
  color: #ccc;
}

.settings-signin-btn {
  font-size: 12px !important;
  padding: 6px 16px !important;
  margin-bottom: 6px;
}

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

.settings-auth-explain {
  margin-top: 4px;
}

.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; }
.settings-help-link { text-align: center; margin-top: 12px; font-size: 11px; }
.settings-help-link a { color: var(--text-muted); text-decoration: none; }
.settings-help-link a:hover { color: var(--text-secondary); text-decoration: underline; }

/* Premium tier badges */
.settings-tier-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 3px;
  margin: 6px 0 4px;
  font-family: monospace;
}

.settings-tier-premium {
  background: #1a2a1a;
  border: 1px solid #3a5a3a;
  color: #6a8;
}

.settings-tier-trial {
  background: #2a2a1a;
  border: 1px solid #5a5a3a;
  color: #ca8;
}

.settings-tier-free {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #888;
}

/* Upgrade button */
.settings-upgrade-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-size: 12px !important;
  padding: 8px 16px !important;
  background: #1a2a1a;
  border-color: #3a5a3a;
  color: #6a8;
}

.settings-upgrade-btn:hover {
  background: #2a3a2a;
  border-color: #4a6a4a;
  color: #8ca;
}

.settings-upgrade-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Creature list */
.settings-creature-list {
  margin: 8px 0;
}

.creature-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #222;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
}

.creature-list-item:hover {
  border-color: #333;
}

.creature-list-active {
  border-color: #3a5a3a;
  background: #111a11;
}

.creature-list-emoji {
  font-size: 18px;
  flex-shrink: 0;
}

.creature-list-name {
  color: #ccc;
  flex: 1;
}

.creature-list-species {
  color: #555;
  font-size: 10px;
  flex-shrink: 0;
}

.creature-list-badge {
  font-size: 10px;
  color: #6a8;
  padding: 2px 6px;
  border: 1px solid #3a5a3a;
  border-radius: 3px;
  flex-shrink: 0;
}

.creature-list-switch-btn {
  font-size: 10px !important;
  padding: 2px 8px !important;
  flex-shrink: 0;
}

.creature-list-delete-btn {
  font-size: 10px !important;
  padding: 2px 6px !important;
  color: #c66 !important;
  border-color: #633 !important;
  flex-shrink: 0;
}

.creature-list-delete-btn:hover {
  background: #2a1a1a;
  color: #f88 !important;
}

.settings-new-creature-btn {
  display: block;
  width: 100%;
  margin-top: 4px;
  font-size: 11px !important;
  padding: 6px 12px !important;
}

/* Drive pct in creature modal */
.drive-pct {
  color: #555;
  width: 30px;
  text-align: right;
  flex-shrink: 0;
}

/* Tutorial hints */
.tutorial-hint {
  max-width: 480px;
  width: 100%;
  margin: 6px auto 0;
  padding: 8px 12px;
  background: #1a2a2a;
  border: 1px solid #2a4a4a;
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  color: #8ab;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.tutorial-hint:hover {
  border-color: #3a5a5a;
}

.tutorial-hint-dismiss {
  color: #556;
  font-size: 10px;
  flex-shrink: 0;
}

/* Desktop: larger canvas, side log */
@media (min-width: 640px) {
  body {
    padding: 16px 16px 80px;
  }

  h1 {
    font-size: 14px;
    margin-bottom: 8px;
  }

  #canvas-wrap {
    max-width: 520px;
  }

  #status-bar {
    margin-top: 8px;
  }

  #drives-hud {
    margin-top: 8px;
  }

  .log-panel {
    max-height: 200px;
  }

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

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

  .species-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
