/* =========================
   CORE / RESET
========================= */
:root{
  --app-height: 100vh;
  --stage-offset-y: 0px; /* regulacja wysokości sceny: np. -30px / +40px */

  --stage-scale: 1;
}

html, body{
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  height: var(--app-height);
  margin: 0;
  background:#fff;
  overflow:auto;
}

body{
  font:13px/1.35 ui-monospace, Menlo, Consolas, monospace;
  color:#000;
}

.muted{ color:#666; font-size:12px; }
hr.sep{ border:none; border-top:1px solid #ddd; margin:12px 0; }
.hidden{ display:none !important; }



/* ===== VIEWPORT (scroll container) ===== */
#stage-wrap{
  width:100%;
  height:auto;                 /* kończy się na zawartości */
  overflow:visible;
  -webkit-overflow-scrolling: touch;
  padding:0;
  display:block;
}

/* ===== STAGE AREA ===== */
#stage-area{
  position:relative;
  min-width:calc(400px * var(--stage-scale));
  padding-top:0;
  min-height:0;
  display:block;
}

/* mobile: zostaw miejsce na nagłówek */
@media (max-width: 560px){
  #stage-area{ padding-top:120px; }
}

/* ===== STAGE ===== */
#stage-scale{
  position:relative;
  width:calc(400px * var(--stage-scale));
  height:calc(600px * var(--stage-scale));

  margin:0 auto;               /* wyśrodkowanie poziome */
  border:1px solid #ccc;
  overflow:hidden;
  touch-action: pan-x pan-y;
  background:#000;
}

#stage{
  position:absolute;
  left:0;
  top:0;
  width:400px;
  height:600px;

  background:#000 url('/img/scena.png') no-repeat center center / 100% 100%;
  transform:scale(var(--stage-scale));
  transform-origin:0 0;
}




/* tutorial jako overlay w viewport (DZIAŁA na telefonie) */
#tutorial-hints{
  position: fixed;
  left: 8px;
  top: 52px;            /* żeby nie nachodził na Koszyk (0) */
  right: auto;
  transform: none;
  pointer-events: none;
  z-index: 1400;        /* wyżej niż koszyk (1300) */
}
#tutorial-hints .tutorial{ pointer-events:auto; }

/* opcjonalnie: na wąskich ekranach niech zajmuje prawie całą szerokość */
#tutorial-hints .tcard{ width: min(400px, calc(100vw - 16px)); }



/* =========================
   ACTORS / SPRITES / BUBBLES
========================= */
.actor{
  position:absolute;
  left:0; top:0;
  width:38px; height:56px;
  will-change:transform;
  transform-origin:50% 100%;
  pointer-events:auto;
  user-select:none;
  touch-action:none;
}

/* Focus/outline fixes (Firefox mobile zielona ramka) */
.actor, .actor *{ outline:none !important; }
.actor:focus, .actor *:focus{ outline:none !important; }

.sprite{
  width:38px; height:56px;
  background-image:url('/img/sprites.png');
  background-repeat:no-repeat;
  background-position:0 0;
  transform-origin:50% 100%;
  image-rendering: pixelated; /* spójnie na wszystkich */
}

.label{
  position:absolute;
  left:50%;
  top:60px;
  transform:translateX(-50%);
  font:13px ui-monospace, Menlo, Consolas, monospace;
  color:#222;
  background:rgba(255,255,255,.85);
  padding:2px 6px;
  border-radius:6px;
  border:1px solid #ddd;
  white-space:nowrap;
  max-width:200px;
  overflow:hidden;
  text-overflow:ellipsis;
}
.me .label{ border-color:#7ab8ff; }

.bubble{
  position:absolute;
  left:50%;
  bottom:67px;
  transform:translateX(-50%);
  max-width:260px;
  font:13px/1.35 ui-monospace, Menlo, Consolas, monospace;
  color:#000;
  background:#fff;
  border:1px solid #222;
  border-radius:12px;
  padding:6px 10px;
  box-shadow:0 2px 6px rgba(0,0,0,.15);
  display:none;
  z-index:1000;
  pointer-events:auto;
}
.bubble::after{
  content:"";
  position:absolute;
  left:50%;
  bottom:-8px;
  transform:translateX(-50%);
  border-left:8px solid transparent;
  border-right:8px solid transparent;
  border-top:8px solid #222;
  width:0; height:0;
}
.bubble::before{
  content:"";
  position:absolute;
  left:50%;
  bottom:-7px;
  transform:translateX(-50%);
  border-left:7px solid transparent;
  border-right:7px solid transparent;
  border-top:7px solid #fff;
  width:0; height:0;
}
.bubble.show{ display:block; }
.bubble.editing{ display:block; }

.bubble-view{
  white-space:pre-wrap;
  word-wrap:break-word;
}
.bubble-editor{
  display:none;
  min-height:1.5em;
  outline:none;
  white-space:pre-wrap;
  word-wrap:break-word;
  -webkit-user-select:text;
  user-select:text;
}

/* mrugający „kursor”/hint gdy puste — tylko bez fokusu */
.bubble-editor.empty:not(:focus)::after{
  content:"|";
  display:inline-block;
  margin-left:1px;
  animation: caretBlink 1s steps(1) infinite;
  color:#000;
}
@keyframes caretBlink{ 50%{ opacity:0; } }

.bubble.editing .bubble-view{ display:none; }
.bubble.editing .bubble-editor{ display:block; }

/* =========================
   HINT (lewy dół)
========================= */
#hint{
  position:fixed;
  left:8px;
  bottom:8px;
  top:auto;
  font:13px ui-monospace, Menlo, Consolas, monospace;
  color:#444;
  background:rgba(255,255,255,.9);
  padding:6px 8px;
  border-radius:6px;
  border:1px solid #eee;
  z-index:900;
}

