/* ============ Knollenkrieg — Stylesheet ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #12140e;
  --panel: #1d2117;
  --panel2: #262b1e;
  --border: #3a4230;
  --text: #e8e6d8;
  --muted: #9a9a88;
  --accent: #8fce5e;
  --accent-dark: #5a9142;
  --gold: #e8c35a;
  --hp: #d9534f;
  --xp: #6fc36f;
  --r1: #9a9a88;  /* gewöhnlich */
  --r2: #6fbf5e;  /* ungewöhnlich */
  --r3: #5aa2e8;  /* selten */
  --r4: #b06fe8;  /* episch */
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

/* width/height explizit: ohne sie zeigt der Browser das Canvas in seiner
   internen (DPR-skalierten) Groesse an und es ragt aus dem Fenster raus */
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at center, rgba(20,24,14,.92), rgba(10,12,7,.97));
  z-index: 20;
  padding: 24px;
  overflow-y: auto;
}
.screen.overlay { background: rgba(10, 12, 7, .88); }

h1.title {
  font-size: clamp(42px, 8vw, 84px);
  letter-spacing: 3px;
  color: var(--accent);
  text-shadow: 0 4px 0 #2c4420, 0 8px 24px rgba(0,0,0,.6);
  font-weight: 900;
}
.subtitle { color: var(--muted); font-size: 18px; margin-top: -8px; }
h2 { font-size: 32px; color: var(--accent); letter-spacing: 1px; }
h3 { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 10px 0 6px; }
.small-hint { font-size: 11px; text-transform: none; letter-spacing: 0; }

.hint { color: var(--muted); font-size: 13px; margin-top: 18px; }
.menu-stats { color: var(--muted); font-size: 14px; text-align: center; line-height: 1.6; }
.menu-stats b { color: var(--gold); }

#menu-main { display: flex; flex-direction: column; align-items: center; gap: 14px; }

