* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none; /* Vendor prefix for WebKit browsers */
    -moz-user-select: none;    /* Vendor prefix for Firefox */
    -ms-user-select: none;     /* Vendor prefix for Internet Explorer/Edge */
    user-select: none;         /* Standard property */
}

body {
    background-color: #f5f7fa;
    min-width: 340px;
    /*display: none;*/
}

.icon-bak {
    display: none;
    font-size: 1.1rem;
}

.container {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    margin: 0;
}

.control-container {
    width: 100%;
    background-color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    position: sticky; /* Make the controls sticky */
    top: 0; /* Stick to the top of the viewport */
    height: 48px;
    display: flex;
    z-index: 1; /* Higher than the main content */
    flex-direction: column;
}

.control-padding {
    padding-left: 224px;
}

/* Style for the dropdown */
#difficulty-select {
    margin: 0; /* Margin for spacing */
    padding: 0 0.5rem; /* Padding for better touch targets */
    border: 1px solid #ccc; /* Light border */
    border-radius: 12px; /* Rounded corners */
    background-color: #ffffff; /* White background */
    font-size: 0.9rem; /* Font size */
    cursor: pointer; /* Pointer cursor on hover */
    transition: border-color 0.3s ease; /* Smooth border color change */
}

/* Change border color on focus */
#difficulty-select:focus {
    border-color: #4dd0e1; /* Change border color on focus */
    outline: none; /* Remove default outline */
}

.fake-header {
    height: 48px;
    width: 100%;
}

.control-pane {
    background-color: white;
    z-index: 1000; /* Ensure it stays above other content */
}

.controls {
    margin: 0 auto;
    padding: 8px;
    background-color: white; /* Ensure background is white for visibility */
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    justify-content: space-between;
    width: 100%;
    max-width: 430px;
    height: 48px;
}

.custom-control-pane {
    display: none;
}

.custom-control {
    height: 48px;
    font-size: 0.9rem;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #4a5568;
    font-weight: 500;
    min-width: 60px;
}

.controls input {
    padding: 0.3rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s ease;
    flex: 0 1 50px;
    font-size: 0.9rem;
    width: auto;
    max-width: 60px;
}

.controls input[type="number"]:focus {
    border-color: #3b82f6;
}

button {
    background-color: #f0f4ff;
    color: #3b82f6;
    border: none;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 40px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

button.hover::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 1010;
    transform: translate(0%, 150%);
    background: white;
    border-radius: 6px;
    width: fit-content;
    display: flex;
    padding: 0.2rem;
    border: 1px solid black;
    color: black;
    font-size: 0.8rem;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

button.tip-left.hover::after {
    transform: translate(-50%, 150%);
}

button.tip-right.hover::after {
    transform: translate(50%, 150%);
}

button.tip-top.hover::after {
    transform: translate(-50%, 50%);
}

button.tip-up.hover::after {
    transform: translate(50%, -150%);
}

button.clicked.hover {
    background-color: #f0f4ff;
    transform: translateY(0);
}

button.hover {
    background-color: #e0e7ff;
    transform: translateY(-1px);
}

button:active {
    transform: scale(0.95);
}

button:disabled {
    background-color: #8B8B8B;
    color: white;
    cursor: not-allowed;
}

/* for some icon which looks smaller */
.button-image-scale {
    transform: scale(1.2);
}

.main-content {
    display: flex;
}

.fake-left-rail {
    width: 224px;
    min-width: 224px;
}

.fake-left-rail.hidden {
    display: none;
}

#fake-game-header {
    display: none;
}

.game-section {
    display: flex;
    flex-direction: column;
    flex: 1; /* Allow the game section to take the remaining space */
    padding: 0.5rem 7px;
}

.game-container {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
}

.player-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    row-gap: 1rem;
}

#player1-info {
    order: 1;
}

#player1-board {
    order: 2;
}

/* Add visual separation between players */
.player-section:first-child {
    margin-right: auto;
}

.player-section:last-child {
    margin-left: auto;
}

.player-section.hidden {
    display: none;
}

.player-info {
    width: 100%;
    max-width: 345px;
    padding: 6px 10px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    text-align: center;
    box-sizing: border-box;
    border: 2px solid transparent;
}

.player-info h2 {
    color: #4a5568;
    font-size: 1.1rem;
}

