/* Die Stämme Offline – klassischer Braun/Pergament-Look */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: Verdana, Arial, sans-serif;
  font-size: 13px;
  background: #436213 url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"><rect width="40" height="40" fill="%23436213"/><circle cx="10" cy="10" r="1.5" fill="%234d6f1a"/><circle cx="30" cy="25" r="2" fill="%233c570f"/></svg>');
  color: #3b2b18;
}
#app { max-width: 1100px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

#topbar {
  background: linear-gradient(#7a5b32, #5e4423);
  border: 2px solid #3b2b18; border-top: none;
  border-radius: 0 0 8px 8px;
  color: #f4e4bc;
  display: flex; align-items: center; gap: 16px;
  padding: 8px 14px; flex-wrap: wrap;
}
#logo { font-weight: bold; font-size: 17px; text-shadow: 1px 1px 2px #000; }
#logo .offline { font-size: 11px; color: #ffd87a; }
#village-bar { display: flex; gap: 4px; align-items: center; }
#village-bar select { padding: 3px 6px; border-radius: 4px; border: 1px solid #3b2b18; background: #f4e4bc; font-family: inherit; }
#village-bar button { padding: 3px 8px; cursor: pointer; border: 1px solid #3b2b18; background: #c1a264; border-radius: 4px; }
#res-bar { margin-left: auto; display: flex; gap: 14px; font-size: 13px; }
.res b { color: #fff; }

#main { display: flex; flex: 1; gap: 10px; padding: 10px 0; }
#menu {
  width: 190px; flex-shrink: 0;
  background: #f4e4bc; border: 2px solid #7a5b32; border-radius: 6px;
  padding: 8px; height: fit-content;
  display: flex; flex-direction: column; gap: 4px;
}
#menu button {
  text-align: left; padding: 8px 10px; cursor: pointer;
  background: #e7d5a8; border: 1px solid #b09a6a; border-radius: 4px;
  font-family: inherit; font-size: 13px; color: #3b2b18;
  position: relative;
}
#menu button:hover { background: #d9c48d; }
#menu button.active { background: #c1a264; font-weight: bold; }
.badge {
  background: #c0392b; color: #fff; border-radius: 10px;
  font-size: 10px; padding: 1px 6px; margin-left: 4px;
}

