body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background-color: #f0f0f0;
    color: #333;
    padding-top: 70px;
    padding-bottom: 30px;
}

.common-navigation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: #2c3e50;
    padding: 10px 0;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
}

.common-navigation a {
    color: #ecf0f1;
    margin: 0 20px;
    text-decoration: none;
    font-size: 1em;
    padding: 8px 15px;
    border-radius: 4px;
    transition: background-color 0.3s, color 0.3s;
}

.common-navigation a:hover {
    background-color: #3498db;
    color: #fff;
    text-decoration: none;
}

.container {
    background-color: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    width: 90%;
    max-width: 450px; /* 盤面の最大サイズを考慮 */
    margin-top: 20px;
}

h1 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.game-setup-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
    gap: 10px; /* Flexboxのgapプロパティで間隔調整 */
    flex-wrap: wrap; /* 画面幅が狭い場合に折り返し */
}

.game-setup-controls label {
    font-weight: bold;
    margin-right: 5px;
}

#boardSizeSelect {
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ced4da;
    font-size: 0.9em;
}

#newGameButton {
    padding: 8px 15px;
    font-size: 0.9em;
    background-color: #28a745; /* Green for new game */
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#newGameButton:hover {
    background-color: #218838;
}


.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px; /* Reduced margin */
    font-size: 0.95em; /* Slightly smaller */
    background-color: #e9ecef;
    padding: 8px 12px; /* Reduced padding */
    border-radius: 4px;
}

.game-info div {
    margin: 0 5px;
}
.game-info .highscore-display {
    font-size: 0.9em;
    color: #6c757d;
}

.control-button-ingame { /* For reset button etc. */
    font-size: 0.8em;
    padding: 6px 10px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.control-button-ingame:hover {
    background-color: #5a6268;
}


.puzzle-board-container {
    display: flex;
    justify-content: center;
    margin-bottom: 15px; /* Reduced margin */
    height: auto; /* Let JS control height based on tiles */
}

.puzzle-board {
    display: grid;
    border: 3px solid #555; /* Thicker border for board */
    border-radius: 5px;
    background-color: #777; /* Darker background for board */
    padding: 5px;
    box-shadow: inset 0 0 8px rgba(0,0,0,0.3);
    /* Width and height will be set by JS for flexibility */
    /* Example: Fixed total board width for consistency, tile size adjusts */
    /* width: 300px;
       height: 300px; */
}

/* Grid definitions for different sizes */
.puzzle-board.size-3x3 { grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 4px; }
.puzzle-board.size-4x4 { grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); gap: 4px; }
.puzzle-board.size-5x5 { grid-template-columns: repeat(5, 1fr); grid-template-rows: repeat(5, 1fr); gap: 3px; }
.puzzle-board.size-6x6 { grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(6, 1fr); gap: 3px; }

.tile {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #4a90e2; /* A nice blue */
    color: white;
    font-weight: bold;
    border-radius: 3px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s, transform 0.15s ease-out;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    /* Font size and tile dimensions (width/height) will be set by JS */
}

.tile:hover {
    background-color: #357abd;
}
.tile:active {
    transform: scale(0.96);
}

.tile.empty {
    background-color: #9e9e9e; /* Grey for empty */
    cursor: default;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.2);
}
.tile.empty:hover {
    background-color: #9e9e9e;
}
.tile.empty:active {
    transform: none;
}

.controls {
    margin-top: 10px;
    min-height: 2em;
}

#messageDisplay {
    font-size: 1.1em;
    font-weight: bold;
    color: #28a745;
}

.hidden {
    display: none !important;
}

.rules-container {
    margin-top: 20px;
    padding: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #f9f9f9;
    text-align: left;
}
.rules-container h2 {
    text-align: center;
    color: #2c3e50;
    margin-top: 0;
}
.rules-container ul, .rules-container p {
    padding-left: 10px;
    margin-bottom: 8px;
}
.rules-container li {
    margin-bottom: 5px;
}
#externalLinkPlaceholder {
    font-style: italic;
    color: #777;
}

.rules-toggle-button, #toggleRulesButton {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 15px;
    font-size: 0.9em;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}

.rules-toggle-button:hover, #toggleRulesButton:hover {
    background-color: #2980b9;
}
