body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #11161d;
    color: #e7edf5;
}

.page {
    width: min(1500px, calc(100vw - 40px));
    margin: 40px auto;
    padding: 0;
}

.card {
    background: #1a222c;
    border: 1px solid #2b3642;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-stats {
    display: flex;
    align-items: stretch;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar-stat {
    min-width: 110px;
    padding: 10px 14px;
    border: 1px solid #334152;
    border-radius: 8px;
    background: #131a22;
    text-align: center;
}

.topbar-stat-label {
    color: #95a4b5;
    font-size: 13px;
    margin-bottom: 4px;
}

.topbar-stat-value {
    font-size: 24px;
    font-weight: bold;
    line-height: 1.1;
    color: #f3f7fb;
}

.topbar-stat-sub {
    color: #7f8e9f;
    font-size: 13px;
    margin-top: 2px;
}

.dashboard-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.85fr);
    gap: 20px;
    align-items: start;
}

.dashboard-main,
.dashboard-side {
    min-width: 0;
}

h1, h2 {
    margin-top: 0;
    color: #f3f7fb;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #d8e0ea;
}

input[type="email"],
input[type="password"],
input[type="text"] {
    width: 100%;
    max-width: 420px;
    padding: 10px 12px;
    border: 1px solid #3a4756;
    border-radius: 6px;
    box-sizing: border-box;
    margin-bottom: 12px;
    background: #0f141a;
    color: #eef3f8;
}

input[type="email"]::placeholder,
input[type="text"]::placeholder {
    color: #6f8091;
}

input[type="email"]:focus,
input[type="text"]:focus,
textarea:focus {
    outline: none;
    border-color: #5b8cff;
    box-shadow: 0 0 0 3px rgba(91, 140, 255, 0.18);
}

button,
.button {
    display: inline-block;
    padding: 10px 16px;
    border: 1px solid #4c7dff;
    background: #4c7dff;
    color: #ffffff;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
}

button:hover,
.button:hover {
    filter: brightness(1.06);
}

.button.secondary {
    background: #1a222c;
    color: #cfe0ff;
    border-color: #44556a;
}

.inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.inline-form input {
    margin-bottom: 0;
}

.muted {
    color: #96a3b2;
}

.alert {
    padding: 12px 14px;
    border-radius: 6px;
    margin-top: 10px;
    margin-bottom: 16px;
}

.alert-error {
    background: #3a1f24;
    color: #ffb7bf;
    border: 1px solid #7a3a45;
}

.alert-success {
    background: #1f3326;
    color: #bce8c7;
    border: 1px solid #3f6a4a;
}

.card p {
    line-height: 1.55;
}

.card ul {
    margin-top: 10px;
    margin-bottom: 16px;
    padding-left: 22px;
}

.card li {
    margin-bottom: 8px;
    line-height: 1.5;
}

pre {
    background: #0f141a;
    border: 1px solid #2f3a46;
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: monospace;
    font-size: 14px;
    color: #d8f1ff;
}

#profile-message,
#flag-message {
    margin-top: 10px;
}

#my-score-summary,
#leaderboard {
    min-height: 24px;
}

a {
    color: #82b1ff;
}

a:hover {
    text-decoration: underline;
}

.stats-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-box {
    min-width: 180px;
    padding: 16px;
    border: 1px solid #2e3946;
    border-radius: 8px;
    background: #131a22;
}

.stat-label {
    color: #95a4b5;
    font-size: 14px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: bold;
    color: #f3f7fb;
}

.challenge-item {
    border: 1px solid #2d3844;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #141b23;
}

.challenge-item.solved {
    background: #16251b;
    border-color: #2c5940;
}

.challenge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.challenge-name {
    font-weight: bold;
    margin-bottom: 6px;
    color: #f1f6fb;
}

.challenge-description {
    color: #adb9c6;
    line-height: 1.45;
    font-size: small;
}

.challenge-meta {
    text-align: right;
    min-width: 180px;
}

.challenge-points {
    font-weight: bold;
    margin-bottom: 6px;
    color: #d9e7ff;
}

.challenge-status {
    color: #96a3b2;
    font-size: 14px;
}

.score-table {
    width: 100%;
    border-collapse: collapse;
}

.score-table th,
.score-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #2c3743;
    text-align: left;
}

.score-table th {
    background: #131a22;
    color: #d7e3f0;
}

.score-table tr:hover td {
    background: #1d2630;
}

.event-feed-scroll {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.45;
    background: #0f141a;
    border: 1px solid #2a3540;
    border-radius: 8px;
    padding: 10px 12px;
    color: #cfe0f3;
}

.event-line {
    white-space: nowrap;
    overflow-x: auto;
    padding: 3px 0;
    border-bottom: 1px solid #202933;
}

.event-line:last-child {
    border-bottom: none;
}

.event-item {
    padding: 12px 0;
    border-bottom: 1px solid #27313b;
}

.event-item:last-child {
    border-bottom: none;
}

.event-message {
    margin-bottom: 4px;
}

.event-time {
    color: #7f8e9f;
    font-size: 13px;
}

@media (max-width: 1000px) {
    .dashboard-layout {
        grid-template-columns: 1fr;
    }

    .page {
        width: calc(100vw - 30px);
    }
}
