:root {
    --md-sys-color-primary: rgb(41 34 0);
  --md-sys-color-surface-tint: rgb(109 94 15);
  --md-sys-color-on-primary: rgb(255 255 255);
  --md-sys-color-primary-container: rgb(79 66 0);
  --md-sys-color-on-primary-container: rgb(255 255 255);
  --md-sys-color-secondary: rgb(40 34 9);
  --md-sys-color-on-secondary: rgb(255 255 255);
  --md-sys-color-secondary-container: rgb(74 67 39);
  --md-sys-color-on-secondary-container: rgb(255 255 255);
  --md-sys-color-tertiary: rgb(4 40 21);
  --md-sys-color-on-tertiary: rgb(255 255 255);
  --md-sys-color-tertiary-container: rgb(40 74 52);
  --md-sys-color-on-tertiary-container: rgb(255 255 255);
  --md-sys-color-error: rgb(78 0 2);
  --md-sys-color-on-error: rgb(255 255 255);
  --md-sys-color-error-container: rgb(140 0 9);
  --md-sys-color-on-error-container: rgb(255 255 255);
  --md-sys-color-background: rgb(255 249 238);
  --md-sys-color-on-background: rgb(30 27 19);
  --md-sys-color-surface: rgb(255 249 238);
  --md-sys-color-on-surface: rgb(0 0 0);
  --md-sys-color-surface-variant: rgb(234 226 208);
  --md-sys-color-on-surface-variant: rgb(39 36 24);
  --md-sys-color-outline: rgb(71 67 53);
  --md-sys-color-outline-variant: rgb(71 67 53);
  --md-sys-color-shadow: rgba(0 0 0);
  --md-sys-color-scrim: rgba(0 0 0);
  --md-sys-color-inverse-surface: rgb(51 48 39);
  --md-sys-color-inverse-on-surface: rgb(255 255 255);
  --md-sys-color-inverse-primary: rgb(255 236 162);
  --md-sys-color-primary-fixed: rgb(79 66 0);
  --md-sys-color-on-primary-fixed: rgb(255 255 255);
  --md-sys-color-primary-fixed-dim: rgb(53 44 0);
  --md-sys-color-on-primary-fixed-variant: rgb(255 255 255);
  --md-sys-color-secondary-fixed: rgb(74 67 39);
  --md-sys-color-on-secondary-fixed: rgb(255 255 255);
  --md-sys-color-secondary-fixed-dim: rgb(51 45 19);
  --md-sys-color-on-secondary-fixed-variant: rgb(255 255 255);
  --md-sys-color-tertiary-fixed: rgb(40 74 52);
  --md-sys-color-on-tertiary-fixed: rgb(255 255 255);
  --md-sys-color-tertiary-fixed-dim: rgb(16 51 31);
  --md-sys-color-on-tertiary-fixed-variant: rgb(255 255 255);
  --md-sys-color-surface-dim: rgb(224 217 204);
  --md-sys-color-surface-bright: rgb(255 249 238);
  --md-sys-color-surface-container-bright-lowest: rgb(255 255 255);
  --md-sys-color-surface-container-bright-low: rgb(250 243 229);
  --md-sys-color-surface-container-bright: rgb(244 237 223);
  --md-sys-color-surface-container-bright-high: rgb(238 232 218);
  --md-sys-color-surface-container-bright-highest: rgb(232 226 212);
}

