/* PTO Quiz — wspólne style
   H-00218 | pto.name
   Mobile-first, dark theme, kontrastowe kolory ABCD jak Kahoot
*/

:root {
    --bg-1: #1a1a2e;
    --bg-2: #16213e;
    --bg-3: #0f3460;
    --fg: #ffffff;
    --fg-muted: #b0b8d4;
    --accent: #46b3e6;
    --success: #4caf50;
    --error: #ef5350;
    --warning: #ffa726;

    --opt-a: #e74c3c;  /* czerwony */
    --opt-b: #3498db;  /* niebieski */
    --opt-c: #f1c40f;  /* żółty */
    --opt-d: #2ecc71;  /* zielony */

    --radius: 12px;
    --gap: 16px;
}

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

html, body {
    background: var(--bg-1);
    color: var(--fg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
}

body {
    background: linear-gradient(135deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
}

/* === Strona główna (index.php — formularz PIN) === */

.page-join {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.join-screen {
    width: 100%;
    max-width: 440px;
    text-align: center;
}

.join-header { margin-bottom: 40px; }

.logo {
    font-size: 56px;
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1;
}
.logo span {
    color: var(--accent);
    margin-left: 8px;
}

.tagline {
    margin-top: 12px;
    color: var(--fg-muted);
    font-size: 18px;
}

.join-form {
    background: rgba(255,255,255,0.05);
    padding: 32px 24px;
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

.join-label {
    display: block;
    font-size: 14px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

#pin-input {
    width: 100%;
    padding: 20px;
    font-size: 40px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 8px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: var(--radius);
    background: rgba(0,0,0,0.3);
    color: var(--fg);
    margin-bottom: 16px;
    font-family: 'Courier New', monospace;
}
#pin-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(70,179,230,0.2);
}

.btn-primary, .btn-secondary, .btn-danger {
    display: inline-block;
    width: 100%;
    padding: 18px 24px;
    font-size: 18px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    color: white;
}
.btn-primary { background: var(--accent); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(70,179,230,0.4); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); }
.btn-danger { background: var(--error); }

.join-footer {
    margin-top: 32px;
    color: var(--fg-muted);
    font-size: 13px;
}

/* === Lobby (host i gracz) === */

.lobby {
    padding: 24px;
    text-align: center;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.lobby-header {
    margin-bottom: 32px;
}

.pin-display {
    font-size: 96px;
    font-weight: 900;
    letter-spacing: 12px;
    color: var(--accent);
    line-height: 1;
    margin: 24px 0;
    font-family: 'Courier New', monospace;
}

/* === Nowy layout lobby: URL/PIN po lewej, QR po prawej === */
.lobby-grid {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 48px;
    align-items: center;
    justify-content: center;
    margin: 32px auto;
    max-width: 1200px;
    padding: 0 24px;
}

@media (max-width: 880px) {
    .lobby-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

.lobby-info {
    text-align: left;
}

.big-url-label, .big-pin-label {
    font-size: 22px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 600;
    margin-bottom: 8px;
}
.big-pin-label { margin-top: 28px; }

.big-url {
    font-size: clamp(48px, 7vw, 96px);
    font-weight: 900;
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 0 40px rgba(70, 179, 230, 0.5);
    letter-spacing: -2px;
    word-break: break-all;
    background: linear-gradient(135deg, #46b3e6 0%, #ffffff 50%, #46b3e6 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 4s ease-in-out infinite;
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.big-pin {
    font-size: clamp(56px, 9vw, 128px);
    font-weight: 900;
    letter-spacing: 12px;
    color: white;
    line-height: 1;
    font-family: 'Courier New', monospace;
    background: rgba(255,255,255,0.06);
    border: 3px solid rgba(70,179,230,0.4);
    border-radius: 20px;
    padding: 20px 32px;
    display: inline-block;
    text-shadow: 0 0 24px rgba(255,255,255,0.3);
}

/* === QR === */
.lobby-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.qr-frame {
    background: white;
    padding: 20px;
    border-radius: 24px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.4), 0 0 0 4px var(--accent);
    width: 320px;
    height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 880px) {
    .qr-frame {
        width: 240px;
        height: 240px;
        padding: 14px;
    }
}

.qr-frame > div, .qr-frame img, .qr-frame canvas, .qr-frame svg, .qr-frame table {
    width: 100% !important;
    height: 100% !important;
    display: block;
    image-rendering: pixelated;
}
.qr-frame table { border-collapse: collapse; }
.qr-frame td { padding: 0; }

.qr-caption {
    font-size: 18px;
    color: var(--fg-muted);
    font-weight: 600;
}

/* Stary url-display zostaje na zgodność wstecz */
.url-display {
    color: var(--fg-muted);
    font-size: 18px;
    margin: 8px 0 24px;
    word-break: break-all;
}
.url-display strong { color: var(--fg); }

.players-list {
    flex: 1;
    margin: 24px 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    max-height: 40vh;
    overflow-y: auto;
}

.player-chip {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 10px 18px;
    border-radius: 999px;
    font-weight: 600;
    animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop-in {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.players-counter {
    font-size: 24px;
    color: var(--fg-muted);
    margin: 12px 0;
}

/* === Pytanie (host i gracz) === */

.question-screen {
    padding: 24px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    color: var(--fg-muted);
    font-size: 18px;
    font-weight: 600;
}
.q-progress { color: var(--accent); }

.q-text {
    background: rgba(255,255,255,0.08);
    padding: 32px 24px;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 24px;
    flex-shrink: 0;
}
.q-text h2 {
    font-size: 28px;
    line-height: 1.4;
    font-weight: 700;
}

@media (min-width: 900px) {
    .q-text h2 { font-size: 36px; }
}

.timer {
    font-size: 56px;
    font-weight: 900;
    text-align: center;
    color: var(--accent);
    margin: 16px 0;
    font-variant-numeric: tabular-nums;
}
.timer.urgent { color: var(--error); animation: pulse 0.5s infinite; }

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    flex: 1;
    align-content: stretch;
}

@media (min-width: 600px) {
    .options-grid { grid-template-columns: 1fr 1fr; }
}

.option-btn {
    padding: 24px;
    font-size: 20px;
    font-weight: 700;
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    transition: transform 0.15s, box-shadow 0.2s, opacity 0.3s;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 100px;
}
.option-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.3); }
.option-btn:active { transform: translateY(0); }
.option-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.option-btn[data-letter="A"] { background: var(--opt-a); }
.option-btn[data-letter="B"] { background: var(--opt-b); }
.option-btn[data-letter="C"] { background: var(--opt-c); color: #2c2c2c; }
.option-btn[data-letter="D"] { background: var(--opt-d); }

.option-letter {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.option-btn.correct {
    box-shadow: 0 0 0 6px var(--success), 0 0 30px var(--success);
}
.option-btn.wrong {
    box-shadow: 0 0 0 6px var(--error);
    opacity: 0.4;
}
.option-btn.faded { opacity: 0.3; }

/* Statystyki na host po reveal */
.option-stat {
    margin-left: auto;
    font-size: 24px;
    font-weight: 800;
}

/* === Odpowiedź gracza po wyborze === */

.waiting-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 24px;
}

.waiting-screen h1 {
    font-size: 32px;
    margin-bottom: 16px;
}

.waiting-screen .nick-badge {
    font-size: 48px;
    font-weight: 900;
    color: var(--accent);
    margin: 16px 0;
}

.result-card {
    padding: 32px;
    border-radius: var(--radius);
    text-align: center;
    max-width: 90%;
    margin-top: 24px;
    animation: pop-in 0.5s ease-out;
}
.result-card.correct { background: var(--success); }
.result-card.wrong { background: var(--error); }
.result-card .delta {
    font-size: 56px;
    font-weight: 900;
    margin: 16px 0;
}

/* === Reveal / Ranking === */

.reveal-screen {
    padding: 24px;
    min-height: 100vh;
}

.ranking {
    list-style: none;
    margin: 24px 0;
}

.ranking li {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 18px;
    transition: background 0.2s;
}

.ranking .rank-num {
    font-size: 24px;
    font-weight: 900;
    color: var(--accent);
    min-width: 40px;
}

.ranking .rank-nick { flex: 1; font-weight: 600; }

.ranking .rank-score {
    font-weight: 800;
    font-size: 22px;
    color: var(--accent);
}

.ranking li:nth-child(1) { background: linear-gradient(90deg, gold, transparent); color: #1a1a2e; }
.ranking li:nth-child(1) .rank-score { color: #1a1a2e; }
.ranking li:nth-child(2) { background: linear-gradient(90deg, silver, transparent); color: #1a1a2e; }
.ranking li:nth-child(2) .rank-score { color: #1a1a2e; }
.ranking li:nth-child(3) { background: linear-gradient(90deg, #cd7f32, transparent); color: #1a1a2e; }
.ranking li:nth-child(3) .rank-score { color: #1a1a2e; }

.ranking-mine {
    background: rgba(70, 179, 230, 0.2) !important;
    border: 2px solid var(--accent);
}

/* === Final podium === */

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    margin: 32px 0;
    min-height: 280px;
}

.podium-spot {
    background: rgba(255,255,255,0.08);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 16px;
    text-align: center;
    flex: 1;
    max-width: 180px;
    animation: rise 0.8s ease-out;
}
.podium-spot.gold { height: 280px; background: linear-gradient(180deg, gold, #b8860b); color: #1a1a2e; }
.podium-spot.silver { height: 220px; background: linear-gradient(180deg, silver, #696969); color: #1a1a2e; }
.podium-spot.bronze { height: 180px; background: linear-gradient(180deg, #cd7f32, #5d3a1a); color: white; }

@keyframes rise {
    0% { transform: translateY(100%); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.podium-spot .place { font-size: 56px; font-weight: 900; line-height: 1; }
.podium-spot .nick { font-size: 22px; font-weight: 700; margin: 8px 0; }
.podium-spot .score { font-size: 32px; font-weight: 800; }

/* === Common === */

.alert {
    padding: 16px;
    border-radius: var(--radius);
    margin: 16px 0;
    font-weight: 600;
}
.alert-error { background: rgba(239, 83, 80, 0.2); border: 1px solid var(--error); color: var(--error); }
.alert-success { background: rgba(76, 175, 80, 0.2); border: 1px solid var(--success); color: var(--success); }

.controls {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.controls button {
    flex: 1;
}

.text-center { text-align: center; }
.text-muted { color: var(--fg-muted); }
.text-xl { font-size: 24px; }
.text-2xl { font-size: 32px; }
.text-3xl { font-size: 48px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.hidden { display: none !important; }

/* === Embed/iframe — ukryj header gdy w iframe === */
@media (display-mode: standalone), (display-mode: minimal-ui) {
    .iframe-only-hide { display: none; }
}

/* When inside iframe — slim down */
body.iframe-mode .lobby-header .logo { font-size: 36px; }
body.iframe-mode .pin-display { font-size: 64px; }

/* Print — hide */
@media print {
    body { background: white; color: black; }
}

/* === PYTANIA TXT (otwarte odpowiedzi tekstowe) === */

/* Gracz: pole textarea z licznikiem */
.txt-input-wrap {
    max-width: 720px;
    margin: 24px auto 0;
    padding: 0 16px;
}
.txt-input-wrap textarea#play-txt-input {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.35);
    color: var(--fg);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 16px;
    line-height: 1.5;
    resize: vertical;
    min-height: 120px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.txt-input-wrap textarea#play-txt-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(70,179,230,0.25);
}
.txt-input-wrap textarea#play-txt-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.txt-counter {
    margin-top: 8px;
    font-size: 13px;
    color: var(--fg-muted);
    display: flex;
    gap: 12px;
    align-items: baseline;
    flex-wrap: wrap;
}
.txt-counter #play-txt-counter-current {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--success);
    transition: color 0.15s;
}
.txt-counter #play-txt-counter-current.too-short { color: var(--error); }
.txt-counter #play-txt-counter-current.near-max  { color: var(--warning); }
.txt-counter #play-txt-counter-current.at-max    { color: var(--error); }
.txt-counter .txt-counter-min { color: var(--fg-muted); }
.txt-input-wrap button#play-txt-submit {
    margin-top: 16px;
    width: 100%;
}

/* Host: blok pytania TXT (zamiast options-grid) */
.txt-host-block {
    max-width: 800px;
    margin: 32px auto 0;
    padding: 32px 24px;
    text-align: center;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.08);
}
.txt-host-status {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 12px;
}
.txt-host-status #host-txt-answered-count {
    font-size: 48px;
    font-weight: 900;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}
.txt-host-meta {
    color: var(--fg-muted);
    font-size: 14px;
}

/* Host: lista odpowiedzi w reveal */
.txt-answers-list {
    max-width: 900px;
    margin: 16px auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.txt-answers-heading {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}
.txt-answer {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    padding: 14px 18px;
    transition: background 0.15s;
}
.txt-answer:hover { background: rgba(255,255,255,0.09); }
.txt-answer-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.txt-answer-nick {
    color: var(--accent);
    font-size: 16px;
}
.txt-answer-time {
    color: var(--fg-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.txt-answer-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.5;
    color: var(--fg);
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Result-card dla TXT (gracz po reveal) */
.result-card.txt {
    background: rgba(70,179,230,0.15);
    border: 2px solid var(--accent);
}

/* === ADMIN: formularz tworzenia/edycji quizu TXT === */
#quiz-txt-form label {
    display: block;
    font-size: 13px;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 12px;
}
#quiz-txt-form input[type="text"],
#quiz-txt-form input[type="number"],
#quiz-txt-form textarea {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.3);
    color: var(--fg);
    font-size: 14px;
    font-family: inherit;
    text-transform: none;
    letter-spacing: normal;
}
#quiz-txt-form textarea {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    resize: vertical;
}
#quiz-txt-form input:focus,
#quiz-txt-form textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(70,179,230,0.2);
}
#quiz-txt-form input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
}
.qf-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 12px;
}
.qf-checkbox {
    display: flex !important;
    align-items: center;
    gap: 10px;
    text-transform: none !important;
    font-size: 14px !important;
    letter-spacing: normal !important;
    color: var(--fg) !important;
    align-self: end;
}
.qf-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
}
.qf-question-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}
.qf-question-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.qf-question-num {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent);
}

/* === ADMIN: tabela odpowiedzi TXT w szczegółach gry === */
.txt-admin-question {
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
}
.txt-admin-question h4 {
    font-size: 16px;
    color: var(--accent);
    margin-bottom: 12px;
    font-weight: 700;
}
.txt-admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.txt-admin-table th,
.txt-admin-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    vertical-align: top;
}
.txt-admin-table th {
    color: var(--fg-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
