@font-face {
    font-family: "Architects Daughter";
    src: url("../media/ArchitectsDaughter.ttf") format("truetype");
    font-display: swap;
}

:root {
    --ink-900: #2d1d10;
    --ink-700: #4d3520;
    --ink-500: #7a5b34;
    --gold-500: #a97b2d;
    --gold-300: #d7b36d;
    --paper-100: #f4ead2;
    --paper-200: #ecddb6;
    --paper-300: #ddc38e;
    --shadow: rgba(52, 33, 12, 0.28);
    --surface: rgba(255, 248, 231, 0.9);
    --surface-strong: rgba(255, 248, 231, 0.95);
    --nav-height: 86px;
    --content-width: min(1120px, calc(100vw - 32px));
    color-scheme: light;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Georgia, "Times New Roman", serif;
    color: var(--ink-900);
    background:
        linear-gradient(180deg, rgba(115, 74, 30, 0.12), rgba(45, 29, 16, 0.22)),
        url("../media/SfondoDEF.JPG") center/cover fixed;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

.page-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top, rgba(255, 241, 210, 0.42), transparent 38%),
        radial-gradient(circle at bottom right, rgba(99, 62, 22, 0.24), transparent 28%);
}

.app-shell {
    width: var(--content-width);
    margin: 0 auto;
    padding: 28px 0 calc(var(--nav-height) + 36px);
}

.hero-card,
.panel {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(121, 84, 33, 0.28);
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255, 249, 237, 0.94), rgba(245, 233, 206, 0.9));
    box-shadow: 0 24px 60px var(--shadow);
    backdrop-filter: blur(10px);
}

.hero-card {
    padding: 28px;
}

.hero-card::after,
.panel::after {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(169, 123, 45, 0.22);
    border-radius: 20px;
    pointer-events: none;
}

.hero-banner {
    display: flex;
    gap: 18px;
    align-items: center;
}

.hero-banner-art {
    width: min(100%, 340px);
    max-width: 40%;
    object-fit: contain;
}

.eyebrow,
.panel-kicker,
.save-status {
    margin: 0;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.76rem;
    color: var(--ink-500);
}

.hero-card h1,
.panel h2 {
    margin: 0.25rem 0 0;
    font-size: clamp(2rem, 4vw, 3.2rem);
    line-height: 1;
}

.hero-copy,
.panel-copy {
    max-width: 58ch;
    font-size: 1.04rem;
    line-height: 1.6;
}

.hero-status {
    display: inline-flex;
    margin-top: 10px;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(169, 123, 45, 0.12);
    color: var(--ink-700);
}

.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.install-app-button {
    display: none;
    margin-top: 14px;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
    gap: 22px;
    margin-top: 22px;
}

.workspace-grid.is-authenticated {
    grid-template-columns: minmax(0, 1fr);
}

.panel {
    padding: 26px;
}

