/* Krzemowe Przygody — "Leśny szlak": painted background, wooden boards, parchment, stone arch. */
:root {
  --story-bg: url(/static/img/bg_default.jpg);
  --ink: #33220f;
  --wood-ink: #3d220b;
  --cream: #fff3cf;
  --red: #7a2a16;
  --head: Almendra, Georgia, serif;
  --body: Alegreya, Georgia, serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink);
  font: 500 17px/1.45 var(--body);
  background: #2b3a22 var(--story-bg) center / cover fixed no-repeat;
  display: flex; flex-direction: column;
}
body::before { /* keeps text legible on any painted background */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: linear-gradient(rgba(20,25,10,.22), rgba(20,25,10,.12) 40%, rgba(25,18,5,.55));
}
body > * { position: relative; z-index: 1; }
[hidden] { display: none !important; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
img { max-width: 100%; }

/* ---- surfaces ---- */
.board {
  background: linear-gradient(rgba(255,240,200,.22), rgba(110,60,10,.22)), url(/static/img/tex_board.jpg) center / cover;
  color: var(--wood-ink); text-shadow: 0 1px 0 rgba(255,235,180,.6);
}
.parch { background: #f1e3c0 url(/static/img/tex_parchment.jpg) center / cover; color: var(--ink); }
.ask {
  margin: 14px 0 8px; text-align: center; font: 700 21px/1.15 var(--head); color: var(--cream);
  text-shadow: 0 2px 3px #1c1405, 0 0 8px rgba(0,0,0,.8);
}

/* ---- page frame ---- */
.wrap { width: 100%; max-width: 560px; margin: 0 auto; padding: 12px 12px 20px; flex: 1; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.title {
  font: 700 18px/1 var(--head); padding: 8px 13px 7px; border-radius: 4px; text-decoration: none;
  box-shadow: 0 3px 6px rgba(0,0,0,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.badge {
  flex: none; font: 700 13px/1 var(--head); padding: 6px 10px; border-radius: 3px; text-decoration: none;
  box-shadow: 0 2px 5px rgba(0,0,0,.5); white-space: nowrap;
}
.foot {
  margin-top: auto; padding: 14px 12px 18px; text-align: center; font-size: 13.5px; color: #f3e6c4;
  text-shadow: 0 1px 3px #000; background: linear-gradient(transparent, rgba(0,0,0,.45));
}
.foot a { margin: 0 6px; }
.foot p { margin: 4px 0 0; }

/* ---- cards and prose ---- */
.card { padding: 16px 18px; border-radius: 5px; box-shadow: 0 5px 14px rgba(0,0,0,.55); margin-bottom: 14px; }
.card h1, .card h2 { font-family: var(--head); margin: 0 0 8px; line-height: 1.15; }
.card h1 { font-size: 27px; } .card h2 { font-size: 21px; margin-top: 16px; }
.card p { margin: 0 0 10px; }
.flash { padding: 10px 14px; border-radius: 4px; background: #7a2a16; color: #ffe9c2; font-weight: 700; margin-bottom: 12px; box-shadow: 0 3px 8px rgba(0,0,0,.5); }
.placeholder { border: 2px dashed #a1481f; padding: 8px 12px; border-radius: 4px; background: rgba(255,255,255,.35); }

/* ---- buttons ---- */
.go {
  display: block; width: 100%; margin: 14px 0 0; padding: 14px 12px; text-align: center; border-radius: 6px; text-decoration: none;
  font: 700 21px/1.1 var(--head); background: linear-gradient(#9a3a1e, #6d2110); color: #ffe9c2; text-shadow: 0 2px 2px #2a0b03;
  box-shadow: 0 4px 0 #3d1206, 0 8px 12px rgba(0,0,0,.6);
}
.go:active { transform: translateY(2px); box-shadow: 0 2px 0 #3d1206, 0 4px 8px rgba(0,0,0,.6); }
.go[disabled] { filter: grayscale(.7) brightness(.85); cursor: default; }
.plank {
  display: block; width: 100%; margin: 10px 0 0; padding: 13px 12px; text-align: center; border-radius: 6px; text-decoration: none;
  font: 700 19px/1.1 var(--head); box-shadow: 0 4px 0 #5a3814, 0 8px 12px rgba(0,0,0,.55);
}
.plank.off { filter: grayscale(.6); opacity: .85; }
.link { text-decoration: underline; font-weight: 700; }
.danger { color: #8a1c0c; }

/* ---- start view ---- */
.form { padding: 13px 15px 14px; border-radius: 4px; box-shadow: 0 4px 10px rgba(0,0,0,.5); }
.form label.lbl, .lbl { display: block; font: 700 16px var(--head); color: #5a3410; margin: 0 0 4px; }
.input {
  width: 100%; border: 0; border-bottom: 2px solid #7b5a2c; background: transparent; color: var(--ink);
  font: 500 22px var(--body); padding: 0 2px 3px; margin-bottom: 12px; border-radius: 0; outline: none;
}
.input:focus { border-bottom-color: var(--red); }
.seg { display: flex; gap: 8px; margin-bottom: 10px; }
.seg:last-child { margin-bottom: 0; }
.seg label { flex: 1; position: relative; }
.seg input, .tile input, .moods input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; padding: 8px 4px; border: 2px solid #8c6a37; border-radius: 4px;
  font: 700 15.5px/1.1 var(--head); color: #6b4a1e; cursor: pointer;
}
.seg input:checked + span { background: var(--red); border-color: #5a1a0c; color: #ffe9c2; }
.seg input:focus-visible + span, .tile input:focus-visible ~ span, .moods input:focus-visible + span { outline: 3px solid #ffd77a; outline-offset: 2px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles.three { grid-template-columns: 1fr 1fr 1fr; }
.tile {
  position: relative; display: block; border-radius: 6px; padding: 6px 6px 7px; text-align: center; cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,.55); font: 700 15px/1.1 var(--head);
}
.tile img { display: block; width: 100%; aspect-ratio: 1 / .8; object-fit: cover; border-radius: 4px; margin-bottom: 5px; box-shadow: 0 0 0 2px rgba(90,50,10,.5); }
.tiles.three .tile img { aspect-ratio: 1 / 1; }
.tile:has(input:checked) { outline: 4px solid #ffd77a; outline-offset: 1px; }
.moods { display: grid; gap: 9px; }
.moods label { position: relative; display: block; }
.moods span { display: block; padding: 11px 12px; border-radius: 6px; text-align: center; font: 700 17px/1.1 var(--head); cursor: pointer; box-shadow: 0 4px 8px rgba(0,0,0,.5); }
.moods input:checked + span { outline: 4px solid #ffd77a; outline-offset: 1px; }
.err { margin: -4px 0 10px; color: #a31d0a; font-weight: 700; font-size: 15.5px; }
.err.onbg { margin: 10px 0 0; padding: 8px 12px; border-radius: 4px; background: #7a2a16; color: #ffe9c2; text-align: center; }
.resume { padding: 12px 15px 14px; border-radius: 4px; margin-bottom: 14px; box-shadow: 0 4px 10px rgba(0,0,0,.5); text-align: center; }
.resume p { margin: 0; font: 700 18px var(--head); }
.resume .go { margin-top: 10px; }

/* ---- player ---- */
.player { display: flex; flex-direction: column; flex: 1; }
.app { display: flex; flex-direction: column; }
.arch {
  position: relative; margin: 0 2px; padding: 7px 7px 6px; background: #8b8474 url(/static/img/tex_stone.jpg) center / 420px auto;
  border-radius: 150px 150px 8px 8px / 70px 70px 8px 8px; box-shadow: 0 8px 16px rgba(0,0,0,.55), inset 0 0 0 2px rgba(40,35,25,.5);
}
.arch .frame {
  position: relative; width: 100%; aspect-ratio: 3 / 4; max-height: 62vh; max-height: 62dvh; overflow: hidden; background: #f6ecd2;
  border-radius: 144px 144px 4px 4px / 64px 64px 4px 4px; box-shadow: 0 0 0 2px rgba(40,35,25,.7);
}
.pic { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity 1s ease; }
.pic.on { opacity: 1; }
.wait {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px;
  font: 700 21px/1.2 var(--head); color: #5a3410; background: rgba(246,236,210,.82);
}
.wait span { animation: breathe 1.8s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.text { margin: -26px 12px 0; padding: 9px 13px; border-radius: 3px; font: 500 16.5px/1.34 var(--body); box-shadow: 0 4px 10px rgba(0,0,0,.55); min-height: 3.2em; position: relative; }
.text:empty { visibility: hidden; }
.dots { display: flex; justify-content: center; gap: 8px; margin: 10px 0 6px; min-height: 11px; }
.dots i { width: 11px; height: 11px; border-radius: 50%; background: rgba(255,240,200,.35); box-shadow: 0 1px 2px rgba(0,0,0,.6); }
.dots i.on { background: #ffd77a; }
.controls { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 8px; }
.round { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-size: 21px; box-shadow: 0 3px 0 #5a3814, 0 6px 10px rgba(0,0,0,.6); }
.round.small { width: 42px; height: 42px; font-size: 16px; }
.round:active { transform: translateY(2px); }
.choices { margin-top: 2px; }
.sign-wrap { filter: drop-shadow(0 4px 5px rgba(0,0,0,.6)); margin-bottom: 9px; }
.sign {
  display: block; width: 93%; padding: 11px 38px 11px 18px; text-align: left;
  clip-path: polygon(0 0, 91% 0, 100% 50%, 91% 100%, 0 100%);
}
.sign-wrap:nth-child(even) .sign { margin-left: 7%; padding: 11px 18px 11px 38px; text-align: right; clip-path: polygon(9% 0, 100% 0, 100% 100%, 9% 100%, 0 50%); }
.sign b { display: block; font: 700 17.5px/1.15 var(--head); }
.sign small { display: block; font: italic 400 14px/1.2 var(--body); margin-top: 2px; text-shadow: none; }
.sign[disabled] { filter: grayscale(.5) brightness(.9); }
.failed { margin-top: 12px; padding: 14px; border-radius: 4px; text-align: center; box-shadow: 0 4px 10px rgba(0,0,0,.5); }
.failed p { margin: 0; font: 700 20px var(--head); }
.thinking { text-align: center; font: italic 500 16px var(--body); color: var(--cream); text-shadow: 0 1px 3px #000; margin: 8px 0; }

/* ---- upgrade modal ---- */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(15,10,3,.72); display: grid; place-items: center; padding: 14px; overflow: auto; }
.modal-box { position: relative; width: 100%; max-width: 440px; padding: 20px 18px 16px; border-radius: 6px; box-shadow: 0 12px 30px rgba(0,0,0,.7); }
.modal-box h2 { font: 700 23px/1.15 var(--head); margin: 0 26px 6px 0; }
.modal-box p { margin: 0 0 10px; }
.plan { border-top: 1px solid rgba(120,85,40,.5); padding: 10px 0 4px; }
.plan h3 { margin: 0; font: 700 19px var(--head); }
.plan .price { float: right; font: 700 19px var(--head); color: var(--red); }
.plan p { margin: 2px 0 0; font-size: 15.5px; }
.modal-x { position: absolute; top: 8px; right: 10px; font-size: 20px; padding: 6px; }
.modal-later { display: block; margin: 12px auto 0; }

/* ---- landing ---- */
.hero { text-align: center; margin: 8vh 0 18px; }
.hero .sign-title { display: inline-block; font: 700 clamp(30px, 9vw, 46px)/1 var(--head); padding: 14px 24px 12px; border-radius: 6px; box-shadow: 0 6px 14px rgba(0,0,0,.6); }
.hero p { color: var(--cream); text-shadow: 0 2px 4px #000; font-size: 19px; margin: 16px auto 0; max-width: 30em; }
.devlogin { margin-top: 14px; font-size: 15px; }
.devlogin input { font: inherit; padding: 4px 6px; width: 60%; }

/* ---- landscape phones: picture left, everything else right ---- */
@media (orientation: landscape) and (max-height: 520px) {
  .wrap.playing { max-width: none; padding: 8px 12px; }
  .wrap.playing .top { display: none; }
  .player { flex-direction: row; gap: 14px; align-items: stretch; }
  .player .stage { flex: none; height: calc(100dvh - 16px); aspect-ratio: 3 / 4; display: flex; }
  .player .arch { margin: 0; height: 100%; width: 100%; border-radius: 10px; }
  .player .arch .frame { height: 100%; max-height: none; aspect-ratio: auto; border-radius: 6px; }
  .player .side { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; }
  .player .text { margin: 0 0 8px; }
  .sign { padding-top: 8px; padding-bottom: 8px; }
  .wrap.playing ~ .foot { display: none; }
}
@media (min-width: 700px) { body { font-size: 18px; } .wrap { max-width: 600px; } }
@media (prefers-reduced-motion: reduce) { .pic { transition: none; } .wait span { animation: none; } }
