/* Base: colours, fonts, buttons, forms, and the screens outside the game (title, menu, setup, library, settings).
   One of the stylesheets in css/, loaded in the order listed in index.html (order matters). */

/* =====================================================================
   Kismetale - "moderni pixel" (retro textovka s pixelovymi scenami)
   Rozlozeni: telefon (zaklad), tablet (>= 760px), PC (>= 1180px).
   ===================================================================== */

:root{
  /* Vsechny barvy jsou z palety Apollo (docs/art/apollo.hex). */
  --bg:#10141f;
  --bg-deep:#090a14;
  --panel:#172038;
  --panel-2:#1e1d39;
  --line:#253a5e;
  --line-hi:#3c5e8b;
  --text:#c7cfcc;
  --text-hi:#ebede9;
  --dim:#819796;
  --accent:#e8c170;
  --accent-ink:#090a14;
  --accent-2:#a4dddb;

  /* klicova slova v pribehu */
  --k-place:#a8ca58;
  --k-npc:#df84a5;
  --k-item:#e8c170;
  --k-danger:#cf573c;

  --hp:#cf573c;
  --hp-dark:#a53030;
  --fate:#73bed3;
  --fate-dark:#3c5e8b;

  --font-title:'Jacquard 12','Jersey 15',serif;
  --font-ui:'Jersey 15',ui-monospace,monospace;
  --font-story:'Atkinson Hyperlegible',system-ui,-apple-system,'Segoe UI',sans-serif;

  --gutter:14px;
  --content-max:680px;
  --safe-top:env(safe-area-inset-top, 0px);
  --safe-bottom:env(safe-area-inset-bottom, 0px);
}

/* Barevny nadech podle sveta (herni obrazovka a tvorba postavy). */
body[data-theme="horror"]{--bg:#10141f;--bg-deep:#090a14;--panel:#241527;--panel-2:#341c27;--line:#4d2b32;--line-hi:#7a4841;--accent:#cf573c;--accent-ink:#090a14;--accent-2:#d7b594;}

/* ---------- Zaklad ---------- */
*{box-sizing:border-box;margin:0;padding:0;}
html,body{height:100%;}
body{
  background:var(--bg);
  color:var(--text);
  font-family:var(--font-ui);
  font-size:19px;
  overflow:hidden;
  -webkit-tap-highlight-color:transparent;
}
button,input,textarea{font:inherit;color:inherit;}
button{cursor:pointer;background:none;border:none;}
.hidden{display:none !important;}
.px{image-rendering:pixelated;image-rendering:crisp-edges;}
/* Zvetsovani v celych nasobcich (js/pixel.js, pixelFit): rozmery a pozici nastavuje skript. */
.px-fit{position:absolute;right:auto;bottom:auto;max-width:none;object-fit:fill;}

#app{
  position:relative;
  width:100%;
  height:100vh;
  height:100dvh;
  overflow:hidden;
  overflow:clip; /* ani fokus pole, ani klavesnice nesmi ramecek odscrollovat */
  background:var(--bg);
  transition:background-color .3s ease;
}

/* Pixelovy ramecek: zubate rohy (clip-path) + dvojita linka. */
.pbox{
  position:relative;
  background:var(--panel);
  box-shadow:inset 0 0 0 3px var(--line), inset 0 0 0 6px var(--panel), inset 0 0 0 7px rgba(0,0,0,.35);
  clip-path:polygon(0 6px,3px 6px,3px 3px,6px 3px,6px 0,calc(100% - 6px) 0,calc(100% - 6px) 3px,calc(100% - 3px) 3px,calc(100% - 3px) 6px,100% 6px,100% calc(100% - 6px),calc(100% - 3px) calc(100% - 6px),calc(100% - 3px) calc(100% - 3px),calc(100% - 6px) calc(100% - 3px),calc(100% - 6px) 100%,6px 100%,6px calc(100% - 3px),3px calc(100% - 3px),3px calc(100% - 6px),0 calc(100% - 6px));
}
.section{padding:18px 20px;margin-bottom:14px;}
.box-title{font-family:var(--font-ui);font-weight:400;font-size:24px;line-height:1;letter-spacing:1px;color:var(--accent);margin-bottom:10px;text-shadow:2px 2px 0 rgba(0,0,0,.45);}
.box-title.center{text-align:center;}
.box-copy{color:var(--text);font-family:var(--font-story);font-size:16px;line-height:1.5;margin-bottom:14px;}
.kicker{display:block;font-size:14px;color:var(--dim);letter-spacing:1px;}
.sub{color:var(--dim);font-size:15px;line-height:1.4;}
.sub-label{font-size:14px;color:var(--dim);margin:12px 0 6px;}

