:root {
  --ink: #ece6d8;
  --ink-dim: #b8b0a0;
  --panel: rgba(10, 10, 12, 0.82);
  --panel-edge: rgba(236, 230, 216, 0.16);
  --p1: #ff8a3d;
  --p2: #3dd6c8;
  --gold: #f2c94c;
  --bad: #ff4040;
  --warn: #ffb03a;
  --good: #9fe870;
  --syn: #b58cff;
  --light: #fff0c8;
  --mono: "Courier New", ui-monospace, "DejaVu Sans Mono", monospace;
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b1024;
  color: var(--ink);
}

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

[hidden] { display: none !important; }

/* ---------------- winieta */
#vignette {
  position: fixed; inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(5, 8, 20, 0.6) 100%);
}

#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; }
#flash.red { animation: flashRed 0.9s ease-out; }
#flash.white { animation: flashWhite 0.25s ease-out; }
@keyframes flashRed { from { opacity: 1; background: rgba(160, 0, 0, 0.55); } to { opacity: 0; background: rgba(160, 0, 0, 0); } }
@keyframes flashWhite { from { opacity: 1; background: rgba(255, 255, 255, 0.25); } to { opacity: 0; } }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05em 0.4em;
  margin: 0 0.1em;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom-width: 3px;
  font: inherit;
  font-size: 0.88em;
  text-align: center;
}
kbd.big { font-size: 1.1em; padding: 0.15em 0.6em; }

.p1 { color: var(--p1); font-weight: bold; }
.p2 { color: var(--p2); font-weight: bold; }
.muted { color: var(--ink-dim); opacity: 0.85; }

/* ---------------- HUD */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  padding: 14px 18px;
  pointer-events: none;
  font-family: var(--mono);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
}
#night { font-size: 16px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-dim); }
#clock { font-size: 40px; font-weight: bold; letter-spacing: 0.05em; color: #ffdf9a; text-shadow: 0 0 12px rgba(255, 190, 90, 0.45); }

.hud-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.meter-label { font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-dim); }
#meter { position: relative; width: 240px; height: 14px; border: 1px solid rgba(255, 223, 154, 0.5); border-radius: 3px; background: rgba(0, 0, 0, 0.6); overflow: hidden; }
#meter i { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, 0.45); }
#meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #7fb8ff, #ffdf9a); transition: width 0.08s linear; }
#meter.warn #meter-fill { background: linear-gradient(90deg, #ffb03a, #ff7a3a); }
#meter.eye { border-color: var(--bad); }
#meter.eye #meter-fill { background: var(--bad); animation: blink 0.35s steps(2) infinite; }
#quota-wrap { position: relative; width: 240px; height: 20px; margin-top: 4px; border-radius: 3px; background: rgba(0, 0, 0, 0.55); overflow: hidden; border: 1px solid rgba(242, 201, 76, 0.35); }
#quota-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: rgba(242, 201, 76, 0.35); }
#quota-wrap.done { border-color: var(--good); }
#quota-wrap.done #quota-fill { background: rgba(159, 232, 112, 0.4); }
#quota { position: relative; display: block; text-align: center; font-size: 13px; line-height: 20px; font-weight: bold; }

.hud-right { justify-self: end; }
.coins { display: flex; align-items: center; gap: 8px; font-size: 24px; font-weight: bold; }
.coin-icon {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3a0, var(--gold) 55%, #9a7000);
}

@keyframes blink { 50% { opacity: 0.35; } }