/* =========================
   OFFER PANEL (produkty przy półce)
========================= */
#offer-panel{
  position:fixed;
  left:50%;
  bottom:0;
  transform:translateX(-50%);
  width: min(400px, calc(100vw - 16px));
  height:500px;
  max-height:500px;
  overflow-y:auto;
  font:13px/1.35 ui-monospace, Menlo, Consolas, monospace;
  color:#000;
  background:#fff;
  border:1px solid #222;
  border-radius:12px 12px 0 0;
  padding:10px 10px 8px;
  box-shadow:0 -2px 10px rgba(0,0,0,.25);
  display:none;
  z-index:1200;
}
#offer-close{
  position:absolute;
  top:4px;
  right:6px;
  border:none;
  background:transparent;
  cursor:pointer;
  font-size:14px;
  line-height:1;
}
.offer-title{ font-weight:800; font-size:18px; letter-spacing:0.2px; }
.offer-body{ margin-top:4px; }
#offer-panel ul{ padding-left:18px; margin:4px 0; }

.film-list{ max-height:460px; overflow-y:auto; padding-right:6px; }
.film-item{
  display:flex;
  gap:12px;
  margin-bottom:18px;
  padding-bottom:12px;
  border-bottom:1px solid #ccc;
}
.film-item img{
  width:90px; height:90px;
  object-fit:contain;
  object-position:center;
  background:#fff;
}
.film-item .info{ flex:1; display:flex; flex-direction:column; }
.film-item .title{ font-weight:bold; margin-bottom:6px; font-size:14px; }
.film-item .pid{ font-size:12px; color:#444; margin-bottom:2px; }
.film-item ul{ margin:0; padding-left:18px; font-size:13px; }
.film-item li{ margin-bottom:2px; }

.price-row{
  margin-top:6px;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:10px;
}
.price-block{ display:flex; flex-direction:column; align-items:flex-end; gap:2px; }
.price-gross{ font-weight:800; font-size:14px; }
.price-net{ font-size:12px; color:#666; }
.price-tag{opacity:.85;font-size:12px;margin-left:6px;}
.add-btn{
  padding:6px 10px;
  border:1px solid #222;
  background:#fff;
  border-radius:10px;
  cursor:pointer;
  font:13px ui-monospace, Menlo, Consolas, monospace;
}
.add-btn:active{ transform:translateY(1px); }

/* =========================
   CART
========================= */
#top-controls{
  position:fixed;
  right:8px;
  top:8px;
  z-index:1301;
  display:flex;
  align-items:center;
  gap:8px;
}
#lang-select{
  padding:7px 10px;
  border:1px solid #222;
  background:#fff;
  border-radius:10px;
  font:13px ui-monospace, Menlo, Consolas, monospace;
  cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.12);
}

#cart-btn{
  position:static;
  padding:8px 10px;
  border:1px solid #222;
  background:#fff;
  border-radius:10px;
  font:13px ui-monospace, Menlo, Consolas, monospace;
  cursor:pointer;
  box-shadow:0 2px 8px rgba(0,0,0,.12);
}