/* ---------- Buttons ---------- */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  color: var(--text);
}
.big-btn {
  font-size: 22px; font-weight: 700;
  padding: 14px 46px;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #14200c;
  border-radius: 10px;
  box-shadow: 0 4px 0 #37592a, 0 6px 16px rgba(0,0,0,.5);
  transition: transform .06s;
}
.big-btn:hover { transform: translateY(-2px); }
.big-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 #37592a; }
.big-btn:disabled { filter: grayscale(.8) brightness(.6); cursor: default; transform: none; }
.flat-btn {
  font-size: 15px;
  padding: 9px 22px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.flat-btn:hover { background: #313827; }
.flat-btn.danger { color: #e88; border-color: #6a3a34; }
.flat-btn:disabled { opacity: .45; cursor: default; }
.row-center { display: flex; gap: 14px; justify-content: center; align-items: center; flex-wrap: wrap; }
.col-center { display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* ---------- Karten ---------- */
.card-grid {
  display: flex; flex-wrap: wrap; gap: 14px;
  justify-content: center;
  max-width: 1080px;
}
.card {
  width: 225px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
  transition: transform .08s, border-color .08s;
  position: relative;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.card.locked-look { border-style: dashed; }
.card .card-name { font-weight: 700; font-size: 17px; }
.card .card-sub { font-size: 12px; color: var(--muted); }
.card .card-desc { font-size: 13px; line-height: 1.45; color: var(--text); white-space: pre-line; }
.card .card-desc .neg { color: #e88; }
.card .card-desc .pos { color: var(--accent); }
.card .card-icon { font-size: 34px; line-height: 1; height: 40px; display:flex; align-items:center; }
.card .card-icon canvas { image-rendering: pixelated; }
.card .price { font-weight: 700; color: var(--gold); font-size: 15px; }
.card .price.too-expensive { color: #e88; }
.card .best { font-size: 11px; color: var(--gold); }
.card.r1 { border-color: #4a4a40; } .card.r1 .card-sub { color: var(--r1); }
.card.r2 { border-color: #3f6b38; } .card.r2 .card-sub { color: var(--r2); }
.card.r3 { border-color: #38567b; } .card.r3 .card-sub { color: var(--r3); }
.card.r4 { border-color: #64407e; } .card.r4 .card-sub { color: var(--r4); }
.card.r2:hover { border-color: var(--r2); }
.card.r3:hover { border-color: var(--r3); }
.card.r4:hover { border-color: var(--r4); }
.card .tier-pips { display: flex; gap: 3px; }
.card .tier-pips i { width: 10px; height: 10px; border-radius: 2px; background: #3a4230; }
.card .tier-pips i.on { background: var(--gold); }
.lock-btn {
  position: absolute; top: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 6px;
  background: var(--panel2);
  border: 1px solid var(--border);
  font-size: 14px;
  z-index: 2;
}
.lock-btn.locked { background: #4d431e; border-color: var(--gold); }
.card.sold { opacity: .35; pointer-events: none; }
.card.blocked { filter: saturate(.5) brightness(.8); }
.card .full-hint { color: #e88; font-size: 12px; font-weight: 700; }

.mini-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.mini-card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  display: flex; align-items: center; gap: 7px;
  position: relative;
}
.mini-card .tier-tag { color: var(--gold); font-size: 11px; font-weight: 700; }
.mini-card .sell-x {
  background: none; border: none; color: #e88; font-size: 12px;
  padding: 0 0 0 4px; cursor: pointer;
}
.mini-card.r2 { border-color: #3f6b38; }
.mini-card.r3 { border-color: #38567b; }
.mini-card.r4 { border-color: #64407e; }

/* ---------- Shop ---------- */
#screen-shop { justify-content: flex-start; padding-top: 28px; }
#shop-head { display: flex; align-items: center; gap: 26px; }
#shop-mats { font-size: 24px; font-weight: 800; color: var(--gold); display: flex; align-items: center; gap: 8px; }
#shop-body { display: flex; gap: 26px; align-items: flex-start; max-width: 1240px; width: 100%; justify-content: center; }
#shop-left { display: flex; flex-direction: column; gap: 14px; align-items: center; max-width: 780px; }
#shop-offers { min-height: 240px; }
#shop-owned { width: 100%; }
#shop-right {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  min-width: 250px;
}
#stats-panel { font-size: 13px; line-height: 1.85; }
#stats-panel .stat-row { display: flex; justify-content: space-between; gap: 18px; }
#stats-panel .stat-row b { color: var(--accent); font-weight: 600; }
#stats-panel .stat-row b.neg { color: #e88; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud-topleft { position: absolute; top: 14px; left: 16px; display: flex; flex-direction: column; gap: 6px; width: 240px; }
.bar-wrap {
  position: relative;
  height: 26px;
  background: rgba(0,0,0,.55);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.bar-wrap.slim { height: 16px; }
.bar { height: 100%; width: 50%; transition: width .15s; }
.bar.hp { background: linear-gradient(180deg, #e06560, #b03e3a); }
.bar.xp { background: linear-gradient(180deg, #83d883, #4e9c4e); }
.bar-wrap span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
#hud-topcenter { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); text-align: center; }
#wave-label { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: 1px; }
#wave-timer { font-size: 38px; font-weight: 900; text-shadow: 0 2px 6px rgba(0,0,0,.7); }
#hud-topright { position: absolute; top: 14px; right: 16px; }
#mat-count { font-size: 22px; font-weight: 800; color: var(--gold); display: flex; align-items: center; gap: 7px; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.mat-icon {
  width: 16px; height: 16px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f5dd8a, #c9992b);
  display: inline-block;
  box-shadow: 0 0 6px rgba(232,195,90,.5);
}
#hud-weapons { position: absolute; bottom: 12px; left: 16px; display: flex; gap: 6px; }
#hud-weapons .wslot {
  width: 42px; height: 42px;
  background: rgba(0,0,0,.45);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  position: relative;
}
#hud-weapons .wslot .t {
  position: absolute; bottom: 1px; right: 3px;
  font-size: 9px; font-weight: 800; color: var(--gold);
}
#boss-bar-wrap {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  width: min(520px, 70vw); height: 18px;
  background: rgba(0,0,0,.6);
  border: 1px solid #6a3a34;
  border-radius: 6px;
  overflow: hidden;
}
#boss-bar { height: 100%; background: linear-gradient(180deg, #b06fe8, #7b3aa8); width: 100%; transition: width .2s; }
#boss-bar-wrap span {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  text-shadow: 0 1px 2px rgba(0,0,0,.9);
}

/* ---------- Endscreens ---------- */
.death-title { color: #e06560; font-size: 46px; }
.win-title { color: var(--gold); font-size: 46px; }
.end-stats {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 30px;
  font-size: 16px; line-height: 2;
  min-width: 300px;
}
.end-stats .stat-row { display: flex; justify-content: space-between; gap: 30px; }
.end-stats b { color: var(--gold); }
.end-stats .record { color: var(--accent); font-weight: 700; text-align: center; }

#pause-stats { max-width: 560px; display: flex; flex-wrap: wrap; gap: 4px 22px; justify-content: center; font-size: 13px; color: var(--muted); }
#pause-stats .stat-row b { color: var(--accent); margin-left: 6px; }
#pause-stats .stat-row b.neg { color: #e88; }

@media (max-width: 900px) {
  #shop-body { flex-direction: column; align-items: center; }
  #shop-right { width: 100%; max-width: 780px; }
  .card { width: 190px; }
}
