/* style.css - Tiny Living Village Cozy Pixel-Art Stylesheet */

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

:root {
  --bg-dark: #12141a;
  --panel-bg: rgba(28, 32, 44, 0.94);
  --panel-border: #454f63;
  --accent-gold: #ffca28;
  --accent-amber: #ffa000;
  --accent-green: #66bb6a;
  --accent-blue: #42a5f5;
  --accent-purple: #ab47bc;
  --accent-pink: #ec407a;
  --accent-red: #ef5350;
  --parchment: #fdf6e2;
  --parchment-border: #d4b26f;
  --text-main: #eceff1;
  --text-muted: #90a4ae;
  --font-retro: 'Press Start 2P', monospace, 'Courier New', Courier;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-retro);
  font-size: 11px;
  color: var(--text-main);
  image-rendering: pixelated;
}

#gameContainer {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

canvas#gameCanvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
}

canvas#gameCanvas:active {
  cursor: grabbing;
}

/* ---------------- Top HUD Bar ---------------- */
#topHud {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.hud-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-bg);
  padding: 8px 12px;
  border-radius: 8px;
  border: 2px solid var(--panel-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.res-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
}

.res-icon {
  font-size: 14px;
}

.time-group {
  display: flex;
  gap: 12px;
  font-size: 11px;
}

.hud-day {
  color: var(--accent-gold);
  font-weight: bold;
}

.hud-time {
  letter-spacing: 1px;
}

.weather-pill {
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 9px;
}

.controls-group {
  display: flex;
  gap: 6px;
}

.speed-buttons {
  display: flex;
  gap: 3px;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px;
  border-radius: 6px;
}

.hud-btn {
  background: #2a3142;
  border: 1px solid #4a5568;
  color: var(--text-main);
  padding: 5px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-btn:hover {
  background: #3b455c;
  border-color: var(--accent-gold);
}

.hud-btn.active {
  background: var(--accent-amber);
  color: #12141a;
  border-color: #ffd54f;
  font-weight: bold;
}

/* ---------------- Bottom Build Hotbar ---------------- */
.build-bar {
  position: absolute;
  bottom: 48px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-bg);
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid var(--panel-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.build-bar.hidden {
  transform: translateX(-50%) translateY(120px);
  opacity: 0;
  pointer-events: none;
}

.build-header {
  font-size: 9px;
  color: var(--accent-gold);
  margin-right: 6px;
  letter-spacing: 1px;
}

.build-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #222838;
  border: 2px solid #374158;
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
  min-width: 58px;
  transition: all 0.15s ease;
}

.build-btn:hover {
  background: #30394f;
  border-color: var(--accent-gold);
  transform: translateY(-2px);
}

.build-btn.active {
  background: #4a3810;
  border-color: var(--accent-gold);
  box-shadow: 0 0 10px rgba(255, 202, 40, 0.4);
}

.btn-demolish:hover {
  border-color: var(--accent-red);
}

.btn-demolish.active {
  background: #4a1818;
  border-color: var(--accent-red);
}

.b-icon {
  font-size: 16px;
}

/* ---------------- Bottom Event Ticker ---------------- */
#eventTickerContainer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 34px;
  background: rgba(18, 20, 26, 0.95);
  border-top: 2px solid var(--panel-border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  font-size: 9px;
  z-index: 10;
}

.ticker-label {
  color: var(--accent-amber);
  font-weight: bold;
  flex-shrink: 0;
}

.ticker-content {
  display: flex;
  gap: 20px;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-item {
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.ticker-item:hover {
  color: #ffffff;
  text-decoration: underline;
}

.ticker-item.type-conflict {
  color: #ff8a80;
}

.ticker-item.type-social {
  color: #b388ff;
}

.ticker-item.type-rumor {
  color: #ea80fc;
}

.ticker-item.type-event {
  color: #ffe57f;
}

/* ---------------- Villager Side Drawer ---------------- */
.villager-panel {
  position: absolute;
  top: 60px;
  right: 12px;
  bottom: 48px;
  width: 360px;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 6px 24px rgba(0, 0, 0, 0.6);
  z-index: 20;
  overflow: hidden;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.villager-panel.hidden {
  transform: translateX(400px);
  opacity: 0;
  pointer-events: none;
}

.panel-header {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 2px solid var(--panel-border);
}

#vPortraitCanvas {
  background: #1e2330;
  border: 2px solid #374158;
  border-radius: 6px;
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.panel-identity {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title-row h2 {
  font-size: 14px;
  color: var(--accent-gold);
}

.btn-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
}

.btn-close:hover {
  color: #ffffff;
}

.job-badge {
  display: inline-block;
  align-self: flex-start;
  background: #2e384d;
  color: #81d4fa;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 8px;
  letter-spacing: 1px;
}

.panel-bio {
  font-size: 8px;
  line-height: 1.4;
  color: var(--text-muted);
}

.activity-status {
  font-size: 8px;
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.status-indicator {
  font-size: 8px;
}

/* Needs Bars */
.needs-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.15);
  border-bottom: 1px solid var(--panel-border);
}

.need-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  margin-bottom: 3px;
}

.bar-track {
  height: 6px;
  background: #181b24;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #2e3547;
}

.bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}

.hunger-fill { background: var(--accent-green); }
.energy-fill { background: var(--accent-blue); }
.social-fill { background: var(--accent-purple); }
.mood-fill { background: var(--accent-pink); }

/* Panel Tabs */
.panel-tabs {
  display: flex;
  border-bottom: 2px solid var(--panel-border);
  background: #1c212e;
}

.panel-tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 4px;
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.panel-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.panel-tab-btn.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
  background: rgba(0, 0, 0, 0.2);
}

