:root {
  --bg: #14131c;
  --bg-elev: #1e1c29;
  --bg-elev-2: #262336;
  --line: #322e44;
  --text: #f2f0f8;
  --text-dim: #9d97b5;
  --accent: #2ee6a8;
  --accent-ink: #06281d;
  --danger: #ff6b6b;
  --ps: #3f8cf2;
  --xbox: #33c481;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, .total, .price { font-family: "Sora", "IBM Plex Sans", sans-serif; }

.hidden { display: none !important; }

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 20px) 18px calc(var(--safe-bottom) + 40px);
}

/* --- Horní lišta ---------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.topbar h1 { font-size: 26px; font-weight: 800; margin: 0; letter-spacing: -0.02em; }

.add-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}
.add-btn:active { transform: scale(0.94); }

/* --- Přehled -------------------------------------------------------------- */

.dashboard {
  background: linear-gradient(150deg, var(--bg-elev-2), var(--bg-elev));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 14px;
}

.dashboard .label { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.dashboard .total { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.dashboard .sub { font-size: 13px; color: var(--text-dim); margin-top: 6px; }
.dashboard .sub strong { color: var(--accent); }

.checked-at {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin: 0 0 18px;
}

/* --- Seznam her ----------------------------------------------------------- */

.game-list { display: flex; flex-direction: column; gap: 10px; }

.game-card {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
  color: inherit;
}
.game-card:active { background: var(--bg-elev-2); }
.game-card--hit { border-color: var(--accent); }

.game-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--bg-elev-2);
}
.game-badge img { width: 24px; height: 24px; }
.game-badge--ps { background: rgba(63, 140, 242, 0.16); }
.game-badge--xbox { background: rgba(51, 196, 129, 0.16); }

.game-info { min-width: 0; display: block; }
.game-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-meta { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }

.game-price { text-align: right; display: block; }
.price { display: block; font-size: 16px; font-weight: 700; white-space: nowrap; }
.price--hit { color: var(--accent); }
.price--unknown { color: var(--text-dim); font-weight: 600; }
.price-was {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  text-decoration: line-through;
  margin-top: 2px;
}
.deal-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 8px;
}

/* --- Prázdný stav --------------------------------------------------------- */

.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}
.empty h2 { font-size: 18px; color: var(--text); margin: 0 0 8px; }
.empty p { font-size: 14px; line-height: 1.5; margin: 0 0 22px; }

/* --- Tlačítka ------------------------------------------------------------- */

.btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn--ghost { background: transparent; }
.btn--destructive { background: transparent; color: var(--danger); border-color: rgba(255, 107, 107, 0.4); }
.btn:active { transform: scale(0.99); }

/* --- Sheet formulář ------------------------------------------------------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 12, 0.6);
  backdrop-filter: blur(2px);
  z-index: 10;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  top: 6vh;
  z-index: 11;
  background: var(--bg);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sheet form { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.sheet-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-header h2 { font-size: 16px; margin: 0; text-align: center; white-space: nowrap; }

.sheet-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
  padding: 6px;
}
.sheet-btn:first-child { justify-self: start; }
.sheet-btn--primary { justify-self: end; color: var(--accent); font-weight: 700; }

.sheet-body {
  padding: 4px 16px calc(var(--safe-bottom) + 28px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.form-section { margin-top: 22px; }
.form-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 10px 4px;
  font-weight: 600;
}
.form-section--danger { margin-top: 30px; }

.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 15px;
}
.field > span { color: var(--text-dim); flex-shrink: 0; }
.field input[type="text"],
.field input[type="url"] {
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  text-align: right;
  outline: none;
}
.field input::placeholder { color: #5f5977; }
.field--stacked { flex-direction: column; align-items: stretch; gap: 8px; }
.field--stacked > span { text-align: left; }
.field--stacked input { text-align: left; }
.field--readonly strong { font-weight: 700; }
.field--switch input { width: 20px; height: 20px; accent-color: var(--accent); }

.hint {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
  margin: 6px 4px 12px;
}

.lookup-status { font-size: 13px; margin: 10px 4px 0; }
.lookup-status--ok { color: var(--accent); }
.lookup-status--err { color: var(--danger); }
.lookup-status--busy { color: var(--text-dim); }

/* --- Výběr platformy ------------------------------------------------------ */

.platform-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }

