body {
    font-family: sans-serif;
    margin: 20px;
    background-color: #f0f0f0;
    color: #333;
}

h1 {
    text-align: center;
    color: #555;
}

#chessboard-container {
    margin: 20px auto; /* Center the board */
    box-shadow: 0 0 10px rgba(0,0,0,0.2);
}

.controls, .info {
    /* text-align: center; */ /* For .controls, flexbox will handle centering */
    margin-top: 20px;
}

/* Specific styling for .controls as a flex container */
.controls {
    display: flex;
    justify-content: center; /* Center the group of items */
    align-items: center; /* Vertically align items within the flex line */
    flex-wrap: wrap; /* Allow items to wrap if not enough space */
}

/* Ensure .info still has text-align: center if it's not a flex container */
.info {
    text-align: center;
}

.controls button, .app-button {
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    display: inline-flex; /* For centering content */
    align-items: center; /* Center content vertically */
    justify-content: center; /* Center content horizontally */
    color: inherit;
    font: inherit;
}

.controls button {
    /* padding: 10px 15px; */ /* Replaced by fixed size and flex centering */
    width: 40px; /* Fixed width */
    height: 40px; /* Fixed height */
    margin: 5px;
    padding: 0; /* Remove padding if icon is to fill */
}

.app-button {
    height: 40px;
    padding: 0 14px;
}

.info select {
    /* padding: 10px 15px; */ /* Replaced by fixed size and flex centering */
    width: 40px; /* Fixed width */
    height: 40px; /* Fixed height */
    margin: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
}

.controls button.control-btn { /* More specific selector for icon buttons */
    /* Icon will be centered by flex properties above */
}

.icon {
  width: 24px; /* Icon size, button padding will create space around it if needed */
  height: 24px;
  fill: currentColor;
}

/* Allow #load-pgn-button (text button) to be wider */
#load-pgn-button {
    width: auto;         /* Override fixed width from .controls button */
    padding: 0 12px;     /* Add horizontal padding for the text */
    /* Inherits height: 40px and display: inline-flex for centered text, which is fine */
}

/* Allow #learn-side (select element) to be wider and look standard */
#learn-side {
    width: auto;         /* Override fixed width from .info select */
    padding: 0 8px;      /* Horizontal padding (typical for select elements) */
    display: inline-block; /* Revert to standard select element display behavior */
    text-align: left;    /* Ensure text is left-aligned, not centered by inline-flex */
    /* Inherits height: 40px, margin, border, etc. which are fine */
}

.controls button:not(:disabled):hover, .app-button:not(:disabled):hover, .info select:hover {
    background-color: #e9e9e9;
}

.controls button:disabled, .app-button:disabled {
    background-color: #e3e3e3;
    border-color: #b9b9b9;
    color: #8a8a8a;
    cursor: not-allowed;
    box-shadow: inset 0 0 0 1px #c6c6c6;
}

.controls button:disabled .icon {
    opacity: 0.6;
}

.lifebuoy-bands {
    fill: none;
}

#hint-button:not(:disabled) .lifebuoy-ring {
    fill: #c8c8c8;
}

#hint-button:not(:disabled) .lifebuoy-bands {
    fill: #c25450;
}

.move-info {
    text-align: center;
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    min-height: 1.5em; /* Ensure it has some height even when empty */
    font-family: monospace;
    font-size: 1.1em;
}

.player-names {
    text-align: center; /* Center the text within the div */
    margin: 10px auto; /* Center the div itself, similar to chessboard-container */
    width: 400px; /* Match the chessboard width for alignment */
    max-width: 100vw;
    font-size: 1.2em; /* Slightly larger font for names */
    font-weight: bold;
    color: #444;
    padding: 5px 0; /* Some vertical padding */
}

.move-info-wrapper {
    position: relative;
}

.hint-bubble {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: fit-content;
    max-width: calc(100% - 20px);
    padding: 8px 14px;
    background-color: #fff8c5;
    border: 1px solid #e0c96a;
    border-radius: 8px;
    color: #573a00;
    font-size: 1em;
    font-weight: 500;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    animation: hint-bubble-fade-in 0.2s ease-in;
    z-index: 10;
    box-sizing: border-box;
}

