* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0b0b0d;
  --bg2: #131318;
  --card: #1a1a20;
  --line: #2c2c34;
  --text: #e8e8ec;
  --muted: #8b8b96;
  --chrome-grad: linear-gradient(180deg, #ffffff 0%, #d9dde3 28%, #9aa1ab 47%, #5f6670 50%, #aab1bb 53%, #e6e9ee 75%, #b7bdc6 100%);
  --chrome-edge: #454b54;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #23232c 0%, transparent 60%),
    repeating-linear-gradient(45deg, #0d0d10 0 2px, #0b0b0d 2px 6px),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

.hidden { display: none !important; }
.screen { min-height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Chrome logo ---------- */
.logo-chrome {
  font-weight: 900;
  font-style: italic;
  font-size: 52px;
  letter-spacing: 2px;
  background: var(--chrome-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 1px rgba(0,0,0,.8)) drop-shadow(0 0 18px rgba(190,200,215,.25));
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}
.logo-chrome span { display: block; font-size: .42em; letter-spacing: 10px; font-style: normal; }
.logo-chrome.small { font-size: 22px; display: flex; align-items: baseline; gap: 6px; }
.logo-chrome.small span { display: inline; font-size: .8em; letter-spacing: 3px; }

/* ---------- Przyciski ---------- */
.btn-chrome {
  appearance: none; border: 1px solid var(--chrome-edge); cursor: pointer;
  background: var(--chrome-grad);
  color: #17181c; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
  padding: 14px 22px; border-radius: 10px; font-size: 15px;
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 -8px 14px rgba(0,0,0,.28) inset, 0 6px 16px rgba(0,0,0,.55);
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
  transition: transform .08s, filter .15s;
}
.btn-chrome:active { transform: translateY(1px) scale(.99); filter: brightness(.92); }
.btn-chrome.slim { padding: 9px 14px; font-size: 13px; border-radius: 8px; }

.btn-dark {
  appearance: none; cursor: pointer; background: #23232b; color: var(--text);
  border: 1px solid var(--line); padding: 14px 22px; border-radius: 10px; font-size: 15px;
}
.btn-icon {
  appearance: none; cursor: pointer; background: #1d1d24; color: var(--text);
  border: 1px solid var(--line); width: 38px; height: 38px; border-radius: 10px; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.btn-icon.on { background: var(--chrome-grad); color: #17181c; border-color: var(--chrome-edge); }

/* ---------- Login ---------- */
#screen-login { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px; text-align: center;
  background: linear-gradient(180deg, #1c1c22, #141419);
  border: 1px solid var(--line); border-radius: 20px; padding: 40px 28px 32px;
  box-shadow: 0 30px 60px rgba(0,0,0,.6), 0 1px 0 rgba(255,255,255,.06) inset;
}
.logo-sub { color: var(--muted); font-size: 11px; letter-spacing: 2px; text-transform: uppercase; margin: 14px 0 30px; }
.login-card input {
  width: 100%; margin-bottom: 12px; padding: 14px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: #101015; color: var(--text); font-size: 16px;
}
.login-card input:focus { outline: none; border-color: #6d7480; }
.login-card .btn-chrome { width: 100%; margin-top: 6px; }
.error { color: #ff6b6b; font-size: 14px; margin-top: 12px; min-height: 1em; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: rgba(11,11,13,.85); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; font-weight: 600; }

/* ---------- Home ---------- */
.home-body {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 28px 20px calc(env(safe-area-inset-bottom) + 40px);
}
.crew-art {
  width: min(340px, 78vw); border-radius: 16px; border: 1px solid var(--line);
  box-shadow: 0 16px 40px rgba(0,0,0,.5); margin-bottom: 8px;
}
.menu-tile {
  appearance: none; cursor: pointer; width: min(420px, 100%);
  border: 1px solid var(--chrome-edge); border-radius: 16px; padding: 26px 24px;
  background: var(--chrome-grad);
  box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 -12px 20px rgba(0,0,0,.3) inset, 0 10px 26px rgba(0,0,0,.55);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  transition: transform .1s;
}
.menu-tile:not(.disabled):active { transform: scale(.985); }
.tile-title { font-size: 26px; font-weight: 900; font-style: italic; letter-spacing: 2px; color: #17181c; text-shadow: 0 1px 0 rgba(255,255,255,.55); }
.tile-sub { font-size: 12px; font-weight: 700; letter-spacing: 3px; color: #3d434c; text-transform: uppercase; }
.menu-tile.disabled { filter: grayscale(.4) brightness(.55); cursor: not-allowed; }

/* ---------- Licznik ---------- */
.counter-badge {
  background: var(--chrome-grad); color: #17181c; font-weight: 900; font-size: 15px;
  border: 1px solid var(--chrome-edge); border-radius: 999px; padding: 5px 13px;
  text-shadow: 0 1px 0 rgba(255,255,255,.5);
}

/* ---------- Lista SQP ---------- */
.plate-list {
  padding: 16px; display: grid; gap: 16px;
  grid-template-columns: 1fr;
  max-width: 1100px; width: 100%; margin: 0 auto;
  padding-bottom: calc(env(safe-area-inset-bottom) + 30px);
}
@media (min-width: 720px) { .plate-list { grid-template-columns: 1fr 1fr; } }

.plate-card {
  background: linear-gradient(180deg, #1b1b21, #141419);
  border: 1px solid var(--line); border-radius: 16px; padding: 14px;
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.plate-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* Tablica jak unijna rejestracja */
.plate-badge {
  display: inline-flex; align-items: stretch; border-radius: 6px; overflow: hidden;
  border: 2px solid #16181c; box-shadow: 0 2px 6px rgba(0,0,0,.5);
  font-family: "Arial Narrow", Arial, sans-serif;
}
.plate-badge .eu { background: #003399; color: #ffcc00; font-size: 9px; display: flex; align-items: flex-end; justify-content: center; padding: 3px 4px; font-weight: 700; }
.plate-badge .num {
  background: linear-gradient(180deg, #ffffff, #dfe3e8);
  color: #14161a; font-weight: 800; font-size: 19px; letter-spacing: 2px;
  padding: 4px 12px; display: flex; align-items: center; white-space: nowrap;
}
.plate-meta { color: var(--muted); font-size: 12px; text-align: right; line-height: 1.5; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.photo-grid .ph {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); cursor: pointer; background: #0f0f13;
}
.photo-grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .ph .by {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 6px 4px;
  font-size: 9px; color: #d6d6de; background: linear-gradient(transparent, rgba(0,0,0,.85));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.photo-grid .add-more {
  aspect-ratio: 1; border: 1px dashed #4a4a55; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px;
  color: var(--muted); background: transparent; font-size: 22px;
}
.photo-grid .add-more small { font-size: 9px; letter-spacing: 1px; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 18px;
}
.modal-card {
  width: 100%; max-width: 440px; max-height: 90dvh; overflow: auto;
  background: linear-gradient(180deg, #1e1e25, #15151a);
  border: 1px solid var(--line); border-radius: 18px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.7);
}
.modal-title {
  font-size: 18px; font-weight: 900; font-style: italic; letter-spacing: 2px; margin-bottom: 16px;
  background: var(--chrome-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.modal-card input[type=text] {
  width: 100%; padding: 14px 16px; border-radius: 10px; font-size: 18px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  border: 1px solid var(--line); background: #101015; color: var(--text); margin-bottom: 12px;
}
.modal-card input[type=text]:focus { outline: none; border-color: #6d7480; }
.file-drop {
  display: block; border: 1px dashed #4a4a55; border-radius: 12px; padding: 22px 14px;
  text-align: center; color: var(--muted); cursor: pointer; font-size: 14px;
}
.file-drop input { display: none; }
.previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-top: 12px; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn-dark { flex: 1; }
.modal-actions .btn-chrome { flex: 2; }
.progress { height: 6px; border-radius: 3px; background: #23232b; margin-top: 14px; overflow: hidden; }
#add-progress-bar { height: 100%; width: 0%; background: var(--chrome-grad); transition: width .2s; }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.92);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 100vw; max-height: 88dvh; object-fit: contain; }
.lightbox-meta {
  position: absolute; bottom: calc(env(safe-area-inset-bottom) + 14px); left: 0; right: 0;
  text-align: center; color: #cfcfd8; font-size: 13px;
}
.lightbox-close {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 14px;
  appearance: none; background: rgba(30,30,36,.8); color: #fff; border: 1px solid var(--line);
  width: 40px; height: 40px; border-radius: 50%; font-size: 16px; cursor: pointer;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  background: var(--chrome-grad); color: #17181c; font-weight: 700; font-size: 14px;
  border: 1px solid var(--chrome-edge); border-radius: 999px; padding: 11px 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  max-width: 86vw; text-align: center;
}

.empty-note { color: var(--muted); text-align: center; padding: 60px 20px; grid-column: 1 / -1; }

/* ---------- Świeżo dodane (podświetlenie po wejściu) ---------- */
.ph.fresh, .plate-card.fresh-card { transition: box-shadow 1s ease; }
.ph.fresh {
  box-shadow: 0 0 0 2px #e6e9ee, 0 0 14px 3px rgba(210,220,235,.75);
  animation: freshPulse 1.1s ease-in-out infinite;
}
.plate-card.fresh-card {
  box-shadow: 0 0 0 1px #b7bdc6, 0 0 22px 2px rgba(200,210,225,.35), 0 10px 26px rgba(0,0,0,.35);
}
@keyframes freshPulse {
  0%, 100% { box-shadow: 0 0 0 2px #e6e9ee, 0 0 14px 3px rgba(210,220,235,.75); }
  50% { box-shadow: 0 0 0 2px #9aa1ab, 0 0 6px 1px rgba(210,220,235,.35); }
}
.ph .new-badge {
  position: absolute; top: 5px; left: 5px; z-index: 2;
  background: var(--chrome-grad); color: #17181c; font-size: 9px; font-weight: 900;
  letter-spacing: 1px; padding: 3px 7px; border-radius: 999px; border: 1px solid var(--chrome-edge);
  animation: badgePop .5s cubic-bezier(.2, 1.6, .4, 1) both;
}
@keyframes badgePop { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Statystyki / pojedynek ---------- */
.stats-card {
  max-width: 1100px; margin: 16px auto 0; padding: 18px;
  background: linear-gradient(180deg, #1b1b21, #141419);
  border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
  margin-left: 16px; margin-right: 16px;
}
@media (min-width: 1132px) { .stats-card { margin-left: auto; margin-right: auto; } }
.stats-title {
  text-align: center; font-size: 15px; font-weight: 900; font-style: italic; letter-spacing: 3px;
  background: var(--chrome-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 14px;
}
.stats-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; }
.stats-side { text-align: center; opacity: 0; animation: sideIn .55s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.stats-side.right { animation-delay: .18s; }
@keyframes sideIn { from { opacity: 0; transform: translateY(14px) scale(.9); } to { opacity: 1; transform: none; } }
.stats-name { font-size: 17px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; }
.stats-gems { min-height: 22px; font-size: 15px; letter-spacing: 2px; }
.stats-gems span { display: inline-block; animation: gemDrop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes gemDrop { from { transform: translateY(-14px) scale(0); opacity: 0; } to { transform: none; opacity: 1; } }
.stats-vs {
  font-size: 22px; font-weight: 900; font-style: italic;
  background: var(--chrome-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: vsSpin .7s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: .1s;
}
@keyframes vsSpin { from { transform: scale(0) rotate(-180deg); opacity: 0; } to { transform: none; opacity: 1; } }
.stats-rows { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.stats-row-label {
  text-align: center; color: var(--muted); font-size: 10px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 4px;
}
.stats-duo { display: grid; grid-template-columns: 34px 1fr 1fr 34px; gap: 8px; align-items: center; }
.stats-num { font-weight: 900; font-size: 15px; text-align: center; font-variant-numeric: tabular-nums; }
.bar-track { height: 12px; border-radius: 6px; background: #101015; border: 1px solid var(--line); overflow: hidden; }
.bar-track .bar {
  height: 100%; width: 0; transition: width 1s cubic-bezier(.2, .8, .2, 1);
  background: var(--chrome-grad); box-shadow: 0 0 8px rgba(210,220,235,.5);
}
.bar-track.left { transform: scaleX(-1); }
.stats-verdict {
  text-align: center; margin-top: 16px; font-size: 15px; font-weight: 900; letter-spacing: 1px;
  opacity: 0; animation: verdictIn .6s cubic-bezier(.2, 1.5, .4, 1) forwards; animation-delay: 1.1s;
}
.stats-verdict .crown {
  background: var(--chrome-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
@keyframes verdictIn { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }
.stats-foot { text-align: center; color: var(--muted); font-size: 10px; margin-top: 10px; letter-spacing: 1px; }
