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

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    min-height: 100vh;
    color: #333;
    display: flex;
    flex-direction: column;
}

.hidden { display: none !important; }

/* ─── Top bar ─── */
#topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    background: rgba(255,255,255,0.95);
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
#topbar .logo {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 3px;
    color: #1e3c72;
}
#topbar .right { display: flex; align-items: center; gap: 12px; }
#topbar .welcome { font-size: 14px; color: #555; }
#topbar .welcome strong { color: #1e3c72; }

/* ─── Buttons ─── */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: 0.2s;
    letter-spacing: 0.3px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-login    { background: #1e3c72; color: #fff; }
.btn-login:hover:not(:disabled)    { background: #2a5298; }
.btn-register { background: #28a745; color: #fff; }
.btn-register:hover:not(:disabled) { background: #218838; }
.btn-accept   { background: #28a745; color: #fff; }
.btn-accept:hover:not(:disabled)   { background: #218838; }
.btn-decline  { background: #dc3545; color: #fff; }
.btn-decline:hover:not(:disabled)  { background: #c82333; }
.btn-logout   { background: #6c757d; color: #fff; padding: 8px 14px; font-size: 13px; }
.btn-logout:hover { background: #5a6268; }
.btn-profile  { background: #eef2f7; color: #1e3c72; padding: 8px 14px; font-size: 13px; }
.btn-profile:hover { background: #dde6f0; }

/* ─── Main view ─── */
#view {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

/* ─── Cards ─── */
.container {
    background: #fff;
    padding: 40px 35px;
    border-radius: 14px;
    box-shadow: 0 12px 45px rgba(0,0,0,0.35);
    width: 100%;
    max-width: 480px;
}
.container.wide { max-width: 720px; }

.brand { text-align: center; margin-bottom: 28px; }
.brand h1 {
    font-size: 44px; letter-spacing: 6px; font-weight: 800;
    background: linear-gradient(90deg, #1e3c72, #2a5298);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}
.brand .tagline {
    font-size: 13px; color: #888;
    letter-spacing: 2px; text-transform: uppercase;
}

.section-title {
    font-size: 15px; font-weight: 700;
    color: #1e3c72; text-transform: uppercase;
    letter-spacing: 1.5px; margin-bottom: 14px;
    padding-bottom: 8px; border-bottom: 2px solid #eee;
}
.section { margin-bottom: 28px; }
.section:last-child { margin-bottom: 0; }

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block; margin-bottom: 6px;
    font-size: 13px; font-weight: 600; color: #555;
}
.form-group input {
    width: 100%; padding: 12px 14px;
    border: 1px solid #ccc; border-radius: 6px;
    font-size: 14px;
}
.form-group input:focus {
    outline: none; border-color: #1e3c72;
    box-shadow: 0 0 0 3px rgba(30,60,114,0.12);
}

.btn-submit { width: 100%; padding: 13px 20px; font-size: 15px; }

.error   { color: #dc3545; font-size: 13px; margin-top: 8px; text-align: center; min-height: 18px; }
.success { color: #28a745; font-size: 13px; margin-top: 8px; text-align: center; min-height: 18px; }

.divider {
    display: flex; align-items: center;
    color: #bbb; font-size: 12px;
    letter-spacing: 2px; margin: 24px 0;
}
.divider::before, .divider::after {
    content: ''; flex: 1; height: 1px; background: #eee;
}
.divider span { padding: 0 12px; }

/* ─── Modal ─── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}
.modal {
    background: #fff; padding: 30px;
    border-radius: 10px; max-width: 600px;
    max-height: 80vh; overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}
.modal h2 { color: #1e3c72; margin-bottom: 15px; }
.modal p, .modal li { line-height: 1.6; margin-bottom: 12px; font-size: 14px; color: #444; }
.modal ul { padding-left: 20px; margin-bottom: 15px; }
.modal-buttons { display: flex; gap: 12px; margin-top: 25px; }
.modal-buttons .btn { flex: 1; }

/* ─── Chatroom ─── */
.chatroom h1 {
    font-size: 40px; color: #1e3c72;
    margin-bottom: 12px; text-align: center;
    letter-spacing: 1px;
}
.chatroom .sub {
    font-size: 15px; color: #666;
    margin-bottom: 24px; text-align: center;
}
.chatroom .hello {
    font-size: 18px; color: #1e3c72;
    font-weight: 600; text-align: center;
}

.loading { color: #fff; font-size: 16px; }
.message-box {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 20px; border-radius: 8px;
    text-align: center; color: #856404;
}

/* ─── Chatbox ─── */
.chatroom { text-align: center; }
.chatroom .sub { margin-bottom: 18px; }

.chatbox {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e6e6e6;
    border-radius: 12px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.08);
    overflow: hidden;
}

.chatlog {
    flex: 1;
    min-height: 320px;
    max-height: 55vh;
    overflow-y: auto;
    padding: 16px 18px;
    text-align: left;
    background: #fafbfc;
    font-size: 14px;
    line-height: 1.5;
}

.chatlog .msg { margin-bottom: 8px; word-wrap: break-word; }
.chatlog .msg .who { font-weight: 700; color: #1e3c72; margin-right: 6px; }
.chatlog .msg .when { color: #999; font-size: 11px; margin-left: 6px; }
.chatlog .msg.bot .who { color: #b02a37; }
.chatlog .msg.trivia .text { color: #1e3c72; font-weight: 600; }
.chatlog .msg.system .text { color: #6c757d; font-style: italic; }

.chatform {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #eee;
    background: #fff;
}
.chatform input {
    flex: 1;
    padding: 11px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
}
.chatform input:focus {
    outline: none;
    border-color: #1e3c72;
    box-shadow: 0 0 0 3px rgba(30,60,114,0.12);
}
.chatform .btn { padding: 11px 20px; }


/* ─── Override: Instant Access button, bright orange ─── */
.btn.btn-visitor {
    background: #ff6a00 !important;
    color: #ffffff !important;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.4px;
}
.btn.btn-visitor:hover:not(:disabled) {
    background: #e65c00 !important;
}

/* ─── Country flag next to username in chat log ─── */
.chatlog .msg .flag {
    width: 16px;
    height: 12px;
    margin-right: 5px;
    vertical-align: baseline;
    border-radius: 2px;
    box-shadow: 0 0 1px rgba(0,0,0,0.35);
    display: inline-block;
}
