/* --- 0. RESET E FONT --- */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* {
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* Fondamentale per far funzionare l'input del wizard */
input {
    -webkit-user-select: text !important;
    user-select: text !important;
}

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a;
    color: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Press Start 2P', cursive;
    overscroll-behavior: none;
    position: fixed;
}

/* --- 1. ANIMAZIONI --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 2. CONTENITORI PRINCIPALI --- */
#game-container {
    position: relative;
    width: 100dvw;
    height: 100dvh;
    background-color: #000;
    overflow: hidden;
    image-rendering: pixelated;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain; 
}

/* --- 3. SCHERMATA INIZIALE --- */
#startScreen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    z-index: 10;
    padding-top: calc(env(safe-area-inset-top, 0px) + 32px);
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
    overflow-y: auto;
    pointer-events: none;
}

#startScreen > * { pointer-events: auto; }

/* Blocco titolo in cima — contiene tutto */
#start-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    text-align: center;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 0 18px;
}

/* Pannello pixel: griglia 2x2 (linee non visibili), sfondo pieno così le vignette
   del canvas non traspaiono sotto al testo */
.start-panel {
    width: 100%;
    max-width: 340px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
    padding: 16px;
    background: rgba(12, 8, 26, 0.90);
    border: 2px solid rgba(138, 43, 226, 0.55);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.7), 0 0 22px rgba(138, 43, 226, 0.35);
}

.panel-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-align: center;
    min-width: 0;
}

.cell-label {
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    line-height: 1.6;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.42);
}

/* Cella-link (Collection) senza bordi */
.cell-link {
    justify-content: flex-start;
    text-decoration: none;
    cursor: pointer;
    gap: 8px;
}
.cell-link:active { opacity: 0.7; }

.opensea-logo {
    width: 30px;
    height: 30px;
    display: block;
}

/* Riga "optional" + tastino "i", senza andare a capo */
.wallet-optional {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.42);
}

.info-i {
    flex: 0 0 auto;
    width: 14px;
    height: 14px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(201, 168, 255, 0.8);
    border-radius: 50%;
    color: #c9a8ff;
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    line-height: 1;
    cursor: pointer;
}
.info-i:active { background: #8a2be2; color: #fff; border-color: #8a2be2; }

.wallet-info {
    grid-column: 1 / -1;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    line-height: 1.8;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    text-align: left;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    padding-top: 10px;
}
.wallet-info[hidden] { display: none; }

/* Pulsante CONTINUE (run salvata) — occupa l'intera larghezza in cima al pannello */
#continueBtn {
    grid-column: 1 / -1;
    width: 100%;
    background: rgba(138, 43, 226, 0.18);
    border: 2px solid #c9a8ff;
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    letter-spacing: 1px;
    padding: 13px 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
#continueBtn:active { background: #8a2be2; color: #fff; }
.wallet-info p {
    margin: 0 0 10px;
}
.wallet-info p:last-child {
    margin-bottom: 0;
}

/* Rimuoviamo start-bottom — non più usato */

#start-title {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(14px, 5vw, 22px);
    color: #fff;
    letter-spacing: 3px;
    text-shadow: 2px 2px #000, 0 0 30px rgba(138,43,226,0.6);
    line-height: 1.4;
    white-space: nowrap;
}

/* Fantasma pixel-art al posto della "O" di SHADOWS */
#start-title .rs-ghost {
    height: 1.01em;               /* +10% rispetto a 0.92em */
    width: auto;
    color: #fff;                  /* corpo = currentColor, bianco come le lettere */
    vertical-align: 0.03em;       /* alzato di ~0.15em rispetto a -0.12em */
    margin: 0 6px 0 calc(2px - 0.05em);   /* avvicinato ~5% (0.05em) verso la "D", spazio verso la "W" invariato */
    filter: drop-shadow(0 0 12px rgba(138,43,226,0.7));  /* stesso glow viola del titolo */
}

#start-subtitle {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(7px, 2.2vw, 9px);
    color: rgba(255,255,255,0.35);
    letter-spacing: 1px;
    line-height: 1.9;
    max-width: 260px;
}

