:root {
  --bg: #0f1b2d;
  --bg-2: #16324f;
  --panel: #14243a;
  --line: #22344c;
  --fg: #f2f5f9;
  --dim: #9fb0c3;
  --acc: #4fc3f7;
  --acc-2: #ffd54f;
  --bad: #ff8a80;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* Elementy z display innym niż block muszą respektować atrybut hidden. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(1100px 520px at 80% -10%, rgba(79, 195, 247, .16), transparent 60%),
    radial-gradient(900px 480px at -10% 10%, rgba(255, 213, 79, .07), transparent 55%),
    var(--bg);
  color: var(--fg);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.55;
}

a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
.dim { color: var(--dim); }

/* ---------- górny pasek ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 27, 45, .72);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.brand:hover { text-decoration: none; }

.brand-mark {
  font-weight: 800;
  letter-spacing: .06em;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--acc), #2196c9);
  color: #071320;
}

.brand-text { font-weight: 600; letter-spacing: .01em; }

.brand-group {
  font-size: 13px;
  font-weight: 600;
  color: var(--acc);
  border: 1px solid rgba(79, 195, 247, .35);
  background: rgba(79, 195, 247, .08);
  border-radius: 999px;
  padding: 4px 12px;
}

.brand-group.is-admin { color: var(--acc-2); border-color: rgba(255, 213, 79, .4); background: rgba(255, 213, 79, .08); }

.group-badge {
  margin-bottom: 20px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0d1929;
  color: var(--dim);
  font-size: 15px;
}

.group-badge strong { color: var(--fg); }

.nav { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.nav a {
  color: var(--dim);
  padding: 7px 13px;
  border-radius: 999px;
  font-size: 15px;
  border: 1px solid transparent;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}

.nav a:hover { color: var(--fg); background: rgba(79, 195, 247, .1); text-decoration: none; }
.nav a.is-active { color: var(--acc); border-color: rgba(79, 195, 247, .45); background: rgba(79, 195, 247, .08); }
.nav .nav-out { color: #7d8ea3; }

/* ---------- układ ---------- */

.wrap { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 40px 24px 64px; }

.foot {
  border-top: 1px solid var(--line);
  padding: 20px 24px;
  text-align: center;
  color: var(--dim);
  font-size: 14px;
}

.hero { margin-bottom: 34px; animation: rise .45s ease both; }
.hero h1 { font-size: clamp(30px, 5.2vw, 46px); line-height: 1.1; letter-spacing: -.02em; }
.hero h1::after { content: ""; display: block; width: 54px; height: 3px; margin-top: 14px; border-radius: 2px; background: var(--acc); }
.hero p { color: var(--dim); max-width: 62ch; margin-top: 16px; }
.hero-sm h1 { font-size: clamp(26px, 4.2vw, 36px); }

.hero p.anon {
  color: var(--fg);
  border-left: 3px solid var(--acc-2);
  background: rgba(255, 213, 79, .07);
  padding: 12px 16px;
  border-radius: 0 10px 10px 0;
}

.back { display: inline-block; margin-bottom: 20px; font-size: 15px; color: var(--dim); }
.back::before { content: "← "; }
.back:hover { color: var(--acc); }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- kafelki klas ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel), #101d30);
  color: var(--fg);
  overflow: hidden;
  animation: rise .45s ease both;
  animation-delay: calc(var(--i, 0) * 55ms);
  transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.tile::after {
  content: "";
  position: absolute;
  inset: auto -30% -60% auto;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79, 195, 247, .22), transparent 70%);
  opacity: 0;
  transition: opacity .25s ease;
}

.tile:hover { transform: translateY(-4px); border-color: rgba(79, 195, 247, .55); box-shadow: var(--shadow); text-decoration: none; }
.tile:hover::after { opacity: 1; }

.tile-badge {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--acc);
  border: 1px solid rgba(79, 195, 247, .4);
  border-radius: 999px;
  padding: 3px 10px;
}

.tile-title { font-size: 21px; font-weight: 600; line-height: 1.25; }
.tile-meta { color: var(--dim); font-size: 14px; }

/* ---------- lista prezentacji ---------- */

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

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--fg);
  animation: rise .4s ease both;
  animation-delay: calc(var(--i, 0) * 50ms);
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}

.row:hover { transform: translateX(4px); border-color: rgba(79, 195, 247, .5); background: #17293f; text-decoration: none; }

.row-num {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(79, 195, 247, .12);
  color: var(--acc);
  font-weight: 700;
}

.row-title { flex: 1; font-size: 18px; }
.row-go { color: var(--dim); font-size: 14px; }
.row:hover .row-go { color: var(--acc); }

/* ---------- przełącznik trybu ---------- */

.switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  flex-wrap: wrap;
}