/* ---------- Obrazovky ---------- */
.screen{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  visibility:hidden;
  opacity:0;
  transition:opacity .14s ease-in, visibility 0s linear .14s;
}
/* The old screen fades out first, then the new one fades in: no two screens on top of each other. */
.screen.active{visibility:visible;opacity:1;transition:opacity .22s ease-out .12s;}
.screen.wide{--content-max:1120px;}
.screen-header,
.screen-body,
.screen-footer{
  padding-left:max(var(--gutter), calc((100% - var(--content-max)) / 2));
  padding-right:max(var(--gutter), calc((100% - var(--content-max)) / 2));
}
.screen-header{
  display:flex;
  align-items:center;
  gap:12px;
  padding-top:calc(12px + var(--safe-top));
  padding-bottom:10px;
  flex-shrink:0;
}
.screen-header h2{font-family:var(--font-title);font-weight:400;font-size:42px;line-height:1;color:var(--accent);text-shadow:3px 3px 0 #000;}
.screen-body{flex:1;overflow-y:auto;padding-top:4px;padding-bottom:calc(28px + var(--safe-bottom));}
.screen-body.centered{display:flex;flex-direction:column;}
.screen-body.centered > .center-wrap{margin:auto 0;width:100%;}
.screen-footer{flex-shrink:0;padding-top:12px;padding-bottom:calc(14px + var(--safe-bottom));background:var(--bg);box-shadow:0 -3px 0 var(--line);}

/* ---------- Tlacitka ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  min-height:46px;
  padding:8px 18px;
  background:var(--panel-2);
  color:var(--text-hi);
  font-size:18px;
  box-shadow:inset 0 0 0 3px var(--line-hi), inset 0 -4px 0 3px rgba(0,0,0,.25);
}
.btn:active:not(:disabled){transform:translateY(2px);}
.btn:disabled{opacity:.45;cursor:not-allowed;}
.btn:focus-visible,.menu-item:focus-visible,.icon-btn:focus-visible{outline:3px solid var(--accent);outline-offset:2px;}
.btn.primary{background:var(--accent);color:var(--accent-ink);box-shadow:inset 0 0 0 3px rgba(0,0,0,.25), inset 0 -4px 0 3px rgba(0,0,0,.2);}
.btn.danger{background:#602c2c;color:#ebede9;box-shadow:inset 0 0 0 3px #a53030;}
.btn.small{min-height:34px;padding:4px 12px;font-size:15px;}
.btn.full{width:100%;}
@media (hover:hover){ .btn:hover:not(:disabled){filter:brightness(1.12);} }

.icon-btn{
  position:relative;
  width:44px;
  height:44px;
  flex-shrink:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:var(--panel-2);
  color:var(--accent);
  font-size:22px;
  line-height:1;
  box-shadow:inset 0 0 0 3px var(--line-hi);
}
.icon-btn:active{transform:translateY(2px);}

/* ---------- Formulare ---------- */
.field + .field{margin-top:16px;}
.field label{display:block;font-size:15px;color:var(--dim);margin-bottom:6px;}
.field input,
.field textarea{
  width:100%;
  background:var(--bg-deep);
  border:none;
  box-shadow:inset 0 0 0 2px var(--line);
  color:var(--text-hi);
  padding:12px 14px;
  font-family:var(--font-story);
  font-size:16px; /* 16px = iOS pri fokusu nezoomuje */
}
.field textarea{resize:vertical;min-height:86px;line-height:1.45;}
.field input::placeholder,.field textarea::placeholder,#playerInput::placeholder{color:var(--dim);}
.field input:focus,.field textarea:focus{outline:none;box-shadow:inset 0 0 0 2px var(--accent);}

/* ---------- Uvod a hlavni menu ---------- */
.screen-title{overflow-y:auto;}
.screen-bg{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;opacity:.6;}
@media (orientation: portrait){
  .screen-title .screen-bg{bottom:auto;top:max(0px, calc(38% - 60vw));height:auto;aspect-ratio:1;-webkit-mask-image:linear-gradient(180deg,transparent,#000 18%,#000 70%,transparent);mask-image:linear-gradient(180deg,transparent,#000 18%,#000 70%,transparent);}
}
.screen-title::after{content:'';position:absolute;inset:0;pointer-events:none;background:linear-gradient(180deg,rgba(0,0,0,.05),rgba(0,0,0,.72) 78%);}
.title-layout{
  position:relative;
  z-index:1;
  min-height:100%;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:20px;
  padding:calc(24px + var(--safe-top)) var(--gutter) calc(48px + var(--safe-bottom));
}
.title-head{text-align:center;}
.logo-title{font-family:var(--font-title);font-weight:400;font-size:88px;line-height:.9;color:var(--accent);text-shadow:4px 4px 0 #000, 0 0 30px rgba(0,0,0,.6);}
.logo-tagline{margin-top:4px;font-size:17px;letter-spacing:2px;color:var(--text-hi);text-shadow:2px 2px 0 #000;}
.login-box,.menu-box{width:100%;max-width:380px;padding:20px 22px;}
#loginStatus{min-height:20px;margin:10px 0 8px;font-size:15px;color:var(--accent);text-align:center;}
.fine-print{margin-top:12px;font-family:var(--font-story);font-size:13px;line-height:1.45;color:var(--dim);text-align:center;}
.menu-item{
  display:flex;
  align-items:center;
  gap:10px;
  width:100%;
  padding:8px 4px 8px 26px;
  text-align:left;
  font-size:23px;
  color:var(--text);
  position:relative;
}
.menu-item::before{content:'▸';position:absolute;left:4px;color:var(--accent);visibility:hidden;}
.menu-item:hover,.menu-item:focus-visible{color:var(--accent);}
.menu-item:hover::before,.menu-item:focus-visible::before,.menu-item.sel::before{visibility:visible;}
.menu-item.sel{color:var(--accent);}
.menu-item.dim{color:var(--dim);}
.menu-label{flex-shrink:0;}
.menu-meta{margin-left:auto;font-size:14px;color:var(--dim);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;}
.title-foot{position:absolute;left:var(--gutter);right:var(--gutter);bottom:calc(12px + var(--safe-bottom));z-index:1;display:flex;justify-content:space-between;font-size:14px;color:var(--dim);text-shadow:2px 2px 0 #000;}

/* ---------- Vyber sveta ---------- */

/* ---------- Tvorba postavy ---------- */
.selected-genre-card{display:flex;align-items:center;gap:14px;padding:12px 14px 12px 12px;margin-bottom:14px;}
.selected-genre-art{width:96px;height:72px;flex-shrink:0;object-fit:cover;box-shadow:0 0 0 2px var(--line-hi);}
.selected-genre-copy{flex:1;min-width:0;}
#selectedGenreTitle{display:block;font-family:var(--font-ui);font-weight:400;font-size:30px;line-height:1;letter-spacing:1px;color:var(--accent);}
#selectedGenreDescription{font-size:15px;color:var(--dim);}
.option-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;}
.option-card{
  position:relative;
  padding:10px 12px;
  cursor:pointer;
  background:var(--bg-deep);
  box-shadow:inset 0 0 0 2px var(--line);
}
.option-card.selected{box-shadow:inset 0 0 0 3px var(--accent);background:var(--panel-2);}
.option-card.selected .g-title::before{content:'▸ ';color:var(--accent);}
.option-card .g-title{font-size:17px;color:var(--text-hi);}
.option-card .g-desc{font-family:var(--font-story);font-size:13px;color:var(--dim);line-height:1.35;margin-top:2px;}
.stat-row{display:flex;align-items:center;gap:10px;padding:6px 6px 6px 12px;margin-bottom:8px;background:var(--bg-deep);box-shadow:inset 0 0 0 2px var(--line);}
.stat-row-label{flex:1;font-size:18px;}
.stat-row-controls{display:flex;align-items:center;gap:6px;}
.stat-btn{width:40px;height:40px;background:var(--panel-2);color:var(--accent);font-size:22px;box-shadow:inset 0 0 0 2px var(--line-hi);}
.stat-btn:active:not(:disabled){transform:translateY(2px);}
.stat-btn:disabled{opacity:.3;cursor:not-allowed;}
.stat-row-value{min-width:36px;text-align:center;font-size:22px;color:var(--text-hi);}
#statsRemaining{font-size:15px;color:var(--accent);text-align:right;}

/* ---------- Knihovna ---------- */
#libraryGrid{display:grid;grid-template-columns:1fr;gap:12px;padding-top:4px;}
.story-card{display:flex;gap:14px;padding:12px;cursor:pointer;}
.sc-art{width:112px;height:84px;flex-shrink:0;object-fit:cover;box-shadow:0 0 0 2px var(--line-hi);}
.sc-body{flex:1;min-width:0;display:flex;flex-direction:column;}
.story-card .sc-genre{font-size:14px;color:var(--story-color, var(--accent));}
.story-card .sc-title{font-size:26px;line-height:1.05;color:var(--text-hi);}
.story-card .sc-meta{font-family:var(--font-story);font-size:13px;color:var(--dim);}
.story-card .sc-actions{display:flex;gap:8px;margin-top:auto;padding-top:8px;}
.story-card .sc-actions .btn{min-height:36px;padding:4px 12px;font-size:15px;}
.library-empty{grid-column:1 / -1;width:100%;max-width:440px;margin:0 auto;padding:16px 16px 20px;text-align:center;}
.library-empty img{display:block;width:100%;aspect-ratio:4 / 3;object-fit:cover;margin-bottom:16px;box-shadow:0 0 0 3px var(--line-hi);}
.library-empty .box-copy{margin-bottom:16px;}

/* ---------- Hra s prateli ---------- */

/* ---------- Nastaveni ---------- */
.settings-list{display:flex;flex-direction:column;gap:12px;}
.settings-row{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:40px;font-size:18px;text-align:left;width:100%;}
.settings-row strong{font-weight:400;color:var(--accent);}
.toggle{width:52px;height:28px;position:relative;background:var(--bg-deep);box-shadow:inset 0 0 0 2px var(--line);}
.toggle::after{content:'';position:absolute;top:5px;left:5px;width:18px;height:18px;background:var(--dim);transition:transform .15s ease;}
.toggle.on{box-shadow:inset 0 0 0 2px var(--accent);}
.toggle.on::after{transform:translateX(24px);background:var(--accent);}
