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

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    background-color: #000;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #fff;
    overflow-x: hidden;
    padding: 24px 4vw 40px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, video {
    will-change: contents;
    backface-visibility: hidden;
}

/* =========================================
   RIP / MEMORIAL SECTION
   ========================================= */

.rip-section {
    max-width: 900px;
    margin: 0 auto 40px auto;
    text-align: center;
}

.rip-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rip-image-wrapper {
    width: 220px;
    height: 280px;
    border-radius: 12px;
    overflow: hidden;
    margin: 0 auto 20px auto;
    /* Elegant memorial frame/border with double glow */
    border: 3px solid rgba(255, 255, 255, 0.85);
    outline: 1px solid rgba(255, 255, 255, 0.2);
    outline-offset: 4px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 255, 255, 0.08);
    background: #000;
    cursor: zoom-in;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.rip-image-wrapper:hover {
    transform: scale(1.02);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.9), 0 0 25px rgba(255, 255, 255, 0.15);
}

.rip-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.rip-title {
    font-size: 1.8rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.rip-subtitle {
    font-size: 0.95rem;
    color: #888;
    line-height: 1.5;
    margin-bottom: 14px;
    max-width: 480px;
}

.rip-condolence-link {
    display: inline-block;
    color: #38bdf8;
    font-size: 0.9rem;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
    transition: color 0.2s;
}

.rip-condolence-link:hover {
    color: #7dd3fc;
}

/* =========================================
   CONDOLENCES HORIZONTAL SCROLL TICKER
   ========================================= */

.condolences-ticker {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    margin-top: 28px;
    padding: 14px 0;
    border-top: 1px solid #1a1a1a;
    border-bottom: 1px solid #1a1a1a;
    background: #050505;
    overflow: hidden;
    display: flex;
    user-select: none;
}

.ticker-track {
    display: flex;
    align-items: center;
    white-space: nowrap;
    animation: marquee 35s linear infinite;
    will-change: transform;
}

.condolences-ticker:hover .ticker-track {
    animation-play-state: paused;
}

.ticker-item {
    font-size: 0.88rem;
    color: #999;
    padding: 0 12px;
}

.ticker-item strong {
    color: #e2e8f0;
    font-weight: 500;
}

.ticker-item.empty {
    color: #555;
    font-style: italic;
}

.ticker-bullet {
    color: #38bdf8;
    font-size: 0.7rem;
    opacity: 0.6;
    margin: 0 4px;
}

.ticker-loading {
    color: #555;
    font-size: 0.85rem;
    padding: 0 20px;
}

.ticker-del-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 11px;
    line-height: 16px;
    cursor: pointer;
    margin-left: 6px;
    vertical-align: middle;
}

@keyframes marquee {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* =========================================
   GALLERY / MASONRY
   ========================================= */

.gallery-container {
    max-width: 1600px;
    margin: 0 auto;
}

.masonry {
    column-count: 4;
    column-gap: 12px;
}

@media (max-width: 1200px) {
    .masonry { column-count: 3; }
}

@media (max-width: 800px) {
    .masonry { column-count: 2; column-gap: 10px; }
}

@media (max-width: 500px) {
    .masonry { column-count: 2; column-gap: 8px; }
}

@media (max-width: 350px) {
    .masonry { column-count: 1; }
}

.item {
    display: inline-block;
    width: 100%;
    margin-bottom: 12px;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.3s ease;
    background: #111;
}

.item:hover { transform: scale(1.02); }
.item:active { transform: scale(0.98); }

.item img, .item video {
    width: 100%;
    display: block;
    height: auto;
}

/* =========================================
   MODAL / LIGHTBOX
   ========================================= */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.98);
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    padding: 10px;
}

.modal-content {
    max-width: 95%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 1001;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
}

@media (max-width: 600px) {
    .close { top: 10px; right: 10px; font-size: 24px; }
}

.modal-wrapper {
    position: relative;
    display: inline-block;
    max-width: 95%;
    max-height: 95%;
}

.comment-box {
    position: absolute;
    border: 2px solid #38bdf8;
    background: rgba(56, 189, 248, 0.2);
    box-sizing: border-box;
    cursor: pointer;
    transition: background 0.2s;
}

.comment-box:hover { background: rgba(56, 189, 248, 0.4); }

.comment-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
    margin-bottom: 5px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.comment-box:hover .comment-tooltip { opacity: 1; }

.comment-tooltip strong {
    display: block;
    margin-bottom: 2px;
    color: #38bdf8;
}

.selection-box {
    position: absolute;
    border: 2px dashed #fff;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
}

/* =========================================
   DIALOGS
   ========================================= */