.dark-theme {

    --md-sys-color-primary: rgb(255 250 245);
  --md-sys-color-surface-tint: rgb(219 198 110);
  --md-sys-color-on-primary: rgb(0 0 0);
  --md-sys-color-primary-container: rgb(224 202 114);
  --md-sys-color-on-primary-container: rgb(0 0 0);
  --md-sys-color-secondary: rgb(255 250 245);
  --md-sys-color-on-secondary: rgb(0 0 0);
  --md-sys-color-secondary-container: rgb(214 202 165);
  --md-sys-color-on-secondary-container: rgb(0 0 0);
  --md-sys-color-tertiary: rgb(239 255 240);
  --md-sys-color-on-tertiary: rgb(0 0 0);
  --md-sys-color-tertiary-container: rgb(173 212 183);
  --md-sys-color-on-tertiary-container: rgb(0 0 0);
  --md-sys-color-error: rgb(255 249 249);
  --md-sys-color-on-error: rgb(0 0 0);
  --md-sys-color-error-container: rgb(255 186 177);
  --md-sys-color-on-error-container: rgb(0 0 0);
  --md-sys-color-background: rgb(21 19 11);
  --md-sys-color-on-background: rgb(232 226 212);
  --md-sys-color-surface: rgb(21 19 11);
  --md-sys-color-on-surface: rgb(255 255 255);
  --md-sys-color-surface-variant: rgb(75 71 57);
  --md-sys-color-on-surface-variant: rgb(255 250 245);
  --md-sys-color-outline: rgb(209 202 184);
  --md-sys-color-outline-variant: rgb(209 202 184);
  --md-sys-color-shadow: rgba(0, 0, 0);
  --md-sys-color-scrim: rgba(0, 0, 0);
  --md-sys-color-inverse-surface: rgb(232 226 212);
  --md-sys-color-inverse-on-surface: rgb(0 0 0);
  --md-sys-color-inverse-primary: rgb(50 42 0);
  --md-sys-color-primary-fixed: rgb(253 231 139);
  --md-sys-color-on-primary-fixed: rgb(0 0 0);
  --md-sys-color-primary-fixed-dim: rgb(224 202 114);
  --md-sys-color-on-primary-fixed-variant: rgb(28 22 0);
  --md-sys-color-secondary-fixed: rgb(242 231 192);
  --md-sys-color-on-secondary-fixed: rgb(0 0 0);
  --md-sys-color-secondary-fixed-dim: rgb(214 202 165);
  --md-sys-color-on-secondary-fixed-variant: rgb(27 22 2);
  --md-sys-color-tertiary-fixed: rgb(201 240 210);
  --md-sys-color-on-tertiary-fixed: rgb(0 0 0);
  --md-sys-color-tertiary-fixed-dim: rgb(173 212 183);
  --md-sys-color-on-tertiary-fixed-variant: rgb(0 27 12);
  --md-sys-color-surface-dim: rgb(21 19 11);
  --md-sys-color-surface-bright: rgb(60 57 48);
  --md-sys-color-surface-container-bright-lowest: rgb(16 14 7);
  --md-sys-color-surface-container-bright-low: rgb(30 27 19);
  --md-sys-color-surface-container-bright: rgb(34 32 23);
  --md-sys-color-surface-container-bright-high: rgb(45 42 33);
  --md-sys-color-surface-container-bright-highest: rgb(56 53 43);

}

body {
    font-family: 'Roboto', sans-serif;
    margin: 0;
    padding: 0;
    /*background-color: var(--background-color);*/
/*background-color: var(--md-sys-color-surface-dim);*/
background-color: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
}

main {
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
}

#mainContent {
    margin-bottom: 150px;
}

#listContent {
    margin-bottom: 100px;
}

#newGameButton {
    margin-top: 16px;
}

#scoreChart {
    height: 400px; 
    width: 100%; 
}

#cropCanvas {
    border: 1px solid var(--md-sys-color-inverse-surface); 
    margin-top: 10px; 
}

#cameraPreview {
    max-width: 100%;
    min-height: 250px;
}

.app-bar {
    color: var(--md-sys-color-on-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px;
    height: 64px;
    position: sticky; /* Make the app bar sticky */
    top: 0; /* Stick to the top */
    z-index: 1000; /* Ensure it appears above other content */
    transition: background-color 0.3s;
}

.app-bar.scrolled {
    background-color: var(--md-sys-color-surface-container-bright);
}

.app-bar h1 {
    font-size: 20px;
    margin: 0;
}

.app-bar-actions {
    display: flex;
}

.app-bar .icon-button {
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface);
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    border-radius: 50%;
}

.app-bar .icon-button:hover, .app-bar .icon-button.active {
    background-color: var(--md-sys-color-surface-variant);
}

.drawer {
    position: fixed;
    top: 64px;
    left: 0;
    width: 280px;
    height: calc(100% - 64px);
    background-color: var(--md-sys-color-surface-container-bright);
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    z-index: 1000;
    color: var(--md-sys-color-on-surface);
}

.drawer.open {
    transform: translateX(0);
}

.drawer ul, .menu ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.drawer li, .menu li {
    padding: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.drawer li:hover, .menu li:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.drawer ul li {
    display: flex;
    align-items: center;
    padding: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
    color: var(--md-sys-color-on-surface);
}

.drawer ul li:hover {
    background-color: var(--md-sys-color-surface-variant);
}

.drawer ul li .material-icons {
    margin-right: 16px;
    color: var(--md-sys-color-on-surface);
}

.menu {
    position: absolute;
    top: 64px;
    right: 0;
    background-color: var(--md-sys-color-surface);
    z-index: 1000;
    border-radius: 4px;
    overflow: hidden;
}

.card {
    background-color: var(--md-sys-color-surface-container-bright);
    border-radius: 4px;
    padding: 24px;
    margin-bottom: 24px;
}

.game-card.finished {
    background-color: var(--md-sys-color-error);
    color: var(--md-sys-color-surface-dim);
}

.game-card.finished .icon-button .material-icons {
    color: var(--md-sys-color-surface-dim);
}

.game-card.finished .icon-button:hover {
    background-color: var(--md-sys-color-error-container);
}

.player-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.player-card {
    display: flex;
    align-items: center;
    background-color: var(--md-sys-color-surface-container-bright);
    border-radius: 8px;
    padding: 16px;
}

.avatar-container {
    position: relative;
    width: 60px;
    height: 60px;
    margin-right: 16px;
    flex-shrink: 0;
}

.player-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.take-photo-btn {
    position: absolute;
    bottom: -4px;
    right: -4px;
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
    padding: 0;
}

.take-photo-btn:hover {
    background-color: var(--md-sys-color-tertiary-fixed);
}

.take-photo-btn .material-icons {
    font-size: 16px;
}

.player-info {
    flex-grow: 1;
}

.player-info h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
}

