/* ============================================================
   style.css  –  Casper's Crown Coin Empire
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --bg-card: #16213e;
  --bg-light: #0f3460;
  --accent: #e94560;
  --gold: #ffd700;
  --text: #eee;
  --text-muted: #888;
  --success: #4caf50;
  --danger: #f44336;
  --radius: 10px;
  --nav-height: 60px;
}

html, body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border-bottom: 2px solid var(--bg-light);
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

#hud-coins-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--gold);
}

#hud-income {
  font-size: 0.85rem;
  color: var(--success);
}

#hud-house {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.hud-title {
  font-size: 0.8rem;
  font-weight: bold;
  letter-spacing: 1px;
  color: var(--accent);
  text-transform: uppercase;
}

/* ---------- Screens ---------- */
.screen-container {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
}

.screen {
  display: none;
  padding: 16px;
  min-height: 100%;
}

.screen.active {
  display: block;
}

/* World screen fills space and scrolls horizontally for large grids */
#screen-world.active {
  display: block;
  padding: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- Bottom Nav ---------- */
#bottom-nav {
  display: none;
  justify-content: space-around;
  background: var(--bg-card);
  border-top: 2px solid var(--bg-light);
  padding: 8px 4px;
  flex-shrink: 0;
  z-index: 100;
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.nav-btn .nav-icon {
  font-size: 1.3rem;
}

.nav-btn:hover, .nav-btn.active {
  color: var(--gold);
  background: var(--bg-light);
}

/* ---------- Intro Screen ---------- */
#screen-intro.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 24px;
  min-height: 80vh;
}

.intro-title {
  font-size: 2.2rem;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.intro-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  max-width: 400px;
}

.intro-choices {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.intro-choice {
  background: var(--bg-card);
  border: 3px solid var(--bg-light);
  border-radius: var(--radius);
  padding: 24px 32px;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  width: 180px;
}

.intro-choice:hover {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(255, 215, 0, 0.15);
}

.intro-choice .choice-emoji {
  font-size: 3rem;
  display: block;
  margin-bottom: 8px;
}

.intro-choice .choice-label {
  font-weight: bold;
  font-size: 1.1rem;
}

.intro-choice .choice-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ---------- Game Grid ---------- */
#game-grid {
  display: grid;
  gap: 5px;
  padding: 6px;
  min-height: 100%;
}

.grid-cell {
  background: var(--bg-card);
  border: 2px solid var(--bg-light);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  padding: 4px;
}

.grid-cell:hover {
  transform: scale(1.05);
  z-index: 2;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.15);
}

