:root {
  --bg: #0b0d10;
  --panel: #151a21;
  --panel-2: #1d2530;
  --line: #2a3542;
  --fg: #e8edf2;
  --muted: #8ea0b5;
  --accent: #7cf46a;
  --accent-2: #5ad1ff;
  --danger: #ff6b6b;
  --warn: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

button {
  font: inherit;
  font-weight: 600;
  color: #0b0d10;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  transition: filter .12s ease, transform .05s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: var(--panel-2); color: var(--fg); border: 1px solid var(--line); }
button.warn { background: var(--warn); }
button.danger { background: var(--danger); color: #fff; }
button.big { padding: 18px 40px; font-size: 22px; border-radius: 12px; }

input[type="password"], input[type="text"] {
  font: inherit;
  color: var(--fg);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Ekran startowy / bramki ---------- */
.center-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
  padding: 24px;
}
.center-screen h1 { font-size: clamp(32px, 7vw, 72px); margin: 0; letter-spacing: -1px; }
.center-screen p { color: var(--muted); max-width: 620px; margin: 0; line-height: 1.5; }

/* ---------- Kuchnia ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .spacer { flex: 1; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 18px 80px; }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.dropzone.drag { border-color: var(--accent); background: #17251a; color: var(--fg); }

.tabs {
  display: flex;
  gap: 6px;
  margin-top: 24px;
  border-bottom: 1px solid var(--line);
}
.tab {
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 14px;
  font-weight: 600;
}
.tab:hover { filter: none; color: var(--fg); }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }
.pill {
  display: inline-block;
  min-width: 18px;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.grid-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.thumb {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.thumb .imgbox { background: #000; aspect-ratio: 336/240; display: flex; align-items: center; justify-content: center; }
.thumb .imgbox img { width: 100%; height: 100%; object-fit: contain; }
.thumb .meta { padding: 8px 10px; display: flex; gap: 8px; align-items: center; }
.thumb .meta .name { font-size: 12px; color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Editor detalu */
.editor { margin-top: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.editor h2 { margin: 0 0 4px; font-size: 16px; }
.editor-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
@media (max-width: 800px) { .editor-cols { grid-template-columns: 1fr; } }

.canvas-stage { position: relative; background: #000; border-radius: 8px; overflow: hidden; display: inline-block; line-height: 0; touch-action: none; }
.canvas-stage canvas { display: block; }
.selrect { position: absolute; border: 1px solid var(--accent-2); background: rgba(90,209,255,.18); pointer-events: none; }

.preview-box { background: #000; border-radius: 8px; display: inline-block; line-height: 0; }
.preview-box canvas { display: block; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.swatch { display: flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; font-size: 12px; user-select: none; }
.swatch .chip { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(255,255,255,.25); }
.swatch.subject { outline: 2px solid var(--accent); }
.swatch.bg { opacity: .55; }

.editor-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.toast.err { border-color: var(--danger); }

/* ---------- Konkurs ---------- */
#play { min-height: 100vh; display: flex; flex-direction: column; }
.play-top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; }
.timer { font-variant-numeric: tabular-nums; font-size: 28px; font-weight: 700; letter-spacing: 1px; }
.timer.warn { color: var(--warn); }
.timer.over { color: var(--danger); }
.counter { color: var(--muted); font-size: 15px; }
.play-stage { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; }
.board { position: relative; line-height: 0; background: #000; box-shadow: 0 0 0 2px var(--line); }
.board img { display: block; }
.tiles { position: absolute; inset: 0; display: grid; }
.tile { background: #0b0d10; border: 1px solid #05070a; transition: opacity .25s ease; }
.tile.revealed { opacity: 0; }
.badge { position: absolute; top: 10px; left: 10px; background: var(--accent); color: #06210a; font-weight: 800; padding: 6px 12px; border-radius: 8px; font-size: 16px; }
.badge.miss { background: var(--danger); color: #fff; }
.play-controls { display: flex; gap: 12px; padding: 16px 20px 28px; justify-content: center; flex-wrap: wrap; }
.summary { color: var(--muted); text-align: center; padding: 8px; font-size: 14px; }