#comment-dialog, #admin-dialog, #condolence-dialog, #contact-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #111827;
    border: 1px solid #1f2937;
    padding: 20px;
    border-radius: 8px;
    z-index: 1005;
    display: none;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    width: calc(100% - 40px);
    max-width: 320px;
    max-height: 90vh;
    overflow-y: auto;
}

#condolence-dialog p {
    font-size: 0.85rem;
    color: #94a3b8;
}

#comment-dialog input, #comment-dialog textarea,
#admin-dialog input, #condolence-dialog input,
#condolence-dialog textarea, #contact-dialog input,
#contact-dialog textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #374151;
    background: #030712;
    color: white;
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
}

#comment-dialog textarea, #contact-dialog textarea, #condolence-dialog textarea {
    resize: vertical;
    min-height: 80px;
}

.dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 4px;
}

.dialog-buttons button {
    padding: 8px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    font-family: 'Montserrat', sans-serif;
    touch-action: manipulation;
}

.btn-cancel { background: #1f2937; color: #9ca3af; }
.btn-save { background: #38bdf8; color: #030712; font-weight: 600; }
.btn-login { background: #22c55e; color: white; }

.admin-delete-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 24px;
    display: none;
    z-index: 1004;
    touch-action: manipulation;
}

.comment-box:hover .admin-delete-btn,
.comment-box:active .admin-delete-btn { display: block; }

@media (max-width: 600px) {
    .admin-delete-btn { width: 28px; height: 28px; font-size: 16px; line-height: 28px; }
}

/* =========================================
   FOOTER & ATTRIBUTION
   ========================================= */

.attribution {
    text-align: center;
    padding: 36px 0 20px;
    font-size: 0.85em;
    color: #666;
    letter-spacing: 0.5px;
}

.action-links {
    margin-top: 12px;
    font-size: 0.9em;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.action-links a {
    color: #38bdf8;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.action-links a:active { background: rgba(56, 189, 248, 0.2); }
.action-links .separator { color: #555; }

/* =========================================
   ADMIN PANEL
   ========================================= */

.pending-panel {
    position: fixed;
    top: auto;
    bottom: 20px;
    right: 20px;
    left: auto;
    width: 340px;
    max-height: 60vh;
    background: #111827;
    border: 1px solid #1f2937;
    padding: 14px;
    border-radius: 6px;
    z-index: 1006;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.pending-panel.collapsed {
    width: 140px;
    max-height: 44px;
    overflow: hidden;
}

.pending-panel.collapsed #panel-content,
.pending-panel.collapsed > button {
    display: none;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.panel-header h3 {
    color: #fff;
    font-size: 0.95em;
    margin: 0;
}

.panel-tabs {
    display: flex;
    gap: 5px;
    flex: 1;
}

.panel-tab {
    background: #1f2937;
    border: none;
    color: #9ca3af;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    font-family: inherit;
    font-weight: 500;
}

.panel-tab.active {
    background: #38bdf8;
    color: #030712;
}

.panel-tab span {
    background: #ef4444;
    color: white;
    padding: 1px 5px;
    border-radius: 8px;
    font-size: 0.7em;
    margin-left: 4px;
}

.panel-collapse {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 1.1em;
    padding: 4px;
    transition: transform 0.3s;
}

.pending-panel.collapsed .panel-collapse {
    transform: rotate(-90deg);
}

#panel-content { flex: 1; overflow-y: auto; }
#messages-list { flex: 1; }

.pending-actions { display: flex; gap: 8px; margin-top: 8px; }

.pending-actions button {
    flex: 1;
    padding: 6px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    font-size: 0.8em;
}

.message-item {
    background: #030712;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #1f2937;
}

.message-item strong { color: #38bdf8; font-size: 0.85em; }
.message-item small { color: #64748b; display: block; margin-top: 3px; font-size: 0.75em; }
.message-item p { color: #cbd5e1; margin-top: 6px; font-size: 0.85em; line-height: 1.4; }

.pending-panel > button:last-child { flex-shrink: 0; margin-top: 10px; }

@media (max-width: 600px) {
    .rip-title { font-size: 1.5rem; }
    .rip-image-wrapper { width: 190px; height: 240px; }
    .attribution { padding: 20px 0; }
    .action-links { font-size: 0.75em; gap: 6px; }
    .action-links a { padding: 4px 6px; }
    .action-links .separator { display: none; }
}

@media (max-width: 500px) {
    .pending-panel {
        width: calc(100% - 20px);
        right: 10px;
        left: 10px;
        bottom: 10px;
        max-height: 70vh;
    }
}
