* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 540px;
    background-color: #fbf5ec;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.screen.active {
    display: flex;
}

/* Help Modal Styles */
.help-modal-content {
    background-color: #cccccc;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 32px;
    color: #333;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    z-index: 10;
}

.close-btn:hover {
    color: #000;
}

.help-title {
    font-size: 20px;
    padding: 20px;
    padding-right: 50px;
    text-align: center;
    width: 100%;
    background-color: #bbbbbb;
    border-radius: 8px 8px 0 0;
}

.help-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    width: 100%;
}

#helpVideo {
    border-radius: 8px;
    margin-bottom: 20px;
    background-color: #000;
}

.help-text {
    font-size: 16px;
    text-align: center;
    line-height: 1.5;
    padding: 0 10px;
    min-height: 120px;
}

.help-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px;
    padding-bottom: 30px;
}

.nav-btn {
    font-size: 20px;
    font-weight: bold;
    padding: 8px 16px;
    border: none;
    background-color: #3f51b5;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.nav-btn:hover {
    background-color: #303f9f;
}

.page-indicator {
    font-size: 16px;
    min-width: 60px;
    text-align: center;
}

/* Game Window Styles */
.title-bar {
    width: 100%;
    background-color: #3f51b5;
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.title-text {
    font-size: 20px;
    font-weight: 500;
}

.menu-btn {
    background-color: #303f9f;
    color: white;
    border: 1px solid white;
    cursor: pointer;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    font-size: 14px;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    right: 16px;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 150px;
}

.menu-dropdown.hidden {
    display: none;
}

.menu-item {
    display: block;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-bottom: 1px solid #f0f0f0;
    background: none;
    text-align: left;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.menu-item:hover {
    background-color: #e8f0fe;
    color: #3f51b5;
}

.menu-item:first-child {
    border-radius: 8px 8px 0 0;
}

.menu-item:last-child {
    border-radius: 0 0 8px 8px;
    border-bottom: none;
}

.status-panel {
    width: 100%;
    padding: 12px 16px;
    display: flex;
    justify-content: space-around;
    font-size: 16px;
    background-color: #fbf5ec;
}

.board-container {
    width: 512px;
    height: 512px;
    position: relative;
    margin: 10px 0;
    border: 2px solid #8b7355;
}

.game-board {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.game-board td {
    width: 72px;
    height: 72px;
    text-align: center;
    vertical-align: middle;
    cursor: default;
    position: relative;
    background-color: #e8dcc8;
    border: 1px solid #c4b5a0;
}

/* Cells with clickable content show pointer cursor */
.game-board td:has(img),
.game-board td:has(.direction-arrow) {
    cursor: pointer;
}

/* board border */
.game-board td[data-row="0"],
.game-board td[data-row="6"],
.game-board td[data-col="0"],
.game-board td[data-col="6"] {
    background-color: #3f51b5;
    cursor: default;
}
/* center square */
.game-board td[data-row="3"][data-col="3"] {
    background-color: #ffb6c1;
}

.game-board img {
    width: 68px;
    height: 68px;
    display: block;
    margin: auto;
    pointer-events: none;
}

.direction-arrow {
    position: absolute;
    font-size: 32px;
    color: #3f51b5;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    text-shadow: 0 0 3px white, 0 0 5px white;
    user-select: none;
}

.arrow-up {
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.arrow-down {
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.arrow-left {
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.arrow-right {
    left: 2px;
    top: 50%;
    transform: translateY(-50%);
}

.button-panel {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    flex-wrap: wrap;
    justify-content: center;
}

.game-btn {
    padding: 8px 16px;
    border: none;
    background-color: #3f51b5;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.game-btn:hover:not(:disabled) {
    background-color: #303f9f;
}

.game-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.history-panel {
    padding: 10px 16px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 14px;
}

.hidden {
    display: none !important;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background-color: white;
    padding: 24px;
    border-radius: 8px;
    max-width: 460px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 16px;
    font-size: 18px;
}

.board-selection {
    margin-bottom: 20px;
}

.board-selection label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
}

.board-selection input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
}

.message-text {
    margin-bottom: 20px;
}

.message-text p {
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
    white-space: pre-line;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border: none;
    background-color: #3f51b5;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.modal-btn:hover {
    background-color: #303f9f;
}

/* Responsive Design */
@media (max-width: 530px) {
    .board-container {
        width: 100%;
        height: auto;
        aspect-ratio: 1;
    }

    .game-board {
        width: 100%;
        height: auto;
    }

    .screen {
        max-width: 100%;
    }
}