#cart-popup{
  position:fixed;
  right:8px;
  top:52px;
  z-index:1300;
  width: min(380px, calc(100vw - 16px));
  max-width:calc(100vw - 16px);
  max-height:calc(100vh - 100px);
  background:#fff;
  border:1px solid #222;
  border-radius:12px;
  box-shadow:0 4px 14px rgba(0,0,0,.2);
  display:none;
  overflow-y:auto;
  scrollbar-width:none;
  -ms-overflow-style:none;
}

#cart-popup::-webkit-scrollbar{
  display:none;
}

.cart-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 10px 6px;
  border-bottom:1px solid #ddd;
}
.cart-title{ font-weight:800; font-size:16px; }
.cart-actions{ display:flex; gap:8px; align-items:center; }
.cart-actions button{
  padding:6px 10px;
  border:1px solid #222;
  background:#fff;
  border-radius:10px;
  cursor:pointer;
}
#cart-close{
  border:none;
  background:transparent;
  font-size:16px;
  line-height:1;
  padding:0 6px;
  cursor:pointer;
}

#cart-body{
  padding:10px;
  max-height:360px;
  overflow:auto;
}

.cart-line{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding:10px 0;
  border-bottom:1px solid #eee;
}
.cart-line:last-child{ border-bottom:none; }

.cart-line-info{
  flex:1;
}

.cart-product-name{
  font-weight:600;
  margin-bottom:5px;
  font-size:14px;
}

.cart-prices{
  display:flex;
  flex-direction:column;
  gap:3px;
  font-size:13px;
  color:#666;
}

.cart-unit-price{
  color:#666;
}

.cart-total-price{
  color:#666;
}

.cart-line-controls{
  display:flex;
  align-items:center;
  gap:5px;
  white-space:nowrap;
}

.cart-line-controls .add-btn{
  padding:4px 8px;
  font-size:12px;
  border:1px solid #ccc;
  background:#f5f5f5;
  border-radius:3px;
  cursor:pointer;
}

.cart-line-controls .add-btn:hover{
  background:#e0e0e0;
}

.cart-qty{
  min-width:25px;
  text-align:center;
  font-weight:600;
}

.cart-sum{
  padding:10px;
  border-top:1px solid #ddd;
  display:flex;
  justify-content:space-between;
  gap:8px;
}
.sum-col{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:2px;
}
.sum-gross{ font-weight:900; font-size:14px; }
.sum-net{ font-size:12px; color:#666; }

.qty-box{ display:flex; align-items:center; gap:6px; }
.qty-btn{
  width:28px;
  height:28px;
  border:1px solid #222;
  background:#fff;
  border-radius:8px;
  cursor:pointer;
}
.qty-val{ min-width:26px; text-align:center; }

/* =========================
   CHECKOUT VIEW
========================= */
.checkout-wrap{ max-width:980px; margin:0 auto; padding:60px 12px 40px; }
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:10px;
}
.topbar h1{ font-size:18px; margin:0; font-weight:900; }
.topbar a{
  display:inline-block;
  padding:7px 10px;
  border:1px solid #222;
  border-radius:10px;
  text-decoration:none;
  color:#000;
  background:#fff;
}

.grid{ display:grid; grid-template-columns: 1.2fr 0.8fr; gap:12px; align-items: start; }
@media (max-width: 860px){ .grid{ grid-template-columns:1fr; align-items: auto; } }

#order-summary{
  border:1px solid #222;
  border-radius:12px;
  background:#fff;
  padding:12px;
  box-shadow:0 2px 10px rgba(0,0,0,.08);
}
#order-summary h2{ margin:0 0 12px 0; font-size:14px; font-weight:900; }
#order-summary-total{ font-weight:bold; color:#222; }

.card{
  border:1px solid #222;
  border-radius:12px;
  background:#fff;
  padding:12px;
  box-shadow:0 2px 10px rgba(0,0,0,.08);
}
.card h2{ margin:0 0 8px 0; font-size:14px; font-weight:900; }