/* ---------------- panele graczy */
#panels {
  position: fixed;
  left: 16px; right: 16px; bottom: 16px;
  display: flex; justify-content: space-between; gap: 16px;
  pointer-events: none;
}
.panel {
  width: min(330px, 46vw);
  padding: 8px 12px 10px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  font-size: 14px;
}
.panel.p1 { border-left: 4px solid var(--p1); }
.panel.p2 { border-left: 4px solid var(--p2); margin-left: auto; }
.pname { font-weight: bold; margin-bottom: 5px; }
.panel.p1 .pname { color: var(--p1); }
.panel.p2 .pname { color: var(--p2); }
.pname .mode { color: var(--ink-dim); font-weight: normal; font-size: 12px; margin-left: 6px; }
.pname .off { color: var(--bad); font-weight: normal; font-size: 12px; }
.bar { height: 10px; border-radius: 2px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, #9fe870, #e6ff9a); }
.bar.battery.low > div { background: var(--warn); animation: blink 0.4s steps(2) infinite; }
.bar.battery.empty { outline: 1px solid var(--bad); }
.bar.revive > div { background: linear-gradient(90deg, #fff0c8, #ffffff); }
.items { margin-top: 5px; min-height: 1.2em; color: var(--ink-dim); font-size: 13px; }
.hint { margin-top: 3px; min-height: 1.2em; font-size: 13px; color: var(--light); }
.panel.caught { border-color: rgba(255, 64, 64, 0.5); }
.panel.caught .pname { color: var(--bad) !important; letter-spacing: 0.05em; }
.prog { display: inline-block; width: 70px; height: 7px; margin-left: 6px; background: rgba(255, 255, 255, 0.12); vertical-align: middle; }
.prog i { display: block; height: 100%; background: var(--light); }

/* ---------------- build */
#builds {
  position: fixed;
  left: 16px; top: 100px;
  display: flex; flex-direction: column; gap: 6px;
  pointer-events: none;
  max-width: min(60vw, 380px);
}
.build {
  display: flex; flex-wrap: wrap; gap: 5px; align-items: center;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--panel);
  font-size: 12px;
}
.build.p1 { border-left: 3px solid var(--p1); }
.build.p2 { border-left: 3px solid var(--p2); }
.build span { padding: 1px 6px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.build.syn { color: var(--syn); font-weight: bold; border-left: 3px solid var(--syn); }

/* ---------------- komunikaty */
#toast {
  position: fixed;
  bottom: 74px; left: 50%; /* na dole: u góry jest dziadek i jego dymek */
  transform: translate(-50%, -10px);
  padding: 9px 18px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  font-size: 18px; font-weight: bold;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  text-align: center;
  max-width: min(760px, calc(100vw - 32px));
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { color: var(--bad); }
#toast.warn { color: var(--warn); }
#toast.good { color: var(--good); }
#toast.news { color: var(--light); }
#toast.boss { color: var(--bad); font-size: 22px; border-color: var(--bad); }
#toast.syn { color: var(--syn); }

#floaters { position: fixed; inset: 0; pointer-events: none; }
.floater {
  position: absolute;
  top: 44%;
  font-size: 24px; font-weight: 900;
  text-shadow: 0 2px 4px #000;
  animation: floatUp 1.2s ease-out forwards;
}
.floater.coin { color: var(--gold); }
.floater.bat { color: var(--good); }
@keyframes floatUp {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-80px); opacity: 0; }
}

