:root {
    --bg: #f0f2f5;
    --surface: #ffffff;
    --primary: #2c3e50;
    --primary-dark: #1a252f;
    --legit: #27ae60;
    --legit-dark: #219653;
    --phish: #e74c3c;
    --phish-dark: #c0392b;
    --border: #e0e0e0;
    --text: #2c3e50;
    --text-muted: #7f8c8d;
    --info-bg: #e8f4f8;
    --info-border: #3498db;
    --bonus: #f39c12;
}

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

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    padding: 20px;
    min-height: 100vh;
}

.game-container {
    max-width: 820px;
    width: 100%;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary);
    color: white;
    padding: 14px 20px;
    border-radius: 10px 10px 0 0;
    gap: 12px;
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

header h1 { font-size: 1.2rem; }

.team-name-display {
    font-size: 0.78rem;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 2px 10px;
    color: #d1fae5;
    font-weight: 600;
    width: fit-content;
}

.btn-leaderboard-header {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}

.btn-leaderboard-header:hover { background: rgba(255,255,255,0.25); }

.score-board {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: bold;
    font-size: 1rem;
}

.streak-display {
    background: linear-gradient(135deg, #e67e22, #f39c12);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.85; }
    to { opacity: 1; }
}

/* Progress bar */
.progress-bar-wrap {
    height: 4px;
    background: #dde1e7;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #27ae60);
    transition: width 0.4s ease;
    width: 0%;
}

/* Main */
main {
    background: var(--surface);
    padding: 22px;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.instruction-panel {
    background: var(--info-bg);
    padding: 13px 16px;
    border-left: 4px solid var(--info-border);
    border-radius: 4px;
    margin-bottom: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Type badge */
.type-badge-row {
    margin-bottom: 12px;
}

.type-badge {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.type-email {
    background: #dbeafe;
    color: #1d4ed8;
}

.type-sms {
    background: #d1fae5;
    color: #065f46;
}

/* Email client */
.email-client {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 20px;
    overflow: hidden;
}

.email-header {
    background: #f9f9f9;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}

.email-row {
    margin-bottom: 6px;
    font-size: 0.92rem;
}

.email-row:last-child { margin-bottom: 0; }

.email-body {
    padding: 20px;
    min-height: 180px;
    white-space: pre-wrap;
    line-height: 1.65;
    font-size: 0.95rem;
}

/* SMS Phone mockup */
.sms-phone {
    background: #1c1c1e;
    border-radius: 28px;
    max-width: 380px;
    margin: 0 auto 20px;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0,0,0,0.35), inset 0 0 0 1px rgba(255,255,255,0.08);
}

.sms-status-bar {
    background: #1c1c1e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px 4px;
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
}

.sms-contact-bar {
    background: #f2f2f7;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px 10px;
    border-bottom: 1px solid #d1d1d6;
}

.sms-back {
    font-size: 1.8rem;
    color: #007aff;
    line-height: 1;
    font-weight: 300;
    cursor: default;
}

.sms-avatar {
    font-size: 1.6rem;
    background: #c7c7cc;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sms-contact-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1c1c1e;
}

.sms-contact-number {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sms-messages {
    background: #ffffff;
    padding: 16px 16px 20px;
    min-height: 180px;
}

.sms-timestamp {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.sms-bubble {
    background: #e5e5ea;
    color: #1c1c1e;
    border-radius: 18px 18px 18px 4px;
    padding: 10px 14px;
    max-width: 85%;
    font-size: 0.92rem;
    line-height: 1.5;
    word-break: break-word;
}

/* RTL languages: Arabic, Urdu, Hebrew — flip bubble tail to right */
.sms-bubble[dir="rtl"] {
    border-radius: 18px 18px 4px 18px;
    text-align: right;
    font-size: 1rem;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 4px;
}

.btn {
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    transition: background 0.18s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-legit { background: var(--legit); }
.btn-legit:hover:not(:disabled) { background: var(--legit-dark); }

.btn-phish { background: var(--phish); }
.btn-phish:hover:not(:disabled) { background: var(--phish-dark); }

.btn-next { background: var(--primary); }
.btn-next:hover { background: var(--primary-dark); }

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 520px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
}

.modal-content h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.modal-content p {
    margin-bottom: 22px;
    line-height: 1.6;
    font-size: 0.96rem;
    color: #444;
    text-align: left;
}

/* Feedback bonus badge */
.feedback-bonus {
    background: var(--bonus);
    color: white;
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 14px;
}

/* Red flag modal */
.redflag-header {
    margin-bottom: 18px;
}

.redflag-correct-badge {
    background: var(--legit);
    color: white;
    display: inline-block;
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

.redflag-subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 0 !important;
    text-align: center !important;
}

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

.redflag-btn {
    background: #f5f7fa;
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 11px 16px;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.redflag-btn:hover {
    background: #eaf0fb;
    border-color: #3498db;
}

/* Game over screen */
.game-over {
    text-align: center;
    padding: 20px 0;
}

.game-over-icon { font-size: 3rem; margin-bottom: 12px; }

.game-over h2 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.final-score {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.final-score-label {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 16px;
}

.grade-badge {
    display: inline-block;
    border: 2px solid;
    border-radius: 30px;
    padding: 5px 20px;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 24px;
}

.score-breakdown {
    background: #f9f9f9;
    border-radius: 8px;
    padding: 14px 20px;
    margin-bottom: 24px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 0.92rem;
    border-bottom: 1px solid var(--border);
}

.breakdown-row:last-child { border-bottom: none; }

/* Game over actions */
.game-over-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-leaderboard-gameover {
    background: #2980b9;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    transition: background 0.18s;
}

.btn-leaderboard-gameover:hover { background: #1f6fa8; }

/* Team result card on game over */
.team-result {
    margin-bottom: 20px;
}

.team-result-loading {
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 10px 0;
}

.team-result-error {
    color: var(--phish);
    font-size: 0.88rem;
}

.team-result-card {
    background: linear-gradient(135deg, #1a3a5c, #2c3e50);
    color: white;
    border-radius: 10px;
    padding: 16px 20px;
    max-width: 320px;
    margin: 0 auto;
}

.team-result-name {
    font-size: 0.85rem;
    opacity: 0.75;
    margin-bottom: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.team-result-stats {
    display: flex;
    justify-content: space-around;
}

.team-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.team-stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
}

.team-stat-label {
    font-size: 0.7rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Save & Quit button */
.save-quit-wrap {
    text-align: center;
    margin-top: 14px;
}

.btn-save-quit {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}

.btn-save-quit:hover {
    color: var(--text);
    background: #f0f2f5;
}

/* Resume modal */
.resume-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-start-fresh {
    background: none;
    border: 2px solid var(--border);
    color: var(--text-muted);
    padding: 11px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.btn-start-fresh:hover {
    border-color: #aaa;
    color: var(--text);
}

/* Team registration screen */
.team-modal-content {
    max-width: 420px !important;
    text-align: center;
}

.team-screen-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.team-screen-subtitle {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 22px !important;
    text-align: center !important;
    line-height: 1.5;
}

.team-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.team-input-wrap input {
    padding: 12px 14px;
    font-size: 1rem;
    border: 2px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
    text-align: center;
    font-family: inherit;
}

.team-input-wrap input:focus {
    border-color: var(--info-border);
}

.team-error {
    color: var(--phish);
    font-size: 0.88rem;
    margin-top: 8px;
    text-align: center !important;
    margin-bottom: 0 !important;
}

/* Leaderboard modal */
.leaderboard-modal-content {
    max-width: 560px !important;
}

.leaderboard-modal-content h2 {
    text-align: center;
    margin-bottom: 18px;
}

.leaderboard-body {
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-loading {
    text-align: center;
    color: var(--text-muted);
    padding: 20px 0;
    margin: 0 !important;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.leaderboard-table th {
    background: #f0f2f5;
    padding: 9px 12px;
    text-align: left;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    position: sticky;
    top: 0;
}

.leaderboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.leaderboard-table tr:last-child td { border-bottom: none; }

.leaderboard-table tr:hover td { background: #f9f9f9; }

.leaderboard-own-row td {
    background: #eaf4ff !important;
    font-weight: 600;
}

.leaderboard-team-name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Leaderboard reset */
.leaderboard-reset-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.btn-reset-toggle {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 5px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-family: inherit;
    transition: color 0.2s, border-color 0.2s;
}

.btn-reset-toggle:hover { color: #e74c3c; border-color: #e74c3c; }

.reset-form {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
    align-items: center;
}

.reset-form input[type="password"] {
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.88rem;
    width: 150px;
}

.btn-reset-confirm {
    background: #e74c3c;
    color: #fff;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 700;
}

.btn-reset-confirm:hover { background: #c0392b; }

.reset-message {
    margin: 8px 0 0;
    font-size: 0.84rem;
    font-weight: 600;
}

.hidden { display: none !important; }

/* Music Player Widget */
.music-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}
.music-toggle {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid var(--primary-dark);
    background: var(--primary);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, background 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.music-toggle:hover { background: var(--primary-dark); transform: scale(1.08); }
.music-panel {
    width: 300px;
    border-radius: 8px;
    overflow: hidden;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    border: 1px solid var(--border);
}
.music-panel.open { display: block; }
