:root {
  --ink: #1d1b2e;
  --paper: #fff8ec;
  --accent: #ff7a45;
  --accent-dark: #d9582a;
  --good: #3fbf6f;
  --bad: #e5484d;
  --panel: rgba(255, 248, 236, 0.96);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1d1b2e; color: var(--ink);
  font-family: 'Fredoka', system-ui, sans-serif;
  user-select: none;
}
#app, #app canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#clock-wrap {
  position: absolute; top: 14px; left: 16px;
  background: rgba(29, 27, 46, 0.78); color: #fff; border-radius: 16px;
  padding: 6px 20px 8px; text-align: center; min-width: 150px;
}
#clock { font-size: 64px; font-weight: 700; letter-spacing: 1px; font-variant-numeric: tabular-nums; line-height: 1.05; white-space: nowrap; }
#clock .s { font-size: 40px; opacity: .9; }
#clock .ms { font-size: 26px; opacity: .7; display: inline-block; min-width: 2.2em; text-align: left; }
#clock.late { animation: latepulse 1s infinite; }
@keyframes latepulse { 50% { color: #ff4d4f; } }
#clock.late { color: #ff8c8c; }
#clock-sub { font-size: 16px; opacity: 0.85; font-weight: 600; }
#clock-pops { position: absolute; left: 100%; top: 6px; margin-left: 10px; }

#stress-wrap { position: absolute; top: 18px; left: 50%; transform: translateX(-50%); width: min(560px, 46vw); }
#stress-bar {
  height: 34px; border-radius: 17px; overflow: hidden; border: 3px solid #fff; position: relative;
  background: linear-gradient(90deg, #2fbf5b 0%, #a6d94a 30%, #ffd23f 55%, #ff8a3d 78%, #e5322d 100%);
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
#stress-mask {
  position: absolute; inset: 0; background: rgba(29, 27, 46, 0.82);
  transform-origin: right; transform: scaleX(0); transition: transform .25s;
}
#stress-bar.bump { animation: bump .35s; }
@keyframes bump { 30% { transform: scale(1.06); } }
#stress-icon {
  position: absolute; left: -26px; top: -9px; width: 52px; height: 52px; border-radius: 50%;
  background: #fff; border: 3px solid #2fbf5b; font-size: 30px; line-height: 46px; text-align: center;
  box-shadow: 0 4px 12px rgba(0,0,0,.35);
}
#stress-label { text-align: center; color: #fff; font-weight: 700; font-size: 16px; margin-top: 4px; text-shadow: 0 2px 4px rgba(0,0,0,.6); }
#stress-pops { position: absolute; left: 0; right: 0; top: 36px; height: 0; }
.pop {
  position: absolute; transform: translateX(-50%); font-size: 44px; font-weight: 700; color: #ff4d4f; white-space: nowrap;
  -webkit-text-stroke: 2px #1d1b2e; text-shadow: 0 4px 0 #1d1b2e; animation: pop 1.6s forwards;
}
#clock-pops .pop { position: relative; transform: none; font-size: 38px; display: block; }
@keyframes pop { 0% { opacity: 0; translate: 0 10px; scale: .5; } 12% { opacity: 1; scale: 1.2; } 25% { scale: 1; } 75% { opacity: 1; } 100% { opacity: 0; translate: 0 34px; } }

#score {
  position: absolute; top: 18px; right: 18px; color: #fff; font-size: 30px; font-weight: 700;
  text-shadow: 0 2px 6px rgba(0,0,0,.55); font-variant-numeric: tabular-nums;
}
#hand {
  position: absolute; bottom: 44px; left: 18px; color: #fff; font-size: 18px; font-weight: 600;
  background: rgba(29, 27, 46, 0.7); padding: 6px 14px; border-radius: 12px;
}
#hint {
  position: absolute; bottom: 110px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 20px; font-weight: 600; background: rgba(29, 27, 46, 0.7);
  padding: 6px 16px; border-radius: 12px; opacity: 0; transition: opacity .15s;
}
#hint.on { opacity: 1; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 5px 10px; align-items: center; font-size: 14px; }
.keys kbd {
  font: inherit; font-weight: 700; font-size: 12px; justify-self: end; white-space: nowrap;
  background: #fff; color: var(--ink); border-radius: 6px; padding: 2px 7px; box-shadow: 0 2px 0 #9a9a9a;
}
#keys {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.8); opacity: .3;
}
.keys.big { font-size: 16px; margin: 4px 0 18px; }
.keys.big kbd { font-size: 14px; }
#crosshair {
  position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px;
  border: 3px solid rgba(255,255,255,.9); border-radius: 50%; box-shadow: 0 0 4px rgba(0,0,0,.6);
}
#phone-ring {
  position: absolute; top: 110px; left: 50%; transform: translateX(-50%);
  background: #fff; color: var(--ink); font-size: 24px; font-weight: 700; padding: 10px 22px;
  border-radius: 18px; animation: ring .25s infinite alternate; box-shadow: 0 6px 18px rgba(0,0,0,.35);
}
@keyframes ring { from { transform: translateX(-50%) rotate(-3deg); } to { transform: translateX(-50%) rotate(3deg); } }
#dog-alert {
  position: absolute; width: 40px; height: 40px; margin: -54px 0 0 -20px; border-radius: 50%;
  background: var(--bad); color: #fff; font-size: 30px; font-weight: 700; text-align: center; line-height: 40px;
  box-shadow: 0 3px 10px rgba(0,0,0,.4); animation: pulse .4s infinite alternate;
}
@keyframes pulse { to { transform: scale(1.2); } }