/* ---------------- ekrany */
#overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  overflow-y: auto;
}
.card {
  width: min(760px, 100%);
  margin: auto;
  padding: 26px 32px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.8);
  text-align: center;
  line-height: 1.45;
}
.card h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: clamp(54px, 13vw, 104px);
  letter-spacing: 0.25em;
  padding-left: 0.25em;
  color: var(--light);
  text-shadow: 0 0 18px rgba(255, 220, 140, 0.8), 0 0 60px rgba(255, 180, 80, 0.45);
}
@keyframes flicker {
  0%, 18%, 22%, 62%, 64%, 100% { opacity: 1; }
  20%, 63% { opacity: 0.35; }
}
.card h2 { margin: 0 0 10px; font-size: 28px; }
.tag { font-size: 20px; margin: 6px 0 16px; color: var(--ink); font-style: italic; }
.rules { text-align: left; color: var(--ink-dim); }
.rules p { margin: 8px 0; }
.controls { margin: 16px 0; display: grid; gap: 8px; font-size: 14px; text-align: left; }
.cta { display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; margin-top: 18px; font-size: 18px; font-weight: bold; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
@media (max-width: 640px) { .cards { grid-template-columns: 1fr; } }
.upgrade {
  position: relative;
  display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
  padding: 16px 14px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
}
.upgrade:hover { transform: translateY(-3px); border-color: var(--light); box-shadow: 0 0 24px rgba(255, 230, 170, 0.2); }
.upgrade .key {
  position: absolute; top: -12px; right: -10px;
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--light); color: #1a1408; font-weight: 900;
}
.uname { font-size: 17px; font-weight: bold; }
.uname small { font-weight: normal; color: var(--ink-dim); }
.utag { font-size: 12px; padding: 1px 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); }
.tag-Cisza { color: #bcd4ff; background: rgba(140, 180, 255, 0.15); }
.tag-Siła { color: #ff9a6a; background: rgba(255, 120, 60, 0.15); }
.tag-Dywersja { color: #d5b4ff; background: rgba(181, 140, 255, 0.15); }
.tag-Dziadek { color: #fff0a0; background: rgba(255, 240, 160, 0.15); }
.udesc { font-size: 14px; color: var(--ink-dim); }
.synergies { text-align: left; font-size: 13px; color: var(--ink-dim); padding-left: 18px; margin: 0; }
.synergies li.on { color: var(--syn); }
.end.won h2 { color: var(--good); }
.end.lost h2 { color: var(--bad); }
.big-stat { font-size: 20px; }
.record { color: var(--gold); font-weight: bold; font-size: 20px; }

@media (max-width: 640px) {
  #clock { font-size: 28px; }
  #meter, #quota-wrap { width: 150px; }
  .card { padding: 20px 16px; }
  #panels { flex-direction: column; }
  .panel { width: 100%; }
  .panel.p2 { margin-left: 0; }
}

code {
  font-family: var(--mono);
  font-size: 0.85em;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  word-break: break-all;
}

/* ---------------- dymek nad dziadkiem */
#zzz {
  --zc: #bcd4ff;
  --crack: 0;
  position: fixed;
  transform: translate(-50%, -100%);
  padding: 6px 14px 8px;
  border-radius: 18px;
  background: rgba(10, 14, 30, 0.75);
  border: 2px solid var(--zc);
  color: var(--zc);
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: bold;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 0 10px var(--zc);
  transition: font-size 0.15s, color 0.15s;
  animation: zfloat 2.4s ease-in-out infinite;
}
#zzz::after {
  content: "";
  position: absolute; left: 50%; bottom: -10px;
  width: 12px; height: 12px;
  transform: translateX(-50%) rotate(45deg);
  background: rgba(10, 14, 30, 0.75);
  border-right: 2px solid var(--zc);
  border-bottom: 2px solid var(--zc);
}
#zzz.snore { --zc: #b58cff; animation: zsnore 0.4s ease-in-out infinite; }
#zzz.warn-in { opacity: 0.8; }
#zzz.grumble { animation: zshake 0.2s linear infinite; }
#zzz.eye { font-size: 40px !important; border-style: dashed; animation: zshake 0.1s linear infinite; font-style: normal; }
@keyframes zfloat { 50% { transform: translate(-50%, calc(-100% - 6px)); } }
@keyframes zsnore { 50% { transform: translate(-50%, -100%) scale(1.12); } }
@keyframes zshake { 25% { transform: translate(calc(-50% - 2px), -100%); } 75% { transform: translate(calc(-50% + 2px), -100%); } }

#freeze {
  position: fixed; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: clamp(40px, 9vw, 86px);
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--bad);
  text-shadow: 0 0 24px rgba(255, 0, 0, 0.6), 0 4px 0 #000;
  pointer-events: none;
  animation: blink 0.5s steps(2) infinite;
}

/* ---------------- mikrofon */
#mic {
  position: fixed; left: 50%; bottom: 16px;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  font-size: 12px;
  pointer-events: none;
}
.mic-label { color: var(--ink-dim); letter-spacing: 0.08em; }
.mic-meter { position: relative; width: 160px; height: 8px; border-radius: 2px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.mic-meter > div { height: 100%; background: var(--good); transition: width 0.05s linear; }
.mic-meter.speech > div { background: var(--warn); }
.mic-meter.shout > div { background: var(--bad); }
.mic-meter i { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.5); }
.mic-status { margin-top: 4px; padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); }
.good { color: var(--good); }
.bad { color: var(--bad); }
.carry { color: var(--ink); font-size: 13px; }

/* ---------------- kalibracja */
.calib-bar { position: relative; height: 26px; margin: 18px 0 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.calib-bar .lvl { height: 100%; background: linear-gradient(90deg, var(--good), var(--warn) 50%, var(--bad)); transition: width 0.05s linear; }
.calib-bar .mark { position: absolute; top: 4px; font-size: 12px; color: var(--ink); border-left: 1px solid rgba(255, 255, 255, 0.6); padding-left: 4px; }
.prog.big { display: block; width: 100%; height: 6px; margin: 10px 0; }

@media (max-width: 640px) {
  #mic { bottom: auto; top: 150px; }
}
