body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #f7f8fc;
    color: #333;
}

h1 {
    color: #1ca433;
    margin-bottom: 20px;
}

.hero-logo {
    width: 220px;
    height: auto;
    display: block;
    margin: 10px auto 0 auto;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.hero-logo:hover {
    transform: scale(1.05);
}

#game-container {
    background-color: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid #e8e8e8;
}

#grid-wrapper {
    position: relative;
    width: calc((60px + 5px) * 6 - 5px);
    height: calc((60px + 5px) * 6 - 5px);
    transform-origin: center center;
    transition: transform 0.8s ease-in-out;
    margin: 0 auto;
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

#grid {
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(6, 60px);
    grid-template-rows: repeat(6, 60px);
    gap: 5px;
}

.cell {
    width: 60px;
    height: 60px;
    background-color: #e0e0e0;
    border: 1px solid #dcdcdc;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s ease;
}

.stone {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.1);
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.2);
}

.cell:hover {
    background-color: #d5d5d5;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    font-weight: 500;
}

button:active {
    transform: scale(0.98);
}

#turn-indicator {
    font-size: 16px;
    font-weight: 500;
    color: #555;
    margin: 0;
}

.game-over-container {
    margin: 15px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

#game-over-text {
    font-size: 18px;
    font-weight: 500;
    color: #555;
}

.game-over-buttons {
    display: flex;
    gap: 10px;
}

#download-gif-btn {
    background-color: #8e44ad;
}

#download-gif-btn:hover {
    background-color: #71368a;
}

.game-over-btn {
    background-color: #1ca433;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    width: 100%;
    min-width: 120px;
}

.game-over-btn:hover {
    background-color: #158c2b;
}

.game-over-btn:active {
    transform: scale(0.98);
}

#analyze-btn {
    background-color: #007bff;
}

#analyze-btn:hover {
    background-color: #0056b3;
}

#share-gif-btn {
    background-color: #e74c3c;
}

#share-gif-btn:hover {
    background-color: #c0392b;
}

/* Grid easter egg styling */
.grid-easter-egg {
    cursor: pointer;
    transition: color 0.2s ease;
    position: relative;
}

.grid-easter-egg:hover {
    color: #3498db;
    text-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* Settings modal styling */
.settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex !important;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.settings-modal.hidden {
    display: none !important;
}

.settings-content {
    background-color: #2c3e50;
    border-radius: 10px;
    padding: 20px;
    min-width: 300px;
    max-width: 90%;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #34495e;
    padding-bottom: 10px;
}

.settings-header h3 {
    margin: 0;
    color: #ecf0f1;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: #bdc3c7;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.settings-body {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    color: #fff;
    font-weight: 500;
    font-size: 14px;
}

.log-controls {
    display: flex;
    gap: 10px;
}

.copy-logs-btn, .clear-logs-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-logs-btn {
    background-color: #3498db;
    color: white;
}

.copy-logs-btn:hover {
    background-color: #2980b9;
    transform: translateY(-1px);
}

.copy-logs-btn:active {
    transform: translateY(0);
}

.copy-logs-btn.copying {
    background-color: #27ae60;
}

.clear-logs-btn {
    background-color: #95a5a6;
    color: white;
}

.clear-logs-btn:hover {
    background-color: #7f8c8d;
    transform: translateY(-1px);
}

.clear-logs-btn:active {
    transform: translateY(0);
}

.log-stats {
    font-size: 11px;
    color: #bdc3c7;
    font-family: monospace;
    line-height: 1.4;
}

.setting-item span {
    color: #bdc3c7;
    font-family: monospace;
}

.new-game-btn {
    background-color: #1ca433;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.new-game-btn:hover {
    background-color: #158c2b;
}

.new-game-btn:active {
    transform: scale(0.98);
}

#countdown {
    font-weight: bold;
    color: #007bff;
    background-color: #eef5ff;
    padding: 4px 8px;
    border-radius: 6px;
}

#settings-icon {
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

#settings-icon:hover {
    background-color: #f0f0f0;
}

#settings-pane {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    padding: 25px 30px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 1001;
    width: 320px;
    text-align: center;
    border: 1px solid #e8e8e8;
}

#settings-content h2 {
    margin-top: 0;
    margin-bottom: 25px;
    color: #2c3e50;
}

.settings-actions {
    display: flex;
    justify-content: space-around;
    margin-top: 25px;
    margin-bottom: 20px;
}

