@import url('https://fonts.googleapis.com/css2?family=Onest:wght@700&display=swap');

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

html, body {
  height: 100%;
  background: #0f0f0f;
  color: #e0e0e0;
  font-family: "Onest", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
}

/* ── App container ──────────────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  height: 100%;
}

/* ── Landing screen ─────────────────────────────────────────── */
#landing-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.6s ease, transform 0.6s ease;
  z-index: 10;
}

#landing-screen.hidden {
  display: none;
}

#landing-screen.fade-out {
  opacity: 0;
  transform: scale(1.1);
  pointer-events: none;
}

#landing-inner {
  text-align: center;
}

#title {
  font-size: clamp(3rem, 15vw, 10rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 60px rgba(255, 255, 255, 0.08);
  transition: color 0.2s ease;
}

#title:hover {
  color: #f0c040;
}

.subtitle {
  margin-top: 1rem;
  font-size: 1.1rem;
  font-weight: 400;
  color: #888;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1;   }
}

/* ── Game screen ────────────────────────────────────────────── */
#game-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

#game-screen.hidden {
  display: none;
}

/* ── Board area ─────────────────────────────────────────────── */
#board-area {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

#factory-ring {
  position: relative;
  width: min(65vmin, 600px);
  height: min(65vmin, 600px);
}

/* ── Factory wrapper (positioning + active indicator) ────────── */
.factory-wrapper {
  position: absolute;
  width: 50px;
  height: 44px;
  transform: translate(-50%, -50%);
  transition: transform 0.3s ease;
}

/* Active: scale up the wrapper (the inner triangle grows with it) */
.factory-wrapper.active {
  transform: translate(-50%, -50%) scale(1.25);
  z-index: 3;
}

/* White circle behind the active factory triangle.
   The triangle's centroid is at ~66% of its height (not 50%),
   so we offset the circle down so it sits on the visual centre. */
.factory-wrapper.active::after {
  content: "";
  position: absolute;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  left: 50%;
  top: calc(50% + 5px);
  transform: translate(-50%, -50%);
  z-index: -1;
}

/* Move-preview: dashed ring on the destination factory. */
.factory-wrapper.move-preview::after {
  content: "";
  position: absolute;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2.5px dashed rgba(255, 255, 255, 0.5);
  background: transparent;
  left: 50%;
  top: calc(50% + 5px);
  transform: translate(-50%, -50%);
  z-index: -1;
}

/* ── Factory inner (the visible triangle) ────────────────────── */
.factory-inner {
  width: 100%;
  height: 100%;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.type-0 { background: #dc2626; }
.type-1 { background: #16a34a; }
.type-2 { background: #2563eb; }
.type-3 { background: #f59e0b; }

/* Blocked (uncollectable) — overrides type colour with grey. */
.factory-inner.blocked { background: #4a4a4a; }

/* ── Direction arrows ───────────────────────────────────────── */
.direction-arrow {
  position: absolute;
  width: 10px;
  height: 10px;
  clip-path: polygon(0% 0%, 100% 50%, 0% 100%);
  background: #555;
  pointer-events: none;
  z-index: 0;
}

/* ── Orders panel (top right overlay) ───────────────────────── */
#orders-panel {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(15, 15, 15, 0.88);
  border: 1px solid #222;
  border-radius: 8px;
  padding: 10px 14px;
  min-width: 160px;
  z-index: 6;
  backdrop-filter: blur(6px);
}

.panel-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #666;
  margin-bottom: 6px;
}

#order-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #1a1a1a;
  border-radius: 4px;
  border: 1px solid #222;
}

.order-item .order-reqs {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.order-item .order-req {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 0.85rem;
  color: #aaa;
}

.order-item .order-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.order-item .order-pts {
  margin-left: auto;
  font-weight: 700;
  color: #f0c040;
  font-size: 0.9rem;
  white-space: nowrap;
}

.action-btn {
  padding: 10px 24px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s;
}

.action-btn:hover:not(:disabled) {
  background: #2a2a2a;
  border-color: #f0c040;
  color: #f0c040;
}

.action-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ── Bottom bar: deck, inventory, actions, prompt ────────────── */
#bottom-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.25rem;
  background: #141414;
  border-top: 1px solid #222;
  flex-shrink: 0;
}

#bar-left {
  flex: 1;
  display: flex;
}

#bar-center {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#bar-right {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

#bar-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

#bar-actions .action-btn {
  padding: 6px 18px;
  font-size: 0.95rem;
}

.bar-section {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.bar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #666;
}

/* ── Deck cards ─────────────────────────────────────────────── */
#deck-cards {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.deck-card {
  width: 60px;
  height: 78px;
  border-radius: 6px;
  background: #222;
  border: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: #ccc;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s, opacity 0.2s, transform 0.15s;
}

.deck-card:hover {
  background: #2a2a2a;
  border-color: #f0c040;
}

.deck-card.selected {
  border-color: #f0c040;
  background: #2a2a2a;
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(240, 192, 64, 0.3);
}

.deck-card.used {
  display: none;
}

/* ── Inventory ──────────────────────────────────────────────── */
#inventory-slots {
  display: flex;
  gap: 5px;
}

.inv-slot {
  width: 52px;
  height: 52px;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.inv-slot .inv-count {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  margin-top: 8px;
}

/* ── Scoring screen ─────────────────────────────────────────── */
#scoring-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f0f0f;
  z-index: 20;
}

#scoring-screen.hidden {
  display: none;
}

#scoring-inner {
  width: min(500px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  text-align: center;
}

#scoring-title {
  font-size: 1.8rem;
  font-weight: 800;
  color: #f0c040;
  margin-bottom: 1.5rem;
}

.scoring-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #666;
  margin-bottom: 0.5rem;
  text-align: left;
}

#scoring-inventory {
  margin-bottom: 1.25rem;
}

#scoring-inv-slots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#scoring-order-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.scoring-order {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #1a1a1a;
  border-radius: 6px;
  border: 1px solid #222;
  text-align: left;
}

.scoring-order.fulfilled {
  border-color: #16a34a;
  background: #0f1f0f;
}

.scoring-order.fulfilled .order-req {
  opacity: 0.5;
}

.scoring-order-check {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid #555;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #666;
  flex-shrink: 0;
}

.scoring-order.fulfilled .scoring-order-check {
  border-color: #16a34a;
  background: #16a34a;
  color: #fff;
}

.scoring-order-pts {
  margin-left: auto;
  font-weight: 700;
  color: #f0c040;
  font-size: 0.85rem;
  white-space: nowrap;
}

#scoring-result {
  background: #141414;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

#scoring-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #aaa;
}

.score-val {
  font-weight: 600;
  color: #ccc;
}

#scoring-total {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #222;
  font-size: 1.2rem;
  font-weight: 800;
  color: #f0c040;
  text-align: center;
}

#scoring-restart {
  margin-top: 0.5rem;
}
