/* ============================================================
   VX DUNGEON — tema visivo
   Ispirazione: boardgame fantasy anni '80 (HeroQuest), pietra
   incisa, oro e ferro battuto, torce, pergamena.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap');

:root {
    --stone-black: #120f0c;
    --stone-dark: #221b15;
    --stone-mid: #362b21;
    --iron: #4a453d;
    --iron-light: #8a8175;
    --gold: #d8ad4d;
    --gold-bright: #f3d187;
    --gold-deep: #8a651f;
    --blood: #7a1f1f;
    --blood-bright: #a83232;
    --ember: #e2762f;
    --parchment: #e9dfc4;
    --parchment-dim: #b9ad8f;

    --font-display: 'Cinzel Decorative', serif;
    --font-body: 'Cormorant Garamond', serif;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--parchment);
    background: var(--stone-black);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-x: hidden;
    position: relative;
}

/* ---------- Sfondo: pietra scura con vignettatura e grana ---------- */

.stone-backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    background:
        radial-gradient(ellipse at 50% 30%, rgba(90, 70, 45, 0.35), transparent 55%),
        radial-gradient(ellipse at 50% 100%, rgba(0, 0, 0, 0.75), transparent 60%),
        linear-gradient(180deg, #1a1512 0%, #100d0a 60%, #0a0807 100%);
}

.stone-backdrop::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: 0.5;
    mix-blend-mode: overlay;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/></svg>");
    background-size: 180px 180px;
}

.stone-backdrop::after {
    content: "";
    position: absolute;
    inset: 0;
    box-shadow: inset 0 0 18vw rgba(0, 0, 0, 0.85);
}

/* ---------- Torce a parete ---------- */

.torch {
    position: fixed;
    top: 8vh;
    width: 64px;
    height: 220px;
    z-index: 1;
    pointer-events: none;
}

.torch.left { left: clamp(16px, 6vw, 120px); }
.torch.right { right: clamp(16px, 6vw, 120px); }

.torch .bracket {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 14px;
    height: 90px;
    background: linear-gradient(180deg, var(--iron-light), var(--iron) 60%, #211d18);
    border-radius: 3px;
    box-shadow: 0 0 0 1px #0d0b09;
}

.torch .flame-glow {
    position: absolute;
    bottom: 78px;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(226, 118, 47, 0.55), rgba(226, 118, 47, 0.12) 45%, transparent 70%);
    animation: glow-flicker 2.6s ease-in-out infinite;
    filter: blur(2px);
}

