html {
    background-color: black;
    background-image: url(../images/very_darkened.jpg);
    background-size: cover;
    background-attachment: fixed;
    background-position: center;
}

/* Guards against any later rule (e.g. display:flex) fighting the [hidden] attribute */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
}

.profile-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Roboto Regular', Arial, Helvetica, sans-serif;
    color: #e0e0e0;
}

.profile-page > header,
.profile-page > header .logo {
    width: 100%;
}

.profile-page > header {
    margin-bottom: 24px;
}

.profile-page > header .logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-page > header .logo img {
    margin-top: 10px;
}

.logout-discord-btn {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #f2f3f5;
    font-size: 0.82rem;
    padding: 8px 12px;
}

.logout-discord-btn:hover {
    background-color: rgba(255, 255, 255, 0.12);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 1.5rem;
}

.profile-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.share-profile-btn {
    position: absolute;
    top: 56px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.12s;
    z-index: 5;
}

.share-profile-btn:hover {
    background: rgba(0, 0, 0, 0.65);
    transform: scale(1.06);
}

.share-profile-btn svg {
    width: 20px;
    height: 20px;
}

.share-profile-btn .share-icon-check {
    display: none;
}

.share-profile-btn.is-copied .share-icon-link {
    display: none;
}

.share-profile-btn.is-copied .share-icon-check {
    display: block;
}

.share-icon-check {
    color: #4ade80;
}

.privacy-popup {
    position: absolute;
    top: 52px;
    right: 12px;
    width: 260px;
    max-width: calc(100vw - 64px);
    background: rgba(8, 6, 7, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
    z-index: 6;
}

.privacy-popup-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.privacy-popup-actions {
    margin-top: 12px;
    display: flex;
    justify-content: flex-end;
}

.privacy-toggle-title {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
}

.privacy-toggle-hint {
    color: #999;
    font-size: 0.85rem;
    margin-top: 2px;
}

.toggle-switch {
    display: inline-block;
    width: 50px;
    height: 25px;
    background: #555;
    border-radius: 15px;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-switch.active {
    background: #e53935;
}

.toggle-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: left 0.3s;
}

.toggle-switch.active .toggle-slider {
    left: 27px;
}

.profile-loading,
.profile-error {
    text-align: center;
    padding: 3rem 1rem;
    color: #999;
    font-size: 1.1rem;
}

.profile-error {
    color: #ff6b6b;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.lock-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.profile-private-message {
    flex-direction: column;
    gap: 12px;
}

.lock-icon-large {
    width: 56px;
    height: 56px;
}

.profile-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.profile-panel {
    background: rgba(8, 6, 7, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 1.25rem;
}

.profile-section-title {
    font-family: 'Heavitas', 'Creepster', cursive;
    font-weight: normal;
    font-size: 1.2rem;
    color: #ffa500;
    margin-bottom: 0.9rem;
}

.discord-bot-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 0.9rem;
    background: #20254a;
    border: 1px solid #5865f2;
    box-shadow: 0 4px 18px rgba(88, 101, 242, 0.2);
}

.discord-bot-d-icon {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 7px;
    object-fit: cover;
}

.discord-bot-copy {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
    color: #fff;
}

.discord-bot-copy strong {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.discord-bot-invite {
    padding: 0.35rem 0.65rem;
    border-radius: 5px;
    background: #5865f2;
    color: #fff;
    font-size: 0.85rem;
    font-weight: bold;
    text-decoration: none;
    transition: background-color 0.2s;
}

.discord-bot-invite:hover {
    background: #7280ff;
}

.discord-bot-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #aaa;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: background-color 0.2s, color 0.2s;
}

.discord-bot-close:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* Hero header: banner + big overlapping avatar + headline stats */
.profile-hero {
    position: relative;
    border-radius: 18px;
    /* visible (not hidden) so the settings popup can escape the banner's box */
    overflow: visible;
    background: rgba(8, 6, 7, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.profile-hero-banner {
    position: relative;
    height: 120px;
    border-radius: 18px 18px 0 0;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(58, 10, 16, 0.35) 0%, rgba(10, 3, 5, 0.45) 70%),
        url(../images/dbdlelogo.png);
    background-repeat: no-repeat;
    background-size: cover, auto 85%;
    background-position: center, center;
}

.profile-settings-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.12s;
    z-index: 5;
}

.profile-settings-btn:hover {
    background: rgba(0, 0, 0, 0.65);
    transform: scale(1.06);
}

.profile-settings-btn svg {
    width: 20px;
    height: 20px;
}

.profile-hero-main {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 20px;
    padding: 0 24px 20px;
    margin-top: -55px;
}

.profile-avatar-wrap {
    flex-shrink: 0;
}

.profile-avatar-img {
    width: 130px;
    height: 130px;
    border-radius: 24px;
    border: 4px solid #17080a;
    background: #0a0a0a;
    object-fit: cover;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.55);
}

.profile-avatar-img,
.favorite-killer-image {
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
}

.profile-hero-identity {
    flex: 1;
    min-width: 200px;
    padding-bottom: 10px;
}