.row{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
@media (max-width: 560px){ .row{ grid-template-columns:1fr; } }

.f{ display:flex; flex-direction:column; gap:4px; margin-bottom:10px; }

label{ font-size:12px; color:#222; }

input, select{
  font:13px ui-monospace, Menlo, Consolas, monospace;
  padding:8px 10px;
  border:1px solid #222;
  border-radius:10px;
  outline:none;
}

.small{ font-size:12px; color:#666; }
.chk{ display:flex; align-items:center; gap:8px; margin:10px 0; }
.btn{
  padding:8px 12px;
  border:1px solid #222;
  border-radius:10px;
  background:#fff;
  cursor:pointer;
  font-weight:900;
}
.err{ color:#b00020; font-size:12px; margin-bottom:8px; }

.sumline{ padding:8px 0; border-bottom:1px solid #eee; }
.sumline:last-child{ border-bottom:none; }
.pname{ font-weight:800; }
.priceBig{ font-weight:900; font-size:14px; }
.priceSmall{ font-size:12px; color:#666; }

.tot{ margin-top:10px; padding-top:10px; border-top:1px solid #ddd; }
.totBig{ font-weight:900; font-size:16px; }
.totSmall{ font-size:12px; color:#666; }

/* =========================
   JOIN OVERLAY (name + gender)
========================= */
#join-overlay{
  position:fixed;
  inset:0;
  z-index:2000;
  display:none;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
}
#join-overlay.show{ display:flex; }

.join-card{
  width:min(420px, calc(100vw - 24px));
  border:1px solid #222;
  border-radius:14px;
  background:#fff;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
  padding:14px;
}

.join-title{
  font-weight:900;
  font-size:16px;
  margin:0 0 8px 0;
}

.join-row{ display:flex; flex-direction:column; gap:6px; margin-bottom:10px; }

.join-row input{
  font:13px ui-monospace, Menlo, Consolas, monospace;
  padding:8px 10px;
  border:1px solid #222;
  border-radius:10px;
  outline:none;
}

.gender-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
  margin-top:6px;
}

.gender-card{
  border:1px solid #222;
  border-radius:12px;
  padding:10px;
  cursor:pointer;
  user-select:none;
  background:#fff;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
}
.gender-card.selected{
  outline:2px solid #7ab8ff;
  outline-offset:2px;
}

.gender-sil{
  width:38px;
  height:56px;
  background-image:url('/img/sprites.png');
  background-repeat:no-repeat;
  image-rendering: pixelated;
  border:1px solid #ddd;
  border-radius:10px;
  background-color:#f6f6f6;
}
.gender-m .gender-sil{ background-position: 0px 0px; }
.gender-f .gender-sil{ background-position: 0px -57px; }

.join-actions{
  display:flex;
  gap:8px;
  margin-top:12px;
}
.join-actions button{
  padding:8px 12px;
  border:1px solid #222;
  border-radius:10px;
  background:#fff;
  cursor:pointer;
  font-weight:900;
  font:13px ui-monospace, Menlo, Consolas, monospace;
}
.join-actions .primary{ background:#000; color:#fff; }

.join-error{
  margin-top:8px;
  color:#b00020;
  font-size:12px;
  display:none;
}
.join-error.show{ display:block; }

/* =========================
   TUTORIAL CARDS (dymek)
========================= */
.tcard{
  width:400px;
  max-width:calc(100vw - 16px);
  display:flex;
  align-items:flex-end;
  gap:10px;
}

.tgirl{
  width:38px;
  height:44px;
  flex:0 0 auto;
  background-image:url('/img/sprites.png');
  background-repeat:no-repeat;
  image-rendering: pixelated;
  border:1px solid #ddd;
  border-radius:10px;
  background-color:#f6f6f6;
  background-position: 0px -57px; /* dziewczyna idle */
}

.tbox{
  position:relative;
  flex:1;
  border:1px solid #222;
  border-radius:12px;
  background:#fff;
  padding:10px 34px 10px 12px;
  box-shadow:0 2px 10px rgba(0,0,0,.12);
}

.tbox::after{
  content:"";
  position:absolute;
  left:-8px;
  bottom:16px;
  border-right:8px solid #222;
  border-top:8px solid transparent;
  border-bottom:8px solid transparent;
  width:0; height:0;
}
.tbox::before{
  content:"";
  position:absolute;
  left:-7px;
  bottom:16px;
  border-right:7px solid #fff;
  border-top:7px solid transparent;
  border-bottom:7px solid transparent;
  width:0; height:0;
}

.ttext{
  font:13px/1.35 ui-monospace, Menlo, Consolas, monospace;
  color:#000;
}

.tclose{
  position:absolute;
  top:6px;
  right:8px;
  width:24px;
  height:24px;
  border:none;
  background:transparent;
  cursor:pointer;
  font-size:18px;
  line-height:24px;
}
.tclose:active{ transform:translateY(1px); }


/* ===== WRITE TIP UI (bottom-right, pointer click -> bubble) ===== */
#write-tip-ui.wtui{
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 1600; /* above tutorial-hints (1400) and cart (1300) */
  pointer-events: none;
}
#write-tip-ui.hidden{ display:none !important; }

#write-tip-ui .wtui-hero{
  width: 38px;
  height: 44px;
  background-image:url('/img/sprites.png');
  background-repeat:no-repeat;
  image-rendering: pixelated;
  border:1px solid #ddd;
  border-radius:10px;
  background-color:#f6f6f6;
  /* same frame as .tgirl in tutorial */
  background-position: 0px -57px;
  box-shadow:0 10px 30px rgba(0,0,0,.18);
}

#write-tip-ui .wtui-pointer{
  position: fixed;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0;
  transform: translate(-50%,-50%) scale(1);
}

#write-tip-ui .wtui-bubble{
  position: fixed;
  max-width: 260px;
  padding: 8px 10px;
  border:1px solid #222;
  border-radius: 12px;
  background:#fff;
  font:13px/1.35 ui-monospace, Menlo, Consolas, monospace;
  color:#000;
  opacity: 0;
  transform: translate(-50%,-100%) scale(.95);
  transform-origin: 20px 100%;
  box-shadow:0 16px 40px rgba(0,0,0,.25);
}
#write-tip-ui .wtui-bubble::after{
  content:"";
  position:absolute;
  left:90%;
  bottom:-8px;
  transform:translateX(-50%);
  border-left:8px solid transparent;
  border-right:8px solid transparent;
  border-top:8px solid #222;
  width:0; height:0;
}
#write-tip-ui .wtui-bubble::before{
  content:"";
  position:absolute;
  left:90%;
  bottom:-7px;
  transform:translateX(-50%);
  border-left:7px solid transparent;
  border-right:7px solid transparent;
  border-top:7px solid #fff;
  width:0; height:0;
}

@keyframes wtuiPointerClick {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(1); }
  12%  { opacity: 1; }
  62%  { opacity: 1; }
  70%  { transform: translate(-50%,-50%) scale(.85); }
  78%  { transform: translate(-50%,-50%) scale(1); }
  100% { opacity: 0; }
}
@keyframes wtuiBubblePop {
  0%   { opacity: 0; transform: translate(-50%,-110%) scale(.92); }
  100% { opacity: 1; transform: translate(-50%,-120%) scale(1); }
}
#write-tip-ui.wt-on .wtui-pointer{ animation: wtuiPointerClick 2.2s ease-in-out forwards; }
#write-tip-ui.wt-show .wtui-bubble{ animation: wtuiBubblePop .18s ease-out forwards; }