#rotate-button, #reset-button {
    background-color: #f0f0f0;
    color: #333;
}

#rotate-button:hover, #reset-button:hover {
    background-color: #e0e0e0;
}

#close-settings {
    width: 100%;
    background-color: #007bff;
    color: white;
}

#close-settings:hover {
    background-color: #0056b3;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    z-index: 1000;
}

.hidden {
    display: none;
}
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 0 5px;
}
.top-left-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
    min-width: 140px;
}
.top-center-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
}
.gif-share-col { display:flex; flex-direction:column; align-items:center; gap:8px; }
.gif-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1ca433;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.top-center-display img {
    max-height: 120px;
    border-radius: 8px;
    border: 1px solid #ddd;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.top-center-display img:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
/* removed icon button styles; GIF itself is the share trigger */
.share-text {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    text-align: center;
    margin: 0;
    cursor: pointer;
    transition: color 0.2s ease;
}
.share-text:hover {
    color: #333;
}

.gameplay-status {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 12px;
    margin-bottom: 20px;
}

.rotation-info {
    display: flex;
    align-items: center;
    gap: 6px;
}
.control-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 10px 0;
}
select {
    padding: 10px;
    font-size: 16px;
    border-radius: 8px;
    border: 1px solid #ccc;
    background-color: #fff;
}

.version {
    margin-top: 20px;
    font-size: 12px;
    color: #aaa;
}

/* Mode Selection Styles */
.mode-selection {
    background-color: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid #e8e8e8;
    text-align: center;
    max-width: 500px;
    margin: 20px;
}

.mode-selection h2 {
    color: #1ca433;
    margin-bottom: 30px;
    font-size: 24px;
}

/* General color setting */
.color-setting {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 20px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}
.color-label { color:#666; font-weight:500; }
.color-radio { display:flex; align-items:center; gap:6px; }

/* AI mode custom block */
.ai-mode-block {
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    background-color: #f8f9fa;
}
.ai-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}
.ai-difficulty { display:flex; gap:14px; justify-content:center; }
.ai-diff-btn { min-width: 140px; }

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
    justify-content: center;
}

.mode-button {
    background-color: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 16px 20px;
    width: 100%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.mode-button:hover {
    background-color: #e9ecef;
    border-color: #1ca433;
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(28, 164, 51, 0.2);
}

.mode-button:active {
    transform: translateY(0);
}

.mode-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.mode-description {
    font-size: 14px;
    color: #666;
}

/* Hidden class for showing/hiding sections */
.hidden {
    display: none !important;
}

/* Waiting Room Styles */
.waiting-room {
    background-color: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
    border: 1px solid #e8e8e8;
    text-align: center;
    max-width: 500px;
    margin: 20px;
}

.waiting-content h2 {
    color: #1ca433;
    margin-bottom: 20px;
    font-size: 24px;
}

.waiting-status {
    font-size: 18px;
    color: #333;
    margin-bottom: 30px;
}

/* Spinner Animation */
.spinner {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}

.spinner-inner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1ca433;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Sharing Section */
.sharing-section {
    margin: 30px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.sharing-section p {
    margin-bottom: 15px;
    font-weight: 500;
    color: #333;
}

.link-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.guest-link-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
    font-family: monospace;
}

.copy-btn {
    padding: 12px 20px;
    background-color: #1ca433;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.copy-btn:hover {
    background-color: #158c2b;
}

.copy-btn:active {
    transform: translateY(1px);
}

.copy-feedback {
    color: #1ca433;
    font-size: 14px;
    font-weight: 500;
    margin-top: 5px;
}

/* Cancel Button */
.cancel-btn {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
    margin-top: 20px;
}

.cancel-btn:hover {
    background-color: #5a6268;
}

.cancel-btn:active {
    transform: translateY(1px);
}

/* Replay Controls */
.replay-controls {
    margin-top: 20px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.replay-info {
    margin-bottom: 15px;
}

#replay-step-info {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    padding: 8px 16px;
    background-color: white;
    border: 1px solid #bdc3c7;
    border-radius: 8px;
    display: inline-block;
}

.replay-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.replay-btn {
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    font-size: 20px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
}

.replay-btn:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.replay-btn:active {
    transform: translateY(0);
}

.replay-btn:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.replay-icon {
    line-height: 1;
}

.exit-replay-btn {
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.exit-replay-btn:hover {
    background-color: #c0392b;
}

.exit-replay-btn:active {
    transform: translateY(1px);
}