.profile-hero-discord,
.profile-hero-discord-unlinked {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.profile-hero-name-stack {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    justify-content: flex-start;
}

.profile-hero-username {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: left;
    line-height: 1.15;
    order: 1;
}

.profile-badges {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 18px;
    order: 2;
}

.profile-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(35, 35, 40, 0.9);
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.28);
    line-height: 1;
}

.profile-badge img,
.profile-hero-badge img {
    width: 14px;
    height: 14px;
    display: block;
    filter: brightness(0) invert(1);
}

.profile-badge-staff {
    background: #b87918;
    box-shadow: 0 2px 7px rgba(184, 121, 24, 0.38);
}

.profile-badge-tester {
    background: #327fad;
    box-shadow: 0 2px 7px rgba(50, 127, 173, 0.38);
}

.profile-badge-booster {
    background: #f47fff;
    box-shadow: 0 2px 7px rgba(244, 127, 255, 0.38);
}

.profile-hero-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: #5865f2;
    box-shadow: 0 2px 7px rgba(88, 101, 242, 0.38);
    line-height: 1;
    flex-shrink: 0;
    margin-left: 2px;
    order: 2;
}

.profile-badge,
.profile-hero-badge {
    position: relative;
    cursor: help;
    text-decoration: none;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.16s ease, filter 0.16s ease;
}

.profile-hero-badge {
    cursor: pointer;
}

.profile-badge:hover,
.profile-hero-badge:hover {
    transform: translateY(-2px) scale(1.08);
    filter: brightness(1.12);
}

.profile-badge::after,
.profile-hero-badge::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 10;
    padding: 6px 9px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 5px;
    background: #18191c;
    color: #f2f3f5;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, 4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.profile-badge:hover::after,
.profile-hero-badge:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
}

