@font-face {
    font-family: 'GvTime';
    src: url('../fonts/gvtime.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --primary-orange: #E05E02;
    --primary-orange-hover: #c45202;
    --dark-bg: #222222;
    --dark-hover: #141414;
    --card-bg: rgba(255, 255, 255, 0.96);
    --border-color: rgba(224, 94, 2, 0.35);
    --text-color: #111111;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
}

#app-container {
    position: relative;
    width: 100vw;
    max-width: 480px;
    height: 100vh;
    height: 100dvh;
    max-height: 920px;
    margin: 0 auto;
    background-color: #ffffff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.25);
}

.bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../images/background.png');
    background-size: cover;
    background-position: center;
    opacity: 0.35;
    z-index: 0;
    pointer-events: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 10px 12px 14px 12px;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.25s ease;
    overflow: hidden;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
    margin-bottom: 8px;
    gap: 8px;
    flex-shrink: 0;
}

.top-bar.flex-end {
    justify-content: flex-end;
}

.screen-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 8px;
    min-height: 0;
    width: 100%;
}

.btn-pop {
    border: none;
    outline: none;
    border-radius: 14px;
    font-weight: 900;
    font-size: 22px;
    color: #ffffff;
    cursor: pointer;
    text-align: center;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
    transition: transform 0.08s ease, background-color 0.15s ease, box-shadow 0.08s ease;
}

.btn-pop:active {
    transform: scale(0.96);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}

