:root {
    --old-blue: #1f6fb2;
    --old-danger: #e3342f;
    --old-success: #38c172;
    --old-border: #ccc;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: #212529;
    background: #eee url("../images/ESBRASS.jpg");
    font-family: Nunito, sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    line-height: 1.6;
}

.app-shell {
    width: 100%;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0 15px;
}

.game-panel {
    background-color: #fff;
    min-width: 300px;
    max-width: 500px;
    width: 100%;
    user-select: none;
    border: 1px solid #000;
    border-radius: 10px;
    margin-top: 0.25rem;
    margin-bottom: 0.25rem;
    overflow: visible;
}

.game-panel:focus {
    outline: none;
}

.game-header {
    position: relative;
    padding: 0 15px;
    text-align: center;
}

.game-description {
    margin-top: 0.25rem;
    margin-bottom: 0;
    font-size: x-small;
    color: #212529;
}

.game-title {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-size: smaller;
    font-weight: 500;
    line-height: 1.2;
}

.level-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 0.35rem;
    margin: 0 -15px;
    padding: 0.25rem 15px 0;
}

.level-select {
    width: 125px;
    flex: 0 0 125px;
    height: calc(1.6em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.7875rem;
    line-height: 1.6;
    border: 1px solid #ced4da;
    border-radius: 0.2rem;
    color: #495057;
    background-color: #fff;
    font-weight: 400;
}

.input-mode-select {
    width: 205px;
    flex: 0 1 205px;
    height: calc(1.6em + 0.5rem + 2px);
    padding: 0.25rem 0.5rem;
    font-size: 0.7875rem;
    line-height: 1.6;
    border: 1px solid #ced4da;
    border-radius: 0.2rem;
    color: #495057;
    background-color: #fff;
    font-weight: 400;
}

.input-mode-label {
    margin: 0 0 0 auto;
    color: #555;
    font-size: 0.7rem;
    line-height: 1;
    white-space: nowrap;
}

.keyboard-connect {
    display: none;
    align-items: center;
    gap: 0.2rem;
    height: calc(1.6em + 0.5rem + 2px);
}

.keyboard-connect.is-visible {
    display: inline-flex;
}

.ble-button {
    width: 24px;
    height: 24px;
    cursor: pointer;
    color: var(--old-blue);
}

.ble-button svg {
    display: block;
    margin: 4px auto;
    fill: currentColor;
}

.ble-button[data-state="connected"] {
    color: var(--old-success);
}

.ble-button[data-state="error"] {
    color: var(--old-danger);
}

.ble-button:disabled {
    color: #777;
    cursor: default;
}

.ble-status {
    min-width: 28px;
    font-size: 0.7rem;
    line-height: 1;
    color: #555;
}

.ble-status[data-state="connected"] {
    color: var(--old-success);
}

.ble-status[data-state="error"] {
    color: var(--old-danger);
}

.icon-button {
    border: 0;
    background: transparent;
    padding: 0;
    line-height: 1;
}

.help-button {
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 0;
    width: 20px;
    height: 20px;
}

.info-button {
    cursor: pointer;
    position: absolute;
    right: 42px;
    top: 0;
    width: 20px;
    height: 20px;
    color: var(--old-blue);
    font-size: 15px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

.info-button span {
    display: block;
    width: 20px;
    height: 20px;
    border: 1.5px solid currentColor;
    border-radius: 50%;
    font-family: Georgia, "Times New Roman", serif;
    font-style: italic;
    line-height: 17px;
}

.info-button:hover,
.info-button:focus-visible {
    color: blue;
}

.help-button .bi-question-circle {
    fill: var(--old-danger);
}

.help-button:hover .bi-question-circle,
.help-button:focus-visible .bi-question-circle {
    fill: blue;
}

.help-image {
    position: absolute;
    top: 40px;
    left: 15px;
    z-index: 999;
    width: calc(100% - 30px);
}

.game-info-modal {
    user-select: text;
}

.game-info-modal .modal-dialog {
    max-width: 680px;
}

.game-info-modal .modal-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.game-info-modal .modal-body {
    font-size: 0.92rem;
    line-height: 1.5;
}

.info-section + .info-section {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid #e4e4e4;
}

.info-section h3 {
    margin: 0 0 0.45rem;
    color: #1f6fb2;
    font-size: 0.98rem;
    font-weight: 600;
}

.info-section p,
.info-section ul {
    margin-bottom: 0.55rem;
}

.info-section ul {
    padding-left: 1.2rem;
}

.info-inline-toggle {
    display: inline;
    margin-left: 0.2rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: #1f6fb2;
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
}

.info-inline-toggle:hover,
.info-inline-toggle:focus-visible {
    color: #174f80;
}

.bluetooth-device-info {
    margin-top: 0.65rem;
    padding: 0.75rem;
    border: 1px solid #d7e6f2;
    border-radius: 6px;
    background: #f7fbff;
}

.bluetooth-device-info p:last-of-type {
    margin-bottom: 0.7rem;
}

.contact-email-line {
    margin: 0.35rem 0 0.65rem;
}

.contact-email-line img {
    display: block;
    width: min(100%, 252px);
    height: auto;
}

.digit-trumpet-gallery {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.6rem;
}

.digit-trumpet-gallery figure {
    margin: 0;
    text-align: center;
}

.digit-trumpet-gallery img {
    width: 100%;
    height: 160px;
    object-fit: contain;
}

.digit-trumpet-gallery figcaption {
    margin-top: 0.25rem;
    color: #555;
    font-size: 0.76rem;
    font-weight: 600;
}

.instruction-fingering-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}

.instruction-fingering-grid figure {
    margin: 0;
    text-align: center;
}

.instruction-fingering-grid img {
    width: 100%;
    max-width: 150px;
    height: 90px;
    object-fit: contain;
}

.instruction-fingering-grid figcaption {
    margin-top: 0.2rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.instruction-scale {
    margin: 0.45rem 0 0.6rem;
    text-align: center;
}

.instruction-scale img {
    width: 100%;
    max-width: 520px;
    max-height: 260px;
    object-fit: contain;
}

.instruction-scale figcaption {
    margin-top: 0.25rem;
    color: #555;
    font-size: 0.78rem;
}

.note-stage {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 150px;
    padding: 0 15px;
}

.note-image {
    width: 250px;
    height: 150px;
    object-fit: fill;
    display: block;
}

.sound-row {
    position: relative;
    width: 250px;
    height: 30px;
    margin: 0 auto;
}

.sound-button {
    position: absolute;
    width: 30px;
    height: 30px;
    left: 30px;
    top: 0;
    cursor: pointer;
}

.sound-button .sound-on,
.sound-button .sound-off {
    width: 30px;
    height: 30px;
}

.sound-button .sound-on {
    fill: var(--old-blue);
}

.sound-button .sound-off {
    display: none;
}

.sound-button.is-muted .sound-on {
    display: none;
}

.sound-button.is-muted .sound-off {
    display: block;
}

.game-body {
    display: grid;
    grid-template-columns: 41.6666667% 58.3333333%;
    padding: 0 15px;
}

.score-column {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-width: 0;
    padding: 0 15px;
}

.timer-control {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    margin-bottom: 0.35rem;
}

.timer-label {
    margin: 0;
    color: #555;
    font-size: 0.72rem;
    line-height: 1;
    white-space: nowrap;
}

.timer-select {
    width: 82px;
    height: calc(1.6em + 0.5rem + 2px);
    padding: 0.25rem 0.35rem;
    font-size: 0.75rem;
    line-height: 1.6;
    border: 1px solid #ced4da;
    border-radius: 0.2rem;
    color: #495057;
    background-color: #fff;
    font-weight: 400;
}

.result-table {
    table-layout: fixed;
    width: 100%;
    margin-bottom: 0.5rem;
}

.result-table tr:not(:last-child) {
    border-bottom: 1px solid var(--old-border);
}

.result-table th {
    padding: 10px;
    text-align: right;
    min-width: 80px;
    max-width: 100px;
    width: 70%;
    color: #212529;
}

.result-table td {
    text-align: left;
    color: #212529;
}

.start-form {
    margin: 0;
}

.result-table tr.is-success th,
.result-table tr.is-success td {
    color: var(--old-success);
}

.result-table tr.is-danger th,
.result-table tr.is-danger td {
    color: var(--old-danger);
}

.start-button {
    width: 100px;
    height: 80px;
    padding: 1px 6px;
    border-radius: 0;
    font-weight: 400;
    color: buttontext;
    background-color: buttonface;
    border: 2px outset buttonborder;
}

.start-button:active {
    border-style: inset;
}

.answer-panel {
    min-width: 0;
}

.trumpet-panel {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 15px;
}

.trumpet-image {
    width: 180px;
    height: 120px;
    object-fit: contain;
}

.fingering-pad {
    display: grid;
    grid-template-columns: repeat(4, 38px);
    grid-template-rows: 38px;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 190px;
    min-height: 44px;
}

.fingering-pad.is-touchpad {
    grid-template-rows: 38px 38px;
    min-height: 88px;
}

.fingering-pad.is-bluetooth {
    display: none;
}

.fingering-button {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 0;
    border: 2px outset buttonborder;
    color: #212529;
    background: buttonface;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1;
    text-align: center;
}

.fingering-button:disabled {
    cursor: default;
    opacity: 1;
}

.fingering-button:not(:disabled) {
    cursor: pointer;
}

.fingering-button:active,
.fingering-button.is-active {
    border-style: inset;
    color: #fff;
    background: #5b5b5b;
}

.fingering-play-button {
    display: none;
    grid-column: 1;
    grid-row: 1;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: var(--old-blue);
}

.fingering-pad.is-touchpad .fingering-play-button {
    display: flex;
}

.fingering-play-icon {
    display: block;
    width: 25px;
    height: 25px;
    fill: currentColor;
}

.fingering-key {
    grid-row: 1;
}

.fingering-pad.is-touchpad .fingering-key {
    grid-row: 2;
}

.fingering-key-n {
    grid-column: 1;
}

.fingering-key-1 {
    grid-column: 2;
}

.fingering-key-2 {
    grid-column: 3;
}

.fingering-key-3 {
    grid-column: 4;
}

.game-footer {
    padding: 1.5rem 15px 0.45rem;
    text-align: center;
    font-size: x-small;
}

.game-footer a {
    color: #3490dc;
    text-decoration: none;
}

.game-footer a:hover {
    color: #1d68a7;
    text-decoration: underline;
}

.game-footer > span {
    display: block;
    margin-top: 0;
    white-space: nowrap;
}

#currentYear {
    display: inline;
}

.like-row {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    margin-top: 0.35rem;
}

.like-button {
    padding: 1px 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    color: #212529;
    font-size: 0.75rem;
    line-height: 1.5;
    cursor: pointer;
}

.like-button:disabled {
    cursor: default;
    opacity: 0.65;
}

.like-icon {
    cursor: pointer;
    filter: grayscale(100%);
}

.like-icon.is-liked {
    filter: none;
}

.like-message {
    min-height: 1rem;
    color: #555;
}

@media (max-width: 575.98px) {
    .level-select {
        width: 110px;
        flex-basis: 110px;
        min-width: 110px;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .input-mode-select {
        width: auto;
        min-width: 0;
        flex: 1 1 auto;
        padding-left: 0.35rem;
        padding-right: 0.35rem;
    }

    .input-mode-label {
        margin-left: 0;
        font-size: 0.66rem;
    }

    .keyboard-connect {
        gap: 0.12rem;
    }

    .ble-status {
        min-width: 22px;
    }

    .instruction-fingering-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .digit-trumpet-gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .digit-trumpet-gallery img {
        height: 150px;
    }

    .game-body {
        padding: 0;
    }

    .score-column,
    .trumpet-panel {
        padding: 0 10px;
    }
}

@media (max-width: 380px) {
    .result-table th,
    .result-table td {
        padding-left: 4px;
        padding-right: 4px;
        font-size: 0.86rem;
    }
}
