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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: radial-gradient(circle at 50% 0%, #2A0E38 0%, #150824 50%, #0A0412 100%);
    min-height: 100vh;
    color: #FFF1F2;
    padding-top: 80px;
    overflow-x: hidden;
}

/* Header */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(15, 7, 25, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(244, 63, 94, 0.2);
    padding: 16px 32px;
    z-index: 1000;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.logo {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #FF6097 0%, #FF2A85 50%, #FDA4AF 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    flex-shrink: 0;
    text-shadow: 0 0 25px rgba(255, 42, 133, 0.5);
}

.nav-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.user-email {
    color: #FBCFE8;
    font-size: 14px;
    font-weight: 500;
    margin-right: 6px;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(244, 63, 94, 0.12);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(244, 63, 94, 0.25);
}

/* Redesigned Buttons */
.btn-secondary {
    position: relative;
    padding: 9px 20px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 114, 182, 0.35);
    color: #FFE4E6;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    backdrop-filter: blur(8px);
}

.btn-secondary:hover {
    background: rgba(244, 63, 94, 0.22);
    border-color: #F43F5E;
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.35);
}

.btn-secondary:active {
    transform: translateY(0);
}

.btn-primary {
    position: relative;
    padding: 9px 22px;
    background: linear-gradient(135deg, #FF2A85 0%, #F43F5E 50%, #FB7185 100%);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #FFFFFF;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    box-shadow: 0 4px 18px rgba(244, 63, 94, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    overflow: hidden;
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 24px rgba(255, 42, 133, 0.65), 0 0 30px rgba(244, 63, 94, 0.4);
}

.btn-primary:active {
    transform: translateY(1px) scale(0.98);
}

/* Container */
.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

h1 {
    text-align: center;
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #FFA3C6 0%, #FF2A85 50%, #F43F5E 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 36px;
    filter: drop-shadow(0 0 30px rgba(255, 42, 133, 0.4));
}

/* Big Generate Button */
.generate-control {
    display: flex;
    justify-content: center;
    margin: 0 auto 28px;
}

.generate-btn {
    position: relative;
    padding: 16px 44px;
    background: linear-gradient(135deg, #FF1475 0%, #FF2A85 45%, #F43F5E 100%);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #FFFFFF;
    border-radius: 16px;
    cursor: pointer;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 6px 28px rgba(255, 20, 117, 0.55), 0 0 20px rgba(244, 63, 94, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 36px rgba(255, 20, 117, 0.75), 0 0 45px rgba(255, 42, 133, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

.generate-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    filter: grayscale(0.4);
}

/* Roll Display Slots */
.roll-display {
    min-height: 96px;
    margin: 0 auto 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22, 10, 36, 0.65);
    border: 1.5px solid rgba(244, 114, 182, 0.3);
    border-radius: 20px;
    max-width: 460px;
    width: 100%;
    padding: 14px 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), inset 0 0 20px rgba(244, 63, 94, 0.08);
    box-sizing: border-box;
    backdrop-filter: blur(12px);
}

.roll-container {
    display: flex;
    gap: 9px;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
}

.digit-slot {
    width: 50px;
    height: 72px;
    background: linear-gradient(180deg, #1C0A28 0%, #2A103A 100%);
    border: 2px solid rgba(244, 114, 182, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 38px;
    font-weight: 800;
    color: #FFF1F2;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);
    position: relative;
    user-select: none;
    transition: all 0.25s ease;
}

.digit-slot.placeholder {
    color: rgba(244, 114, 182, 0.25);
    border-color: rgba(244, 114, 182, 0.12);
    background: rgba(25, 11, 38, 0.6);
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.5);
}

.digit-slot.spinning {
    color: #FF54A5;
    border-color: #FF2A85;
    box-shadow: 0 0 22px rgba(255, 42, 133, 0.8), inset 0 0 12px rgba(255, 42, 133, 0.4);
    transform: scale(1.08);
    background: #250A33;
}

.digit-slot.locked {
    color: #FF75B0;
    border-color: #F43F5E;
    text-shadow: 0 0 18px rgba(255, 117, 176, 0.9);
    background: linear-gradient(180deg, #2D0D39 0%, #40124D 100%);
    box-shadow: 0 0 16px rgba(244, 63, 94, 0.45);
    animation: digitDrop 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes digitDrop {
    0% {
        transform: translateY(-16px) scale(1.25);
        filter: brightness(2.2);
    }
    70% {
        transform: translateY(3px) scale(0.96);
    }
    100% {
        transform: translateY(0) scale(1);
        filter: brightness(1);
    }
}

.countdown {
    margin: 0 auto 24px;
    color: #FBCFE8;
    text-align: center;
    font: 600 18px/1.4 'Courier New', monospace;
    text-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}

/* Card */
.card {
    background: rgba(24, 10, 38, 0.72);
    border: 1.5px solid rgba(244, 114, 182, 0.22);
    border-radius: 20px;
    padding: 32px;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), inset 0 0 30px rgba(244, 63, 94, 0.05);
}

.card.visible {
    opacity: 1;
    transform: translateY(0);
}

.cover-wrapper {
    text-align: center;
    margin-bottom: 24px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.spoiler-cover {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 12px;
    background: #12051C;
    max-width: min(350px, 100%);
    width: 100%;
    margin: 0 auto;
    border: 1px solid rgba(244, 114, 182, 0.25);
    box-shadow: 0 10px 35px rgba(0, 0, 0, 0.6);
}

.cover {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    object-fit: contain;
}

.spoiler-cover .cover {
    filter: blur(24px);
    transform: scale(1.08);
    transition: filter .35s ease, transform .35s ease;
}

.spoiler-cover.revealed .cover {
    filter: none;
    transform: scale(1);
}

.reveal-cover {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(18, 5, 28, 0.65);
    color: #FFE4E6;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(255, 42, 133, 0.8);
    width: 100%;
    height: 100%;
    transition: all 0.2s;
}

.reveal-cover:hover {
    background: rgba(18, 5, 28, 0.45);
    color: #FFFFFF;
}

.spoiler-cover.revealed .reveal-cover {
    display: none;
}

.title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 18px;
    line-height: 1.4;
    color: #FFF1F2;
    overflow-wrap: break-word;
    word-break: break-word;
}

.metadata {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: rgba(13, 5, 22, 0.55);
    border: 1px solid rgba(244, 114, 182, 0.15);
    border-radius: 12px;
}

.meta-item {
    color: #FBCFE8;
    font-size: 14px;
}

.meta-item strong {
    color: #FDA4AF;
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.meta-value {
    display: inline-block;
    min-width: 60px;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: #FFFFFF;
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.tag {
    padding: 6px 14px;
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 114, 182, 0.3);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #F472B6;
    transition: all 0.2s;
}

.tag:hover {
    background: rgba(244, 63, 94, 0.22);
    border-color: #EC4899;
    color: #FFE4E6;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.view-btn {
    padding: 14px 36px;
    background: rgba(244, 63, 94, 0.12);
    border: 1.5px solid rgba(244, 114, 182, 0.45);
    color: #FF70B8;
    border-radius: 14px;
    text-decoration: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-block;
    box-shadow: 0 4px 16px rgba(244, 63, 94, 0.25);
}

.view-btn:hover {
    background: linear-gradient(135deg, #FF2A85 0%, #F43F5E 100%);
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 42, 133, 0.55);
    border-color: transparent;
}

.share-btn {
    padding: 14px 30px;
    background: rgba(255, 42, 133, 0.15);
    border: 1.5px solid rgba(255, 42, 133, 0.45);
    color: #FFF1F2;
    border-radius: 14px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(255, 42, 133, 0.25);
    font-family: inherit;
}

.share-btn:hover {
    background: linear-gradient(135deg, #FF1475 0%, #FF2A85 100%);
    color: #FFFFFF;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 42, 133, 0.55);
    border-color: transparent;
}

.share-btn:active {
    transform: translateY(1px);
}

.share-btn.copied {
    background: rgba(34, 197, 94, 0.25) !important;
    border-color: #22C55E !important;
    color: #4ADE80 !important;
    box-shadow: 0 0 18px rgba(34, 197, 94, 0.4) !important;
}

/* Loading & Spinner */
.loading {
    text-align: center;
    padding: 48px;
    display: none;
}

.loading.visible {
    display: block;
}

.spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 16px;
    border: 4px solid rgba(244, 114, 182, 0.2);
    border-top-color: #FF2A85;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 16px rgba(255, 42, 133, 0.4);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error */
.error {
    background: rgba(225, 29, 72, 0.15);
    border: 1px solid rgba(225, 29, 72, 0.4);
    color: #FECDD3;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    margin: 24px auto;
    max-width: 600px;
    display: none;
}

.error.visible {
    display: block;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 4, 16, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: rgba(25, 11, 40, 0.96);
    border: 1.5px solid rgba(244, 114, 182, 0.3);
    border-radius: 20px;
    padding: 32px;
    max-width: 420px;
    width: 100%;
    position: relative;
    box-sizing: border-box;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(244, 63, 94, 0.2);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: #F472B6;
    font-size: 26px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #FFF1F2;
    transform: scale(1.1);
}

.modal h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 22px;
    color: #FFF1F2;
    background: linear-gradient(135deg, #FFA3C6, #FF2A85);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #FBCFE8;
    font-size: 14px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 13px 16px;
    background: rgba(14, 5, 24, 0.65);
    border: 1.5px solid rgba(244, 114, 182, 0.25);
    border-radius: 12px;
    color: #FFF1F2;
    font-size: 14px;
    transition: all 0.2s;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: #FF2A85;
    box-shadow: 0 0 16px rgba(255, 42, 133, 0.4);
    background: rgba(14, 5, 24, 0.9);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.form-actions button {
    flex: 1;
}

.switch-mode {
    text-align: center;
    margin-top: 18px;
    color: #F472B6;
    font-size: 14px;
}

.switch-mode button {
    background: none;
    border: none;
    color: #FDA4AF;
    cursor: pointer;
    text-decoration: underline;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
}

.switch-mode button:hover {
    color: #FFFFFF;
}

/* History Modal & Grid */
.history-modal-content {
    max-width: 820px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    overflow-y: auto;
    max-height: calc(85vh - 120px);
    margin-top: 18px;
    padding-right: 6px;
}

.history-card {
    background: rgba(20, 8, 32, 0.75);
    border: 1.5px solid rgba(244, 114, 182, 0.2);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}

.history-card:hover {
    transform: translateY(-4px);
    border-color: #FF2A85;
    box-shadow: 0 8px 24px rgba(255, 42, 133, 0.35);
}

.history-cover {
    width: 100%;
    height: 240px;
    object-fit: cover;
    background: #100418;
    display: block;
}

.history-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.history-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: #FFF1F2;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.history-meta {
    font-size: 11px;
    color: #F472B6;
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-meta a {
    color: #FDA4AF;
    text-decoration: none;
    font-weight: 700;
}

.history-meta a:hover {
    color: #FFFFFF;
    text-decoration: underline;
}

.history-empty {
    text-align: center;
    color: #F472B6;
    padding: 48px 16px;
    font-size: 15px;
}

/* Tablet & Mobile Media Queries */
@media (max-width: 768px) {
    body {
        padding-top: 70px;
    }

    header {
        padding: 10px 16px;
    }

    .logo {
        font-size: 21px;
    }

    .container {
        padding: 24px 14px;
    }

    h1 {
        font-size: 34px;
        margin-bottom: 24px;
    }

    .card {
        padding: 20px 14px;
        border-radius: 16px;
    }

    .title {
        font-size: 18px;
    }

    .metadata {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 12px;
    }

    .meta-item {
        font-size: 13px;
    }

    .user-email {
        max-width: 120px;
        font-size: 12px;
    }

    .btn-secondary, .btn-primary {
        padding: 7px 14px;
        font-size: 13px;
    }

    .history-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .history-cover {
        height: 190px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 16px 10px;
    }

    .card {
        padding: 16px 10px;
    }

    .digit-slot {
        width: 36px;
        height: 54px;
        font-size: 26px;
        border-radius: 10px;
    }

    .roll-container {
        gap: 5px;
    }

    .roll-display {
        padding: 8px 10px;
        min-height: 80px;
        border-radius: 16px;
    }

    .generate-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }

    .actions {
        flex-direction: column;
    }

    .view-btn, .share-btn {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    .user-email {
        max-width: 90px;
        font-size: 11px;
    }

    .nav-buttons {
        gap: 6px;
    }

    .btn-secondary, .btn-primary {
        padding: 6px 10px;
        font-size: 12px;
    }
}
/* Profile Page Styles */
.profile-card {
    background: rgba(24, 10, 38, 0.72);
    border: 1.5px solid rgba(244, 114, 182, 0.22);
    border-radius: 20px;
    padding: 32px;
    max-width: 1000px;
    margin: 0 auto 36px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    gap: 28px;
    align-items: center;
    box-sizing: border-box;
}

.profile-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF1475 0%, #FF2A85 50%, #FDA4AF 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    font-weight: 800;
    color: #FFFFFF;
    flex-shrink: 0;
    box-shadow: 0 0 24px rgba(255, 42, 133, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

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

.profile-name {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #FFA3C6, #FF2A85);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.profile-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 4px 10px;
    background: rgba(244, 63, 94, 0.18);
    border: 1px solid rgba(244, 114, 182, 0.4);
    border-radius: 12px;
    color: #FDA4AF;
    -webkit-text-fill-color: initial;
}

.profile-email-masked {
    color: #FBCFE8;
    font-size: 14px;
    margin-bottom: 18px;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.profile-stat-box {
    background: rgba(13, 5, 22, 0.6);
    border: 1px solid rgba(244, 114, 182, 0.15);
    border-radius: 12px;
    padding: 12px 16px;
}

.profile-stat-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #FDA4AF;
    margin-bottom: 4px;
}

.profile-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: #FFFFFF;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #FFF1F2;
}

@media (max-width: 768px) {
    .profile-card {
        flex-direction: column;
        text-align: center;
        padding: 24px 16px;
        gap: 18px;
    }

    .profile-name {
        justify-content: center;
        font-size: 22px;
    }

    .profile-avatar {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
}