.player-status {
    height: 32px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.join-game-btn {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    min-width: 40px;
    height: 24px;
    display: none;
}

.game-status {
    display: flex;
}

.player-info .player-action,
.player-info .progress-status,
.player-info .mines-count,
.player-info .timer {
    color: #4a5568;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex: 1;
}

.player-info .timer {
    justify-content: center;
}

.player-info .progress-status {
    justify-content: right;
}

.player-info.winner {
    background-color: #f0fdf4;
    border: 2px solid #10b981;
}

.player-info.winner h2 {
    color: #10b981;
}

.player-info.loser {
    background-color: #f8d7da;
    border: 2px solid #ef4444;
}

.player-info.loser h2 {
    color: #ef4444;
}

.player-alias {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.player-alias input {
    padding: 0.3rem;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s ease;
    flex: 0 1 50px;
    font-size: 0.9rem;
    width: auto;
    max-width: 160px;
}

.player-alias input:focus {
    border-color: #3b82f6;
}

#btn-player2-name {
    cursor: pointer; /* Change cursor to pointer on hover */
    transition: color 0.3s; /* Smooth transition for color change */
}

#btn-player2-name.hidden {
    display: none;
}

#btn-player2-name.hover {
    color: #4376F8; /* Change color on hover */
}

#btn-player2-name.hover::after {
    content: attr(data-tip);
    position: absolute;
    z-index: 1010;
    transform: translate(0%, 25%);
    background: white;
    border-radius: 6px;
    width: fit-content;
    display: flex;
    padding: 0.2rem;
    border: 1px solid black;
    color: black;
    font-size: 0.8rem;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.board-container {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    overflow: auto;
    width: 345px;
    position: relative;
}

.board {
    display: table;
    border-collapse: separate;
    border-spacing: 1px;
    background-color: white;
    margin: auto;
    padding: 10px;
    border-radius: 12px;
    table-layout: fixed;
    width: 100%;
}

.row {
    display: table-row;
}

.cell {
    display: table-cell;
    width: 35px;
    height: 35px;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
    border-radius: 6px;
    transition: all 0.1s ease-out;
    user-select: none;
}

.cell.hidden {
    background-color: #e2e8f0;
}

.revealed {
    background-color: #f8fafc;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.mine {
    background-color: #ef4444;
    color: white;
}

.flagged {
    background-color: #fbbf24;
    color: white;
}

.flagged.tipped {
    border: 2px solid #10b981;
}

.flag-animation {
    animation: flagInsert 0.5s ease-in-out;
}