#content {
  flex: 1; background: #f4e4bc; border: 2px solid #7a5b32; border-radius: 6px;
  padding: 14px; min-height: 500px; overflow-x: auto;
}
h2 { font-size: 16px; margin-bottom: 10px; border-bottom: 2px solid #c1a264; padding-bottom: 6px; }
h3 { font-size: 14px; margin: 12px 0 6px; }

table.ds { width: 100%; border-collapse: collapse; margin: 8px 0; }
table.ds th {
  background: #c1a264; padding: 5px 8px; text-align: left;
  border: 1px solid #a08752; font-size: 12px;
}
table.ds td { padding: 5px 8px; border: 1px solid #d3bf90; background: #faf0d7; }
table.ds tr:nth-child(even) td { background: #f0e2bd; }

button.act {
  padding: 4px 12px; cursor: pointer; font-family: inherit;
  background: linear-gradient(#8a6d3b, #6d5228); color: #f4e4bc;
  border: 1px solid #3b2b18; border-radius: 4px; font-size: 12px;
}
button.act:hover { background: linear-gradient(#9a7d4b, #7d6238); }
button.act:disabled { opacity: 0.45; cursor: not-allowed; }
button.small { padding: 2px 8px; font-size: 11px; }
button.danger { background: linear-gradient(#a04030, #802818); }

input[type=text], input[type=number] {
  padding: 4px 6px; border: 1px solid #a08752; border-radius: 3px;
  background: #fff9ea; font-family: inherit; width: 90px;
}
input.coord { width: 55px; }
label { margin-right: 8px; }

.cost { white-space: nowrap; font-size: 12px; }
.cost .no { color: #c0392b; font-weight: bold; }
.muted { color: #8a795a; font-size: 12px; }
.good { color: #1e7a1e; }
.bad { color: #c0392b; }
.row { display: flex; gap: 20px; flex-wrap: wrap; }
.box {
  background: #faf0d7; border: 1px solid #c1a264; border-radius: 5px;
  padding: 10px; margin: 8px 0;
}

/* Karte */
#map-wrap { position: relative; }
#map-canvas { border: 2px solid #7a5b32; border-radius: 4px; cursor: grab; background: #5a7a2a; }
#map-canvas.dragging { cursor: grabbing; }
#map-tooltip {
  position: absolute; pointer-events: none; background: #3b2b18ee; color: #f4e4bc;
  padding: 6px 10px; border-radius: 5px; font-size: 12px; z-index: 5; display: none;
  white-space: nowrap;
}
#map-ctx {
  position: absolute; background: #f4e4bc; border: 2px solid #7a5b32; border-radius: 5px;
  padding: 8px; z-index: 6; display: none; min-width: 180px;
}
#map-ctx button { display: block; width: 100%; margin: 3px 0; }
.legend { display: flex; gap: 14px; margin-top: 6px; font-size: 12px; flex-wrap: wrap; }
.legend span::before { content: '■ '; }

/* Berichte */
.report-item { cursor: pointer; }
.report-item.unread td { font-weight: bold; }
.report-detail { margin-top: 10px; }
.units-table td, .units-table th { text-align: center; font-size: 11px; padding: 3px 5px; }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #3b2b18; color: #f4e4bc; padding: 10px 20px; border-radius: 6px;
  z-index: 100; box-shadow: 0 2px 12px #0008;
}
#toast.error { background: #7a2018; }
.hidden { display: none !important; }

.progress { background: #d3bf90; border-radius: 3px; height: 14px; overflow: hidden; margin-top: 2px; }
.progress > div { background: linear-gradient(#8ab54a, #6d9a2e); height: 100%; transition: width 1s linear; }

/* Konstruktions-Vorlagen */
.tpl-grid { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 16px; }
.tpl-card {
  display: flex; align-items: flex-start; gap: 14px;
  background: #faf0d7; border: 1px solid #c1a264; border-radius: 6px; padding: 12px;
}
.tpl-icon { font-size: 28px; line-height: 1; flex-shrink: 0; width: 36px; text-align: center; }
.tpl-body { flex: 1; min-width: 0; }
.tpl-body b { font-size: 14px; }
.tpl-body p { margin: 3px 0; }
.tpl-actions { display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }

#login-overlay {
  position: fixed; inset: 0; background: #2a3a10ee; z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
#login-box {
  background: #f4e4bc; border: 3px solid #7a5b32; border-radius: 8px;
  padding: 30px 40px; text-align: center; box-shadow: 0 4px 30px #000a;
}
#login-box h2 { border: none; }
#login-box input { width: 220px; font-size: 15px; padding: 8px; margin: 10px 0; }
#login-box button { font-size: 15px; padding: 8px 24px; }
#login-error { color: #c0392b; min-height: 16px; }
#player-name { color: #ffd87a; font-size: 12px; }

.timer { font-family: 'Courier New', monospace; font-weight: bold; }
.mov-attack { color: #c0392b; }
.mov-support { color: #1e7a1e; }
.mov-return { color: #8a795a; }
.mov-incoming { color: #c0392b; font-weight: bold; }

#map-canvas { display: block; max-width: 100%; touch-action: none; }

/* ---------- Smartphone / schmale Bildschirme ---------- */
@media (max-width: 768px) {
  body { font-size: 14px; }
  #app { max-width: 100%; }

  #topbar { padding: 6px 8px; gap: 8px; }
  #logo { font-size: 15px; }
  #res-bar { margin-left: 0; gap: 8px; flex-wrap: wrap; font-size: 12px; }
  #village-bar select { max-width: 120px; }

  /* Menü wird zur horizontal scrollbaren Tab-Leiste */
  #main { flex-direction: column; gap: 6px; padding: 6px 0; }
  #menu {
    width: 100%; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 6px; gap: 6px;
  }
  #menu button {
    flex: 0 0 auto; white-space: nowrap; padding: 10px 12px;
    font-size: 12px;
  }

  #content { padding: 10px; min-height: 0; }
  h2 { font-size: 15px; }

  table.ds { font-size: 12px; }
  table.ds th, table.ds td { padding: 4px 6px; }

  input[type=text], input[type=number] { width: 76px; padding: 6px; }

  /* Größere Touch-Ziele für Buttons */
  button.act { padding: 8px 14px; font-size: 13px; }
  button.act.small { padding: 6px 10px; font-size: 12px; }

  #login-box { padding: 20px; width: calc(100vw - 32px); max-width: 340px; }
  #login-box input { width: 100%; box-sizing: border-box; }

  .tpl-card { flex-direction: column; }
  .row { gap: 10px; }
}