.hint-bubble::after {
    content: '';
    position: absolute;
    top: -7px;
    left: var(--arrow-x, 50%);
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background-color: #fff8c5;
    border-left: 1px solid #e0c96a;
    border-top: 1px solid #e0c96a;
}

@keyframes hint-bubble-fade-in {
    from { opacity: 0; transform: translateX(-50%) translateY(-4px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.copy-fen-container {
    position: relative; /* Establishes a positioning context for the feedback bubble */
    display: inline-block; /* To keep it in line with other buttons if needed, or adjust as part of flex layout */
}

.copy-feedback {
    display: block; /* Allow transitions by not being 'none'. Initially hidden by opacity/visibility. */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Center on the button */
    background-color: #4CAF50; /* Green background for success */
    color: white;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: bold;
    white-space: nowrap; /* Prevent text from wrapping */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 100; /* Ensure it's above other elements */
    pointer-events: none; /* So it doesn't interfere with button clicks */
    opacity: 0; /* For fade-in/out effect */
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

/* The hidden attribute must win over component display rules */
[hidden] {
    display: none !important;
}

/* Owner login link / logout button (top right of the library page) */
.account-control {
    max-width: 800px;
    margin: 0 auto;
    text-align: right;
}

.account-control form {
    display: inline;
}

.login-section {
    background-color: #fff;
    padding: 15px;
    margin: 20px auto;
    max-width: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

/* Upload Section Styles */
.upload-section {
    background-color: #fff;
    padding: 15px;
    margin: 20px auto;
    max-width: 800px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.upload-section h2 {
    margin-top: 0;
    color: #555;
    font-size: 1.3em;
}

.upload-instructions {
    color: #666;
    font-size: 0.95em;
    margin-bottom: 10px;
}

#pgn-text-input {
    width: 100%;
    height: 200px;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
    resize: vertical;
    box-sizing: border-box;
}

#pgn-text-input:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.upload-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

#choose-file-button, #upload-analyze-button {
    width: auto;
}

#selected-file-name {
    font-style: italic;
    color: #666;
    flex: 1;
    min-width: 150px;
}

.upload-status {
    margin-top: 10px;
    padding: 10px;
    border-radius: 4px;
    font-weight: bold;
}

.upload-status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.upload-status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.upload-status.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.upload-status-link {
    color: inherit;
    text-decoration: underline;
    font-weight: bold;
}

.upload-status-link:hover {
    opacity: 0.8;
}

.upload-progress {
    margin-top: 15px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background-color: #f0f0f0;
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid #ddd;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.progress-text {
    text-align: center;
    margin-top: 8px;
    font-size: 0.9em;
    color: #666;
}

.pgn-selection h2 {
    color: #555;
    font-size: 1.3em;
    margin-bottom: 10px;
}

/* Game Library Styles */
.game-library {
    max-width: 800px;
    margin: 30px auto;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.game-library h2 {
    color: #555;
    font-size: 1.5em;
    margin-top: 0;
    margin-bottom: 15px;
}

.game-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.game-list li {
    padding: 12px 15px;
    margin-bottom: 8px;
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.game-list li:hover {
    background-color: #e9f5ff;
}

.game-list a {
    text-decoration: none;
    color: #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.05em;
}

.game-list a:hover {
    color: #0066cc;
}

.game-name {
    font-weight: 500;
}

.game-meta {
    font-size: 0.9em;
    color: #666;
    margin-left: 10px;
}

.info-message, .error-message {
    padding: 12px;
    margin: 15px 0;
    border-radius: 4px;
    text-align: center;
}

.info-message {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Page Header Styles */
.page-header {
    position: relative;
    text-align: center;
    margin-bottom: 20px;
}

.back-link {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    text-decoration: none;
    color: #0066cc;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.back-link:hover {
    background-color: #e9f5ff;
}