.player-score {
    margin: 0;
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
    font-size: smaller;
}

.dark-theme #mainContent .icon-button, .dark-theme #listContent .icon-button {
    color: var(--md-sys-color-secondary); /* Use secondary color in dark mode */
}

.alert {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-weight: bold;
}

.alert.error {
    background-color: var(--md-sys-color-error-container);
    color: var(--md-sys-color-on-error-container);
    max-width: 300px;
}

.alert.success {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    max-width: 300px;
}

/*
#cameraModal .modal-content {
    max-width: 320px;
}

#cropModal  .modal-content {
    max-width: 320px;
}
    */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: color-mix(in srgb, var(--md-sys-color-shadow) 70%, transparent);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: var(--md-sys-color-surface-container-bright-highest);
    padding: 24px;
    border-radius: 4px;
    max-width: 90%;
    max-height: 90%;
    min-width: 320px;
    overflow-y: auto;
}

.modal-header {
    color: var(--md-sys-color-on-surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h2 {
    margin: 0;
}

.modal-actions {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    align-content: center;
    flex-wrap: nowrap;
}

.input-group {
    margin-bottom: 16px;
}

.hidden {
    display: none !important;
}


.fab {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 20%;
    background-color: var(--md-sys-color-primary-fixed);
    color: var(--md-sys-color-on-primary-fixed);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.3s;
    z-index: 1001;
}

.fab:hover {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    transform: scale(1.1);
}

.games-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 16px;
    border-radius: 8px;
    overflow: hidden;
}

.games-table th, .games-table td {
    padding: 16px;
    text-align: left;
}

.games-table th {
    background-color: var(--md-sys-color-primary-fixed);
    color: var(--md-sys-color-on-primary-fixed);
    font-weight: 500;
}

.games-table tr:last-child td {
    border-bottom: none;
}

.games-table button {
    margin-right: 8px;
    padding: 8px 16px;
    background-color: var(--md-sys-color-primary-fixed);
    color: var(--md-sys-color-on-primary-fixed);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.3s;
}

.games-table button:hover {
    background-color: var(--md-sys-color-primary)
}

.games-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.game-card {
    background-color: var(--md-sys-color-surface-container-bright);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.game-info h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
}

.game-info p {
    margin: 4px 0;
    font-size: 14px;
}

.game-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.icon-button {
    background: none;
    border: none;
    color: var(--md-sys-color-on-surface);
    padding: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    border-radius: 50%;
    width:48px;
    height: 48px;
}

.icon-button:hover {
    background-color: var(--md-sys-color-surface-bright);
}

.winner-box {
    background-color: var(--md-sys-color-tertiary-container);
    color: var(--md-sys-color-on-tertiary-container);
    padding: 32px 16px;
    border-radius: 8px;
    margin-top: 16px;
    margin-bottom: 16px;
    text-align: center;
}

.winner-box h2 {
    margin-top: 0;
}

.winner-box ul {
    list-style-type: none;
    padding: 0;
}

.winner-box li {
    font-size: 18px;
    margin-bottom: 8px;
}

.side-sheet {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px; /* Regola la larghezza come necessario */
    height: 100%;
    background-color: var(--md-sys-color-surface-variant);
    transition: transform 0.3s ease;
    transform: translateX(100%); /* Inizialmente nascosto */
    z-index: 1009; /* Assicurati che appaia sopra altri contenuti */
    overflow-y: auto; /* Aggiungi lo scorrimento verticale se necessario */
    border-top-left-radius: 20px; /* Rounded top left corner */
    border-bottom-left-radius: 20px; /* Rounded bottom left corner */
}

.side-sheet.open {
    transform: translateX(0); /* Mostra il side sheet */
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}

.close-button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--md-sys-color-on-background);
}

.mano-summary-content {
    padding: 16px;
}

.mano-summary-content table {
    width: 100%;
    border-collapse: collapse;
}

.mano-summary-content th, .mano-summary-content td {
    border: 1px solid var(--md-sys-color-background);
    padding: 8px;
    text-align: left;
}