.btn-orange { background: linear-gradient(180deg, #f06a09 0%, #d45600 100%); }
.btn-orange:active { background: #ba4c00; }
.btn-dark { background: linear-gradient(180deg, #3d3d3d 0%, #202020 100%); }
.btn-dark:active { background: #111111; }
.btn-black { background-color: #000000; }
.btn-red { background: linear-gradient(180deg, #e62828 0%, #b81414 100%); }

.btn-nav {
    height: 50px;
    font-size: 21px;
    min-width: 100px;
    padding: 0 16px;
}

.btn-small {
    padding: 8px 18px;
    font-size: 18px;
    border-radius: 12px;
}

.btn-block {
    width: 100%;
    padding: 14px;
}

.btn-large {
    font-size: 28px;
    height: 56px;
}

.btn-circle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-toggle {
    border: 2px solid #555555;
    background: linear-gradient(180deg, #3d3d3d 0%, #202020 100%);
    color: #ffffff;
    border-radius: 12px;
    padding: 8px 14px;
    font-weight: 900;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.btn-toggle.active {
    background: linear-gradient(180deg, #f06a09 0%, #d45600 100%);
    border-color: #ffffff;
}

.styled-select {
    border: 2px solid rgba(255,255,255,0.4);
    outline: none;
    background: linear-gradient(180deg, #f06a09 0%, #d45600 100%);
    color: #ffffff;
    font-weight: 900;
    font-size: 21px;
    padding: 12px 16px;
    border-radius: 14px;
    cursor: pointer;
    text-align-last: center;
    width: 100%;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.screen-title-badge {
    flex: 1;
    height: 50px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-orange);
    font-size: 24px;
    font-weight: 900;
    box-shadow: 0 3px 8px rgba(0,0,0,0.06);
}

.screen-title-group {
    flex: 1;
    height: 50px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 3px 8px rgba(0,0,0,0.06);
}

.screen-title-text {
    flex: 0.55;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-orange);
    font-weight: 900;
    font-size: 22px;
}

.sub-select {
    flex: 0.45;
    border: none;
    outline: none;
    background: #e8e8e8;
    color: #222222;
    font-weight: 900;
    font-size: 19px;
    text-align-last: center;
    border-left: 2px solid var(--border-color);
}

.menu-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    gap: 6px;
}

.title-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 0 12px;
    height: 108px;
    margin: 0 auto;
    flex-shrink: 0;
}

.rock-title {
    font-family: 'GvTime', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    position: absolute;
    font-size: clamp(38px, 9.5vw, 48px);
    font-weight: normal;
    color: var(--primary-orange);
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
    letter-spacing: 1.5px;
    line-height: 0.9;
    margin: 0;
}

.title-top { 
    top: 0; 
    left: 12px; 
}

.title-mid { 
    top: 32px; 
    left: 50%; 
    transform: translateX(-50%); 
}

.title-bot { 
    bottom: 0; 
    right: 12px; 
}

.welcome-user {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 900;
    color: var(--primary-orange);
    flex-shrink: 0;
    margin: 2px 0 4px 0;
}

.menu-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(4, minmax(0, 1fr)); /* Distribuisce perfettamente le 4 righe */
    gap: 8px;
    margin-bottom: 0;
}

.menu-grid .btn-pop {
    width: 100%;
    height: 100%;
    min-height: 0; /* Permette il ridimensionamento verticale automatico */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(15px, 2.2vh, 20px);
    font-weight: 900;
    padding: 0 6px;
    text-transform: uppercase;
    line-height: 1.15;
    border-radius: 12px;
}

/* Manico Chitarra Calibrato e Realistico */
.fretboard-wrapper {
    width: 100%;
    max-width: 310px;
    margin: 0 auto;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.1);
}

#screen-scales .fretboard-wrapper,
#screen-reverse .fretboard-wrapper,
#screen-trainer .fretboard-wrapper {
    max-width: 290px;
}

#screen-chords .fretboard-wrapper {
    max-width: 270px;
}

.trainer-board-wrapper {
    flex: 1;
    min-height: 0;
}

.fretboard-wrapper canvas {
    width: 100%;
    height: 100%;
}

.legend-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 6px 4px;
    scrollbar-width: none;
    min-height: 50px;
    flex-shrink: 0;
}

.legend-scroll::-webkit-scrollbar { display: none; }

.legend-item {
    background-color: #ffffff;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 20px;
    font-weight: 900;
    white-space: nowrap;
    border: 2px solid #d0d0d0;
    box-shadow: 0 3px 6px rgba(0,0,0,0.08);
}

.root-selection-bar {
    display: flex;
    gap: 8px;
    height: 56px;
    flex-shrink: 0;
}

.root-selection-bar .btn-toggle {
    width: 56px;
    font-size: 26px;
    padding: 0;
}

.notes-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    min-height: 54px;
}

.notes-grid .btn-pop {
    padding: 0;
    font-size: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.chord-info-card {
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.chord-desc {
    text-align: center;
    font-size: 22px;
    font-weight: 900;
    color: #111;
    white-space: pre-line;
    line-height: 1.3;
}

.pendulum-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pendulum-container canvas {
    width: 100%;
    height: 100%;
}

.bpm-control-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-shrink: 0;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.bpm-text {
    font-size: 42px;
    font-weight: 900;
    color: var(--primary-orange);
}

.metro-params-row {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

.metro-params-row .btn-pop {
    flex: 0.3;
    font-size: 22px;
    height: 52px;
}

.metro-params-row select {
    flex: 0.35;
    font-size: 21px;
    height: 52px;
}

.tuner-action {
    text-align: center;
    font-size: 46px;
    font-weight: 900;
    color: var(--primary-orange);
    text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000;
    height: 50px;
    flex-shrink: 0;
}

.tuner-string {
    text-align: center;
    font-size: 24px;
    color: #222;
    font-weight: 900;
    flex-shrink: 0;
}

.tuner-canvas-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.1);
    overflow: hidden;
}

.tuner-canvas-container canvas {
    width: 100%;
    height: 100%;
}

.tuner-locked {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    color: #00aa00;
    font-size: 24px;
    font-weight: 900;
}

.tuner-freq {
    text-align: center;
    flex-shrink: 0;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 8px 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.freq-target { font-size: 19px; font-weight: 800; color: #444; }
.freq-current { font-size: 34px; font-weight: 900; color: var(--primary-orange); }

.reverse-result {
    text-align: center;
    font-size: 34px;
    font-weight: 900;
    color: var(--primary-orange);
    min-height: 42px;
    flex-shrink: 0;
}

.reverse-notes {
    text-align: center;
    font-size: 24px;
    font-weight: 900;
    color: #222;
    min-height: 30px;
    flex-shrink: 0;
}

.section-hint {
    text-align: center;
    font-size: 22px;
    color: #222;
    font-weight: 900;
    flex-shrink: 0;
}

.trainer-level {
    text-align: center;
    font-size: 24px;
    font-weight: 900;
    color: var(--primary-orange);
    flex-shrink: 0;
}

.trainer-stats-row {
    display: flex;
    justify-content: space-around;
    align-items: center;
    font-weight: 900;
    font-size: 26px;
    flex-shrink: 0;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.stat-feedback {
    color: #111;
}

.trainer-answers-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    height: 38%;
    flex-shrink: 0;
}

.trainer-answers-grid .btn-pop {
    height: 100%;
    font-size: 24px;
}

.circle-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    box-shadow: 0 6px 14px rgba(0,0,0,0.1);
}

.circle-container canvas {
    width: 100%;
    height: 100%;
}

.circle-info {
    text-align: center;
    font-size: 24px;
    line-height: 1.35;
    flex-shrink: 0;
    font-weight: 900;
}

.circle-chords-grid {
    display: flex;
    justify-content: space-around;
    padding: 12px 16px;
    font-size: 22px;
    font-weight: 900;
    color: #111;
    flex-shrink: 0;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.circle-col div {
    margin-bottom: 6px;
}

.circle-col div:last-child {
    margin-bottom: 0;
}

.key-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 900;
    font-size: 24px;
    flex-shrink: 0;
}

.progression-display-area {
    min-height: 64px;
    background-color: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    text-align: center;
    font-size: 28px;
    font-weight: 900;
    color: var(--primary-orange);
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.progression-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 8px;
    height: 36%;
    flex-shrink: 0;
}

.progression-grid .btn-pop {
    height: 100%;
    font-size: 20px;
    line-height: 1.1;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay.hidden { display: none; }
.hidden { display: none !important; }

.modal-box {
    background-color: #ffffff;
    border: 3px solid var(--primary-orange);
    border-radius: 16px;
    padding: 20px;
    width: 88%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.modal-title {
    text-align: center;
    color: var(--primary-orange);
    font-size: 24px;
    font-weight: 900;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 900;
    font-size: 20px;
}

.setting-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-weight: 900;
    font-size: 19px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-row input, .setting-block input[type="range"] {
    flex: 1;
    accent-color: var(--primary-orange);
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn-preset {
    flex: 1;
    padding: 8px 0;
    font-size: 17px;
    font-weight: 900;
    background-color: #eeeeee;
    color: #000000;
    border-radius: 10px;
    border: 1.5px solid #ddd;
}

.btn-preset.active {
    background: linear-gradient(180deg, #f06a09 0%, #d45600 100%);
    color: #ffffff;
    border-color: #ffffff;
}

.preset-info {
    text-align: center;
    font-size: 15px;
    font-weight: 800;
    color: #555;
}

#circle-canvas {
    touch-action: none;
}

/* Ottimizzazioni per Schermi Desktop (Tablet & PC) */
@media (min-width: 768px) {
    #app-container {
        height: 94vh;
        max-height: 880px;
        min-height: 580px;
        border-radius: 20px;
        border: 2px solid var(--border-color);
    }

    .btn-pop:hover {
        filter: brightness(1.08);
        transform: translateY(-1px);
    }

    .btn-pop:active {
        transform: translateY(1px) scale(0.98);
    }

    .btn-toggle:hover {
        border-color: var(--primary-orange);
    }

    .styled-select:hover {
        filter: brightness(1.05);
    }

    .legend-scroll {
        scrollbar-width: thin;
        scrollbar-color: var(--primary-orange) transparent;
    }

    .legend-scroll::-webkit-scrollbar {
        display: block;
        height: 6px;
    }

    .legend-scroll::-webkit-scrollbar-thumb {
        background: var(--primary-orange);
        border-radius: 3px;
    }
}