/* ═══════════════════════════════════════════════════════════════════
   PSYCH! Party Game - Mobile-First CSS
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --bg: #0a0a1a;
    --bg-card: #151530;
    --bg-card-hover: #1c1c40;
    --primary: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --text: #f0f0ff;
    --text-dim: #8888aa;
    --text-muted: #555577;
    --border: #2a2a50;
    --radius: 12px;
    --radius-lg: 20px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

body {
    background: linear-gradient(135deg, #0a0a1a 0%, #1a0a2e 50%, #0a1a2e 100%);
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─── Container ──────────────────────────────────────────────── */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ─── Hero / Logo ────────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 3rem 0 2rem;
}

.hero.small {
    padding: 1.5rem 0 1rem;
}

.logo-text {
    font-size: 4rem;
    font-weight: 900;
    background: linear-gradient(135deg, #7c3aed, #06b6d4, #f59e0b);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient-shift 3s ease infinite;
    letter-spacing: -2px;
    text-shadow: 0 0 40px rgba(124, 58, 237, 0.3);
}

.logo-text.small {
    font-size: 2.5rem;
}

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

.subtitle {
    font-size: 1.2rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

.description {
    color: var(--text-muted);
    margin-top: 1rem;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: white;
    width: 100%;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #9333ea);
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 30px rgba(124, 58, 237, 0.6);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary), #0891b2);
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669) !important;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4) !important;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-dim);
    box-shadow: none;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    width: auto;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border-radius: var(--radius-lg);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-icon {
    font-size: 1.4rem;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1.5rem 0;
}

/* ─── QR Code Section ────────────────────────────────────────── */
.qr-section {
    text-align: center;
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.qr-section h3 {
    color: var(--primary-light);
    font-size: 1rem;
    margin-bottom: 1rem;
}

.qr-wrapper {
    display: inline-block;
    background: white;
    padding: 12px;
    border-radius: var(--radius);
}

.qr-code-img {
    width: 160px;
    height: 160px;
    display: block;
}

.qr-url {
    margin-top: 0.75rem;
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--secondary);
    font-weight: 600;
    user-select: all;
}

/* ─── How to Play ────────────────────────────────────────────── */
.how-to-play {
    margin-top: 2.5rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.how-to-play h3 {
    text-align: center;
    margin-bottom: 1.25rem;
    color: var(--primary-light);
    font-size: 1.1rem;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.step-text {
    color: var(--text-dim);
    font-size: 0.95rem;
}

/* ─── Forms ──────────────────────────────────────────────────── */
.form-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.1rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.rounds-selector {
    display: flex;
    gap: 0.5rem;
}

.round-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.round-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.error-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    text-align: center;
}

.back-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}

/* ─── Game Layout ────────────────────────────────────────────── */
.game-container {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(10, 10, 26, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-mini {
    font-size: 1.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #7c3aed, #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-code {
    background: var(--bg-card);
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
    font-weight: 700;
    font-family: monospace;
    font-size: 1rem;
    letter-spacing: 2px;
    border: 1px solid var(--border);
}

.round-info {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
}

/* ─── Timer Bar ──────────────────────────────────────────────── */
.timer-bar {
    height: 4px;
    background: var(--bg-card);
    display: none;
}

.timer-bar.active {
    display: block;
}

.timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

.timer-fill.urgent {
    background: linear-gradient(90deg, var(--danger), var(--accent));
    animation: pulse-bar 0.5s ease infinite;
}

@keyframes pulse-bar {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* ─── Game Content ───────────────────────────────────────────── */
.game-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 60px;
}

.phase-content {
    padding: 1.5rem 1rem;
    animation: fadeIn 0.3s ease;
}

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

/* ─── Lobby ──────────────────────────────────────────────────── */
.lobby-content {
    text-align: center;
}

.waiting-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: bounce 2s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.room-code-big {
    margin: 1.5rem 0;
    padding: 1.25rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 2px dashed var(--primary);
    cursor: pointer;
}

.room-code-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.room-code-value {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.5rem;
    font-family: monospace;
    color: var(--primary-light);
}

.room-code-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.player-count {
    color: var(--text-dim);
    margin-bottom: 1rem;
}

.lobby-players {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 1rem 0 1.5rem;
    text-align: left;
}

.lobby-player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
}

.host-badge {
    margin-left: auto;
}

.waiting-text {
    color: var(--text-muted);
    font-style: italic;
    padding: 1rem;
    animation: pulse 2s ease infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* ─── Question Card ──────────────────────────────────────────── */
.category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(124, 58, 237, 0.2);
    border: 1px solid var(--primary);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 1rem;
}

.question-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border);
    margin-bottom: 1.5rem;
}

.question-card.small {
    padding: 1rem;
    margin-bottom: 1rem;
}

.question-text {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.5;
}

.question-card.small .question-text {
    font-size: 1rem;
}