.panel-login {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.login-form {
    display: grid;
    gap: 12px;
}

.field-label {
    font-size: 0.9rem;
    color: var(--ink-700);
}

.field-row {
    display: grid;
    gap: 12px;
}

input[type="email"] {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid rgba(121, 84, 33, 0.25);
    border-radius: 18px;
    background: rgba(255, 252, 244, 0.9);
}

.callout {
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(91, 63, 24, 0.08);
    color: var(--ink-700);
    line-height: 1.5;
}

.primary-button,
.secondary-button,
.nav-link,
.dice-fab,
.dice-close {
    border: 0;
    border-radius: 999px;
    transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}

.primary-button,
.dice-fab {
    padding: 14px 20px;
    color: #fff6e6;
    background: linear-gradient(180deg, #83571f, #563710);
    box-shadow: 0 12px 26px rgba(84, 52, 19, 0.28);
}

.primary-button:hover,
.dice-fab:hover,
.secondary-button:hover,
.nav-link:hover,
.dice-close:hover {
    transform: translateY(-1px);
}

.primary-button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.secondary-button,
.nav-link,
.dice-close {
    padding: 12px 18px;
    color: var(--ink-900);
    background: rgba(243, 231, 200, 0.9);
    box-shadow: inset 0 0 0 1px rgba(121, 84, 33, 0.18);
}

.hidden {
    display: none;
}

[hidden] {
    display: none !important;
}

.panel-journal {
    min-height: 620px;
}

.panel-frame {
    position: absolute;
    inset: 20px;
    background: url("../media/pagina inventario.png") center top/contain no-repeat;
    opacity: 0.16;
    pointer-events: none;
}

.journal-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.journal-actions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.journal-sheet {
    position: relative;
    z-index: 1;
    min-height: 480px;
    border-radius: 26px;
    background:
        linear-gradient(180deg, rgba(255, 253, 246, 0.86), rgba(246, 232, 200, 0.9)),
        url("../media/SfondoDEF.JPG") center/cover;
    box-shadow: inset 0 0 0 1px rgba(121, 84, 33, 0.14);
    overflow: hidden;
}

#journalTextarea {
    width: 100%;
    min-height: 480px;
    padding: 32px 28px 96px;
    resize: vertical;
    border: 0;
    background: transparent;
    color: var(--ink-900);
    font-family: "Architects Daughter", "Segoe Print", cursive;
    font-size: clamp(1.08rem, 2vw, 1.35rem);
    line-height: 1.7;
}

#journalTextarea:focus {
    outline: none;
}

.journal-lock {
    position: absolute;
    inset: 0;
    display: grid;
    place-content: center;
    gap: 12px;
    padding: 24px;
    text-align: center;
    background: linear-gradient(180deg, rgba(45, 29, 16, 0.16), rgba(45, 29, 16, 0.34));
    color: #fff7e6;
}

.journal-lock strong {
    font-size: 1.3rem;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    width: min(560px, calc(100vw - 20px));
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 10px;
    border-radius: 999px;
    background: rgba(45, 29, 16, 0.92);
    box-shadow: 0 18px 36px rgba(25, 16, 6, 0.28);
    backdrop-filter: blur(14px);
    z-index: 40;
}

.bottom-nav.is-authenticated {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(420px, calc(100vw - 20px));
}

.nav-link {
    min-height: 56px;
    width: 100%;
}

.nav-link.is-active {
    color: #fff6e6;
    background: linear-gradient(180deg, rgba(179, 131, 48, 0.95), rgba(120, 83, 26, 0.95));
}

.nav-link-dice {
    color: #fff6e6;
    background: linear-gradient(180deg, #8f6326, #603d12);
}

.dice-fab {
    position: fixed;
    right: 22px;
    bottom: calc(var(--nav-height) + 28px);
    z-index: 35;
}

.dice-modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: 18px;
    overflow-y: auto;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.dice-modal.is-open {
    opacity: 1;
    pointer-events: auto;
}

.dice-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 19, 10, 0.74);
    backdrop-filter: blur(6px);
}

.dice-panel {
    position: relative;
    width: min(780px, 100%);
    max-height: calc(100vh - 36px);
    padding: 28px;
    overflow-y: auto;
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(255, 248, 235, 0.98), rgba(240, 227, 193, 0.96)),
        url("../media/dado.png") right 18px top 16px/150px auto no-repeat;
    box-shadow: 0 30px 70px rgba(22, 14, 5, 0.42);
}

.dice-close {
    position: absolute;
    right: 18px;
    top: 18px;
}

.dice-tabs {
    display: inline-flex;
    gap: 10px;
    margin-bottom: 20px;
    margin-right: 112px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(111, 70, 21, 0.08);
}

.dice-tab,
.dice-count-button {
    border: 0;
    border-radius: 999px;
    background: rgba(255, 249, 237, 0.9);
    color: var(--ink-900);
    box-shadow: inset 0 0 0 1px rgba(121, 84, 33, 0.18);
    transition: transform 180ms ease, background-color 180ms ease, color 180ms ease;
}

.dice-tab {
    padding: 11px 16px;
}