#wizardIdInput {
    opacity: 0;
    animation: fadeIn 1.2s ease-out forwards;
    animation-delay: 0.6s;
    background: transparent;
    color: #fff;
    border: none;
    border-bottom: 2px solid rgba(255,255,255,0.4);
    padding: 8px 4px;
    font-family: 'Press Start 2P', cursive;
    font-size: 15px;
    text-align: center;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

#wizardIdInput:focus { border-bottom-color: #fff; }

#wizardIdInput::placeholder {
    color: rgba(255,255,255,0.15);
    font-size: 10px;
}

/* Connect wallet (opzionale, sola lettura) */
#connectWalletBtn {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(138,43,226,0.6);
    color: #c9a8ff;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 1px;
    line-height: 1.5;
    padding: 11px 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

#connectWalletBtn:active {
    background: #8a2be2;
    color: #fff;
    border-color: #8a2be2;
}

.wallet-status {
    grid-column: 1 / -1;
    min-height: 10px;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 1px;
    line-height: 1.6;
    color: rgba(255,255,255,0.4);
    text-align: center;
    width: 100%;
}

.wallet-status.wallet-ok   { color: #7fffb0; }
.wallet-status.wallet-warn { color: #ffb060; }

#startButton {
    display: none;
    width: 100%;
    opacity: 0;
    background: transparent;
    border: 2px solid rgba(255,255,255,0.7);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    letter-spacing: 1px;
    padding: 12px 4px;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s, color 0.15s;
}

#startButton.visible {
    display: block;
    animation: fadeIn 0.5s ease-out forwards;
}

#startButton:active {
    background: #fff;
    color: #000;
    transform: none;
    box-shadow: none;
}

/* Indicatore di caricamento del wizard: compare al posto dello START finché il
   wizard non è pronto (poi appare il bottone START GAME). */
.wiz-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 4px;
    box-sizing: border-box;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.75);
}
/* Rispetta l'attributo hidden (una classe con display:flex lo sovrascriverebbe) */
.wiz-loading[hidden] { display: none; }
.wiz-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.22);
    border-top-color: #b98cff;
    border-radius: 50%;
    animation: wiz-spin 0.7s linear infinite;
}
@keyframes wiz-spin { to { transform: rotate(360deg); } }

/* --- 4. SCHERMATA SETUP (WIZARD) --- */
#characterSetup {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.95);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: env(safe-area-inset-top, 16px) 0 env(safe-area-inset-bottom, 16px);
    overflow-y: auto;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

#setup-header {
    width: 100%;
    padding: 10px 16px 0;
    text-align: center;
    flex-shrink: 0;
}

.wiz-title {
    font-size: clamp(9px, 2.8vw, 13px);
    letter-spacing: 2px;
    color: rgba(255,255,255,0.75);
    margin: 0;
    line-height: 1.5;
}

.setup-container {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0 16px 24px;
}

/* Image wrap: si allunga a tutta larghezza ignorando align-items: center del parent */
#wiz-image-wrap {
    align-self: stretch;
    flex-shrink: 0;
    padding-top: 8px;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#setupWizImage {
    width: 50%;
    height: auto;
    aspect-ratio: 1 / 1;
    image-rendering: pixelated;
    display: block;
}

/* Riga: HOW TO PLAY (sx) · immagine+match (centro) · START HUNTING (dx) */
#wiz-image-row {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 8px 12px 0;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
#wiz-image-col {
    flex: 0 1 auto;
    max-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}
#wiz-image-col #wiz-image-wrap {
    width: 100%;
    padding-top: 0;
}
#wiz-image-col #setupWizImage {   /* 2 ID → vince sulle media query */
    width: 100%;
    max-width: 130px;
}
#wiz-image-row #confirmStats,
#wiz-image-row #howToPlayBtn {
    flex: 0 0 auto;
    width: auto;
    min-width: 78px;
    max-width: 112px;
    margin-top: 0;
    align-self: center;
    padding: 12px 8px;
    line-height: 1.8;
}
#howToPlayBtn {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.35);
    color: rgba(255,255,255,0.8);
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    letter-spacing: 2px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
#howToPlayBtn:active { background: #fff; color: #000; }