/* ─── Submit Phase ───────────────────────────────────────────── */
.answer-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.answer-input-group label {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.answer-input-group textarea {
    width: 100%;
    padding: 1rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.1rem;
    resize: none;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s;
}

.answer-input-group textarea:focus {
    border-color: var(--primary);
}

.submitted-msg {
    text-align: center;
    padding: 2rem;
    animation: fadeIn 0.3s ease;
}

.check-icon {
    font-size: 3rem;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.counter-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 1rem;
}

#submit-section.submitted {
    text-align: center;
}

/* ─── Voting Phase ───────────────────────────────────────────── */
.voting-instruction {
    text-align: center;
    color: var(--accent);
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.vote-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.vote-option {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.05rem;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.vote-option:hover:not(:disabled):not(.disabled) {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.vote-option:active:not(:disabled):not(.disabled) {
    transform: scale(0.98);
}

.vote-option.own-answer {
    opacity: 0.5;
    border-style: dashed;
    cursor: not-allowed;
}

.vote-option.disabled {
    opacity: 0.7;
}

.own-badge {
    font-size: 0.7rem;
    background: var(--primary);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    flex-shrink: 0;
}

.vote-text {
    flex: 1;
}

/* ─── Results Phase ──────────────────────────────────────────── */
.results-section {
    margin-bottom: 1.5rem;
}

.reveals {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.reveal-card {
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-card);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.reveal-card.real-answer {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.reveal-card.fake-answer-reveal {
    border-color: var(--border);
}

.reveal-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.reveal-author {
    font-size: 0.85rem;
    color: var(--text-dim);
}

.reveal-voters {
    font-size: 0.8rem;
    color: var(--accent);
    margin-top: 0.25rem;
}

.reveal-voters.empty {
    color: var(--text-muted);
    font-style: italic;
}

.my-score-popup {
    text-align: center;
    padding: 1.25rem;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid var(--primary);
    border-radius: var(--radius-lg);
    animation: popIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.my-score-popup.zero {
    background: rgba(85, 85, 119, 0.1);
    border-color: var(--border);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}

.score-big {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary-light);
}

.my-score-popup.zero .score-big {
    color: var(--text-muted);
}

.score-details {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-top: 0.25rem;
}

/* ─── Game Over ──────────────────────────────────────────────── */
.gameover-content {
    text-align: center;
}

.gameover-header {
    margin-bottom: 1.5rem;
}

.trophy {
    font-size: 4rem;
    animation: bounce 2s ease infinite;
}

.gameover-header h1 {
    font-size: 2rem;
    margin-top: 0.5rem;
}

.winner-card {
    background: var(--bg-card);
    border: 3px solid;
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: popIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.winner-crown {
    font-size: 2rem;
}

.winner-name {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0.25rem 0;
}

.winner-score {
    font-size: 1.2rem;
    color: var(--accent);
    font-weight: 700;
}

.final-standings {
    text-align: left;
    margin-bottom: 1.5rem;
}

.standing-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.standing-row.first {
    background: rgba(124, 58, 237, 0.1);
    border-radius: var(--radius) var(--radius) 0 0;
}

.standing-rank {
    font-size: 1.2rem;
    width: 32px;
    text-align: center;
}

.standing-name {
    flex: 1;
    padding-left: 0.5rem;
    font-weight: 600;
}

.standing-score {
    font-weight: 700;
    color: var(--accent);
    font-family: monospace;
    font-size: 1rem;
}

/* ─── Scoreboard (bottom) ────────────────────────────────────── */
.scoreboard-toggle {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    padding: 0.5rem 1rem;
    background: rgba(21, 21, 48, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    z-index: 200;
    font-size: 0.9rem;
    color: var(--text-dim);
    font-weight: 600;
}

.scoreboard {
    position: fixed;
    bottom: 38px;
    left: 0;
    right: 0;
    max-width: 600px;
    margin: 0 auto;
    background: rgba(21, 21, 48, 0.98);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    z-index: 199;
}

.scoreboard.open {
    max-height: 300px;
    overflow-y: auto;
}

.sb-player {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid rgba(42, 42, 80, 0.5);
}

.sb-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: white;
    flex-shrink: 0;
}

.sb-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
}

.sb-dots {
    font-size: 0.75rem;
}

.sb-dots.disconnected {
    color: var(--danger);
}

.sb-score {
    font-weight: 700;
    font-family: monospace;
    font-size: 0.95rem;
    color: var(--accent);
    min-width: 50px;
    text-align: right;
}

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 400px) {
    .logo-text { font-size: 3rem; }
    .room-code-value { font-size: 2.5rem; }
    .question-text { font-size: 1.05rem; }
    .phase-content { padding: 1rem 0.75rem; }
}

@media (min-width: 600px) {
    .container { padding: 3rem 2rem; }
    .logo-text { font-size: 5rem; }
}

/* ─── Safe area (notched phones) ─────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .scoreboard-toggle {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}