.mano-summary-content th {
    background-color: var(--md-sys-color-tertiary-fixed);
    color: var(--md-sys-color-on-tertiary-fixed);
}

.material-list {
    list-style-type: none;
    padding: 0;
}

.material-list li {
    padding: 16px;
    background-color: var(--md-sys-color-surface-container-bright);
    border-bottom: 1px solid var(--md-sys-color-background); 
    cursor: pointer;
    transition: background-color 0.3s;
}

.material-list li:hover {
    background-color: var(--md-sys-color-surface-container-bright-highest); 
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--md-sys-color-surface-container-bright);
    color: var(--md-sys-color-on-surface);
    font-size: smaller;
    z-index: 1000; /* Ensure it appears above other content */
}

.bottom-nav ul {
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    margin: 0;
    list-style: none;
}

.bottom-nav li {
    text-align: center;
    cursor: pointer;
    color: var(--md-sys-color-on-surface);
    min-width: 48px;
}

.bottom-nav .material-icons {
    font-size: 24px; /* Icon size */
    min-width: 24px;
    display: block;
    border-radius: 8px;
}

.bottom-nav li.active, 
.bottom-nav li:hover {
    font-weight: bold;
}

.bottom-nav li.active .material-icons, 
.bottom-nav li:hover .material-icons {
    background-color: var(--md-sys-color-surface-variant);
}

.custom-legend {
    display: flex;
    flex-direction: column; 
    margin-top: 15px; 
    width: 100%;
}

.cropper-container {
    max-width: 100%;
    height: auto;
}


.form-field {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}

input[type="number"], input[type="text"] {
    width: calc(100% - 16px); /* Sottrai il padding totale */
    padding: 8px;
    border: 1px solid var(--md-sys-color-inverse-surface);
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box; /* Includi padding e bordo nella larghezza */
}

.button-primary {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button-primary:hover {
    background-color: var(--md-sys-color-primary-fixed);
}

.button-outline {
    background-color: transparent;
    color: var(--md-sys-color-on-tertiary);
    border: 1px solid var(--md-sys-color-on-tertiary);
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button-outline:hover {
    background-color: var(--md-sys-color-tertiary-fixed-dim);
}

.button-secondary {
    background-color: var(--md-sys-color-secondary);
    color: var(--md-sys-color-on-secondary);
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.button-secondary:hover {
    background-color: var(--md-sys-color-secondary-fixed); /* Darker shade for hover effect */
}

.snackbar {
    visibility: hidden; /* Hidden by default */
    min-width: 250px; /* Minimum width */
    margin-left: -125px; /* Center the snackbar */
    background-color: var(--md-sys-color-primary); /* Background color */
    color: var(--md-sys-color-on-primary); /* Text color */
    text-align: center; /* Centered text */
    border-radius: 2px; /* Rounded corners */
    padding: 16px; /* Padding */
    position: fixed; /* Sit on top */
    z-index: 1010; /* High z-index */
    left: 50%; /* Center horizontally */
    bottom: 30px; /* Position from the bottom */
    font-size: 17px; /* Font size */
    transition: visibility 0s, opacity 0.5s linear; /* Transition for visibility and opacity */
    opacity: 0; /* Hidden by default */
}

.snackbar.show {
    visibility: visible; /* Show the snackbar */
    opacity: 1; /* Fade in */
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-in {
    animation: slideIn 0.3s ease-in-out;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}


.box-shadow-z1 {
    box-shadow: 0 1px 4px 0 color-mix(in srgb, var(--md-sys-color-shadow) 37%, transparent); 
}
.box-shadow-z2 {
    box-shadow: 0 2px 2px 0 color-mix(in srgb, var(--md-sys-color-shadow) 20%, transparent), 0 6px 10px 0 color-mix(in srgb, var(--md-sys-color-shadow) 30%, transparent); 
}
.box-shadow-z3 {
    box-shadow: 0 11px 7px 0 color-mix(in srgb, var(--md-sys-color-shadow) 19%, transparent), 0 13px 25px 0 color-mix(in srgb, var(--md-sys-color-shadow) 30%, transparent); 
}
.box-shadow-z4 {
    box-shadow: 0 14px 12px 0 color-mix(in srgb, var(--md-sys-color-shadow) 17%, transparent), 0 20px 40px 0 color-mix(in srgb, var(--md-sys-color-shadow) 30%, transparent); 
}
.box-shadow-z5 {
    box-shadow: 0 17px 17px 0 color-mix(in srgb, var(--md-sys-color-shadow) 15%, transparent), 0 27px 55px 0 color-mix(in srgb, var(--md-sys-color-shadow) 30%, transparent); 
}


@media (max-width: 600px) {
    main {
        padding: 16px;
    }

    .card {
        padding: 16px;
    }

    .player-list {
        grid-template-columns: 1fr;
    }
}