/* Circle the Wagons — Styles */

:root {
  --cell-size: 40px;
  --cell-font: 10px;
  --terr-desert: #E8C872;
  --terr-forest: #2D8B46;
  --terr-snow: #D4E5F7;
  --terr-mountains: #8B7355;
  --terr-plains: #A8C256;
  --terr-water: #3A8FD6;
  --bg: #1a1a2e;
  --surface: #16213e;
  --text: #e0e0e0;
  --accent: #e94560;
  --accent2: #0f3460;
  --border: #333;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 2px solid var(--accent);
  flex-wrap: wrap;
  gap: 0.5rem;
}

header h1 {
  font-size: 1.4rem;
  color: var(--accent);
  white-space: nowrap;
}

.controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.controls label {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.controls input, .controls select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
}

.controls input[type="number"] { width: 5rem; }

button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: opacity 0.15s;
}

button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.rules-btn {
  background: var(--accent2);
}

.hint-thinking {
  opacity: 0.6;
  cursor: wait;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

#status-bar {
  text-align: center;
  padding: 0.6rem;
  background: var(--accent2);
  font-size: 0.95rem;
  min-height: 2.2rem;
}

/* Rules panel */
#rules-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.rules-content {
  max-width: 800px;
  margin: 0 auto;
}

.rules-content h2 {
  color: var(--accent);
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
  text-align: center;
}

.rules-columns {
  display: flex;
  gap: 2rem;
  margin-bottom: 1rem;
}

.rules-col {
  flex: 1;
}

.rules-col h3 {
  color: var(--accent);
  font-size: 0.85rem;
  margin: 0.6rem 0 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rules-col h3:first-child {
  margin-top: 0;
}

.rules-col p {
  font-size: 0.8rem;
  color: #bbb;
  line-height: 1.5;
  margin-bottom: 0.4rem;
}

.rules-col kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.1rem 0.35rem;
  font-size: 0.75rem;
  font-family: monospace;
}

#rules-close-btn {
  display: block;
  margin: 0 auto;
  min-width: 120px;
}

/* Bonus display */
#bonus-display {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}

.bonus-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  min-width: 180px;
  max-width: 260px;
  text-align: center;
}

.bonus-card .bonus-name {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bonus-card .bonus-desc {
  font-size: 0.75rem;
  color: #aaa;
  line-height: 1.3;
}

/* Card circle — radial layout */
#circle-area {
  text-align: center;
  padding: 0.5rem 1rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#circle-area h2 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
  color: #ccc;
}

#circle-count { font-size: 0.85rem; color: #888; }

#circle-container {
  position: relative;
  margin: 0 auto;
  /* width/height set dynamically by JS */
}

.circle-card {
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: default;
  /* position/display/grid set inline by JS for radial layout */
  transition: border-color 0.15s, opacity 0.15s;
}

.circle-card.clickable {
  cursor: pointer;
}

.circle-card.clickable:hover {
  border-color: var(--accent);
  z-index: 5;
  filter: brightness(1.15);
}

.circle-card.selected {
  border-color: #ffd700;
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
  z-index: 10;
}

.circle-card.skipped {
  opacity: 0.3;
}

.circle-card .card-label {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: #888;
  white-space: nowrap;
}

.circle-card .skip-label {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6rem;
  color: var(--accent);
  white-space: nowrap;
  font-weight: 700;
}

/* Connector line between circle cards */
.circle-connector {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  height: 2px;
  transform-origin: 0 50%;
  pointer-events: none;
}

#draft-controls {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

#draft-info {
  width: 100%;
  text-align: center;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9rem;
}

.draft-info-ok {
  color: #8bc34a;
}

.draft-info-warn {
  color: #ffc107;
}

.draft-info-danger {
  color: #ff5252;
  background: rgba(255, 82, 82, 0.1);
}

#draft-controls button {
  min-width: 100px;
}

#draft-cancel-btn {
  background: var(--border);
}

/* Towns */
#towns-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 1.5rem;
  padding: 1rem;
  flex-wrap: wrap;
}

.town-panel {
  text-align: center;
}

.town-panel h2 {
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: #ccc;
}

.town-panel h2 .turn-badge {
  display: inline-block;
  font-size: 0.65rem;
  background: var(--accent);
  color: #fff;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  margin-left: 0.3rem;
  vertical-align: middle;
  animation: badge-pulse 1.5s ease-in-out infinite;
}

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.town-grid {
  display: inline-block;
  position: relative;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(0,0,0,0.2);
  min-width: calc(2 * var(--cell-size) + 4px);
  min-height: calc(2 * var(--cell-size) + 4px);
  padding: 2px;
}

/* Placement panel */
#placement-panel {
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
  min-width: 120px;
}

#placement-panel h2 {
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: #ccc;
}

#card-preview {
  display: inline-grid;
  grid-template-columns: var(--cell-size) var(--cell-size);
  grid-template-rows: var(--cell-size) var(--cell-size);
  margin-bottom: 0.5rem;
}

#rotate-btn {
  background: var(--accent2);
  font-size: 0.8rem;
  padding: 0.3rem 0.75rem;
}

#rotate-btn.active {
  background: var(--accent);
  outline: 2px solid rgba(255, 255, 255, 0.3);
}