.profile-hero-stats {
    display: flex;
    gap: 40px;
    padding: 18px 24px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
    align-items: flex-start;
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-size: 2.1rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.hero-stat-streak {
    color: #ff7a45;
}

.hero-stat-streak.is-inactive {
    color: #777;
}

.hero-stat-streak.is-active {
    color: #ff7a45;
}

.current-streak-icon {
    filter: grayscale(1);
    opacity: 0.55;
}

.current-streak-icon.is-active {
    filter: none;
    opacity: 1;
}

.hero-stat-best {
    color: #ffd700;
}

.hero-stat-label {
    font-size: 0.85rem;
    color: #aaa;
    margin-top: 6px;
}

.hero-stat-sub {
    font-size: 0.78rem;
    color: #777;
    margin-top: 3px;
    min-height: 1em;
}

.discord-card-hint {
    color: #ccc;
    font-size: 0.95rem;
}

.discord-card-hint code {
    background: rgba(255, 255, 255, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
}

.link-discord-btn {
    padding: 10px 20px;
    background-color: #5865f2;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.link-discord-btn:hover {
    background-color: #4752c4;
}

.link-discord-btn:disabled {
    opacity: 0.7;
    cursor: default;
}

/* Secondary stat chips */
.profile-panel-grid {
    display: grid;
    grid-template-columns: 140px repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.stat-chip {
    background: rgba(8, 6, 7, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.favorite-killer-image {
    width: 116px;
    height: 116px;
    margin: 2px auto;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.favorite-killer-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
}

.stat-chip-value {
    font-size: 1.6rem;
    font-weight: bold;
    color: #fff;
}

.stat-chip-value-text {
    font-size: 1rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.stat-chip-label {
    font-size: 0.8rem;
    color: #aaa;
    margin-top: 4px;
}

/* Mode breakdown */
.mode-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
}

.mode-card {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
}

.mode-card-icon {
    font-size: 1.7rem;
}

.mode-card-name {
    font-weight: bold;
    margin: 4px 0 10px;
}

.mode-card-stats {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

.mode-card-stat {
    flex: 1;
}

.mode-card-stat-value {
    font-weight: bold;
    font-size: 1.05rem;
    color: #fff;
}

.mode-card-stat-label {
    font-size: 0.7rem;
    color: #999;
    margin-top: 2px;
}

/* History list */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.history-day-button {
    width: 100%;
    cursor: pointer;
    text-align: left;
}

.history-day-button:hover,
.history-day-button:focus-visible {
    background: rgba(255, 255, 255, 0.09);
    transform: translateY(-2px);
    outline: none;
}

.history-status-badge {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
}

.history-status-badge.is-complete {
    background: linear-gradient(135deg, #2f9e44, #1c6e2b);
}

.history-status-badge.is-partial {
    background: linear-gradient(135deg, #f59f00, #b3730a);
}

.history-status-badge.is-missed {
    background: rgba(215, 25, 32, 0.55);
}

.history-status-badge.is-pending {
    background: rgba(255, 255, 255, 0.14);
    color: #ccc;
}

.history-card-info {
    flex: 1;
    min-width: 0;
}

.history-card-title {
    font-weight: bold;
}

.history-card-date {
    color: #999;
    font-size: 0.8rem;
    margin-top: 1px;
}

.history-card-figures {
    text-align: right;
    flex-shrink: 0;
}

.history-card-modes {
    font-size: 0.85rem;
    font-weight: bold;
}

.history-card-attempts {
    color: #999;
    font-size: 0.78rem;
    margin-top: 1px;
}

.profile-empty {
    color: #999;
    font-style: italic;
}

/* Calendar */
.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.9rem;
}

.calendar-title {
    margin-bottom: 0;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-nav-btn {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
}

.calendar-nav-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.calendar-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.calendar-nav-btn svg {
    width: 16px;
    height: 16px;
}

.calendar-month-label {
    font-weight: bold;
    min-width: 130px;
    text-align: center;
    font-size: 0.9rem;
}

.calendar-weekdays,
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    max-width: 224px;
    margin-left: auto;
    margin-right: auto;
}

.calendar-weekdays {
    margin-bottom: 4px;
}

.calendar-weekdays span {
    text-align: center;
    font-size: 0.62rem;
    color: #888;
}

.calendar-day {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.04);
    color: #777;
    border: 0;
    padding: 0;
}

.calendar-day.is-clickable { cursor: pointer; }

.calendar-details-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
    animation: calendar-modal-in 0.18s ease-out;
}

.calendar-details-modal.is-closing {
    animation: calendar-modal-out 0.18s ease-in forwards;
}

@keyframes calendar-modal-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes calendar-modal-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

.calendar-details-dialog {
    position: relative;
    width: min(600px, 100%);
    max-height: min(720px, 90vh);
    overflow: auto;
    padding: 30px;
    background: rgba(8, 6, 7, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65);
}

.calendar-details-dialog .profile-section-title {
    margin: 0 44px 20px 0;
    font-size: 1.35rem;
    color: #ffa500;
}

.calendar-details-close {
    position: absolute;
    top: 16px;
    right: 18px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.calendar-details-close:hover { background: rgba(255, 255, 255, 0.16); }

.calendar-game-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    padding: 15px 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 11px;
    background: rgba(255, 255, 255, 0.055);
    color: #fff;
    text-align: left;
    cursor: pointer;
    transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.calendar-game-btn:hover,
.calendar-game-btn.is-selected {
    background: rgba(255, 165, 0, 0.12);
    border-color: rgba(255, 165, 0, 0.45);
    transform: translateX(3px);
}

.calendar-game-btn strong { color: #ffc266; font-weight: 600; }

.calendar-attempt {
    display: flex;
    align-items: center;
    gap: 10px;
}

.calendar-attempt img {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

.calendar-attempt span {
    font-size: 1.1rem;
}

.calendar-attempt.is-correct {
    color: #86efac;
    font-weight: 700;
}

.calendar-attempt.is-correct img {
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.55), 0 4px 14px rgba(0, 0, 0, 0.35);
}

.calendar-attempts-panel {
    margin-top: 22px;
    padding: 18px 0 0;
}

.calendar-attempts-panel h3 { margin: 0 0 12px; color: #ffa500; font-size: 1.1rem; }
.calendar-attempts-panel ol { margin: 0; padding-left: 28px; color: #eee; font-size: 1rem; line-height: 1.9; }

.calendar-day.is-empty {
    background: transparent;
}

.calendar-day.is-complete {
    background: linear-gradient(135deg, #2f9e44, #1c6e2b);
    color: #fff;
}

.calendar-day.is-partial {
    background: linear-gradient(135deg, #f59f00, #b3730a);
    color: #241800;
}

.calendar-day.is-missed {
    background: rgba(215, 25, 32, 0.25);
    color: #ff9494;
}

.calendar-day.is-unavailable {
    background: rgba(255, 255, 255, 0.03);
    color: #777;
    font-size: 0.8rem;
}

.calendar-day.is-today {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

.calendar-day.is-future {
    background: rgba(255, 255, 255, 0.03);
    color: #555;
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    font-size: 0.7rem;
    color: #aaa;
    align-items: center;
}

.calendar-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 5px;
    vertical-align: middle;
}

.calendar-dot-complete {
    background: linear-gradient(135deg, #2f9e44, #1c6e2b);
}

.calendar-dot-partial {
    background: linear-gradient(135deg, #f59f00, #b3730a);
}

.calendar-dot-missed {
    background: rgba(215, 25, 32, 0.5);
}

.calendar-dot-unavailable {
    background: rgba(255, 255, 255, 0.2);
}

.calendar-dot-future {
    background: rgba(255, 255, 255, 0.15);
}

@media (max-width: 600px) {
    .calendar-details-modal {
        padding: 14px;
    }

    .calendar-details-dialog {
        padding: 22px 18px;
        border-radius: 14px;
    }

    .profile-avatar-img {
        width: 96px;
        height: 96px;
    }

    .profile-hero-main {
        margin-top: -40px;
    }

    .profile-hero-stats {
        gap: 24px;
    }

    .profile-panel-grid {
        grid-template-columns: 140px minmax(0, 1fr);
    }

    .discord-bot-panel {
        gap: 0.5rem;
    }

    .discord-bot-copy strong {
        font-size: 0.9rem;
    }
}
