/* Reset e configurações básicas */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 10px;
}

header p {
    margin-top: -1rem;
    margin-bottom:1rem;
    color: rgb(188, 246, 255);
}

header h1 {
    color: white;
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

nav {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.nav-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.nav-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.nav-btn.active {
    background: white;
    color: #667eea;
    font-weight: bold;
}

/* Main content */
main {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    overflow: hidden;
}

.mode {
    display: none;
    padding: 30px;
}

.mode.active {
    display: block;
}

/* Home Mode */
.home-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.welcome-section {
    margin-bottom: 40px;
}

.welcome-section h2 {
    color: #667eea;
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.welcome-section p {
    font-size: 1.2rem;
    color: #666;
    line-height: 1.6;
}

.creator-info {
    font-size: 1rem !important;
    margin-top: 15px;
    padding: 15px;
    background: #f0f7ff;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.creator-info a {
    color: #667eea;
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s ease;
}

.creator-info a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.home-actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 1rem 0 2rem 0;
}

.primary-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 25px rgba(102, 126, 234, 0.4);
}

.secondary-btn {
    padding: 15px 30px;
    font-size: 1.2rem;
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-3px);
}

.game-rules {
    text-align: left;
    background: #f8f9fa;
    padding: 30px;
    border-radius: 15px;
    margin-top: 20px;
}

.game-rules h3 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

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

.game-rules li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
    color: #555;
    line-height: 1.5;
}

.game-rules li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4caf50;
    font-weight: bold;
}

/* Editor Layout */
/* Editor mode specific container styling */
#editorMode .container {
    width: 100% !important;
    margin: 0 !important;
    max-width: none !important;
}

.editor-mode #container {
    max-width: none;
    width: 100%;
    margin: 0;
}

.editor-layout {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

/* Editor Controls Header */
.editor-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #667eea;
}

.editor-controls-header h2 {
    margin: 0;
    color: #667eea;
    font-size: 1.3rem;
}

.help-button {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-button:hover {
    background: #667eea;
    color: white;
    transform: scale(1.1);
}

/* Editor Controls */
.editor-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 300px;
    max-width: 350px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.grid-size-controls, .editor-tools, .area-tools, .auto-tools, .area-manager {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Area Tools Fold Menu */
.area-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.area-tools-header h3 {
    margin: 0;
    color: #667eea;
}

.fold-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    color: #667eea;
    transition: transform 0.3s ease;
    transform: rotate(-90deg);
}

.fold-toggle.expanded {
    transform: rotate(0deg);
}

.area-tools-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.area-tools-content.expanded {
    max-height: 300px;
    margin-top: 10px;
}

.operation-selector {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Auto Tools Fold Menu */
.auto-tools-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.auto-tools-header h3 {
    margin: 0;
    color: #667eea;
}

.auto-tools-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.auto-tools-content.expanded {
    max-height: 300px;
    margin-top: 10px;
}

.operation-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.operation-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

.operation-checkboxes label:hover {
    background-color: #e3f2fd;
}

.operation-checkboxes input[type="checkbox"] {
    cursor: pointer;
    transform: scale(1.1);
}

#generateAreasBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    margin-top: 5px;
}

#generateAreasBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.batch-generation {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #ddd;
}

.batch-generation h4 {
    margin: 0 0 10px 0;
    color: #667eea;
    font-size: 14px;
    font-weight: 600;
}

.batch-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.batch-controls label {
    font-size: 13px;
    color: #555;
    white-space: nowrap;
}

#batchCount {
    width: 80px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

#generateBatchBtn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
}

#generateBatchBtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.batch-results {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 10px;
    margin: 0;
    font-family: 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-line;
    word-break: break-all;
}

/* Area Manager */
.area-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.area-manager-header h3 {
    margin: 0;
    color: #667eea;
    font-size: 1rem;
}

.area-manager-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.area-manager-content.expanded {
    max-height: 400px;
    margin-top: 10px;
}

.area-list-header {
    display: grid;
    grid-template-columns: 1fr 60px 80px 90px;
    gap: 8px;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 6px;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9rem;
}