/* Panel Body */
.panel-body {
  flex-grow: 1;
  overflow-y: auto;
  padding: 10px;
}

.panel-body::-webkit-scrollbar {
  width: 5px;
}

.panel-body::-webkit-scrollbar-thumb {
  background: #374158;
  border-radius: 3px;
}

/* Relationship Cards */
.relationship-card {
  background: #202636;
  border: 1px solid #323b52;
  border-radius: 6px;
  padding: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.relationship-card:hover {
  background: #283045;
  border-color: var(--accent-gold);
}

.rel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.rel-avatar {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #ffffff55;
  flex-shrink: 0;
}

.rel-names {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.rel-name {
  font-size: 9px;
  font-weight: bold;
}

.rel-job {
  font-size: 7px;
  color: var(--text-muted);
  text-transform: capitalize;
}

.rel-badge {
  font-size: 7px;
  padding: 2px 5px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-friend { background: #1b5e20; color: #a5d6a7; }
.badge-feud { background: #b71c1c; color: #ffcdd2; }
.badge-warning { background: #e65100; color: #ffe0b2; }
.badge-neutral { background: #37474f; color: #cfd8dc; }

.rel-meters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meter-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 7px;
  color: var(--text-muted);
}

.meter-track {
  height: 4px;
  background: #141722;
  border-radius: 2px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
}

.affinity-fill { background: var(--accent-gold); }
.trust-fill { background: var(--accent-blue); }

/* Beliefs Tab */
.belief-card {
  background: #202636;
  border-left: 3px solid var(--accent-purple);
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 0 6px 6px 0;
}

.belief-subject {
  font-size: 8px;
  color: var(--accent-purple);
  margin-bottom: 4px;
}

.belief-claim {
  font-size: 9px;
  line-height: 1.4;
  color: var(--text-main);
  margin-bottom: 6px;
  font-style: italic;
}

.belief-meta {
  font-size: 7px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.provenance-chain {
  color: #80cbc4;
}

/* Diary Tab */
.diary-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.mini-btn {
  background: #2a3142;
  border: 1px solid #4a5568;
  color: var(--text-main);
  padding: 4px 8px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 8px;
  cursor: pointer;
}

.mini-btn:hover {
  background: #3a455c;
}

.diary-day-title {
  font-size: 10px;
  color: var(--accent-gold);
}

.parchment-diary {
  background: var(--parchment);
  color: #3e2723;
  border: 2px solid var(--parchment-border);
  border-radius: 6px;
  padding: 12px;
  box-shadow: inset 0 0 16px rgba(139, 69, 19, 0.15);
  font-family: 'Courier New', Courier, monospace;
}

.diary-header {
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  color: #5d4037;
  border-bottom: 1px dashed var(--parchment-border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}

.diary-body {
  font-size: 11px;
  line-height: 1.6;
}

.empty-state {
  text-align: center;
  padding: 20px 10px;
  color: var(--text-muted);
  font-size: 9px;
}

/* ---------------- Modals ---------------- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 12, 18, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-card {
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7);
  padding: 24px;
  max-width: 460px;
  width: 90%;
}

.title-card {
  text-align: center;
  max-width: 480px;
}

.game-title {
  font-size: 20px;
  color: var(--accent-gold);
  margin-bottom: 10px;
  text-shadow: 2px 2px #000000;
}

.game-subtitle {
  font-size: 9px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 24px;
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-primary {
  background: var(--accent-amber);
  color: #12141a;
  border: 2px solid #ffd54f;
  border-radius: 6px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary:hover {
  background: #ffb300;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 160, 0, 0.35);
}

.btn-large {
  padding: 12px 18px;
  font-size: 11px;
}

.btn-secondary {
  background: #252c3c;
  border: 2px solid #3d4760;
  color: var(--text-main);
  border-radius: 6px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: #333c52;
  border-color: var(--accent-gold);
}

.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
}

.title-footer {
  font-size: 8px;
  color: #607d8b;
  margin-top: 14px;
  line-height: 1.4;
}

/* Tutorial Modal */
.tutorial-card {
  max-width: 500px;
}

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

.tut-header h3 {
  font-size: 11px;
  color: var(--accent-gold);
}

.tut-step {
  font-size: 8px;
  color: var(--text-muted);
}

.tut-content {
  font-size: 9px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.tut-content p {
  margin-bottom: 10px;
}

.tut-content ul {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tut-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Settings Modal */
.settings-card h3 {
  font-size: 12px;
  color: var(--accent-gold);
  margin-bottom: 16px;
}

.setting-row {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 9px;
}

.setting-row input[type="range"] {
  accent-color: var(--accent-gold);
  cursor: pointer;
}

.setting-row small {
  color: var(--text-muted);
  font-size: 8px;
}

.setting-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ---------------- HUD Population Badge ---------------- */
.hud-pop {
  font-size: 10px;
  color: #80cbc4;
  background: rgba(20, 30, 45, 0.65);
  border: 1px solid rgba(128, 203, 196, 0.4);
  padding: 3px 8px;
  border-radius: 12px;
  margin-left: 6px;
  font-weight: bold;
}

/* ---------------- Toast Notification System ---------------- */
.toast-container {
  position: fixed;
  bottom: 40px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  min-width: 240px;
  max-width: 340px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 11px;
  line-height: 1.4;
  color: #f0f4f8;
  background: rgba(20, 24, 34, 0.94);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  border-left: 4px solid #64b5f6;
  pointer-events: auto;
  animation: toast-slide-in 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast.toast-fadeout {
  opacity: 0;
  transform: translateX(40px);
}

.toast-info    { border-left-color: #42a5f5; }
.toast-success { border-left-color: #66bb6a; }
.toast-warn    { border-left-color: #ffa726; }
.toast-danger  { border-left-color: #ef5350; }
.toast-rumor   { border-left-color: #ab47bc; }

/* ---------------- Right-Click Context Menu ---------------- */
.context-menu {
  position: fixed;
  min-width: 170px;
  background: #181d28;
  border: 1px solid #37474f;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  z-index: 2000;
  overflow: hidden;
  padding: 4px 0;
}

.context-menu.hidden {
  display: none;
}

.ctx-item {
  padding: 9px 14px;
  font-size: 11px;
  color: #cfd8dc;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s ease;
  user-select: none;
}

.ctx-item:hover {
  background: #263238;
  color: var(--accent-gold);
}

/* ---------------- Hover Tooltip ---------------- */
.hover-tooltip {
  position: fixed;
  background: rgba(14, 18, 26, 0.92);
  color: #eceff1;
  border: 1px solid #455a64;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  pointer-events: none;
  z-index: 1500;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.hover-tooltip.hidden {
  display: none;
}

/* ---------------- Building Info Card ---------------- */
.building-card {
  position: fixed;
  bottom: 85px;
  left: 20px;
  width: 230px;
  background: rgba(22, 27, 38, 0.95);
  border: 1px solid #455a64;
  border-radius: 10px;
  padding: 12px;
  z-index: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
}

.building-card.hidden {
  display: none;
}

.card-title {
  font-size: 12px;
  font-weight: bold;
  color: var(--accent-gold);
  margin-bottom: 8px;
  border-bottom: 1px solid #37474f;
  padding-bottom: 5px;
}

.card-info-row {
  font-size: 10px;
  color: #b0bec5;
  margin-bottom: 5px;
}

.card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.card-actions .mini-btn {
  flex: 1;
  text-align: center;
  font-size: 9px;
  padding: 5px 6px;
}

.btn-danger {
  border-color: #e57373 !important;
  color: #ef9a9a !important;
}

.btn-danger:hover {
  background: #c62828 !important;
  color: #fff !important;
}

/* ---------------- Win Goals Sidebar Panel ---------------- */
.goals-panel {
  position: fixed;
  right: 18px;
  top: 72px;
  width: 220px;
  background: rgba(18, 23, 34, 0.90);
  border: 1px solid #37474f;
  border-radius: 10px;
  padding: 12px;
  z-index: 400;
  max-height: 55vh;
  overflow-y: auto;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

.goals-header {
  font-size: 11px;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.25);
  padding-bottom: 5px;
  letter-spacing: 0.5px;
}

.goals-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.goal-item {
  font-size: 10px;
  line-height: 1.4;
  padding: 4px 6px;
  border-radius: 4px;
}

.goal-item.goal-done {
  color: #a5d6a7;
  background: rgba(76, 175, 80, 0.15);
}

.goal-item.goal-pending {
  color: #90a4ae;
  background: rgba(255, 255, 255, 0.04);
}

/* ---------------- Victory Screen Modal ---------------- */
.victory-card {
  max-width: 520px;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #161b33 0%, #0c101c 100%);
  border: 2px solid #ffd700;
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.35);
  padding: 28px 24px;
}

.victory-title {
  font-size: 22px;
  color: #ffd700;
  margin: 0 0 8px;
  text-shadow: 0 0 16px rgba(255, 215, 0, 0.6);
}

.victory-subtitle {
  color: #90caf9;
  margin: 0 0 18px;
  font-size: 11px;
  line-height: 1.5;
}

.victory-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
  text-align: left;
}

.victory-stat-item {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
}

.victory-stat-label {
  color: #90caf9;
  display: block;
  font-size: 9px;
  margin-bottom: 2px;
}

.victory-stat-value {
  font-size: 16px;
  font-weight: bold;
  color: #fff;
}

.victory-goals {
  text-align: left;
  margin: 14px 0;
  font-size: 11px;
  color: #c8e6c9;
  background: rgba(46, 125, 50, 0.15);
  border-radius: 8px;
  padding: 10px 14px;
}

.victory-goal-item {
  margin: 5px 0;
}

.victory-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* Confetti animation */
@keyframes confetti-fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(350px) rotate(720deg); opacity: 0; }
}

.confetti-piece {
  position: absolute;
  width: 9px;
  height: 9px;
  animation: confetti-fall 2.5s ease-in forwards;
  z-index: 10;
}
