/* Rome Survival — marble & terracotta */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --marble: #f4ecd8;
  --marble-dark: #e3d7bb;
  --terra: #b03a2e;
  --terra-dark: #8e2b21;
  --ink: #2c2417;
  --gold: #c9a227;
}
body {
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: #1c2733;
  color: var(--marble);
  min-height: 100vh;
}
a { color: var(--gold); }
.muted { opacity: 0.7; }
.btn {
  background: var(--terra);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--terra-dark); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-big { font-size: 19px; padding: 13px 26px; }
.btn.small { font-size: 13px; padding: 5px 10px; }

/* Home */
.home { max-width: 720px; margin: 0 auto; padding: 40px 20px; }
.home h1 { font-size: 42px; margin-bottom: 8px; }
.home h2 { margin: 28px 0 10px; color: var(--gold); }
.tagline { font-size: 17px; opacity: 0.9; margin-bottom: 24px; }
.home-actions { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; margin: 18px 0; }
.join-form { display: flex; gap: 8px; }
.join-form input, .share-row input, #name-input {
  border-radius: 8px;
  border: 1px solid #ffffff33;
  background: #ffffff14;
  color: var(--marble);
  padding: 9px 12px;
  font-size: 15px;
}
.how ol { padding-left: 22px; display: grid; gap: 6px; }
.scores { width: 100%; border-collapse: collapse; }
.scores th, .scores td { text-align: left; padding: 7px 10px; border-bottom: 1px solid #ffffff1f; }
.scores th { color: var(--gold); }

/* Game stage */
#app { display: flex; flex-direction: column; min-height: 100vh; }
#stage { position: relative; flex: 1; display: flex; }
#game {
  width: 100%;
  aspect-ratio: 56 / 36;
  max-height: calc(100vh - 170px);
  display: block;
  margin: 0 auto;
  touch-action: none;
  cursor: crosshair;
}
#hud {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: #10161d;
  font-size: 15px;
  flex-wrap: wrap;
  order: -2;
}
#hud .res { font-weight: 700; }
#hud .phase { margin-left: auto; }
#hud .score { font-weight: 700; color: var(--gold); }
.wave-banner { color: #ff8f7f; font-weight: 800; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
#hud .chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 2px solid var(--c);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 12.5px;
}
.chip.off { opacity: 0.45; }

#hint {
  order: -1;
  padding: 4px 14px;
  font-size: 14px;
  color: var(--gold);
  background: #10161dcc;
  min-height: 22px;
}

#panel {
  background: #10161d;
  padding: 10px 14px;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sel-info { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.sel-info .blurb { font-size: 13px; opacity: 0.75; font-style: italic; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.act { display: flex; flex-direction: column; align-items: center; font-size: 13px; padding: 6px 10px; }
.btn.act small { font-weight: 400; opacity: 0.85; font-size: 11px; }
.tip { font-size: 13px; opacity: 0.7; }
.panel-footer { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tech {
  background: #ffffff14;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12.5px;
  color: var(--gold);
}

#toasts {
  position: fixed;
  top: 60px;
  right: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 30;
  max-width: 320px;
}
.toast {
  background: #10161de8;
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  padding: 9px 13px;
  font-size: 14px;
  animation: slide-in 0.25s ease-out;
}
.toast.good { border-color: #2ecc71; }
.toast.warn { border-color: #e67e22; }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }

#overlay { display: none; }
#overlay.active {
  display: flex;
  position: fixed;
  inset: 0;
  background: #000000a8;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 20px;
}
#overlay.quiz { background: #00000070; }
.modal {
  background: var(--marble);
  color: var(--ink);
  border-radius: 14px;
  padding: 26px 30px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 18px 60px #000c;
}
.modal h2, .modal h3 { margin-bottom: 10px; }
.modal .big { font-size: 18px; margin: 8px 0; }
.modal .muted { color: #00000088; }
.modal p { margin: 8px 0; }
.share-row { display: flex; gap: 8px; margin: 10px 0; }
.share-row input { flex: 1; background: #00000010; color: var(--ink); border-color: #00000022; }
.player-list { list-style: none; margin: 12px 0; display: grid; gap: 6px; }
.player-list li { border-left: 5px solid var(--c); padding-left: 10px; font-weight: 600; }
.how-mini { background: #00000010; border-radius: 8px; padding: 8px 12px; margin: 10px 0; font-size: 14px; }
#name-form { display: flex; gap: 10px; margin-top: 12px; }
#name-form input { flex: 1; background: #00000010; color: var(--ink); border-color: #00000022; }

.quiz-modal .choices { display: grid; gap: 8px; margin: 12px 0; }
.btn.choice { background: var(--ink); text-align: left; }
.btn.choice:hover { background: #000; }
.btn.choice.correct { background: #1e8449; }
.btn.choice.wrong { background: var(--terra-dark); }
.btn.choice:disabled { opacity: 0.75; cursor: default; }
.quiz-result.good { color: #1e8449; font-weight: 700; }
.quiz-result.warn { color: var(--terra); font-weight: 700; }
.quiz-explain { font-style: italic; }
.kills { list-style: none; margin: 10px 0; }

#conn-status {
  position: fixed;
  bottom: 130px;
  left: 14px;
  font-size: 13px;
  color: #ffb347;
  z-index: 25;
}

/* Admin */
.admin-form { display: grid; gap: 10px; margin: 18px 0; }
.admin-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.admin-row span { display: flex; flex-direction: column; }
.admin-row small { opacity: 0.6; }
.admin-row input {
  width: 110px;
  border-radius: 8px;
  border: 1px solid #ffffff33;
  background: #ffffff14;
  color: var(--marble);
  padding: 8px 10px;
  font-size: 15px;
}
.admin-saved { color: #2ecc71; font-weight: 600; }

#zoom-controls {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 15;
}
#zoom-controls button {
  width: 40px;
  height: 40px;
  font-size: 20px;
  border-radius: 10px;
  border: none;
  background: #10161dd9;
  color: var(--marble);
  cursor: pointer;
}
#zoom-controls button:hover { background: #10161d; }