.platform-option {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.platform-option img { width: 20px; height: 20px; opacity: 0.7; }
.platform-option[aria-checked="true"] { color: var(--text); }
.platform-option[aria-checked="true"] img { opacity: 1; }
.platform-option[data-platform="ps"][aria-checked="true"] {
  border-color: var(--ps);
  background: rgba(63, 140, 242, 0.14);
}
.platform-option[data-platform="xbox"][aria-checked="true"] {
  border-color: var(--xbox);
  background: rgba(51, 196, 129, 0.14);
}

/* --- Potvrzovací dialog --------------------------------------------------- */

.confirm-dialog {
  position: fixed;
  z-index: 12;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(340px, calc(100vw - 48px));
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px 20px 18px;
  text-align: center;
}
.confirm-dialog p { margin: 0 0 18px; font-size: 15px; }
.confirm-actions { display: flex; flex-direction: column; gap: 8px; }

/* --- Přepínač hra / předplatné -------------------------------------------- */

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
  margin-top: 18px;
}

.segmented-option {
  padding: 10px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.segmented-option[aria-checked="true"] {
  background: var(--bg-elev-2);
  color: var(--text);
}

/* --- Hledání -------------------------------------------------------------- */

.search-row { display: flex; gap: 8px; margin-bottom: 10px; }

.search-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  outline: none;
}
.search-row input::placeholder { color: #5f5977; }
.search-row input:focus { border-color: var(--accent); }

.btn--inline { width: auto; flex-shrink: 0; padding: 12px 18px; }

.status { font-size: 13px; margin: 4px 4px 10px; }
.status--ok { color: var(--accent); }
.status--err { color: var(--danger); }
.status--busy { color: var(--text-dim); }

/* --- Seznam výsledků ------------------------------------------------------ */

.result-list { display: flex; flex-direction: column; gap: 6px; }

.result {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.result:active { background: var(--bg-elev-2); }
.result[aria-pressed="true"] { border-color: var(--accent); background: var(--bg-elev-2); }

.result-cover {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elev-2);
}
.result-cover--empty { display: grid; place-items: center; }
.result-cover--empty img { width: 22px; height: 22px; }

.result-body { min-width: 0; flex: 1; display: block; }
.result-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-meta { display: block; font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.result-price { font-weight: 700; font-size: 15px; white-space: nowrap; }

.result--variant { padding: 14px 14px; }

.variants-heading { margin-top: 20px; }

/* --- Záložní vkládání odkazu --------------------------------------------- */

.fallback { margin-top: 14px; }
.fallback summary {
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px 4px;
}
.fallback summary::marker { color: var(--text-dim); }
.fallback[open] summary { margin-bottom: 8px; }

/* --- Vybraná položka ------------------------------------------------------ */

.chosen {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elev-2);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.chosen-cover {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elev);
}
.chosen-cover--empty { display: grid; place-items: center; }
.chosen-cover--empty img { width: 24px; height: 24px; }

.chosen-body { min-width: 0; display: block; }
.chosen-title {
  display: block;
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chosen-meta { display: block; font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.chosen-note { color: var(--text-dim); }

/* --- Obálky her a značka obchodu v seznamu -------------------------------- */

.game-badge .cover {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: cover;
}

.store-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(46, 230, 168, 0.16);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}

/* --- Zkušební notifikace -------------------------------------------------- */

.test-push-row { text-align: center; margin: -10px 0 18px; }

.test-push {
  background: none;
  border: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 4px 8px;
}
.test-push:disabled { opacity: 0.5; }

.test-push-status { font-size: 12.5px; margin: 6px 0 0; color: var(--text-dim); }

/* --- Vstupní pole na mobilu ----------------------------------------------- */
/* Safari na iOS stránku sám přiblíží, když klepneš do pole s písmem menším
   než 16 px — a po přiblížení se pak musí posouvat doleva a doprava.
   Šestnáct pixelů je nejmenší velikost, u které se to nestane. */

.field input[type="text"],
.field input[type="url"],
.field input[type="search"],
.search-row input,
.sheet input,
.sheet select,
.sheet textarea {
  font-size: 16px;
}

/* Pojistka proti vodorovnému posouvání, ať už ho způsobí cokoliv. */
html, body { max-width: 100%; overflow-x: hidden; }

/* Dlouhé názvy na úzkých displejích nesmí roztahovat kartu. */
.game-card { grid-template-columns: 44px minmax(0, 1fr) auto; }
.result, .chosen { max-width: 100%; }
.result-body, .chosen-body { min-width: 0; }

/* --- Kde koupit ----------------------------------------------------------- */

.offers { margin-bottom: 18px; }
.offers h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 18px 0 10px 4px;
  font-weight: 600;
}

.offer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--text);
}
.offer:active { background: var(--bg-elev-2); }
.offer--best { border-color: var(--accent); }

.offer-store {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
}

.offer-tag {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 999px;
  padding: 2px 7px;
}

.offer-region { font-size: 11.5px; font-weight: 500; color: var(--text-dim); }

.offer-price { font-size: 15px; font-weight: 700; white-space: nowrap; }
.offer-open { font-size: 14px; color: var(--accent); font-weight: 600; white-space: nowrap; }