@keyframes flagInsert {
    from {
        transform: translateY(-100%) scale(0.5);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.label-mine {
    /*#f20707*/
    background: #ef4444;
    border-radius: 50%;
    border: 1px solid gray;
    margin: 5px;
    width: 25px;
    height: 25px;
}

.label-empty {
    background: #10b981;
    border-radius: 50%;
    border: 1px solid gray;
    margin: 5px;
    width: 25px;
    height: 25px;
}

.label-empty-shine {
    background: #10b981;
    border-radius: 50%;
    border: 1px solid gray;
    margin: 5px;
    width: 25px;
    height: 25px;
    animation: shine 0.5s;
}

/* Modern colors for numbers */
.neighbor-1 { color: #3b82f6; }  /* Blue */
.neighbor-2 { color: #10b981; }  /* Green */
.neighbor-3 { color: #ef4444; }  /* Red */
.neighbor-4 { color: #6366f1; }  /* Indigo */
.neighbor-5 { color: #7c3aed; }  /* Purple */
.neighbor-6 { color: #0ea5e9; }  /* Sky */
.neighbor-7 { color: #475569; }  /* Slate */
.neighbor-8 { color: #64748b; }  /* Gray */

.highlight {
    background-color: #93c5fd;
    transform: scale(0.95);
}

.highlight-shine {
    animation: shine 0.5s ease-in-out;
}

@keyframes shine {
    0% {
        background-color: #e2e8f0;
    }
    50% {
        background-color: #93c5fd;
        transform: scale(0.95);
    }
    100% {
        background-color: #e2e8f0;
    }
}

.cell:active {
    transform: scale(0.95);
}

.revealed:active {
    background-color: #f1f5f9;
}

.mask {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 1;
    margin-top: 48px;
}

.mask.show {
    display: block;
}

/* Add modal styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 1001;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: white;
    margin: 1rem;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    text-align: center;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-content h2 {
    color: #4a5568;
    font-size: 1.5rem;
    margin: 0;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.left-rail {
    width: 224px; /* Fixed width for the left rail */
    background-color: #f7f9fc; /* Light gray background color for a softer look */
    box-shadow: 4px 0 6px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    height: 100vh; /* Full height of the viewport */
    position: fixed;
    top: 0; /* Stick to the top of the viewport */
    left: 0;
    overflow-y: auto; /* Allow scrolling if content overflows */
    transition: transform 0.3s ease; /* Smooth transition for hiding */
    transform: translateX(0); /* Show by default on larger screens */
    z-index: 999; /* Ensure it stays above other content */
}

.left-rail.show {
    transform: translateX(0); /* Show the rail */
}

.left-rail.hidden {
    transform: translateX(-105%); /* Hide the rail off-screen */
}

.game-category {
    margin: auto;
}

.category-header {
    cursor: pointer;
    font-weight: bold;
    background-color: #e7f3ff;
    padding: 1rem 0.7rem 1rem;
    border-top: 1px solid #b0bec5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-header.hover {
    background-color: #e0e0e0; /* Change background color on hover */
    color: #333; /* Change text color on hover */
    font-weight: bold; /* Keep text bold on hover */
}

.arrow {
    height: 20px;
    transition: transform 0.5s; /* Smooth transition for rotation */
}

.arrow.up {
    transform: rotate(180deg); /* Rotate arrow for up direction */
}

.game-list {
    list-style-type: none;
}

.game-list.hidden {
    display: none; /* Hide the game list by default */
}

.game-text {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.game-action {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.game-action.hidden {
    display: none;
}

.game-action button {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    min-width: 30px;
    height: 24px;
}

.game-item {
    background-color: #f0f4ff; /* Light gray background for game items */
    padding: 1rem 0.7rem 1rem 1rem; /* Padding for spacing */
    cursor: pointer; /* Pointer cursor on hover */
    transition: background-color 0.3s ease; /* Smooth background color change */
    border-top: 1px solid #b0bec5; /* Light top border */
    width: 100%; /* Make the item take full width */
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 54px;
}

.game-item.hover {
    background-color: #e0e0e0; /* Slightly darker gray on hover for better visibility */
}

.current-game {
    background-color: #a5d6a7; /* Soft green background for current game */
    color: #1b5e20; /* Dark green text color */
    font-weight: bold; /* Make text bold for emphasis */
    cursor: default; /* Default cursor for non-clickable */
    pointer-events: none; /* Disable pointer events */
}

.game-control-pane {
    height: 64px;
    display: flex;
    gap: 1rem;
    padding: 1rem; /* Padding for the control pane */
    background-color: #f0f4ff; /* Light blue background for a cohesive look */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05) inset;
}

.online-player {
    height: 54px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.7rem 1rem;
    background-color: #f0f4ff;
    border-top: 1px solid #b0bec5;
}

#tool-container {
    display: flex;
    width: 100%;
    padding: 0.5rem 0;
}

#tool-container.hidden {
    display: none;
}

#tool-bar {
    display: flex;
    width: 345px;
    height: 32px;
    gap: 1rem;
    margin: auto;
    border-radius: 12px;
    align-items: center;
    justify-content: center;
}

.my-progress {
    display: flex;
    width: 100%;
    padding: 0.2rem 0;
}

#progress-container {
    display: flex;
    width: 100%;
    padding: 0.5rem 0;
}

#progress-container.hidden {
    display: none;
}

#progress-bar {
    display: flex;
    width: 345px;
    height: 52px;
    gap: 1rem;
    padding: 10px;
    margin: auto;
    background: white;
    border-radius: 12px;
}

#game-progress {
    width: 100%;
    height: 32px;
}

.replay-cursor {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 50%;
    border: 1px solid gray;
    background: white;
    margin: 5px;
    width: 25px;
    height: 25px;
    opacity: 0.6; /* Make it slightly transparent */
    pointer-events: none; /* Prevent it from interfering with mouse events */
    transition: transform 0.5s ease; /* Add transition for smooth movement */
    z-index: 1; /* higher than visualization */
}

/* Add responsive design */
@media (max-width: 1000px) {
    .game-container {
        flex-direction: column;
        align-items: center;
    }

    .player-section {
        margin: 0 !important;
        width: 100%;
    }

    #player1-info {
        order: 2;
    }

    #player1-board {
        order: 1;
    }
}

@media (max-width: 650px) {
    .left-rail {
        width: 224px;
        transform: translateX(-105%); /* Hide off-screen by default */
    }
    .left-rail.show {
        transform: translateX(0); /* Show the rail */
    }
    .fake-left-rail {
        width: 0px;
        min-width: 0px;
    }
    .control-padding {
        padding-left: 0px;
    }
}

@media (max-width: 430px) {
    .controls input {
        width: auto;
        max-width: 58px;
    }
}

@media (max-width: 420px) {
    .controls input {
        width: auto;
        max-width: 56px;
    }
}

@media (max-width: 410px) {
    .controls input {
        width: auto;
        max-width: 54px;
    }
}

@media (max-width: 400px) {
    .controls input {
        width: auto;
        max-width: 52px;
    }
}

@media (max-width: 390px) {
    .controls input {
        width: auto;
        max-width: 50px;
    }
}

@media (max-width: 375px) {
    .controls input {
        width: auto;
        max-width: 44px;
    }
}

@media (max-width: 350px) {
    .controls input {
        width: auto;
        max-width: 40px;
    }
}