/* ===== WRITE TIP UI (stage bottom-right, temporary) ===== */
#stage #write-tip-ui{
  position:absolute;
  right:12px; bottom:12px;
  z-index:99999;
  pointer-events:none;
}
#stage #write-tip-ui .wtui-hero{
  width:38px; height:44px;
  background:url('/img/sprites.png') no-repeat 0px -57px;
  image-rendering:pixelated;
  border:1px solid #222;
  border-radius:10px;
  background-color:#eee;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
}
#stage #write-tip-ui .wtui-pointer{
  position:absolute;
  width:22px; height:22px;
  border-radius:50%;
  border:2px solid #fff;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
  opacity:0;
  left:0; top:0;
  transform:translate(-50%,-50%);
}
#stage #write-tip-ui .wtui-bubble{
  position:absolute;
  padding:8px 10px;
  border:1px solid #222;
  border-radius:12px;
  background:#fff;
  font:13px ui-monospace, Menlo, Consolas, monospace;
  opacity:0;
  left:0; top:0;
  transform:translate(-50%,-100%);
  box-shadow:0 16px 40px rgba(0,0,0,.25);
  white-space:nowrap;
}
#stage #write-tip-ui .wtui-bubble::after{
  content:"";
  position:absolute;
  left:90%;
  bottom:-8px;
  transform:translateX(-50%);
  border-left:8px solid transparent;
  border-right:8px solid transparent;
  border-top:8px solid #222;
  width:0; height:0;
}
#stage #write-tip-ui .wtui-bubble::before{
  content:"";
  position:absolute;
  left:90%;
  bottom:-7px;
  transform:translateX(-50%);
  border-left:7px solid transparent;
  border-right:7px solid transparent;
  border-top:7px solid #fff;
  width:0; height:0;
}

@keyframes wtuiClick {
  0%{opacity:0}
  15%{opacity:1}
  60%{opacity:1}
  70%{transform:translate(-50%,-50%) scale(.85)}
  100%{opacity:0}
}

/* ===== FOOTER ===== */
#footer_game_company {
  background: #f5f5f5;
  padding: 20px;
  margin-top: 40px;
  font-size: 13px;
  color: #666;
  line-height: 1.6;
}

#footer_game_company div {
  margin: 4px 0;
}