/* Popup HOW TO PLAY */
.htp-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    box-sizing: border-box;
}
.htp-box {
    background: #0d0a14;
    border: 2px solid rgba(138,43,226,0.6);
    box-shadow: 0 0 30px rgba(138,43,226,0.5);
    max-width: 360px;
    width: 100%;
    padding: 22px 20px;
    text-align: center;
}
.htp-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 12px;
    color: #fff;
    letter-spacing: 2px;
    margin-bottom: 18px;
    text-shadow: 0 0 14px rgba(138,43,226,0.7);
}
.htp-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px;
    text-align: left;
}
.htp-list li {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    line-height: 1.9;
    color: rgba(255,255,255,0.85);
    margin-bottom: 16px;
}
.htp-key {
    display: block;
    color: #b47bff;
    margin-bottom: 6px;
    letter-spacing: 2px;
}
.htp-close {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    letter-spacing: 3px;
    padding: 12px 20px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.htp-close:active { background: #fff; color: #000; }

/* Stato "match" sotto l'immagine del wizard */
.setup-match {
    min-height: 10px;
    margin-top: 8px;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 1px;
    line-height: 1.6;
    color: rgba(255,255,255,0.4);
    text-align: center;
    width: 100%;
}
.setup-match.match-ok   { color: #7fffb0; }
.setup-match.match-warn { color: #ffb060; }

/* Traits: griglia etichetta | valore */
#traitsDisplay {
    width: 100%;
    display: flex;
    flex-direction: column;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 12px;
}

.trait-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    gap: 8px;
}

.trait-row:last-child { border-bottom: none; }

.trait-key {
    font-size: 8px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 2px;
    flex-shrink: 0;
    min-width: 60px;
}

.trait-val, .rune-val {
    font-size: 9px;
    color: #fff;
    text-align: right;
    line-height: 1.6;
}

/* Stat table */
.stats-panel {
    width: 100%;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 8px 0 12px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}

.stats-table thead tr {
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.stats-table th {
    font-size: 8px;
    color: rgba(255,255,255,0.3);
    letter-spacing: 2px;
    padding: 0 0 8px;
    font-weight: normal;
}

.stats-table th:first-child { text-align: left; }
.stats-table th:not(:first-child) { text-align: right; }

.section-header td {
    font-size: 9px;
    color: #c9a8ff;
    letter-spacing: 3px;
    padding: 16px 0 6px;
    text-transform: uppercase;
    text-align: left;
    font-weight: bold;
    border-top: 1px solid rgba(138,43,226,0.28);
}

.section-header.first-header td {
    padding-top: 6px;
    border-top: none;
}

.stat-row td {
    font-size: 9px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.stat-row td:first-child {
    color: rgba(255,255,255,0.5);
    font-size: 8px;
    letter-spacing: 1px;
}

.stat-row td:nth-child(2) {
    text-align: right;
    color: #fff;
}

.stat-row td:nth-child(3) {
    text-align: right;
    color: #7fffb0;
    font-size: 9px;
    min-width: 30px;
    padding-left: 8px;
}

.prop-effect-row td {
    font-size: 8px;
    letter-spacing: 1px;
    color: rgba(159,232,255,0.85);
    padding: 7px 0 9px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    background: rgba(159,232,255,0.06);
    text-transform: uppercase;
    font-weight: bold;
}

/* Bottone START HUNTING */
#confirmStats {
    width: 100%;
    margin-top: 16px;
    background: transparent;
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    letter-spacing: 3px;
    padding: 14px 0;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s, color 0.15s;
}

#confirmStats:active {
    background: #fff;
    color: #000;
    transform: none;
    box-shadow: none;
}


/* --- 5. POWER-UP SCREEN (Roguelike, mobile-first) --- */
#powerUpScreen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: radial-gradient(ellipse at top, #0d0030 0%, #000 70%);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: env(safe-area-inset-top, 20px) 16px 20px;
    overflow-y: auto;
    gap: 16px;
}

.powerup-header {
    text-align: center;
    position: relative;
    width: 100%;
    padding-top: 8px;
}

.powerup-title {
    font-size: clamp(1rem, 5vw, 1.6rem);
    color: #ffd700;
    text-shadow: 0 0 20px #ffd700, 0 0 40px #ff8800;
    letter-spacing: 4px;
    animation: pulseGlow 1.5s ease-in-out infinite alternate;
}

@keyframes pulseGlow {
    from { text-shadow: 0 0 10px #ffd700; }
    to   { text-shadow: 0 0 30px #ffd700, 0 0 60px #ff4400; }
}

.powerup-subtitle {
    font-size: 7px;
    color: rgba(255,255,255,0.5);
    margin-top: 8px;
    letter-spacing: 1px;
}

.powerup-points-badge {
    display: inline-block;
    margin-top: 10px;
    background: #ffd700;
    color: #000;
    font-size: 10px;
    padding: 4px 14px;
    border-radius: 20px;
    font-family: 'Press Start 2P', cursive;
}

/* Colonna singola: card una sotto l'altra, full-width */
.rogue-skill-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 480px;
}

.rogue-card {
    background: rgba(255,255,255,0.04);
    border: 2px solid rgba(255,255,255,0.18);
    padding: 14px 16px;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, transform 0.08s;
    display: flex;
    flex-direction: column;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}

.rogue-card:active {
    transform: scale(0.98);
}

/* Bordo colorato per rarità */
.rogue-card.rarity-common    { border-color: rgba(170,170,170,0.4); }
.rogue-card.rarity-rare      { border-color: rgba(85,153,255,0.5); }
.rogue-card.rarity-legendary { border-color: rgba(255,170,0,0.6); }

.rogue-card.rarity-common:active    { background: rgba(170,170,170,0.08); border-color: #aaaaaa; }
.rogue-card.rarity-rare:active      { background: rgba(85,153,255,0.08); border-color: #5599ff; }
.rogue-card.rarity-legendary:active { background: rgba(255,170,0,0.1);  border-color: #ffaa00; }

.rogue-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.rogue-path-name {
    font-size: 9px;
    color: #fff;
    letter-spacing: 1px;
    flex: 1;
}

.rogue-rarity {
    font-size: 6px;
    letter-spacing: 2px;
    padding: 3px 8px;
    border: 1px solid currentColor;
    white-space: nowrap;
}

.rogue-rarity.rarity-common    { color: #aaaaaa; }
.rogue-rarity.rarity-rare      { color: #5599ff; }
.rogue-rarity.rarity-legendary { color: #ffaa00; }

/* Stat table */
.rogue-stat-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 8px;
}

.rogue-stat-header {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    font-size: 6px;
    color: rgba(255,255,255,0.28);
    letter-spacing: 1px;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.rogue-stat-header span:not(:first-child) { text-align: right; }

.rogue-stat-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: baseline;
}

.rsg-label {
    font-size: 7px;
    color: rgba(255,255,255,0.5);
    letter-spacing: 1px;
}

.rsg-delta {
    font-size: 9px;
    color: #7fffb0;
    text-align: right;
    min-width: 34px;
}

.rsg-final {
    font-size: 9px;
    color: #fff;
    text-align: right;
    min-width: 34px;
}

/* --- 5b. GAME OVER SCREEN --- */
#gameOverScreen {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #000;
    z-index: 200;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: env(safe-area-inset-top, 32px) 20px env(safe-area-inset-bottom, 24px);
    overflow-y: auto;
    gap: 20px;
    animation: fadeIn 0.4s ease-out;
}

.go-title-block { text-align: center; }

.go-title {
    font-size: clamp(14px, 5vw, 22px);
    color: #fff;
    margin: 0 0 8px;
    letter-spacing: 4px;
}

.go-flavor {
    font-size: 7px;
    color: rgba(255,255,255,0.3);
    margin: 0;
    letter-spacing: 1px;
}

.go-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    max-width: 380px;
}

.go-stat-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 14px 8px;
    text-align: center;
}

.go-stat-value {
    font-size: clamp(14px, 5vw, 20px);
    color: #fff;
    display: block;
    margin-bottom: 6px;
}

.go-stat-label {
    font-size: 6px;
    color: rgba(255,255,255,0.35);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.go-skills-section {
    width: 100%;
    max-width: 380px;
    border: 1px solid rgba(255,255,255,0.1);
    padding: 12px 14px;
}

.go-skills-title {
    font-size: 6px;
    color: rgba(255,255,255,0.3);
    letter-spacing: 3px;
    margin-bottom: 10px;
}

.go-skills-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.go-skills-list li {
    font-size: 7px;
    color: rgba(255,255,255,0.7);
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.go-skills-list li:last-child { border-bottom: none; }

.go-skills-list li.rarity-common    { color: #aaaaaa; }
.go-skills-list li.rarity-rare      { color: #5599ff; }
.go-skills-list li.rarity-legendary { color: #ffaa00; }

.go-restart-btn {
    background: transparent;
    border: 2px solid rgba(255,255,255,0.6);
    color: #fff;
    font-size: 9px;
    padding: 14px 32px;
    letter-spacing: 3px;
    box-shadow: none;
}

.go-restart-btn:active {
    background: #fff;
    color: #000;
    transform: none;
    box-shadow: none;
}

/* --- 6. BOTTONI GENERALI (reset base) --- */
button {
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
}

/* --- 7. RESPONSIVE --- */

/* Telefoni bassi / in orizzontale: compatta immagine e spaziature per far entrare le 4 aree */
@media (max-height: 720px) {
    #setupWizImage { width: 38%; }
    .section-header td { padding: 11px 0 4px; }
    .stat-row td { padding: 4px 0; }
    .trait-row { padding: 4px 0; }
}

@media (max-height: 560px) {
    #setupWizImage { width: 28%; }
    #traitsDisplay { margin-bottom: 6px; }
    .section-header td { padding: 8px 0 3px; }
}

/* Tablet / schermi larghi: tabella stat su due colonne per ridurre lo scroll */
@media (min-width: 720px) {
    .setup-container { max-width: 620px; }
    #statsContainer { /* la tabella resta singola, ma con più respiro */ }
    #setupWizImage { width: 40%; }
}

/* ===== Overlay MOBILE ONLY (mostrato solo su desktop) ===== */
#desktopBlock { display: none; }

html.is-desktop #desktopBlock {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 99999;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 40%, #1a0d2e 0%, #05030a 80%);
    padding: 24px;
    text-align: center;
}

/* Su desktop nascondiamo del tutto il gioco dietro l'overlay */
html.is-desktop #game-container { filter: blur(6px); pointer-events: none; }

.desktop-block-card {
    max-width: 520px;
    border: 2px solid rgba(138, 43, 226, 0.6);
    border-radius: 16px;
    background: rgba(10, 6, 20, 0.92);
    box-shadow: 0 0 0 2px rgba(0,0,0,0.7), 0 0 40px rgba(138,43,226,0.45);
    padding: 40px 32px;
}

.desktop-block-icon {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 18px;
}

.desktop-block-title {
    font-family: "Press Start 2P", monospace;
    font-size: 28px;
    color: #d7b8ff;
    letter-spacing: 4px;
    margin: 0 0 20px;
    text-shadow: 2px 2px #000, 0 0 30px rgba(138,43,226,0.7);
}

.desktop-block-text {
    font-size: 16px;
    line-height: 1.6;
    color: rgba(255,255,255,0.85);
    margin: 0 0 12px;
}

.desktop-block-text strong { color: #b98bff; }

/* ===================== OpenSea link accanto al sottotitolo ===================== */
#start-subtitle .subtitle-opensea {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 8px;
    vertical-align: middle;
    line-height: 0;
}
#start-subtitle .subtitle-opensea svg { width: 16px; height: 16px; display: block; }
#start-subtitle .subtitle-opensea:active { opacity: 0.7; }

/* Logo 𝕏 ingrandito nel bottone di condivisione */
#goShareBtn .x-logo {
    font-size: 1.7em;
    line-height: 0;
    vertical-align: -0.22em;
    margin-left: 2px;
}

/* Invito a seguire su X nella schermata di sconfitta */
/* Bottone "follow me on X" (stesso look degli altri, testo lungo che va a capo) */
#goFollowLink {
    display: inline-block;
    text-align: center;
    line-height: 1.7;
    max-width: 300px;
}
#goFollowLink:active { background: #fff !important; color: #000 !important; }
#goFollowLink:active .x-logo { color: #000; }
#goFollowLink .x-logo {
    font-size: 1.5em;
    line-height: 0;
    vertical-align: -0.2em;
    margin-left: 2px;
    color: #fff;
}

/* ===================== Bottone che apre il simulatore ===================== */
.sim-open-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}
.sim-open-btn:active { opacity: 0.7; }
.sim-open-icon { width: 30px; height: 30px; display: block; }

/* ===================== Popup Simulatore ===================== */
.sim-overlay {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.78);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}
.sim-overlay[hidden] { display: none; }

.sim-modal {
    position: relative;
    width: 100%;
    max-width: 360px;
    max-height: 86vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 16px 18px;
    background: rgba(12, 8, 26, 0.97);
    border: 2px solid rgba(138, 43, 226, 0.6);
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.8), 0 0 26px rgba(138, 43, 226, 0.4);
}

.sim-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    background: rgba(138, 43, 226, 0.18);
    border: 1px solid rgba(138, 43, 226, 0.55);
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}
.sim-close:active { opacity: 0.7; }

.sim-title {
    font-family: 'Press Start 2P', cursive;
    font-size: 11px;
    letter-spacing: 2px;
    color: #fff;
    text-align: center;
    text-shadow: 2px 2px #000, 0 0 18px rgba(138, 43, 226, 0.7);
    margin-bottom: 6px;
}
.sim-sub {
    font-family: 'Press Start 2P', cursive;
    font-size: 6.5px;
    line-height: 1.7;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    margin-bottom: 14px;
}

.sim-rows { display: flex; flex-direction: column; gap: 10px; }

.sim-row {
    display: grid;
    grid-template-columns: 62px 1fr;
    grid-template-areas: "label select" "label bonus";
    align-items: center;
    column-gap: 8px;
    row-gap: 2px;
    border-bottom: 1px solid rgba(138, 43, 226, 0.18);
    padding-bottom: 8px;
}
.sim-row-label {
    grid-area: label;
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    letter-spacing: 1px;
    color: rgba(185, 140, 255, 0.9);
}
.sim-select {
    grid-area: select;
    width: 100%;
    padding: 7px 8px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(138, 43, 226, 0.5);
    color: #fff;
    font-size: 12px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 0;
}
.sim-bonus {
    grid-area: bonus;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 0.5px;
    line-height: 1.5;
    color: #aaa;
    min-height: 8px;
}
.sim-error, .sim-loading {
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    color: rgba(255, 120, 120, 0.9);
    text-align: center;
    padding: 12px 0;
}

.sim-find {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: rgba(138, 43, 226, 0.25);
    border: 2px solid rgba(138, 43, 226, 0.7);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 9px;
    letter-spacing: 2px;
    cursor: pointer;
}
.sim-find:active { background: rgba(138, 43, 226, 0.45); }

.sim-result {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(138, 43, 226, 0.4);
}
.sim-result[hidden] { display: none; }
.sim-result-top { display: flex; gap: 12px; align-items: center; }

/* Elenco dei trait specifici da pickare */
.sim-trait-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid rgba(138, 43, 226, 0.25);
    padding-top: 10px;
}
.sim-trait-item {
    display: grid;
    grid-template-columns: 58px 1fr;
    grid-template-areas: "cat name" "cat bonus";
    column-gap: 8px;
    row-gap: 1px;
    align-items: center;
}
.sim-trait-cat {
    grid-area: cat;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 1px;
    color: rgba(185, 140, 255, 0.9);
}
.sim-trait-name {
    grid-area: name;
    font-size: 12px;
    color: #fff;
    line-height: 1.3;
}
.sim-trait-bonus {
    grid-area: bonus;
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 0.5px;
    line-height: 1.4;
    color: #aaa;
}
.sim-result-img {
    width: 84px;
    height: 84px;
    flex: 0 0 84px;
    object-fit: contain;
    image-rendering: pixelated;
    background: rgba(255, 255, 255, 0.04);
}
.sim-result-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sim-result-name {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    line-height: 1.5;
    letter-spacing: 1px;
    color: #fff;
}
.sim-result-meta {
    font-family: 'Press Start 2P', cursive;
    font-size: 6px;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
}
.sim-use {
    margin-top: 4px;
    padding: 8px 10px;
    background: rgba(80, 200, 120, 0.18);
    border: 1px solid rgba(80, 200, 120, 0.7);
    color: #fff;
    font-family: 'Press Start 2P', cursive;
    font-size: 7px;
    letter-spacing: 1px;
    cursor: pointer;
}
.sim-use:disabled { opacity: 0.4; cursor: default; }
.sim-use:active:not(:disabled) { background: rgba(80, 200, 120, 0.35); }