.grid-cell.locked {
  background: linear-gradient(135deg, #0a0a14, #111122);
  border-color: #2a2a3a;
  opacity: 0.4;
  cursor: default;
}

.grid-cell.locked:hover { transform: none; box-shadow: none; }

.grid-cell.empty {
  border-style: dashed;
  border-color: #3a3a4a;
  background: linear-gradient(135deg, var(--bg-card), #1a1a30);
}

.grid-cell.robs-shop {
  background: linear-gradient(135deg, #2a1a4e, #1a3a2e);
  border-color: #8bc34a;
  box-shadow: inset 0 0 12px rgba(139, 195, 74, 0.15);
}

.grid-cell.business {
  border-width: 2px;
}

.cell-emoji {
  font-size: 1.6rem;
  line-height: 1;
}

.cell-label {
  font-size: 0.6rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cell-sublabel {
  font-size: 0.55rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.cell-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 0.7rem;
}

/* ---------- Business Detail Panel ---------- */
#business-detail {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#business-detail.active {
  display: flex;
}

#business-detail-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 2px solid;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.detail-emoji { font-size: 2.5rem; }

.detail-header h3 { font-size: 1.2rem; }

.detail-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.detail-employee {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  background: var(--bg-light);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.detail-employees-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.detail-employees-list .btn { margin-top: 2px; }

.detail-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Rarity tag ---------- */
.rarity-tag {
  font-size: 0.75rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- Buttons ---------- */
.btn {
  background: var(--bg-light);
  border: 2px solid #555;
  color: var(--text);
  padding: 10px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:hover { border-color: var(--gold); background: #1a4a6e; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 14px 28px; font-size: 1.1rem; }

.btn-success { border-color: var(--success); background: rgba(76, 175, 80, 0.2); }
.btn-success:hover { background: rgba(76, 175, 80, 0.4); }

.btn-danger { border-color: var(--danger); background: rgba(244, 67, 54, 0.2); }
.btn-danger:hover { background: rgba(244, 67, 54, 0.4); }

.btn-disabled { opacity: 0.4; cursor: not-allowed; }
.btn-disabled:hover { border-color: #555; background: var(--bg-light); }

.btn-price {
  font-size: 0.75rem;
  color: var(--gold);
}

/* ---------- Shop ---------- */
.shop-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg-light);
  border: 1px solid #444;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s;
}

.tab-btn:hover, .tab-btn.active {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(255, 215, 0, 0.1);
}

.shop-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 2px solid #444;
  border-radius: var(--radius);
  transition: all 0.2s;
}

.shop-item:hover {
  background: var(--bg-light);
}

.shop-item.cant-afford { opacity: 0.5; }

.shop-item-emoji { font-size: 1.8rem; }

.shop-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-item-info strong { font-size: 0.95rem; }

.shop-item-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.shop-item-buy {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.shop-price {
  font-size: 0.85rem;
  color: var(--gold);
  font-weight: bold;
}

.shop-restock {
  margin-top: 16px;
  text-align: center;
}

/* ---------- Sell ---------- */
.sell-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.sell-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 2px solid #444;
  border-radius: var(--radius);
}

/* ---------- Home ---------- */
.home-house {
  text-align: center;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.home-house-emoji {
  font-size: 4rem;
  display: block;
  margin-bottom: 8px;
}

.home-stats {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.home-upgrade {
  text-align: center;
  margin-bottom: 20px;
}

.home-section {
  margin-bottom: 20px;
}

.home-section h3 {
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 1rem;
}

/* Pet slots */
.pet-slots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pet-slot {
  background: var(--bg-card);
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.pet-slot.filled { border-width: 2px; }

.pet-slot.empty {
  border-style: dashed;
  opacity: 0.6;
}

.pet-emoji { font-size: 1.5rem; }

.assign-pets {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.assign-pets p { width: 100%; font-size: 0.85rem; color: var(--text-muted); }

/* Projects */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.project-card {
  background: var(--bg-card);
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.project-card.built { border-color: var(--success); background: rgba(76, 175, 80, 0.1); }

.project-emoji { font-size: 1.5rem; }

.project-desc { font-size: 0.7rem; color: var(--text-muted); }

.project-status {
  color: var(--success);
  font-weight: bold;
  font-size: 0.8rem;
}

.inventory-summary {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ---------- Holiday ---------- */
.holiday-screen, .holiday-reward {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
  min-height: 60vh;
}

.holiday-icon { font-size: 5rem; }

.holiday-animation {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 20px;
}

.holiday-plane {
  font-size: 4rem;
  animation: fly 2s ease-in-out infinite;
}

@keyframes fly {
  0%, 100% { transform: translateX(-30px) rotate(-5deg); }
  50% { transform: translateX(30px) rotate(5deg); }
}

.holiday-loading {
  width: 200px;
  height: 8px;
  background: var(--bg-light);
  border-radius: 4px;
  overflow: hidden;
}

.holiday-bar {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  animation: loadbar 4s linear forwards;
}

@keyframes loadbar {
  from { width: 0; }
  to { width: 100%; }
}

.holiday-reward .reward-item {
  font-size: 1.5rem;
  padding: 24px 40px;
  border: 3px solid;
  border-radius: var(--radius);
  background: var(--bg-card);
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

.reward-burst {
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 70%);
  border-radius: 50%;
  animation: burst 2s ease-in-out infinite;
}

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

/* ---------- Admin Console ---------- */
#admin-console {
  display: none;
  position: fixed;
  bottom: var(--nav-height);
  left: 0; right: 0;
  height: 250px;
  background: #111;
  border-top: 2px solid var(--accent);
  z-index: 300;
  flex-direction: column;
}

#admin-console.active { display: flex; }

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--accent);
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
}

#admin-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.8rem;
}

.admin-line { color: var(--gold); margin-top: 4px; }
.admin-result { color: #aaa; margin-bottom: 4px; }

#admin-input {
  background: #222;
  border: none;
  border-top: 1px solid #444;
  color: var(--text);
  padding: 10px 12px;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  outline: none;
}

#admin-input::placeholder { color: #555; }

/* ---------- Notifications ---------- */
#notifications {
  position: fixed;
  top: 60px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: 320px;
}

.notification {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  pointer-events: auto;
}

.notification.show { transform: translateX(0); }

.notif-info    { background: var(--bg-light); border-left: 4px solid #2196f3; }
.notif-success { background: rgba(76, 175, 80, 0.2); border-left: 4px solid var(--success); }
.notif-error   { background: rgba(244, 67, 54, 0.2); border-left: 4px solid var(--danger); }

/* ---------- HUD rubies & avatar ---------- */
#hud-rubies {
  font-size: 0.85rem;
  color: #e040fb;
  font-weight: bold;
}

#hud-avatar {
  font-size: 1.1rem;
}

/* ---------- Quest cards ---------- */
.quest-card {
  background: var(--bg-card);
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.quest-card:hover {
  background: var(--bg-light);
}

.quest-card.quest-active {
  border-color: #e040fb;
  box-shadow: inset 0 0 12px rgba(224, 64, 251, 0.15);
}

.quest-card.quest-completed {
  opacity: 0.5;
  border-color: var(--success);
}

.quest-card.quest-locked {
  opacity: 0.6;
}

.quest-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.quest-emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.quest-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.quest-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.quest-reward {
  font-size: 0.85rem;
  color: #e040fb;
  font-weight: bold;
  flex-shrink: 0;
}

.quest-progress-bar {
  height: 6px;
  background: var(--bg-light);
  border-radius: 3px;
  margin-top: 10px;
  overflow: hidden;
}

.quest-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #e040fb, #b388ff);
  border-radius: 3px;
  transition: width 0.3s;
}

.quest-progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
  text-align: right;
}

.quest-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

.quest-done-tag {
  font-size: 0.8rem;
  color: var(--success);
  font-weight: bold;
}

/* ---------- Avatar shop ---------- */
.avatar-shop {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.avatar-card {
  background: var(--bg-card);
  border: 2px solid #444;
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.avatar-card:hover {
  background: var(--bg-light);
}

.avatar-card.avatar-owned {
  border-color: #e040fb;
  box-shadow: inset 0 0 10px rgba(224, 64, 251, 0.15);
}

.avatar-card.avatar-locked {
  opacity: 0.5;
}

.avatar-emoji {
  font-size: 2rem;
}

.avatar-cost {
  font-size: 0.75rem;
  color: #e040fb;
  font-weight: bold;
}

.avatar-equipped {
  font-size: 0.75rem;
  color: var(--success);
  font-weight: bold;
}

/* ---------- Utilities ---------- */
.muted { color: var(--text-muted); font-size: 0.85rem; }

h2 { color: var(--gold); margin-bottom: 16px; font-size: 1.3rem; }
h3 { margin-bottom: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  #hud { padding: 8px 10px; gap: 8px; }
  #hud-coins-wrapper { font-size: 1rem; }
  .hud-title { display: none; }
  .screen { padding: 10px; }

  .cell-emoji { font-size: 1.2rem; }
  .cell-label { font-size: 0.5rem; }
  .cell-sublabel { display: none; }

  .intro-title { font-size: 1.6rem; }
  .intro-choice { width: 140px; padding: 16px; }
  .intro-choice .choice-emoji { font-size: 2rem; }

  .nav-btn { font-size: 0.6rem; padding: 4px 4px; }
  .nav-btn .nav-icon { font-size: 1.1rem; }

  .shop-item { padding: 8px; gap: 8px; }
  .shop-item-emoji { font-size: 1.3rem; }

  .pet-slot { min-width: 80px; padding: 8px; }

  .projects-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

@media (max-width: 380px) {
  #game-grid { gap: 3px; padding: 3px; }
  .grid-cell { border-radius: 6px; }
  .cell-emoji { font-size: 1rem; }
  .cell-label { font-size: 0.45rem; }
}