#toasts { position: absolute; top: 120px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast {
  color: #fff; font-size: 20px; font-weight: 600; text-shadow: 0 2px 5px rgba(0,0,0,.7);
  background: rgba(29, 27, 46, 0.55); padding: 4px 14px; border-radius: 10px;
  animation: toast 2.6s forwards;
}
.toast.big {
  font-size: 44px; font-weight: 700; background: none; color: #ffd166;
  -webkit-text-stroke: 2px #1d1b2e; text-shadow: 0 4px 0 #1d1b2e; animation: bigtoast 2.4s forwards;
}
.toast.bad { background: rgba(229, 72, 77, 0.8); }
@keyframes toast { 0% { opacity: 0; transform: translateY(8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-10px); } }
@keyframes bigtoast { 0% { opacity: 0; transform: scale(.4); } 12% { opacity: 1; transform: scale(1.15); } 20%, 80% { transform: scale(1); opacity: 1; } 100% { opacity: 0; transform: translateY(-30px); } }

/* ---------- Dymki Anety ---------- */
#bubbles { position: fixed; inset: 0; pointer-events: none; }
.bubble {
  position: absolute; max-width: 420px; padding: 16px 22px; border-radius: 22px;
  font-size: 24px; font-weight: 600; line-height: 1.25; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  animation: bubble 5.8s forwards;
}
.bubble .who { display: block; font-size: 15px; opacity: .7; margin-bottom: 2px; }
.bubble.aneta { background: #ffe0ef; color: #6a1b43; border-bottom-left-radius: 4px; }
.bubble.czarek { background: #dff1ff; color: #123a5e; border-bottom-right-radius: 4px; }
.bubble.jedrek { background: #e2f7df; color: #1d4d1a; border-bottom-left-radius: 4px; }
@keyframes bubble { 0% { opacity: 0; transform: scale(.6); } 6% { opacity: 1; transform: scale(1.05); } 10%, 88% { transform: none; opacity: .97; } 100% { opacity: 0; } }

/* ---------- Ekrany ---------- */
.screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(29, 27, 46, 0.45); padding: 16px; overflow-y: auto;
}
.panel {
  background: var(--panel); border-radius: 26px; padding: 28px 34px; max-width: 620px; width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.4); max-height: 100%; overflow-y: auto;
}
.panel.small { max-width: 400px; text-align: center; }
.panel h1 { margin: 0 0 8px; font-size: 46px; color: var(--accent-dark); line-height: 1.05; }
#howto .panel h1 { font-size: 30px; margin-bottom: 14px; }
.panel h2 { margin: 22px 0 8px; font-size: 20px; }
.story { font-size: 18px; line-height: 1.4; margin: 0 0 12px; }
.rules { padding-left: 20px; margin: 0 0 18px; line-height: 1.4; font-size: 16px; }
.rules li { margin-bottom: 6px; }
button {
  font: inherit; font-size: 20px; font-weight: 700; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--accent); color: #fff; padding: 12px 26px; box-shadow: 0 4px 0 var(--accent-dark);
  margin: 4px 6px 4px 0;
}
button:hover { filter: brightness(1.06); }
button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--accent-dark); }
button.ghost { background: #e9e1d2; color: var(--ink); box-shadow: 0 4px 0 #c9bfae; }
button:disabled { opacity: .5; cursor: default; }
#end-sub { font-size: 20px; margin: 0 0 14px; }
#end-stats { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; font-size: 17px; margin-bottom: 16px; }
#end-stats b { text-align: right; font-variant-numeric: tabular-nums; }
#save-row { display: flex; gap: 8px; margin-bottom: 8px; }
#save-row input {
  flex: 1; font: inherit; font-size: 18px; padding: 10px 14px; border-radius: 12px; border: 2px solid #d8cdb9; background: #fff;
}
.lb { margin: 0; padding-left: 26px; font-size: 16px; }
.lb li { padding: 2px 0; }
.lb li span { float: right; font-variant-numeric: tabular-nums; }
.lb .empty { list-style: none; margin-left: -26px; opacity: .6; }

