html {
    overflow-y: scroll;
}

:root {
    --theme-font-family: 'Roboto', 'Segoe UI', Arial, sans-serif;
    --theme-heading-font-family: 'Playfair Display', serif;
    --theme-body-bg: #fff;
    --theme-text: #232733;
    --theme-container-bg: #44474e;
    --theme-container-shadow: rgba(0,0,0,0.10);
    --theme-header-bg-start: #232733;
    --theme-header-bg-end: #2a2d37;
    --theme-header-text: #ffffff;
    --theme-muted-text: #a0aec0;
    --theme-body-text-secondary: #cbd5e0;
    --theme-heading-color: #176a2a;
    --theme-cell-bg: #000;
    --theme-cell-border: #222;
    --theme-cell-text: #fff;
    --theme-cell-icon-bg: #e8f5e9;
    --theme-cell-icon-color: #ffffff;
    --theme-cell-icon-hover: #00bfff;
    --theme-button-grad-start: #63b3ed;
    --theme-button-grad-end: #4da6d6;
    --theme-button-grad-hover-start: #4da6d6;
    --theme-button-grad-hover-end: #3d96c0;
    --theme-button-shadow: rgba(99, 179, 237, 0.3);
    --theme-overlay-bg: rgba(10, 12, 16, 0.92);
    --theme-overlay-close-bg: #ff4d4f;
    --theme-modal-bg: #232733;
    --theme-modal-text: #e0e6ed;
    --theme-modal-border: #4a5568;
    --theme-modal-panel-bg: #1a202c;
    --theme-modal-panel-border: #4a5568;
    --theme-modal-placeholder: #2d3748;
    --theme-modal-button-bg: #4a5568;
    --theme-modal-button-hover: #63b3ed;
    --theme-accent: #4CAF50;
    --theme-accent-hover: #45a049;
    --theme-accent-text: #ffffff;
    --theme-footer-bg: #2d3139;
    --theme-footer-text: #a0aec0;
    --theme-surname-size: 16px;
    --theme-forename-size: 14px;
}

body {
    font-family: var(--theme-font-family);
    background: var(--theme-body-bg);
    margin: 0;
    padding: 0;
    color: var(--theme-text);
    min-height: 100vh;
    overflow-y: scroll;
}

/* Hide scrollbars when page is inside iframe */
body.in-iframe {
    overflow: hidden !important;
}

html.in-iframe {
    overflow: hidden !important;
}

html.overlay-open,
body.overlay-open {
    overflow: hidden !important;
}

.page-overlay {
    position: fixed;
    inset: 0;
    background: var(--theme-overlay-bg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-in-out;
    z-index: 2000;
    overflow: hidden;
    will-change: opacity;
    transform: translateZ(0);
    visibility: hidden;
}

.page-overlay.active {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.page-overlay iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: var(--theme-body-bg);
    display: block;
    overflow: hidden;
}

.page-overlay iframe::-webkit-scrollbar {
    display: none;
}

.overlay-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--theme-overlay-close-bg);
    color: var(--theme-accent-text);
    font-size: 22px;
    line-height: 36px;
    cursor: pointer;
    z-index: 2001;
    opacity: 0;
    pointer-events: none;
}

.cell .names {
    text-align: center;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    margin-bottom: 2px;
}

.cell .name-line {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.cell .surname {
    font-weight: 700;
    color: var(--theme-cell-text);
    font-size: var(--theme-surname-size);
    word-break: break-word;
}

.cell .forename,
.cell .middlename {
    color: var(--theme-cell-text);
    font-size: var(--theme-forename-size);
    word-break: break-word;
}

/* Detail popup theming overrides */
.detail-content {
    color: var(--theme-modal-text) !important;
}
.cell-number-badge {
    background: var(--theme-button-grad-start) !important;
    color: var(--theme-accent-text) !important;
}
.detail-header h2 {
    color: var(--theme-modal-text) !important;
    border-bottom: 2px solid var(--theme-modal-border) !important;
}
.detail-section h3,
.detail-links h3 {
    color: var(--theme-muted-text) !important;
}
.detail-content {
    padding: 12px !important;
    padding-top: 35px !important;
}
.detail-header h2 {
    margin: 0 0 12px 0 !important;
    padding-bottom: 6px !important;
    font-size: 18px !important;
}
.detail-section {
    margin-bottom: 12px !important;
    gap: 8px !important;
}
.detail-field {
    background: rgba(255,255,255,0.05) !important;
    padding: 6px !important;
    margin-bottom: 0 !important;
}
.detail-field label {
    color: var(--theme-body-text-secondary) !important;
    text-align: left !important;
    font-size: 12px !important;
    margin-bottom: 2px !important;
}
.detail-field span {
    color: var(--theme-modal-text) !important;
    text-align: center !important;
    font-size: 13px !important;
}
.detail-links {
    border-top: 2px solid var(--theme-modal-border) !important;
    margin-top: 12px !important;
    padding-top: 12px !important;
}
.detail-links h3 {
    margin: 0 0 10px 0 !important;
    font-size: 14px !important;
}
.link-icons {
    gap: 12px !important;
}
.detail-icon {
    background: rgba(255,255,255,0.1) !important;
}
.detail-icon:hover {
    background: rgba(255,255,255,0.2) !important;
}
.detail-icon[data-title] {
    position: relative;
}
.detail-icon[data-title]:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 50%;
    top: 110%;
    transform: translateX(-50%);
    background: rgba(100, 100, 100, 0.15) !important;
    color: #ffffff !important;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px !important;
    font-family: Roboto, sans-serif !important;
    font-weight: 400 !important;
    letter-spacing: 0 !important;
    line-height: 1 !important;
    white-space: nowrap;
    z-index: 10000;
    text-decoration: none !important;
}

/* Cell highlight animation for transition targets */
@keyframes haloEffect {
    0%, 20% {
        box-shadow: 0 0 30px 15px rgba(76, 175, 80, 0.9);
    }
    50% {
        box-shadow: 0 0 40px 20px rgba(76, 175, 80, 0.7);
    }
    80% {
        box-shadow: 0 0 30px 15px rgba(76, 175, 80, 0.5);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.cell.highlight-target {
    animation: haloEffect 5s ease-in-out;
    position: relative;
    z-index: 100;
}
