body { margin:0; font-family: 'Segoe UI', sans-serif; background:#0b1e2d; color:#ddd; }


/* ===== UI ===== */

/* Game container*/
#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
}

/* Resource top bar */
#top-bar {
  background:#1a2a3a;
  padding:10px;
  display:flex;
  gap:20px;
  font-size:1.1em;
  position: relative; /* Required for z-index to work */
  z-index: 100;  /* Forces it above the hex grid */
  flex-shrink: 0;  /* Prevents it from squishing on small screens */
}


/* ===== Cards ===== */

/* Card: flexible width, allows shrinking & overlapping (left-to-right) */
.card {
  flex: 0 1 120px;  /* Base width, shrinks proportionally when space runs out */
  min-width: 92px;
  height: 135px;
  background: #3a2a1f;
  border: 2px solid #d4a017;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
  margin: 0 -6px;  /* Creates overlap when 9+ cards */
  text-align: center;
  vertical-align: top;
  background-size: cover;
  background-position: center;
  color: #ffffff;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9), -1px -1px 3px rgba(0, 0, 0, 0.9);
  position: relative;  /* Required for z-index stacking */
  transition: all 0.2s ease;
  margin-right: 0px;
  margin-left: 0px;
  z-index: 1;
}
.card:last-child { margin-right: 0; } /* Don't pull the right edge */

/* Hover: pops out, expands spacing, always on top */
.card:hover {
  transform: translateY(-20px) scale(1.1);
  margin: 0 8px; /* Pushes neighbors apart on hover */
  z-index: 999 !important;  /* Hovered card breaks overlap */
}

/* Pointer Events Layering */
#bottom-ui {
  pointer-events: none; /* Default: pass clicks to map */
}


/* Expand Card Targets */
.hex.expand-target {
  box-shadow: 0 0 0 3px #7090ff inset, 0 0 12px #7090ff;
  cursor: crosshair;
  z-index: 6; /* Sits above normal tiles & fog */
}

/* Axe Card Targets */
.hex.axe-target {
  box-shadow: 0 0 0 3px #d97706 inset, 0 0 12px #d97706;
  cursor: crosshair;
  z-index: 6;
}

/* ===== Hand ===== */

/* Hand container: single row, no wrapping, centered */
#hand {
  display: flex;
  flex-direction: row;  /* Left-to-right order */
  flex-wrap: nowrap;  /* Force single line */
  justify-content: center;
  align-items: flex-end;
  padding: 10px 20px;
  overflow: visible;
}


/* ===== Deck ===== */


/* keep deck info bottom-left */
#bottom-ui {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  z-index: 20;  /* Ensure hand floats above map */
  pointer-events: none;  /* Let clicks pass through empty areas to map */
}

/* Deck pile */
.deck-pile {
  position: absolute;
  left: 15px;
  bottom: 15px;
  width: 100px;
  height: 140px;
  background: linear-gradient(135deg, #3a2a1f, #2a1a0f);
  border: 3px solid #d4a017;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #d4a017;
  cursor: pointer;
  z-index: 10;
}

/* Re-enable clicks on interactive children */
#hand, .card, .controls, .deck-pile {
  pointer-events: auto;
}


/* ===== Button ===== */

/* AP Zero Button Animation */
@keyframes inflate-deflate {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.20); } /* Inflate peak */
  100% { transform: scale(1); }    /* Deflate back */
}

#btn-end-turn.pulse-ap-zero {
  animation: inflate-deflate 0.5s ease-in-out forwards;
  box-shadow: 0 0 14px rgba(240, 192, 80, 0.5); /* Subtle glow on trigger */
}

/* Round Card-Style End Turn Button */
#btn-end-turn {
  position: fixed;  /* Detaches from #bottom-ui, locks to viewport */
  bottom: 20px;
  right: 20px;
  width: 70px;
  height: 70px;
  border-radius: 50%;  /* Makes it perfectly round */
  background: linear-gradient(145deg, #3a2a1f, #2a1a0f);
  border: 3px solid #d4a017;
  color: #f0c050;
  font-family: inherit;
  font-weight: bold;
  font-size: 11px;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.1;
  z-index: 30;
  pointer-events: auto;  /* Overrides #bottom-ui's pointer-events: none */
  transition: all 0.2s ease;
  padding: 0;  /* Removes default browser button padding */
}

/* End-turn button hover */
#btn-end-turn:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 24px rgba(212, 160, 23, 0.4);
  background: linear-gradient(145deg, #4a3a2f, #3a2a1f);
}

/* End-turn button */
#btn-end-turn:active {
  transform: scale(0.95);
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}


/* ===== Tiles ===== */

/* Tile */
.hex {
  position: absolute;
  width: 97px; /* tile size */
  height: 84px;
  background: #2a5c3d;
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  border: 1px solid #1a3f2a;
}