.switch-btn {
  border: 0;
  background: transparent;
  color: var(--dim);
  font: inherit;
  font-size: 15px;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .18s ease, color .18s ease;
}

.switch-btn:hover { color: var(--fg); }
.switch-btn.is-on { background: var(--acc); color: #071320; font-weight: 600; }

/* ---------- karty i formularze ---------- */

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 26px;
  animation: rise .4s ease both;
}

.field { margin-bottom: 20px; }

label { display: block; margin-bottom: 7px; font-size: 15px; font-weight: 600; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: #0d1929;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

textarea { resize: vertical; min-height: 84px; }

input::placeholder, textarea::placeholder { color: #6d7f93; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--acc);
  box-shadow: 0 0 0 3px rgba(79, 195, 247, .18);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--acc) 50%), linear-gradient(135deg, var(--acc) 50%, transparent 50%);
  background-position: calc(100% - 20px) center, calc(100% - 14px) center;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  padding: 13px 26px;
  background: var(--acc);
  color: #071320;
  transition: transform .15s ease, filter .18s ease;
}

button:hover { filter: brightness(1.08); transform: translateY(-1px); }
button:active { transform: none; }
button:disabled { opacity: .55; cursor: default; transform: none; }

button.ghost, .ghost-link {
  background: transparent;
  color: var(--acc);
  border: 1px solid rgba(79, 195, 247, .45);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 15px;
}

.ghost-link:hover { text-decoration: none; background: rgba(79, 195, 247, .1); }

.hint { font-size: 14px; margin-top: 6px; }

.alert {
  margin: 0 0 18px;
  padding: 12px 15px;
  border-radius: 10px;
  border: 1px solid rgba(255, 138, 128, .45);
  background: rgba(255, 138, 128, .1);
  color: var(--bad);
  font-size: 15px;
}

.done { border-color: rgba(79, 195, 247, .5); }
.done h2 { font-size: 26px; margin-bottom: 8px; }
.done p { color: var(--dim); margin-bottom: 18px; }

/* ---------- logowanie i błędy ---------- */

.login-body { justify-content: center; align-items: center; }

.login-card {
  width: min(420px, calc(100% - 40px));
  margin: auto;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(160deg, var(--panel), #101d30);
  box-shadow: var(--shadow);
  animation: rise .45s ease both;
  text-align: center;
}

.login-mark {
  display: inline-block;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 8px 14px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--acc), #2196c9);
  color: #071320;
  margin-bottom: 18px;
}

.login-card h1 { font-size: 26px; margin-bottom: 8px; }
.login-card form { margin-top: 22px; text-align: left; }
.login-card button { width: 100%; margin-top: 16px; }
.login-hint { margin-top: 18px; font-size: 14px; }

/* ---------- publiczna strona spod kodu QR ---------- */

.public-body { justify-content: flex-start; }

.public-card {
  width: min(560px, 100%);
  flex: 1 0 auto;
  margin: 0 auto;
  padding: 28px 22px 34px;
  text-align: center;
  animation: rise .4s ease both;
}

.public-card h1 { font-size: clamp(24px, 6.4vw, 32px); line-height: 1.2; margin-bottom: 10px; }
.public-card h2 { font-size: 24px; margin-bottom: 8px; }
.public-card form { margin-top: 22px; text-align: left; }
.public-card textarea { min-height: 160px; }
.public-card button { width: 100%; margin-top: 16px; }
.public-card .hint { margin-top: 10px; }
.public-card .alert { text-align: left; }

.public-deck {
  display: inline-block;
  margin-bottom: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--dim);
  font-size: 14px;
}

/* Pułapka na boty: poza ekranem, poza kolejnością tabulacji, niewidoczna dla ludzi. */
.pole-zapasowe {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ---------- panel ---------- */

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.filters select { width: auto; min-width: 170px; padding: 9px 40px 9px 14px; }

.counter {
  margin-left: auto;
  color: var(--dim);
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
}

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }

table { width: 100%; border-collapse: collapse; font-size: 15px; }

th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }

th { color: var(--acc); font-size: 13px; text-transform: uppercase; letter-spacing: .08em; white-space: nowrap; }

tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(79, 195, 247, .06); }