/* Cells */
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--cell-font);
  font-weight: 700;
  font-family: monospace;
  border: 1px solid rgba(0,0,0,0.15);
  color: #000;
  text-shadow: 0 0 2px rgba(255,255,255,0.5);
  user-select: none;
}

.cell.terr-0 { background: var(--terr-desert); }
.cell.terr-1 { background: var(--terr-forest); color: #fff; text-shadow: none; }
.cell.terr-2 { background: var(--terr-snow); }
.cell.terr-3 { background: var(--terr-mountains); color: #fff; text-shadow: none; }
.cell.terr-4 { background: var(--terr-plains); }
.cell.terr-5 { background: var(--terr-water); color: #fff; text-shadow: none; }

.cell.ghost {
  opacity: 0.5;
  border: 2px dashed var(--accent);
}

.cell.just-placed {
  animation: place-flash 0.6s ease-out;
}

@keyframes place-flash {
  0% { box-shadow: 0 0 12px 4px rgba(233,69,96,0.7); transform: scale(1.08); }
  100% { box-shadow: none; transform: scale(1); }
}

.cell.anchor-highlight {
  outline: 2px solid rgba(255, 215, 0, 0.6);
  outline-offset: -1px;
  cursor: pointer;
  animation: anchor-pulse 1.2s ease-in-out infinite;
}

@keyframes anchor-pulse {
  0%, 100% { outline-color: rgba(255, 215, 0, 0.6); }
  50% { outline-color: rgba(255, 215, 0, 1); box-shadow: 0 0 6px rgba(255, 215, 0, 0.3); }
}

.cell.empty-cell {
  background: rgba(255,255,255,0.03);
  border: 1px dashed rgba(255,255,255,0.1);
}

.cell.footprint-cell {
  outline: 1px solid rgba(255, 215, 0, 0.25);
  outline-offset: -1px;
}

/* Score panel */
#score-panel {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 0.75rem 1rem;
  flex-wrap: wrap;
}

.score-col {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 1rem;
  min-width: 180px;
}

.score-col h3 {
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  color: #ccc;
  text-align: center;
}

.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 0.15rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.score-row.total {
  font-weight: 700;
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  border-bottom: none;
  margin-top: 0.3rem;
  padding-top: 0.3rem;
  color: var(--accent);
}

.score-label { color: #aaa; }
.score-val { color: var(--text); }

.score-row.terrain-header:hover { background: rgba(255,255,255,0.05); border-radius: 3px; }

.score-row.sub-row {
  padding-left: 0.5rem;
  font-size: 0.7rem;
  border-bottom: none;
}

.terr-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

.terr-dot.terr-0 { background: var(--terr-desert); }
.terr-dot.terr-1 { background: var(--terr-forest); }
.terr-dot.terr-2 { background: var(--terr-snow); }
.terr-dot.terr-3 { background: var(--terr-mountains); }
.terr-dot.terr-4 { background: var(--terr-plains); }
.terr-dot.terr-5 { background: var(--terr-water); }

.score-zero { opacity: 0.4; }

/* Game log */
#game-log {
  max-width: 600px;
  margin: 0.75rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

#game-log h3 {
  font-size: 0.85rem;
  color: #ccc;
  margin-bottom: 0.4rem;
}

#log-content {
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.75rem;
  font-family: monospace;
  line-height: 1.5;
  color: #aaa;
}

#log-content .log-entry { padding: 1px 0; }
#log-content .log-p0 { color: #7ec8e3; }
#log-content .log-p1 { color: #ff8a80; }

/* End modal */
#end-modal {
  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;
}

.modal-content {
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.modal-content h2 {
  color: var(--accent);
  margin-bottom: 1rem;
  font-size: 1.5rem;
}

#end-scores {
  margin-bottom: 1.5rem;
  font-size: 1rem;
  line-height: 1.8;
}

#end-scores .winner { color: #ffd700; font-weight: 700; font-size: 1.1rem; }

.modal-breakdown {
  text-align: left;
  font-size: 0.85rem;
  margin: 0.5rem auto;
  max-width: 280px;
}

.modal-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}

.modal-row.section-end { border-bottom: 1px solid #444; }
.modal-row.sub { font-size: 0.75rem; padding-left: 0.5rem; color: #aaa; }
.modal-row.total-row { border-top: 1px solid #444; font-weight: 700; padding-top: 4px; margin-top: 2px; }

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: rgba(224, 224, 224, 0.4);
  border-top: 1px solid rgba(255,255,255,0.05);
}

footer a {
  color: rgba(224, 224, 224, 0.5);
}

footer .shortcuts {
  margin-top: 0.3rem;
  font-size: 0.7rem;
}

footer kbd {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 3px;
  padding: 0 3px;
  font-family: inherit;
  font-size: inherit;
}

/* Hidden utility */
.hidden { display: none !important; }

/* Responsive */
@media (max-width: 768px) {
  :root {
    --cell-size: 28px;
    --cell-font: 8px;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    padding: 0.5rem 1rem;
  }

  header h1 { font-size: 1.1rem; }

  .controls { width: 100%; }

  .rules-columns {
    flex-direction: column;
    gap: 0;
  }

  #bonus-display { gap: 0.5rem; }
  .bonus-card { min-width: 140px; padding: 0.4rem 0.5rem; }

  #towns-row { gap: 0.75rem; padding: 0.5rem; }

  #score-panel { gap: 0.75rem; }
  .score-col { min-width: 140px; }
}