[data-theme="dark"] .area-list-header {
    background: #3d3d3d;
    color: #e0e0e0;
}

.area-header-cell {
    text-align: center;
    color: #555;
}

.area-list {
    max-height: 300px;
    overflow-y: auto;
}

.area-item {
    display: grid;
    grid-template-columns: 1fr 60px 80px 90px;
    gap: 8px;
    padding: 8px;
    background: #fff;
    border-radius: 4px;
    margin-bottom: 4px;
    border: 1px solid #ddd;
}

.area-anchor {
    font-weight: 600;
    color: #333;
    text-align: center;
    padding: 4px;
}

.area-operation select {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: white;
    color: #333;
    font-size: 14px;
    cursor: pointer;
}

.area-operation select:focus {
    outline: none;
    border-color: #007acc;
}

.area-target input {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background-color: white;
    color: #333;
    font-size: 14px;
    text-align: center;
}

.area-target input:focus {
    outline: none;
    border-color: #007acc;
}

.area-actions {
    display: flex;
    gap: 4px;
    justify-content: center;
    align-items: center;
}

.recalc-area-btn, .delete-area-btn {
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
    color: #666;
    min-width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recalc-area-btn:hover {
    background-color: #007acc;
    color: white;
}

.delete-area-btn:hover {
    background-color: #ff4444;
    color: white;
}

.recalc-all-container {
    margin-top: 10px;
    text-align: center;
}

.recalc-all-btn {
    background: #007acc;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    width: 100%;
}

.recalc-all-btn:hover {
    background: #005f99;
}

.area-item:hover {
    background: #f8f9fa;
    border-color: #667eea;
}

.area-anchor {
    font-family: monospace;
    font-size: 0.9rem;
    color: #333;
}

.area-operation {
    text-align: center;
}

.area-operation select {
    width: 50px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.8rem;
}

.area-target {
    text-align: center;
}

.area-target input {
    width: 60px;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    text-align: center;
    font-size: 0.9rem;
}

.area-actions {
    text-align: center;
}

.delete-area-btn {
    background: #ff4757;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.delete-area-btn:hover {
    background: #ff3838;
    transform: scale(1.1);
}

/* Dark mode support for area manager */
@media (prefers-color-scheme: dark) {
    .area-manager-header h3 {
        color: #9ca3af;
    }
    
    .area-list-header {
        background: #374151;
    }
    
    .area-header-cell {
        color: #d1d5db;
    }
    
    .area-item {
        background: #1f2937;
        border-color: #374151;
    }
    
    .area-item:hover {
        background: #374151;
        border-color: #667eea;
    }
    
    .area-anchor {
        color: #e5e7eb;
    }
    
    .area-operation select, .area-target input {
        background: #374151;
        border-color: #4b5563;
        color: #e5e7eb;
    }
}

/* Player Controls */
.player-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.timer-container {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    font-weight: bold;
}

.timer-label {
    color: #667eea;
}

#timer {
    background: #667eea;
    color: white;
    padding: 8px 16px;
    border-radius: 10px;
    min-width: 80px;
    text-align: center;
}

.player-tools {
    display: flex;
    gap: 10px;
}

/* Buttons */
button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

select, input[type="number"], input[type="text"], textarea {
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: border-color 0.3s ease;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: #667eea;
}

/* Specific styling for seed input */
#seedInput {
    width: 100%;
    min-height: 80px;
    resize: vertical;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
}

/* Game Container */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    /* min-height: 400px; */
}

/* Grid */
.grid {
    display: inline-grid;
    gap: 2px;
    background: #000;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    max-width: 60dvh;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
}

.grid-cell {
    width: 100%;
    height: 100%;
    background: #2c2c2c;
    border: 4px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 3rem;
    min-height: 3rem;
    font-weight: bold;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    box-sizing: border-box;
    color: white;
}

.grid-cell:hover {
    background: #3a3a3a;
    border-color: #777;
}

.grid-cell.selected {
    background: #4a4a4a;
    border-color: #fff;
    box-shadow: 0 0 0 2px #fff;
}

