/* Die Stämme – Einzelspieler. Layout and components; colours come from palette.css. */
* { box-sizing: border-box; }
html { font-size: 13px; }
body {
  margin: 0;
  font-family: Verdana, "DejaVu Sans", Arial, sans-serif;
  color: var(--text, #2b1d0e);
  background: var(--bg, #e9d9b4) var(--bg-pattern, none);
  min-height: 100vh;
}
a { color: var(--link, #603000); text-decoration: none; font-weight: bold; }
a:hover { color: var(--link-hover, #a04000); text-decoration: underline; }
h2 { font-size: 1.45rem; margin: .3em 0 .6em; display: flex; align-items: center; gap: .4em; }
h3 { font-size: 1.15rem; margin: 1.2em 0 .4em; }
code { background: rgba(0,0,0,.06); padding: 0 .25em; border-radius: 2px; }
.muted { color: var(--muted, #7a6548); font-weight: normal; }
.warn { color: var(--danger, #b0200c); }
.ok { color: var(--success, #2f6b16); }
.r { text-align: right; }
.inline { display: inline; margin: 0; }
.desc { max-width: 60em; line-height: 1.45; }

/* ---------- header */
.top {
  display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap;
  padding: .3rem 1rem;
  background: var(--panel-head, #c1a264);
  border-bottom: 2px solid var(--border-strong, #7d5a2b);
  box-shadow: 0 2px 4px var(--shadow, rgba(60,40,10,.25));
}
.logo img { height: 42px; display: block; }
.menu { display: flex; flex-wrap: wrap; gap: .2rem .9rem; align-items: center; flex: 1; }
.menu a, .linkbtn { color: var(--panel-head-text, #2b1d0e); }
.linkbtn { background: none; border: 0; font: inherit; font-weight: bold; cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.badge { background: var(--danger, #b0200c); color: #fff; border-radius: 8px; padding: 0 .45em; font-size: .85em; }
.servertime { font-size: .9rem; white-space: nowrap; }

.villagebar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .35rem 1rem;
  background: var(--panel, #f4e4bc);
  border-bottom: 1px solid var(--border, #c4a46a);
}
.villagebar .arrow { font-size: 1rem; padding: 0 .2rem; }
.village-select { font: inherit; font-weight: bold; max-width: 22rem; }
.vb-points { color: var(--muted, #7a6548); }
.resbar { margin-left: auto; display: flex; gap: .9rem; flex-wrap: wrap; }
.res { white-space: nowrap; display: inline-flex; align-items: center; gap: .2rem; }
.res .full, .res.full { color: var(--danger, #b0200c); font-weight: bold; }

.quickbar {
  display: flex; flex-wrap: wrap; gap: .1rem .9rem; padding: .3rem 1rem;
  background: var(--panel-alt, #ead6a8); border-bottom: 1px solid var(--border, #c4a46a); font-size: .92rem;
}

.content { padding: .8rem 1rem 2rem; max-width: 1180px; }
.foot { text-align: center; color: var(--muted, #7a6548); font-size: .85rem; padding: 1rem; }

/* ---------- icons */
.ico { width: 18px; height: 18px; vertical-align: -4px; }
.uico { width: 18px; height: 18px; vertical-align: -4px; }
.uico.big, .bico.big { width: 36px; height: 36px; vertical-align: middle; }
.bico { width: 18px; height: 18px; vertical-align: -4px; }
.dot { width: 12px; height: 12px; vertical-align: -1px; }

/* ---------- tables */
table.vis {
  border-collapse: separate; border-spacing: 0; margin: 0 0 .9rem;
  background: var(--panel, #f4e4bc); border: 1px solid var(--border, #c4a46a);
  box-shadow: 0 1px 2px var(--shadow, rgba(60,40,10,.15));
}
table.vis.wide { width: 100%; }
table.vis th {
  background: var(--panel-head, #c1a264); color: var(--panel-head-text, #2b1d0e);
  text-align: left; padding: .3rem .5rem; font-weight: bold; white-space: nowrap;
}
table.vis td { padding: .28rem .5rem; border-top: 1px solid var(--border, #c4a46a); vertical-align: middle; }
table.vis tr:nth-child(even) td { background: var(--panel-alt, #ead6a8); }
table.vis tr.current td { background: var(--selected-row, #fff3cf); font-weight: bold; }
table.vis tr.locked td { opacity: .62; }
table.vis tr.unread td { font-weight: bold; }
table.units th, table.units td { text-align: center; padding: .25rem .3rem; }
table.units td:first-child { text-align: left; }
td.zero { color: var(--muted, #b4a080); }
.cost { white-space: nowrap; display: inline-flex; gap: .5rem; }
.cost .warn { color: var(--danger, #b0200c); font-weight: bold; }

/* ---------- forms and buttons */
input, select, textarea, button { font: inherit; }
input[type=number], input[type=text], input:not([type]), input[type=password], select, textarea {
  border: 1px solid var(--border-strong, #7d5a2b); background: #fffaf0; padding: .15rem .3rem; border-radius: 2px;
}
input[type=number] { width: 5.5em; }
.btn {
  display: inline-block; cursor: pointer; padding: .22rem .7rem; border-radius: 3px;
  border: 1px solid var(--border-strong, #7d5a2b);
  background: linear-gradient(#f7e8c2, #dcc08a); color: var(--text, #2b1d0e); font-weight: bold;
}
.btn:hover { filter: brightness(1.06); }
.btn.primary { background: linear-gradient(var(--accent-light, #8bb05a), var(--accent, #5b7f2d)); color: var(--accent-text, #fff); }
.btn.attack { background: linear-gradient(#e58a6d, var(--danger, #b0200c)); color: #fff; }
.btn.support { background: linear-gradient(#a3c97a, var(--success, #2f6b16)); color: #fff; }
.btn.small { padding: .05rem .45rem; font-size: .9rem; }
.btn.ghost { background: transparent; }
.flash { padding: .5rem .8rem; border-radius: 3px; margin: 0 0 .8rem; border: 1px solid; }
.flash.error { background: #f8d7cf; border-color: var(--danger, #b0200c); color: #6a1000; }
.flash.success { background: #e2efcf; border-color: var(--success, #2f6b16); color: #20430c; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin: 0 0 .8rem; border-bottom: 2px solid var(--border-strong, #7d5a2b); }
.tabs a { padding: .3rem .8rem; background: var(--panel-alt, #ead6a8); border: 1px solid var(--border, #c4a46a); border-bottom: 0; border-radius: 3px 3px 0 0; }
.tabs a.active { background: var(--panel-head, #c1a264); color: var(--panel-head-text, #2b1d0e); }
.rename { margin-top: 1rem; }
.notes { width: 100%; max-width: 60rem; font-family: inherit; }
.pager a, .pager b { margin-right: .4rem; }

/* ---------- smithy pips */
.pip { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border-strong, #7d5a2b); margin-right: 2px; vertical-align: -2px; background: #fff8e6; }
.pip.on { background: var(--accent, #5b7f2d); }
.pip.pending { background: repeating-linear-gradient(45deg, var(--accent, #5b7f2d) 0 2px, #fff8e6 2px 4px); }

/* ---------- village overview */
.overview { display: grid; grid-template-columns: minmax(0, 620px) minmax(240px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .overview { grid-template-columns: 1fr; } }
.scene { position: relative; width: 100%; max-width: 600px; aspect-ratio: 3 / 2; border: 2px solid var(--border-strong, #7d5a2b); margin-bottom: .8rem; overflow: hidden; background: var(--map-bg, #8aa24e); }
.scene-bg, .scene-wall { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.scene-wall { z-index: 2; }
.scene-b { position: absolute; display: block; z-index: 3; }
.scene-b img { width: 100%; height: 100%; display: block; transition: filter .1s; }
.scene-b:hover img { filter: brightness(1.15) drop-shadow(0 0 3px #fff6c8); }
.scene-b .lvl {
  position: absolute; right: -2px; bottom: -2px; min-width: 18px; padding: 0 3px; text-align: center;
  background: rgba(30,20,8,.78); color: #fff; font-size: 10px; border-radius: 8px; line-height: 16px;
}
.buildings-list { width: 100%; max-width: 600px; }
.ov-right table.vis { width: 100%; }

/* ---------- rally point */
.units-grid td.unit-cell { white-space: nowrap; }
.send-form input[name=x], .send-form input[name=y] { width: 4em; }

/* ---------- farm assistant */
.farm-btn {
  display: inline-block; width: 26px; height: 22px; line-height: 20px; text-align: center; cursor: pointer;
  border: 1px solid var(--border-strong, #7d5a2b); border-radius: 3px; font-weight: bold; color: #fff;
}
.farm-a { background: #3d7ab8; } .farm-b { background: #b8813d; } .farm-c { background: #6a4a9b; }
.farm-btn.disabled { background: #c9b995; color: #fff8; cursor: default; }
.tpl-editor { display: flex; gap: 1rem; flex-wrap: wrap; margin: .5rem 0; }
.tpl-editor ul.ids { columns: 2; font-size: .9rem; padding-left: 1rem; margin: 0; }

/* ---------- reports */
.luckbar { display: inline-block; width: 200px; height: 10px; background: #e7d3a5; border: 1px solid var(--border, #c4a46a); position: relative; vertical-align: middle; }
.luckbar span { position: absolute; top: 0; bottom: 0; }
.luckbar .pos { left: 50%; background: var(--success, #2f6b16); }
.luckbar .neg { right: 50%; background: var(--danger, #b0200c); }

/* ---------- map */
.map-wrap { position: relative; }
.map-controls { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin-bottom: .5rem; }
.map-controls input { width: 4em; }
.map-main { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.map-grid {
  position: relative; display: grid; border: 2px solid var(--border-strong, #7d5a2b);
  background: var(--map-bg, #8aa24e); user-select: none; cursor: grab; outline: none; overflow: hidden;
}
.map-grid.dragging { cursor: grabbing; }
.map-grid .tile { width: 53px; height: 38px; position: relative; background-size: 100% 100%; }
.map-grid .tile.v { cursor: pointer; }
.map-grid .tile .mk { position: absolute; left: 1px; top: 1px; width: 11px; height: 11px; }
.map-grid .tile.cur { outline: 2px solid var(--selected, #fff); outline-offset: -2px; z-index: 1; }
.map-grid .tile.k-left { border-left: 1px solid rgba(0,0,0,.35); }
.map-grid .tile.k-top { border-top: 1px solid rgba(0,0,0,.35); }
.map-grid .tile:hover { filter: brightness(1.12); }
.map-grid .axis { position: absolute; font-size: 10px; color: #fff; text-shadow: 0 0 2px #000; pointer-events: none; }
.mk { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0,0,0,.5); vertical-align: -1px; }
.mk.own { background: var(--own, #f0d000); } .mk.barb { background: var(--barb, #9a9a9a); }
.mk.other { background: var(--other, #a33b1f); } .mk.sel { background: var(--selected, #fff); }
.minimap { border: 2px solid var(--border-strong, #7d5a2b); background: var(--map-bg, #8aa24e); cursor: crosshair; image-rendering: pixelated; }
.map-popup {
  position: absolute; z-index: 10; min-width: 220px; background: var(--panel, #f4e4bc);
  border: 1px solid var(--border-strong, #7d5a2b); box-shadow: 0 3px 10px var(--shadow, rgba(0,0,0,.3)); padding: .5rem .7rem;
}
.map-popup h4 { margin: 0 0 .3rem; }
.map-popup ul { margin: .4rem 0 0; padding-left: 1rem; }

/* ---------- public pages */
body.public { display: flex; align-items: center; justify-content: center; }
.public-box { background: var(--panel, #f4e4bc); border: 2px solid var(--border-strong, #7d5a2b); padding: 1.5rem 2rem; max-width: 30rem; margin: 2rem; box-shadow: 0 4px 16px var(--shadow, rgba(0,0,0,.3)); }
.public-logo { display: block; max-width: 100%; margin: 0 auto 1rem; }
.auth { display: flex; flex-direction: column; gap: .6rem; margin-bottom: 1rem; }
.auth label { display: flex; flex-direction: column; gap: .2rem; font-weight: bold; }
.settings-form label { display: inline-block; min-width: 18rem; }
.map-grid .axis-cell { font-size: 10px; display: flex; align-items: center; justify-content: center; background: var(--panel-head, #c1a264); color: var(--panel-head-text, #2b1d0e); }
.map-grid .axis-cell.top { height: 16px; }
.travel-grid label { display: inline-flex; align-items: center; gap: 2px; margin: 0 .5rem .2rem 0; }
.travel-grid input { width: 4em; }
.bonus-note { background: #fff3cf; border: 1px solid var(--border, #c4a46a); padding: .3rem .6rem; display: inline-block; }
.map-grid .tile .bonus { position: absolute; right: 1px; top: 1px; width: 12px; height: 12px; }
.map-grid .tile .mk.marked { box-shadow: 0 0 0 2px #fff; }
.mark-swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid #333; vertical-align: -2px; }

/* Installable app */
[hidden] { display: none !important; }
.map-grid { touch-action: none; } /* dragging the map must not scroll the page on touch screens */

/* ---------- tablets and phones: wide tables scroll sideways instead of widening the page */
@media (max-width: 1100px) {
  table.vis { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.vis > tbody { display: table; border-spacing: 0; }
  table.vis.wide > tbody { width: 100%; }
}

/* ---------- small screens (phones, installed app) */
@media (max-width: 700px) {
  html { font-size: 14px; -webkit-text-size-adjust: 100%; }
  h2 { font-size: 1.25rem; flex-wrap: wrap; }
  .top { gap: .2rem .8rem; padding: .3rem .6rem 0; }
  .logo img { height: 32px; }
  .servertime { margin-left: auto; font-size: .85rem; }
  .menu, .quickbar, .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
  .menu { order: 3; flex: 1 0 100%; gap: 0; margin: 0 -.6rem; padding: 0 .3rem; }
  .menu a, .menu .linkbtn { display: inline-block; padding: .6rem .5rem; white-space: nowrap; }
  .villagebar { padding: .35rem .6rem; gap: .3rem .4rem; }
  .villagebar .arrow { padding: .35rem .55rem; }
  .village-select { flex: 1; min-width: 0; max-width: none; }
  .resbar { margin-left: 0; width: 100%; justify-content: space-between; gap: .3rem; }
  .quickbar { gap: 0; padding: 0 .3rem; }
  .quickbar a { padding: .55rem .45rem; white-space: nowrap; }
  .tabs a { white-space: nowrap; padding: .5rem .7rem; }
  .content { padding: .6rem .6rem 1.5rem; }
  table.vis > tbody { width: 100%; } /* phones: every table uses the full width */
  /* troop selection: two units per row instead of one very wide row */
  table.vis.units-grid, table.vis.units-grid > tbody { display: block; width: auto; overflow: visible; }
  table.vis.units-grid tr { display: grid; grid-template-columns: 1fr 1fr; }
  table.vis.units-grid td { border-top: 1px solid var(--border, #c4a46a); }
  .units-grid input[type=number] { width: 4.2em; }
  input, select, textarea { font-size: 16px; } /* prevents the automatic zoom on iOS */
  select { max-width: 100%; }
  textarea { max-width: 100%; }
  .btn { padding: .4rem .8rem; }
  .btn.small { padding: .25rem .55rem; }
  .settings-form label { min-width: 0; }
  .luckbar { width: 120px; }
  .public-box { margin: 1rem; padding: 1.2rem 1rem; }
  .map-popup { position: fixed; top: auto !important; left: .5rem !important; right: .5rem; bottom: .5rem; min-width: 0; z-index: 20; }
  .minimap { width: 160px; height: 160px; }
}
