body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    background-color: #f0f0f0;
    color: #333;
}

h1 {
    color: #333;
}

#game-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

#instructions-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: #007bff;
    color: white;
    font-size: 1.2em;
    font-weight: bold;
    font-style: italic;
    font-family: 'Times New Roman', serif;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none; /* Previne a seleção do texto */
}

#instructions-button:hover {
    background-color: #0056b3;
}

#main-container {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

#board-area {
    display: grid;
    grid-template-columns: 30px auto;
    grid-template-rows: auto 30px;
    width: fit-content;
    margin: 0 auto;
    gap: 5px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    max-width: calc(400px + 30px + 5px); /* max-width do game-board + labels + gap */
}

#row-labels {
    grid-column: 1 / 2;
    grid-row: 1 / 2;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    font-weight: bold;
    color: #555;
    padding-right: 5px;
}

#game-board {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    /* width: 100%;  Será definido por JS para um valor fixo como 350px */
    max-width: 400px; /* Ainda útil como um limite superior absoluto */
    border: 2px solid black;
    display: grid;
    background-color: #eee;
    /* A altura será definida por JS para manter as casas quadradas */
}

.corner-spacer {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
}

#col-labels {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    font-weight: bold;
    color: #555;
    padding-top: 5px;
}

.square {
    border: 1px solid #ccc;
    background-color: #f8f8f8;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    transition: background-color 0.2s ease;
}

.square:hover {
    background-color: #e0e0e0;
}

.token { /* Token preto (rastro) */
    width: 75%;
    height: 75%;
    background-color: black;
    border-radius: 50%;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.white-token { /* Token do jogador atual */
    width: 75%;
    height: 75%;
    background-color: white;
    border: 2px solid black;
    border-radius: 50%;
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    box-sizing: border-box;
}

.number-circle { /* Casas objetivo */
    width: 70%;
    height: 70%;
    border: 2px solid black;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: clamp(10px, 2.5vw, 16px);
    color: black;
    background-color: white;
    box-sizing: border-box;
    transition: background-color 0.3s ease;
}

.number-circle.highlighted-goal {
    background-color: lightgreen;
    color: black;
}

.square.occupied {
    cursor: not-allowed;
}

.square.occupied:hover {
    background-color: #f8f8f8;
}

#moves-area {
    width: 300px;
    padding: 15px;
    border: 1px solid #ccc;
    background-color: #fff;
    max-height: 410px;
    overflow-y: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

#moves-area h2 {
    margin-top: 0;
    text-align: center;
    font-size: 1.2em;
    color: #333;
}

#moves-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

#moves-table th, #moves-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center;
}

#moves-table th {
    background-color: #e9e9e9;
    font-weight: bold;
}

#moves-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

#moves-table tbody tr:hover {
    background-color: #e0e0e0;
    cursor: pointer;
}

#moves-table.table-interaction-disabled tbody tr:hover {
    background-color: initial;
    cursor: not-allowed;
}

#results-container {
    margin-top: 30px;
    width: 90%;
    max-width: 900px;
    padding: 15px;
    border: 1px solid #ccc;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    overflow-x: auto;
}

#results-container h2 {
    margin-top: 0;
    text-align: center;
    font-size: 1.2em;
    color: #333;
}

#results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    table-layout: fixed;
}

#results-table th, #results-table td {
    border: 1px solid #ddd;
    padding: 6px;
    text-align: center;
    white-space: nowrap;
}

#results-table th:first-child, #results-table td:first-child {
    width: 120px;
    font-weight: bold;
}

#results-table th {
    background-color: #e9e9e9;
    font-weight: bold;
}

#results-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

#results-table .result-line {
    display: block;
    font-size: 0.85em;
    padding: 2px 0;
}


div[style*="text-align: center"] {
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 15px !important;
}

label {
    margin-right: 5px;
    font-weight: bold;
}
select, input[type="range"], button {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ccc;
    margin-right: 10px;
    font-size: 0.9em;
}
button {
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
button:hover {
    background-color: #0056b3;
}
button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
input[type="radio"] + label {
    font-weight: normal;
    margin-right: 15px;
}
fieldset {
    border-radius: 4px;
    padding: 10px !important;
}
legend {
    margin-left: 10px;
}

#game-end-message {
    padding: 10px;
    border-radius: 4px;
    background-color: #e6f7ff;
    border: 1px solid #91d5ff;
}

/* Estilos do Modal */
.modal {
    display: none; /* Escondido por defeito */
    position: fixed; /* Posição fixa */
    z-index: 1000; /* Fica no topo */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto; /* Adiciona scroll se necessário */
    background-color: rgba(0,0,0,0.5); /* Fundo preto com opacidade */
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; /* 10% do topo e centrado */
    padding: 20px 30px;
    border: 1px solid #888;
    width: 80%;
    max-width: 700px;
    border-radius: 8px;
    position: relative;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}

.modal-content h2, .modal-content h3 {
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
    margin-top: 10px;
}

.modal-content ul {
    list-style-position: inside;
    padding-left: 10px;
}

.modal-content li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close-button:hover,
.close-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}


#footer-iframe {
    width: 100%;
    border: none;
    display: block;
    overflow: hidden;

    /* Default height for single-line view */
    height: 30px;
}

/* Adjust height for two-line view on smaller screens */
@media (max-width: 768px) {
    #footer-iframe {
        height: 60px;
    }
}