.grid-cell.selection-error {
    background: #000 !important;
    border-color: #f44336 !important;
    box-shadow: 0 0 0 2px #f44336 !important;
}

.grid-cell.duplicate {
    background: #ffebee;
    border-color: #f44336;
    color: #f44336;
}

.grid-cell input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    outline: none;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: #fff;
}

.grid-cell input:read-only {
    cursor: pointer;
}

.grid-cell input:focus:not(:read-only) {
    background: rgba(255, 255, 255, 0.1);
    cursor: text;
}

.grid-cell input:not(:read-only) {
    background: rgba(255, 255, 255, 0.05);
    cursor: text;
}

/* Player mode cell value display */
.grid-cell .cell-value {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Flash effect for player cells */
.grid-cell.cell-flash {
    background: #fff !important;
    transition: background 0.05s ease;
}

.grid-cell.cell-flash .cell-value {
    color: #000 !important;
}

.grid-cell.cell-flash .area-label {
    color: #000 !important;
}

.grid-cell .area-label {
    position: absolute;
    top: -4px;
    left: -4px;
    font-size: 1.5rem;
    opacity: 0.5;
    font-weight: bold;
    color: #fff;
    background: rgba(0,0,0,0.8);
    padding: 1px 4px;
    border-radius: 3px;
    border: 1px solid #666;
}

/* Area border styles - territory-like borders */
/* All grid cells start with thick borders that will be colored based on area */

/* Area colors for borders using CSS custom properties */
.grid-cell.area-1 { --area-color: #f44336; }
.grid-cell.area-2 { --area-color: #4caf50; }
.grid-cell.area-3 { --area-color: #2196f3; }
.grid-cell.area-4 { --area-color: #ff9800; }
.grid-cell.area-5 { --area-color: #9c27b0; }
.grid-cell.area-6 { --area-color: #00bcd4; }
.grid-cell.area-7 { --area-color: #8bc34a; }
.grid-cell.area-8 { --area-color: #ff5722; }
.grid-cell.area-9 { --area-color: #795548; }
.grid-cell.area-10 { --area-color: #607d8b; }
.grid-cell.area-11 { --area-color: #e91e63; }
.grid-cell.area-12 { --area-color: #3f51b5; }
.grid-cell.area-13 { --area-color: #009688; }
.grid-cell.area-14 { --area-color: #cddc39; }
.grid-cell.area-15 { --area-color: #ffc107; }
.grid-cell.area-16 { --area-color: #673ab7; }
.grid-cell.area-17 { --area-color: #e57373; }
.grid-cell.area-18 { --area-color: #81c784; }
.grid-cell.area-19 { --area-color: #64b5f6; }
.grid-cell.area-20 { --area-color: #ffb74d; }

/* Territory border classes - only applied to external borders */
.grid-cell.border-top { border-top-color: var(--area-color); }
.grid-cell.border-right { border-right-color: var(--area-color); }
.grid-cell.border-bottom { border-bottom-color: var(--area-color); }
.grid-cell.border-left { border-left-color: var(--area-color); }

/* Remove internal borders between cells of the same area */
.grid-cell:not(.border-top) { border-top: none; }
.grid-cell:not(.border-right) { border-right: none; }
.grid-cell:not(.border-bottom) { border-bottom: none; }
.grid-cell:not(.border-left) { border-left: none; }

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 2rem;
}

.modal-content h3 {
    color: #667eea;
    margin-bottom: 20px;
}

.modal-content p {
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* Difficulty Modal */
.difficulty-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.difficulty-btn {
    padding: 15px 20px;
    font-size: 1.1rem;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

.difficulty-btn.easy {
    background: #4caf50;
    color: white;
}

.difficulty-btn.easy:hover {
    background: #45a049;
    transform: translateY(-2px);
}

.difficulty-btn.beginner {
    background: #8bc34a;
    color: white;
}

.difficulty-btn.beginner:hover {
    background: #7cb342;
    transform: translateY(-2px);
}

.difficulty-btn.medium {
    background: #ff9800;
    color: white;
}

.difficulty-btn.medium:hover {
    background: #f57c00;
    transform: translateY(-2px);
}

.difficulty-btn.hard {
    background: #f44336;
    color: white;
}

.difficulty-btn.hard:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

.difficulty-btn.challenge {
    background: #673ab7;
    color: white;
}

.difficulty-btn.challenge:hover {
    background: #5e35b1;
    transform: translateY(-2px);
}

.difficulty-btn.infinite {
    background: #9c27b0;
    color: white;
    grid-column: 1 / -1;
}

.difficulty-btn.infinite:hover {
    background: #7b1fa2;
    transform: translateY(-2px);
}

#gameIdInput {
    width: 100%;
    margin-bottom: 20px;
}

/* Seed URL Container */
.seed-url-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.seed-url-container input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #f8f9fa;
}

.seed-url-container button {
    padding: 8px 16px;
    white-space: nowrap;
}

/* Custom Game Modal */
.custom-config-section {
    margin-bottom: 25px;
}

.custom-config-section h3 {
    margin-bottom: 15px;
    color: #ddd;
    font-size: 1.1rem;
}

.grid-size-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.grid-size-btn {
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    background: white;
    color: #333;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.grid-size-btn:hover:not(:disabled) {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-1px);
}

.grid-size-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.grid-size-btn:disabled {
    cursor: not-allowed;
    opacity: 0.8;
}

.custom-operations {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.custom-operations label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.custom-operations label:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.custom-operations input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.operation-label {
    font-weight: bold;
    font-size: 1rem;
}

.operation-label.add { color: #28a745; }
.operation-label.subtract { color: #fd7e14; }
.operation-label.multiply { color: #6f42c1; }
.operation-label.divide { color: #17a2b8; }

footer {
    width: 100%;
    text-align: center;
    margin-top: 2rem;
    font-size: 0.8rem;
}

footer img{
    margin-top: 0.3rem;
}

#playerMode footer{
    color: #fff;
}

#playerMode footer a{
    color: #010506;
}

.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .editor-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .editor-controls {
        max-width: none;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .editor-controls {
        padding: 15px;
    }
    
    .player-controls {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px;
    }
    
    .player-tools {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .grid-cell {
        /* width: 50px;
        height: 50px;
        font-size: 1rem; */
    }
    
    .grid-cell input {
        font-size: 1.3rem;
    }
    
    .grid-cell .cell-value {
        /* font-size: 1.3rem; */
    }
    
    .modal-content {
        padding: 20px;
        width: 95%;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .home-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .difficulty-buttons {
        grid-template-columns: 1fr;
    }
    
    .timer-container {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .grid-cell {
        /* width: 40px;
        height: 40px;
        font-size: 0.9rem; */
    }
    
    .grid-cell input {
        font-size: 1.1rem;
    }
    
    .grid-cell .cell-value {
        /* font-size: 1.1rem; */
    }
    
    .grid-cell .area-label {
        font-size: 0.6rem;
        top: 1px;
        left: 2px;
        padding: 0 2px;
    }
    
    .nav-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    button {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
    
    .mode {
        padding: 15px;
    }
    
    .timer-container {
        font-size: 1rem;
    }
    
    #timer {
        padding: 6px 12px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .grid-cell {
        /* width: 35px;
        height: 35px;
        font-size: 0.8rem; */
    }
    
    .grid-cell input {
        font-size: 1rem;
    }
    
    .grid-cell .cell-value {
        /* font-size: 1rem; */
    }
    
    .container {
        padding: 5px;
    }
    
    .modal-content {
        padding: 15px;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .grid-cell {
        border-width: 3px;
    }
    
    .nav-btn {
        border: 2px solid white;
    }
    
    .nav-btn.active {
        border-color: #667eea;
    }
}

/* Solution Verification */
.solution-verification {
    margin-top: 20px;
    width: 100%;
    max-width: 800px;
}

.solution-verification.hidden {
    display: none;
}

.solution-message {
    text-align: center;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.1rem;
}

.solution-message.valid {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

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

.solution-grids {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

.solution-grid {
    display: inline-grid;
    gap: 1px;
    background: #ddd;
    border: 2px solid #999;
    border-radius: 4px;
    padding: 2px;
}

.solution-grid-cell {
    width: 16px;
    height: 16px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: #333;
}

.solution-grid-title {
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
    margin-bottom: 5px;
    color: #666;
}

/* Dark mode support for solution verification */
@media (prefers-color-scheme: dark) {
    .solution-message.valid {
        background-color: #1e4620;
        color: #84c88a;
        border-color: #2d5a31;
    }

    .solution-message.invalid {
        background-color: #4a1e1e;
        color: #f5a6a6;
        border-color: #5a2d2d;
    }

    .solution-grid {
        background: #555;
        border-color: #777;
    }

    .solution-grid-cell {
        background: #333;
        color: #eee;
    }

    .solution-grid-title {
        color: #ccc;
    }
}

/* Operation Indicator */
.operation-indicator-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.operation-indicator {
    width: 80px;
    height: 80px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.operation-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.operation-indicator:hover::before {
    opacity: 1;
}

.operation-symbol {
    font-size: 2.5rem;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    z-index: 1;
    position: relative;
}

/* Operation Colors */
.operation-add {
    background: linear-gradient(135deg, #28a745, #20c997);
}

.operation-subtract {
    background: linear-gradient(135deg, #fd7e14, #ffc107);
}

.operation-multiply {
    background: linear-gradient(135deg, #6f42c1, #e83e8c);
}

.operation-divide {
    background: linear-gradient(135deg, #17a2b8, #007bff);
}

.operation-indicator.pulse {
    animation: operationPulse 0.6s ease;
}

@keyframes operationPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* Victory Wave Animation */
.victory-wave {
    animation: victoryWave 1s ease-in-out;
}

@keyframes victoryWave {
    0% { 
        background-color: #fff3cd;
        transform: scale(1);
        box-shadow: 0 0 15px rgba(255, 193, 7, 0.6);
    }
    15% { 
        background-color: #ffc107;
        transform: scale(1.25);
        box-shadow: 0 0 25px rgba(255, 193, 7, 0.8);
    }
    100% { 
        background-color: inherit;
        transform: scale(1);
        box-shadow: none;
    }
}

/* Help Modal Styles */
.help-modal {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.help-modal h2 {
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.help-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.help-section h3 {
    color: #667eea;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.help-section ul, .help-section ol {
    margin-left: 20px;
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.help-section strong {
    font-weight: 600;
}

/* Dark mode support (basic) */
@media (prefers-color-scheme: dark) {
    .editor-controls, .player-controls {
        background: #2d3748;
        color: white;
    }
    
    select, input[type="number"], input[type="text"] {
        background: #1a202c;
        color: white;
        border-color: #4a5568;
    }
    
    .modal-content {
        background: #2d3748;
        color: white;
    }
}

/* About Modal Styles */
.about-modal {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding-bottom: 0;
}

.about-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.about-section:last-of-type {
    border-bottom: none;
    margin-bottom: 1rem;
}

.about-section h3 {
    color: #667eea;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.about-section p {
    line-height: 1.6;
    margin-bottom: 0.8rem;
    color: #555;
    text-align: justify;
}

.contact-info {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 0.8rem;
}

.contact-info p {
    margin-bottom: 0.5rem;
}

a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

.tech-stack {
    display: grid;
    gap: 0.8rem;
}

.tech-item {
    background: #f8f9fa;
    padding: 0.8rem;
    border-radius: 6px;
    border-left: 4px solid #667eea;
}

.tech-item strong {
    color: #333;
    display: block;
    margin-bottom: 0.3rem;
}

.audio-credits {
    background: #f0f8ff;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #4a90e2;
}

.audio-credits p {
    margin-bottom: 0.5rem;
}

.audio-credits p:last-child {
    margin-bottom: 0;
}

/* Dark mode support for about modal */
@media (prefers-color-scheme: dark) {
    .about-section p {
        color: #cbd5e0;
    }
    
    .contact-info,
    .tech-item,
    .audio-credits {
        background: #4a5568;
    }
    
    .tech-item strong {
        color: #e2e8f0;
    }
    
    .about-section h3 {
        color: #90cdf4;
    }
    
    .contact-info a {
        color: #90cdf4;
    }
}

/* Tutorial Modal Styles */
.tutorial-modal {
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.tutorial-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.tutorial-section:last-of-type {
    border-bottom: none;
}

.tutorial-section h3 {
    color: #667eea;
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tutorial-section p {
    line-height: 1.5;
    margin-bottom: 0.8rem;
    color: #555;
}

.tutorial-section ul {
    margin-left: 1.2rem;
    color: #555;
}

.tutorial-section li {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.tutorial-preferences {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #555;
}

.checkbox-container input[type="checkbox"] {
    margin-right: 0.8rem;
    transform: scale(1.2);
    cursor: pointer;
}

.primary-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: #5a6fd8;
    transform: translateY(-1px);
}

/* Dark mode support for tutorial modal */
@media (prefers-color-scheme: dark) {
    .tutorial-section p,
    .tutorial-section ul,
    .tutorial-section li,
    .checkbox-container {
        color: #cbd5e0;
    }
    
    .tutorial-preferences {
        background: #4a5568;
    }
    
    .tutorial-section h3 {
        color: #90cdf4;
    }
    
    .tutorial-section {
        border-bottom-color: #4a5568;
    }
}

/* Interstitial Ad Modal Styles */
.interstitial-modal {
    /* max-width: 300px; */
    width: 100dvw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    text-align: center;
    padding: 1.5rem;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    border-radius: 0;
}

.interstitial-modal .site-title {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.ad-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.ad-banner {
    width: 200px;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#adLink {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    transition: transform 0.2s ease;
}

#adLink:hover {
    transform: scale(1.02);
}

/* Remove hover effect quando não é clicável */
#adLink[href="#"]:hover {
    transform: none;
}

#adImage {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ad-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

.ad-placeholder p {
    margin: 0.3rem 0;
}

.ad-placeholder p:first-child {
    font-size: 1.2rem;
    font-weight: bold;
}

.ad-caption {
    font-size: 0.8rem;
    color: #666;
    margin-top: -1rem;
    font-style: italic;
}

.site-title {
    color: #4a5568;
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: bold;
}

.game-info {
    margin: 0;
    padding: 1rem;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    min-width: 300px;
}

.game-info h3 {
    margin: 0 0 1rem 0;
    color: #2d3748;
    font-size: 1.1rem;
}

.game-details {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Dark Theme Support */
[data-theme="dark"] .area-item {
    background: #2d2d2d;
    border-color: #555;
}

[data-theme="dark"] .area-anchor {
    color: #e0e0e0;
}

[data-theme="dark"] .area-operation select {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border-color: #555;
}

[data-theme="dark"] .area-target input {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border-color: #555;
}

[data-theme="dark"] .recalc-area-btn, 
[data-theme="dark"] .delete-area-btn {
    color: #ccc;
}

[data-theme="dark"] .recalc-area-btn:hover {
    background-color: #007acc;
    color: white;
}

[data-theme="dark"] .delete-area-btn:hover {
    background-color: #ff4444;
    color: white;
}

[data-theme="dark"] .recalc-all-btn {
    background: #0080cc;
}

[data-theme="dark"] .recalc-all-btn:hover {
    background: #0066aa;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    font-weight: 500;
    color: #4a5568;
}

.detail-value {
    font-weight: bold;
    color: #2b6cb0;
    background: #bee3f8;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Dark mode support for interstitial modal */
@media (prefers-color-scheme: dark) {
    .interstitial-modal {
        background: #2d3748;
        color: #e2e8f0;
    }

    .ad-caption {
        color: #a0aec0;
    }

    .site-title {
        color: #e2e8f0;
    }

    .game-info {
        background: #4a5568;
        border-color: #718096;
    }

    .game-info h3 {
        color: #e2e8f0;
    }

    .detail-label {
        color: #cbd5e0;
    }

    .detail-value {
        color: #2b6cb0;
        background: #2a4365;
    }
}