td.wrap-cell { min-width: 130px; max-width: 260px; white-space: pre-wrap; overflow-wrap: anywhere; }
td .nic { color: #5f7186; }

.del {
  background: transparent;
  color: var(--bad);
  border: 1px solid rgba(255, 138, 128, .35);
  border-radius: 8px;
  padding: 5px 11px;
  font-size: 14px;
}

.del:hover { background: rgba(255, 138, 128, .12); filter: none; }

@media (max-width: 720px) {
  body { font-size: 16px; }

  .wrap { padding: 24px 16px 44px; }

  .top { padding: 10px 14px; gap: 10px; row-gap: 8px; }
  .brand-text { font-size: 15px; }
  .brand-group { order: 3; margin-left: auto; }

  /* Nav łamie się do drugiego rzędu. Przewijanie w poziomie ucinało "Wyloguj". */
  .nav { order: 4; width: 100%; margin-left: 0; gap: 4px; flex-wrap: wrap; }
  .nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
    font-size: 14px;
  }

  .hero { margin-bottom: 26px; }
  .card { padding: 18px 16px; }
  .tiles { grid-template-columns: 1fr; gap: 14px; }
  .tile { padding: 18px; }
  .tile-title { font-size: 19px; }

  .row { padding: 14px; gap: 12px; }
  .row-title { font-size: 16px; }
  .row-go { display: none; }

  /* Palce zamiast myszy: każdy element dotykowy ma co najmniej 44 px wysokości. */
  input, select, textarea { font-size: 16px; min-height: 46px; }
  textarea { min-height: 96px; }
  button { width: 100%; min-height: 48px; }
  button.ghost { width: auto; }

  /* button {width:100%} niżej dotyczy przycisków formularzy, zakładki zostają obok siebie. */
  .switch { width: 100%; flex-wrap: wrap; justify-content: flex-start; }
  .switch-btn { width: auto; flex: 0 1 auto; min-height: 44px; padding: 10px 15px; font-size: 14px; }

  .filters { gap: 8px; }
  .filters select { flex: 1 1 100%; min-width: 0; }
  .counter { margin-left: 0; }
  .ghost-link { min-height: 44px; display: inline-flex; align-items: center; }

  table { font-size: 14px; }
  th, td { padding: 10px 12px; }
  td.wrap-cell { min-width: 110px; max-width: 190px; }
  .del { min-height: 44px; padding: 10px 14px; }

  .public-card { padding: 22px 16px 30px; }
  .foot { padding: 16px; font-size: 13px; }
}

@media (max-width: 380px) {
  .brand-text { display: none; }
  .wrap { padding: 20px 12px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Hasła grup w panelu: duże, do odczytania z rzutnika albo podyktowania. */
code.haslo { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 18px; letter-spacing: .04em; background: var(--line, #22344c); border-radius: 8px; padding: 6px 12px; white-space: nowrap; }

/* Publiczna lista gier i linki w panelu. */
.public-wide { max-width: 720px; }
.public-card .rows { margin-top: 20px; text-align: left; }
.row-sub { display: block; color: var(--dim, #9fb0c3); font-size: 13px; margin-top: 2px; }
.linki { margin-top: 24px; }
.linki ul { padding-left: 20px; margin: 8px 0 0; }
.linki li { margin: 6px 0; }

/* Link powrotu na stronach publicznych (gry, opinia). */
.back-public { align-self: flex-start; margin: 14px 16px 0; color: var(--dim, #9fb0c3); font-weight: 600; font-size: 14px; text-decoration: none; border: 1px solid #2a3f5a; border-radius: 999px; padding: 12px 16px; line-height: 1.2; min-height: 44px; box-sizing: border-box; display: inline-flex; align-items: center; }
.back-public:hover { color: #f2f5f9; }

/* Przełączniki widoczności materiałów w widoku nauczyciela. */
.row-wrap { display: flex; align-items: center; gap: 12px; }
.row-wrap .row { flex: 1; }
.row-wrap.is-hidden .row { opacity: .55; }
.pub-toggle { flex: 0 0 auto; min-height: 44px; padding: 8px 14px; border-radius: 999px; border: 1px solid #2a3f5a; background: transparent; color: var(--dim, #9fb0c3); font: 600 13px -apple-system, "Segoe UI", Arial, sans-serif; cursor: pointer; white-space: nowrap; }
.pub-toggle.is-on { border-color: var(--acc, #4fc3f7); color: var(--acc, #4fc3f7); }
@media (max-width: 600px) { .row-wrap { flex-direction: column; align-items: stretch; } }

/* Cele dotyku: min. 44 px na telefonie. */
.brand { min-height: 44px; display: inline-flex; align-items: center; }
.back { display: inline-flex; align-items: center; min-height: 44px; }
.linki li { margin: 0; }
.linki li a { display: inline-block; padding: 10px 0; }
.error-actions a { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 18px; border: 1px solid #2a3f5a; border-radius: 999px; text-decoration: none; color: var(--fg, #f2f5f9); font-weight: 600; }

/* Telefon: menu w jednym rzędzie, linki łamane tylko w adresach, odstęp pod przełącznikiem. */
.linki li a { overflow-wrap: anywhere; }
@media (max-width: 480px) {
  .nav a { padding: 6px 7px; font-size: 13px; }
  .row-wrap { margin-bottom: 14px; }
  .row-wrap .pub-toggle { min-height: 40px; }
}