.torch .flame {
    position: absolute;
    bottom: 84px;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 46px;
    background: linear-gradient(180deg, #fff2c9 0%, var(--gold-bright) 25%, var(--ember) 60%, var(--blood) 100%);
    border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
    animation: flame-flicker 1.1s ease-in-out infinite alternate;
    box-shadow: 0 0 24px 6px rgba(226, 118, 47, 0.65);
}

@keyframes flame-flicker {
    0%   { transform: translateX(-50%) scaleY(1) scaleX(1) rotate(-2deg); }
    30%  { transform: translateX(-52%) scaleY(1.08) scaleX(0.94) rotate(2deg); }
    60%  { transform: translateX(-48%) scaleY(0.94) scaleX(1.05) rotate(-1deg); }
    100% { transform: translateX(-50%) scaleY(1.05) scaleX(0.97) rotate(1deg); }
}

@keyframes glow-flicker {
    0%, 100% { opacity: 0.75; }
    50% { opacity: 0.5; }
}

@media (max-width: 720px) {
    .torch { display: none; }
}

/* ---------- Il "sigillo" — pannello principale ---------- */

.seal-frame {
    position: relative;
    z-index: 2;
    width: min(460px, 100%);
    background: linear-gradient(160deg, var(--stone-mid), var(--stone-dark) 55%, #170f0b 100%);
    padding: 3px;
    clip-path: polygon(
        6% 0%, 94% 0%, 100% 8%, 100% 92%, 94% 100%, 6% 100%, 0% 92%, 0% 8%
    );
    box-shadow:
        0 0 0 1px #0c0a08,
        0 20px 60px rgba(0, 0, 0, 0.65),
        0 0 80px rgba(216, 173, 77, 0.06);
}

.seal-frame__inner {
    position: relative;
    clip-path: polygon(
        6% 0%, 94% 0%, 100% 8%, 100% 92%, 94% 100%, 6% 100%, 0% 92%, 0% 8%
    );
    background:
        radial-gradient(ellipse at 50% -10%, rgba(216, 173, 77, 0.10), transparent 45%),
        linear-gradient(160deg, #241c15, #1a140f 60%, #120d0a 100%);
    border: 2px solid var(--gold-deep);
    padding: clamp(20px, 5vw, 38px) clamp(18px, 5vw, 34px) 30px;
}

/* rivetti agli angoli */
.seal-frame__inner::before,
.seal-frame__inner::after {
    content: "";
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold-deep) 70%, #241c15 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.seal-frame__inner::before { top: 14px; left: 14px; }
.seal-frame__inner::after { top: 14px; right: 14px; }

.rivet-bottom-left, .rivet-bottom-right {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, var(--gold-bright), var(--gold-deep) 70%, #241c15 100%);
    box-shadow: 0 1px 2px rgba(0,0,0,0.6);
    bottom: 14px;
}
.rivet-bottom-left { left: 14px; }
.rivet-bottom-right { right: 14px; }

/* ---------- Logo ---------- */

.crest {
    display: block;
    width: 100%;
    max-width: 420px;
    margin: 0 auto 6px;
    filter: drop-shadow(0 6px 18px rgba(0,0,0,0.6));
}

.tagline {
    text-align: center;
    font-family: var(--font-body);
    font-style: italic;
    font-size: 0.95rem;
    letter-spacing: 0.06em;
    color: var(--parchment-dim);
    margin: -4px 0 22px;
}

/* ---------- Toggle Accedi / Arruolati ---------- */

.mode-toggle {
    display: flex;
    border: 1px solid var(--gold-deep);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 22px;
}

.mode-toggle button {
    flex: 1;
    padding: 10px 6px;
    background: var(--stone-dark);
    color: var(--parchment-dim);
    border: none;
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    cursor: pointer;
    transition: background 0.25s, color 0.25s;
}

.mode-toggle button + button {
    border-left: 1px solid var(--gold-deep);
}

.mode-toggle button.active {
    background: linear-gradient(180deg, var(--gold), var(--gold-deep));
    color: #1a1310;
}

/* ---------- Campi form ---------- */

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: var(--gold);
    margin-bottom: 6px;
}

.field input {
    width: 100%;
    padding: 11px 12px;
    background: #0f0c0a;
    border: 1px solid var(--iron);
    border-radius: 3px;
    color: var(--parchment);
    font-family: var(--font-body);
    font-size: 1.05rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(216, 173, 77, 0.18);
}

.field input::placeholder {
    color: #5c5346;
}

/* ---------- Selettore di classe ---------- */

.class-select {
    margin-bottom: 20px;
}

.class-select > label {
    display: block;
    font-family: var(--font-display);
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: var(--gold);
    margin-bottom: 10px;
    text-align: center;
}

.class-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.class-medal {
    position: relative;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid var(--iron);
    background: radial-gradient(circle at 35% 30%, #3a2f22, #14100c 75%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.class-medal svg {
    width: 55%;
    height: 55%;
    stroke: var(--parchment-dim);
    fill: none;
    stroke-width: 1.6;
    transition: stroke 0.2s;
}

.class-medal:hover {
    transform: translateY(-2px);
    border-color: var(--gold-deep);
}

.class-medal.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(216, 173, 77, 0.22), 0 0 16px rgba(216, 173, 77, 0.35);
}

.class-medal.selected svg {
    stroke: var(--gold-bright);
}

.class-name {
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--gold-bright);
    margin-top: 8px;
    min-height: 1.2em;
}

/* ---------- Pulsante principale ---------- */

.cta {
    width: 100%;
    padding: 14px;
    margin-top: 6px;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold) 45%, var(--gold-deep));
    border: 1px solid #6b4e17;
    border-radius: 3px;
    color: #1a1310;
    font-family: var(--font-display);
    font-size: 0.85rem;
    letter-spacing: 0.1em;
    cursor: pointer;
    box-shadow: 0 4px 0 #5a4114, 0 8px 16px rgba(0,0,0,0.4);
    transition: transform 0.1s, box-shadow 0.1s;
}

.cta:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #5a4114, 0 4px 10px rgba(0,0,0,0.4);
}

.cta:disabled {
    opacity: 0.55;
    cursor: default;
}

/* ---------- Messaggi di stato ---------- */

.status-msg {
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 3px;
    font-size: 0.92rem;
    text-align: center;
    display: none;
}

.status-msg.show {
    display: block;
}

.status-msg.error {
    background: rgba(122, 31, 31, 0.25);
    border: 1px solid var(--blood-bright);
    color: #f0c9c9;
}

.status-msg.success {
    background: rgba(90, 130, 70, 0.2);
    border: 1px solid #6f9c56;
    color: #d9ecc9;
}

/* ---------- Sezione "benvenuto" post-login (placeholder) ---------- */

.welcome {
    text-align: center;
}

.welcome h2 {
    font-family: var(--font-display);
    color: var(--gold-bright);
    font-size: 1.1rem;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.welcome p {
    color: var(--parchment-dim);
    font-size: 1.05rem;
    line-height: 1.5;
}

.welcome .stats {
    display: flex;
    justify-content: center;
    gap: 22px;
    margin: 18px 0 22px;
}

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

.welcome .stat .value {
    font-family: var(--font-display);
    color: var(--gold);
    font-size: 1.2rem;
    display: block;
}

.welcome .stat .label {
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    color: var(--parchment-dim);
}

.logout-link {
    display: inline-block;
    margin-top: 16px;
    color: var(--parchment-dim);
    font-size: 0.85rem;
    text-decoration: underline;
    cursor: pointer;
}

.hidden {
    display: none !important;
}