/* Terrain Colors */
.hex.prairie { background: #70c080; } /* Soft green */
.hex.beach   { background: #f4e99b; } /* Sand yellow */
.hex.sea      { background: #40a0f0; } /* Ocean blue */
.hex.deep-sea { background: #2068b0; } /* Dark deep blue */

/* Woods tile */
.hex.woods {
  background-color: #2e5e3f; /* Base forest green */
  background-image: url('../assets/board/tree.png');
  background-size: 55%; /* Scales tree to leave room for text */
  background-position: center;
  background-repeat: no-repeat;
}

/* Oak forest - lighter, warmer tone */
.hex.oak {
  background-color: #4a8050; /* Lighter, more vibrant green */
  background-image: url('../assets/board/tree.png'); /* Reuse or replace with oak-specific later */
  background-size: 55%;
  background-position: center;
  background-repeat: no-repeat;
}

/* Tile info */
#tile-info {
  position: absolute;
  top: 0px;  /* Sits below the #top-bar  */
  right: 20px;
  background: #1a2a3a;  /* Matches top-bar color  */
  border: 2px solid #d4a017; /* Matches card/button borders  */
  padding: 10px;
  border-radius: 8px;
  color: #f0c050;  /* Matches end-turn button text  */
  z-index: 110;  /* Higher than top-bar (100)  */
  min-width: 120px;
  pointer-events: none;  /* Clicks pass through to the map  */
  font-size: 0.9em;
}

/* Base texture rules applied to ALL texture classes */
[class*="texture-"] {
  background-size: cover;
  background-position: center;
  color: #ffffff;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9), -1px -1px 3px rgba(0, 0, 0, 0.9);
  background-color: #3a2a1f; /* Fallback color if image fails to load */
}

/* Base overlay icon layer (sits above hexes, ignores skew) */
.tile-icon {
  position: absolute;
  width: 64px;
  height: 64px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  transform: translate(-50%, -50%); /* Perfect centering on the coordinate */
  pointer-events: none;  /* Clicks pass through to the hex below */
  z-index: 10;  /* Renders above hex tiles */
}

/* Woods texture */
.tree-icon {
  background-image: url('../assets/board/forest.png');
}

/* Oak forest icon - lighter/warmer tree */
.oak-icon {
  background-image: url('../assets/board/oak.png') !important;
}

/* Mountain terrain base (color only) */
.hex.mountain {
  background-color: #6b7280; /* Neutral gray */
}

/* Upright mountain icon */
.mount-icon {
  background-image: url('../assets/board/mountain.png');
}

/* Hex grid and background */
.hex-grid {
  position: absolute;
  top: 0; left: 0;
  transform-origin: 0 0; /* Critical: ensures translate() moves exactly 1:1 */
  will-change: transform;  /* GPU acceleration for smooth panning */
}

/* Cursor grabs */
.hex-grid:active {
  cursor: grabbing;
}

/* Stagger every other row to simulate hex grid */
.hex.offset {
  margin-left: 32px; /* half-width offset */
}


/* ===== Fog of War ===== */

.hex.fogged {
  background: #1a2a3a !important; /* Dark base matching UI */
  cursor: default;
}
.hex.fogged::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(255, 255, 255, .7); /* Semi-transparent white */
  z-index: 5;
  pointer-events: auto; /* Blocks clicks on fogged tiles */
}


/* ===== Structures ===== */

/* Structure Background Overrides (MUST be after ALL terrain rules) */
.hex.has-field { background-color: #e6c229; } /* Bright yellow */
.hex.has-house { background-color: #70c080; } /* Prairie green */
/* .hex.placed    { border: 2px solid #d4a017; } */


.house-icon {
  background-image: url('../assets/board/house.png');
}

.field-icon {
  background-image: url('../assets/board/wheat_field.png');
}

/* ====================== MARKET PHASE ====================== */

#market-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#market-modal {
  position: relative;
  background: #9c2a2a;           /* Strong red as requested */
  border: 6px solid #f0c050;
  border-radius: 20px;
  width: 92%;
  max-width: 1100px;
  max-height: 88vh;
  padding: 30px 25px 52px;
  color: #fff;
  box-shadow: 0 0 50px rgba(240, 192, 80, 0.7);
  overflow-y: auto;
  text-align: center;
}

#market-modal h2 {
  text-align: center;
  margin-bottom: 10px;
  font-size: 2.3em;
  text-shadow: 3px 3px 6px rgba(0,0,0,0.6);
  color: #ffdd99;
}

.market-subtitle {
  margin: 0 0 22px;
  opacity: 0.9;
  font-size: 1.05em;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px 20px;
  margin-bottom: 10px;
  align-items: end;
}

.market-card-slot,
.market-deck-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.market-sell-slot {
  position: relative;
  border: 3px dashed #7ec8ff;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
  width: 180px;
  height: 180px;
  overflow: hidden;
  background: #2a3040;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #cce8ff;
  font-weight: bold;
  text-align: center;
  padding: 12px;
}

.market-card-slot:hover .card,
.market-deck-card:hover .card {
  transform: translateY(-12px) scale(1.08);
  margin: 0;
  z-index: 5 !important;
}

.market-sell-slot:hover {
  transform: scale(1.05);
  box-shadow: 0 0 25px #f0c050;
  background: #2a3040;
  border-style: solid;
}

.market-card-slot.is-disabled,
.market-sell-slot.is-disabled,
.market-deck-card.is-disabled {
  opacity: 0.4;
  pointer-events: none;
  cursor: default;
}

.market-card-slot.is-unaffordable {
  cursor: not-allowed;
}

.market-card-slot.is-unaffordable:hover .card {
  transform: none;
}

.market-card-wrap {
  position: relative;
  flex-shrink: 0;
}

.market-card-slot .card,
.market-deck-card .card {
  flex: none;
  width: 120px;
  min-width: 120px;
  height: 135px;
  margin: 0;
}

.market-unaffordable-overlay {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.58);
  pointer-events: none;
  z-index: 2;
}

.market-price-label {
  font-size: 1.05em;
  font-weight: bold;
  text-align: center;
  text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.9);
}