.dice-tab.is-active,
.dice-count-button.is-active {
    color: #fff6e6;
    background: linear-gradient(180deg, #8f6326, #603d12);
}

.dice-view[hidden] {
    display: none !important;
}

.dice-count-selector {
    display: flex;
    flex-wrap: nowrap;
    gap: 10px;
    margin: 16px 0 10px;
}

.dice-count-button {
    padding: 10px 16px;
}

.dice-results {
    display: flex;
    flex-wrap: nowrap;
    gap: 18px;
    margin: 24px 0;
    padding-bottom: 6px;
}

.dice-results-3 {
    display: flex;
}

.dice-results-4 {
    display: flex;
}

.dice-card {
    display: grid;
    flex: 1 1 0;
    min-width: 0;
    justify-items: center;
    gap: 12px;
    padding: 24px;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255, 253, 246, 0.98), rgba(242, 231, 204, 0.92));
    box-shadow: inset 0 0 0 1px rgba(121, 84, 33, 0.14);
    text-align: center;
}

.dice-card.is-rolling {
    animation: tumble 560ms ease;
}

.dice-face-image {
    width: min(100%, 220px);
    aspect-ratio: 1;
    object-fit: contain;
}

.dice-card h3 {
    margin: 0;
    font-size: 1.35rem;
}

.dice-rules-sheet {
    display: grid;
    gap: 16px;
    margin-top: 18px;
    padding: 18px;
    border-radius: 24px;
    background: linear-gradient(180deg, rgba(255, 253, 246, 0.98), rgba(242, 231, 204, 0.92));
    box-shadow: inset 0 0 0 1px rgba(121, 84, 33, 0.14);
}

.dice-rules-image {
    width: 100%;
    max-height: 68vh;
    object-fit: contain;
    border-radius: 18px;
}

.dice-rules-fallback {
    margin: 0;
    padding: 16px;
    border-radius: 18px;
    background: rgba(91, 63, 24, 0.08);
    color: var(--ink-700);
    line-height: 1.6;
}

.large-button {
    min-width: min(100%, 280px);
}

@keyframes tumble {
    0% { transform: rotate(0deg) scale(1); opacity: 1; }
    35% { transform: rotate(10deg) scale(0.94); opacity: 0.4; }
    70% { transform: rotate(-8deg) scale(1.04); opacity: 0.8; }
    100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

@media (max-width: 920px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .status-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-banner {
        align-items: flex-start;
        flex-direction: column;
    }

    .hero-banner-art {
        max-width: 100%;
        width: min(100%, 360px);
    }

    .install-app-button.is-visible {
        display: inline-flex;
        align-self: flex-start;
    }

    .journal-header {
        flex-direction: column;
    }

    .journal-actions {
        align-items: flex-start;
    }
}

@media (max-width: 680px) {
    .app-shell {
        width: min(100vw - 18px, 100%);
        padding-top: 12px;
    }

    .hero-card,
    .panel,
    .dice-panel {
        padding: 20px;
        border-radius: 24px;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .dice-tabs,
    .dice-count-selector {
        width: calc(100% - 100px);
    }

    .dice-tabs {
        margin-right: 0;
    }

    .dice-tab,
    .dice-count-button {
        flex: 1 1 0;
        text-align: center;
    }

    .dice-count-selector {
        gap: 6px;
    }

    .dice-count-button {
        padding: 8px 10px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .dice-results {
        gap: 8px;
    }

    .dice-card {
        gap: 8px;
        padding: 12px 8px;
        border-radius: 20px;
    }

    .dice-face-image {
        width: min(100%, 70px);
    }

    .dice-card h3 {
        font-size: 0.9rem;
    }

    .dice-fab {
        right: 14px;
    }

    .bottom-nav {
        width: calc(100vw - 14px);
        gap: 8px;
        bottom: 10px;
        padding: 8px;
    }

    .nav-link,
    .nav-link-dice {
        min-width: 0;
        font-size: 0.94rem;
    }
}