/* Civilization.io – menu i ekrany w DOM (gra i HUD są rysowane na płótnie). Styl jak w Zombie.io, w barwach ziemi.
   Kolory wyłącznie z palety gry (public/js/palette.js); przezroczystość jako rgba() z kolorem palety. */
:root {
  --accent: #efc85a;
  --accent-dark: #7e5030;
  --accent-mid: #d8a434;
  --accent-low: #b47e24;
  --panel: rgba(27, 24, 19, 0.95);
  --edge: #4a3c2a;
  --text: #f4ecd8;
  --muted: #b8b0a0;
  --field: #16130f;
  --warn: #f0a040;
  --row: #43291a;
  --bg: #1f3f5c;
  --shadow: 13, 11, 8;
  --glow: 239, 200, 90;
  --white-soft: #e8e4da;
  --grey-dark: #403d39;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden; background: var(--bg); font-family: 'Segoe UI', Tahoma, sans-serif; color: var(--text);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; touch-action: none; }

.overlay {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(var(--shadow), 0.45), rgba(var(--shadow), 0.88));
  z-index: 10; padding: 12px; overflow: auto;
}
.overlay.dim { background: rgba(var(--shadow), 0.55); z-index: 12; }
.hidden { display: none !important; }

.panel {
  width: min(460px, calc(100vw - 24px)); padding: 26px 28px 22px; border-radius: 14px; margin: auto;
  background: var(--panel); border: 2px solid var(--edge); box-shadow: 0 12px 50px rgba(var(--shadow), 0.6); text-align: center;
}
.panel h2 { font-family: Impact, 'Arial Black', sans-serif; font-size: 36px; letter-spacing: 2px; color: var(--accent); margin-bottom: 6px; }
.title {
  font-family: Impact, 'Arial Black', sans-serif; font-size: 54px; letter-spacing: 3px; color: var(--accent);
  text-shadow: 0 4px 0 var(--accent-dark), 0 0 30px rgba(var(--glow), 0.35); line-height: 1;
}
.title span { color: var(--white-soft); font-size: 34px; text-shadow: 0 3px 0 var(--grey-dark); }
.subtitle { color: var(--muted); margin: 10px 0 18px; font-size: 15px; }
.note { color: var(--muted); font-size: 13px; margin-bottom: 10px; }

#nick, #lang {
  width: 100%; padding: 12px 14px; font-size: 18px; border-radius: 8px; border: 2px solid var(--edge);
  background: var(--field); color: var(--text); outline: none; margin-bottom: 10px; font-family: inherit;
}
#nick:focus { border-color: var(--accent); }
#lang { font-size: 14px; padding: 6px 10px; margin: 12px 0 0; width: auto; cursor: pointer; }

.btn-play {
  width: 100%; padding: 14px; font-size: 24px; font-family: Impact, 'Arial Black', sans-serif; letter-spacing: 2px;
  background: linear-gradient(var(--accent-mid), var(--accent-low)); color: var(--text); border: none; border-radius: 8px; cursor: pointer;
  box-shadow: 0 4px 0 var(--accent-dark); text-shadow: 0 2px 0 rgba(var(--shadow), 0.35); transition: transform 0.08s;
}
.btn-play:hover { background: var(--accent); }
.btn-play:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dark); }

.status { min-height: 20px; margin: 8px 0 4px; color: var(--warn); font-size: 14px; }
.help { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.6; white-space: pre-line; }

.end-list { list-style: none; text-align: left; margin: 6px 0 10px; }
.end-list li { display: flex; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid var(--row); }
.end-list li.me { color: var(--accent); font-weight: bold; }

/* panele w grze (stacja, magazyn, totem) i menu budowy – po prawej stronie, gra widoczna obok */
.game-panel {
  position: fixed; right: 14px; top: 230px; width: min(380px, calc(100vw - 28px)); max-height: calc(100vh - 330px); overflow: auto;
  background: var(--panel); border: 2px solid var(--edge); border-radius: 12px; padding: 12px 14px; z-index: 8;
  box-shadow: 0 8px 30px rgba(var(--shadow), 0.5); font-size: 14px;
}
.game-panel.wide { width: min(560px, calc(100vw - 28px)); top: 70px; max-height: calc(100vh - 190px); right: 50%; transform: translateX(50%); }
.game-panel h3 { color: var(--accent); font-size: 18px; }
.game-panel h4 { color: var(--muted); font-size: 13px; margin: 10px 0 6px; text-transform: uppercase; letter-spacing: 1px; }
.game-panel .note { font-size: 12px; margin: 4px 0 8px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.btn-x { background: none; border: 1px solid var(--edge); color: var(--muted); border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.btn-small {
  margin-top: 8px; padding: 7px 12px; font-size: 13px; font-weight: bold; border: none; border-radius: 6px; cursor: pointer;
  background: var(--accent-mid); color: var(--field); font-family: inherit;
}
.btn-small:disabled { background: var(--grey-dark); color: var(--muted); cursor: not-allowed; }
.btn-small.danger { background: var(--row); color: var(--text); }
.cost { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.cost-item { display: inline-flex; align-items: center; gap: 2px; font-weight: bold; font-size: 13px; }
.cost-item.missing { color: var(--warn); }
.recipe { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--row); }
.recipe.is-locked { opacity: 0.5; }
.recipe-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.recipe-info small, .build-item small { color: var(--muted); font-size: 12px; }
.recipe-act { display: flex; flex-direction: column; align-items: flex-end; min-width: 86px; }
.recipe-act .btn-small { margin-top: 4px; }
.locked { color: var(--warn); font-size: 12px; }
.bar { width: 100%; height: 8px; background: var(--field); border-radius: 4px; overflow: hidden; margin-top: 6px; min-width: 80px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width 0.1s linear; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot {
  position: relative; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  background: var(--field); border: 1px solid var(--edge); border-radius: 8px; cursor: pointer;
}
.slot:disabled { cursor: default; opacity: 0.5; }
.slot .cnt { position: absolute; right: 3px; bottom: 1px; font-size: 12px; font-weight: bold; color: var(--text); }
.clan-head { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 16px; }
.clan-head input { flex: 1; padding: 5px 8px; font-size: 15px; background: var(--field); color: var(--text); border: 1px solid var(--edge); border-radius: 6px; font-family: inherit; }
.swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.build-era h4 { margin-top: 12px; }
.build-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.build-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; padding: 8px; cursor: pointer;
  background: var(--field); color: var(--text); border: 1px solid var(--edge); border-radius: 8px; font-family: inherit; font-size: 13px;
}
.build-item:hover:not(:disabled) { border-color: var(--accent); }
.build-item.is-locked { opacity: 0.5; cursor: not-allowed; }
.build-item .time { color: var(--muted); }