.market-buy-label {
  color: #f0c050;
}

.market-sell-label {
  color: #9fe870;
}

.market-skip {
  position: absolute;
  left: 22px;
  bottom: 16px;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  color: #ffdd99;
  font-size: 1.05em;
  font-weight: bold;
  cursor: pointer;
  opacity: 0.85;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.market-skip:hover {
  opacity: 1;
  color: #fff;
}

.market-skip.is-disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

.market-sell-slot .sell-icon {
  font-size: 2em;
  margin-bottom: 8px;
}

.market-sell-panel h3 {
  margin: 0 0 8px;
  color: #ffdd99;
}

.market-sell-hint {
  margin: 0 0 18px;
  opacity: 0.85;
}

.market-sell-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-bottom: 20px;
  max-height: 42vh;
  overflow-y: auto;
  padding: 4px;
}

.market-sell-cancel {
  padding: 10px 28px;
  font-size: 1.1em;
  background: #2a1a1a;
  color: #f0c050;
  border: 3px solid #d4a017;
  border-radius: 30px;
  cursor: pointer;
  font-weight: bold;
}

.market-sell-cancel:hover {
  background: #3a2a2a;
}

#btn-continue-market {
  display: block;
  margin: 20px auto 10px;
  padding: 16px 50px;
  font-size: 1.4em;
  background: #1a2a1a;
  color: #f0c050;
  border: 4px solid #d4a017;
  border-radius: 50px;
  cursor: pointer;
  font-weight: bold;
}

#btn-continue-market:hover {
  background: #2a3a2a;
  transform: scale(1.05);
}

/* ====================== IN-GAME DIALOG ====================== */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.dialog-overlay[hidden] {
  display: none !important;
}

.dialog-box {
  background: #2a3a4a;
  border-radius: 16px;
  padding: 28px 32px 22px;
  min-width: 280px;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.dialog-message {
  margin: 0 0 24px;
  font-size: 1.15em;
  line-height: 1.5;
  color: #e8e8e8;
  white-space: pre-wrap;
}

.dialog-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.dialog-btn {
  min-width: 100px;
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  font-size: 1.05em;
  font-weight: bold;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.15s ease;
  color: #fff;
}

.dialog-btn:hover {
  filter: brightness(1.12);
  transform: scale(1.04);
}

.dialog-btn-yes {
  background: #2d8a4e;
}

.dialog-btn-no {
  background: #b33a3a;
}

.dialog-btn-no[hidden] {
  display: none;
}

/* ====================== EVENT PHASE ====================== */

#event-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1001;
}

#event-modal {
  position: relative;
  background: #1a2030;
  border: 6px solid #c44a2a;
  border-radius: 20px;
  width: 92%;
  max-width: 720px;
  max-height: 88vh;
  padding: 30px 25px 36px;
  color: #fff;
  box-shadow: 0 0 50px rgba(196, 74, 42, 0.6);
  overflow-y: auto;
  text-align: center;
}

#event-modal h2 {
  margin-bottom: 8px;
  font-size: 2.1em;
  text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.6);
  color: #ffaa77;
}

.event-subtitle {
  margin: 0 0 20px;
  opacity: 0.85;
  font-size: 1.05em;
}

.event-card-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.event-drawn-card {
  transform: rotate(-2deg);
  box-shadow: 0 0 24px rgba(255, 80, 40, 0.5);
  border-color: #c44a2a !important;
  cursor: default;
  pointer-events: none;
}

.event-details {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 22px;
}

.event-severity {
  font-size: 0.9em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #ff8866;
  margin-bottom: 8px;
}

.event-adverse-title {
  margin: 0 0 10px;
  font-size: 1.6em;
  color: #ff6644;
}

.event-adverse-desc {
  margin: 0;
  line-height: 1.5;
  opacity: 0.92;
}

.event-continue {
  background: #c44a2a;
  color: #fff;
  border: 3px solid #f0c050;
  border-radius: 12px;
  padding: 12px 28px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.event-continue:hover {
  background: #e05a38;
  box-shadow: 0 0 20px rgba(240, 192, 80, 0.5);
  transform: scale(1.04);
}