/* ---------- Intro: czat grupowy ---------- */
#intro { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(29, 27, 46, 0.25); }
#phone-ui {
  width: 340px; height: min(620px, 88vh); background: #f0f2f5; border: 10px solid #15151c; border-radius: 42px;
  display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 30px 80px rgba(0,0,0,.55);
  animation: phonein .6s cubic-bezier(.22, 1, .36, 1);
  transition: transform .8s cubic-bezier(.6,0,.8,.4), opacity .8s;
}
#intro.away #phone-ui { transform: translateY(110vh) rotate(12deg); opacity: .6; }
#intro.away #skip { opacity: 0; }
@keyframes phonein { from { transform: translateY(60vh) scale(.8); } }
.ph-status { display: flex; justify-content: space-between; padding: 8px 20px 2px; font-size: 13px; font-weight: 600; background: #fff; }
.ph-top { display: flex; align-items: center; gap: 10px; padding: 8px 14px 10px; background: #fff; border-bottom: 1px solid #e3e3e8; }
.ph-top b { display: block; font-size: 17px; }
.ph-top small { font-size: 12px; opacity: .6; }
.ph-avatar { width: 40px; height: 40px; border-radius: 50%; background: #ffd9c7; font-size: 22px; line-height: 40px; text-align: center; }
#chat { flex: 1; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; overflow: hidden; }
.msg { max-width: 78%; padding: 7px 12px 8px; border-radius: 16px; font-size: 16px; line-height: 1.25; animation: msgin .25s; }
.msg .from { display: block; font-size: 12px; font-weight: 700; margin-bottom: 1px; }
.msg.them { background: #fff; align-self: flex-start; border-bottom-left-radius: 4px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.msg.me { background: #3b82f6; color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.typing { color: #888; font-style: italic; }
@keyframes msgin { from { opacity: 0; transform: translateY(8px) scale(.95); } }
.ph-input { display: flex; align-items: center; margin: 8px; padding: 10px 14px; background: #fff; border-radius: 22px; font-size: 16px; min-height: 42px; }
.ph-caret { width: 2px; height: 18px; background: #3b82f6; margin-left: 1px; animation: blink 1s steps(1) infinite; }
.ph-send { margin-left: auto; color: #3b82f6; font-size: 18px; }
@keyframes blink { 50% { opacity: 0; } }
#skip { position: fixed; right: 20px; bottom: 20px; }

#stick-badge {
  position: absolute; bottom: 90px; left: 18px; display: flex; align-items: center; gap: 8px;
  background: #ffd166; color: var(--ink); border: 3px solid #fff; border-radius: 16px; padding: 6px 14px 6px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.35); animation: grab .3s;
}
#stick-badge .ico { font-size: 34px; line-height: 1; }
#stick-badge b { font-size: 20px; }
#stick-hits { font-size: 16px; letter-spacing: 2px; color: #8a5a00; }
@keyframes grab { from { transform: scale(.5); opacity: 0; } }
#kick-mark {
  position: absolute; width: 42px; height: 42px; margin: -21px 0 0 -21px; border-radius: 10px;
  background: #fff; color: var(--ink); border: 3px solid #ff7a45; font-size: 26px; font-weight: 700;
  text-align: center; line-height: 36px; box-shadow: 0 4px 0 #d9582a, 0 6px 14px rgba(0,0,0,.4);
  animation: pulse .35s infinite alternate;
}