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

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

#map {
    height: 100vh;
    width: 100vw;
    background-color: #f5f5f5;
}

/* Grid control button styling */
.grid-control {
    background: white;
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.grid-control button {
    background: #fff;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.3s;
}

.grid-control button:hover {
    background: #f4f4f4;
    border-color: rgba(0,0,0,0.4);
}

/* Grid labels styling */
.grid-label {
    background: transparent !important;
    border: none !important;
}

/* Minimap styling */
.leaflet-control-minimap {
    border: 2px solid rgba(0,0,0,0.4);
    border-radius: 4px;
}

/* Leaflet controls styling */
.leaflet-bar {
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
}

.leaflet-bar a {
    background-color: #fff;
    color: #333;
}

.leaflet-bar a:hover {
    background-color: #f4f4f4;
}

/* Info Panel Styling */
.info-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 320px;
    max-height: 90vh;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.info-panel.hidden {
    transform: translateX(350px);
}

.info-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0;
}

.info-panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

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

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.info-panel-content {
    padding: 15px;
}

.info-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.info-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.info-section h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-section p {
    margin: 5px 0;
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

.info-section p strong {
    color: #333;
    font-weight: 600;
    display: inline-block;
    min-width: 140px;
}

.info-section span {
    color: #2c3e50;
    font-weight: 500;
}

/* Checkbox styling */
.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    color: #555;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-weight: normal;
    color: #555;
}

.checkbox-label:hover span {
    color: #2c3e50;
}

/* Detail link in panel */
.detail-link {
    color: #3498db;
    text-decoration: none;
    font-size: 13px;
    margin-left: 8px;
    font-weight: 500;
    transition: color 0.2s;
}

.detail-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

/* ============================================
   CELL DETAIL PAGE STYLES
   ============================================ */

.cell-detail-page {
    background: #f5f5f5;
    overflow-y: auto;
}

.cell-detail-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.cell-header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-link {
    color: #3498db;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    transition: color 0.2s;
}

.back-link:hover {
    color: #2980b9;
    text-decoration: underline;
}

.cell-header h1 {
    font-size: 28px;
    color: #2c3e50;
    margin: 0;
}

/* Content Layout */
.cell-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .cell-content {
        grid-template-columns: 1fr;
    }
}

/* Sections */
.canvas-section,
.cell-info-section,
.neighbors-section,
.raw-data-section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.canvas-section {
    grid-column: 1 / -1;
}

.cell-content section h2 {
    font-size: 20px;
    color: #2c3e50;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

/* Canvas */
.canvas-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f9f9f9;
    border-radius: 4px;
    padding: 10px;
    border: 1px solid #e0e0e0;
}

#cell-canvas {
    border: 2px solid #333;
    cursor: pointer;
    display: block;
}

.canvas-hint {
    text-align: center;
    color: #777;
    font-size: 13px;
    margin-top: 10px;
    font-style: italic;
}

/* Info Groups */
.info-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.info-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.info-group h3 {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 10px 0;
}

.info-group p {
    margin: 5px 0;
    font-size: 14px;
    color: #555;
    line-height: 1.6;
}

.info-group p strong {
    color: #333;
    font-weight: 600;
    display: inline-block;
    min-width: 160px;
}

.info-group span {
    color: #2c3e50;
    font-weight: 500;
}

/* Neighbors Grid */
.neighbor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.neighbor-card {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
}

.neighbor-card:hover {
    background: #f0f0f0;
    border-color: #3498db;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.2);
    transform: translateY(-2px);
}

.neighbor-color {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    margin-right: 12px;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

.neighbor-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.neighbor-info strong {
    color: #2c3e50;
    font-size: 14px;
}

.neighbor-info span {
    color: #777;
    font-size: 12px;
}

/* Raw JSON */
.raw-data-section details {
    margin-top: 10px;
}

.raw-data-section summary {
    cursor: pointer;
    color: #3498db;
    font-weight: 500;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    user-select: none;
}

.raw-data-section summary:hover {
    background: #f0f0f0;
}

.raw-data-section pre {
    background: #2c3e50;
    color: #ecf0f1;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 12px;
    line-height: 1.5;
    margin-top: 10px;
}

/* ==================== Homepage Styles ==================== */

.homepage {
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

.homepage-header {
    text-align: center;
    color: white;
    margin-bottom: 60px;
    padding: 40px 0;
}

.homepage-header h1 {
    font-size: 4rem;
    font-weight: 800;
    margin: 0 0 10px 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    letter-spacing: -1px;
}

.homepage-header .subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
    margin: 0;
}

.worlds-section {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
}

.worlds-section h2 {
    font-size: 2rem;
    color: #2c3e50;
    margin: 0 0 30px 0;
    font-weight: 700;
}

.worlds-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.world-card {
    display: block;
    background: white;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.world-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.15);
    border-color: #667eea;
}

.world-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: #f5f8fa;
}

.world-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.world-card:hover .world-thumbnail img {
    transform: scale(1.05);
}

.world-info {
    padding: 20px;
}

.world-info h3 {
    font-size: 1.5rem;
    color: #2c3e50;
    margin: 0 0 10px 0;
    font-weight: 600;
}

.world-description {
    color: #657786;
    font-size: 0.95rem;
    line-height: 1.5;
    margin: 0 0 15px 0;
}

.world-stats {
    display: flex;
    gap: 15px;
    font-size: 0.9rem;
    color: #8899a6;
}

.world-stats .stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.world-stats .icon {
    opacity: 0.7;
}

.world-params {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e1e8ed;
    font-size: 0.85rem;
}

.world-params .param {
    color: #657786;
    display: flex;
    justify-content: space-between;
}

.world-params .param strong {
    color: #2c3e50;
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #657786;
}

.empty-state p {
    font-size: 1.1rem;
    margin: 10px 0;
}

.empty-state .hint {
    font-size: 0.9rem;
    color: #8899a6;
    font-style: italic;
}

.homepage-footer {
    text-align: center;
    margin-top: 60px;
    padding: 30px 0;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
}

/* World header in map view */
.world-header {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 1000;
    background: rgba(255,255,255,0.95);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    flex-wrap: wrap;
}

.world-header .header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* User navigation styles */
.user-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-nav .username {
    font-weight: bold;
    color: #4CAF50;
    padding: 6px 12px;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 4px;
    font-size: 14px;
}

.nav-btn {
    padding: 8px 16px;
    background: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    font-size: 14px;
    transition: background 0.3s;
    white-space: nowrap;
}

.nav-btn:hover {
    background: #45a049;
}

.nav-btn.logout-btn {
    background: #999;
}

.nav-btn.logout-btn:hover {
    background: #777;
}

.nav-btn.dashboard-btn {
    background: #2196F3;
}

.nav-btn.dashboard-btn:hover {
    background: #0b7dda;
}

.nav-btn.login-btn {
    background: #4CAF50;
}

.nav-btn.login-btn:hover {
    background: #45a049;
}

.back-to-home {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.back-to-home:hover {
    color: #764ba2;
}

.world-title {
    margin: 0;
    font-size: 1.2rem;
    color: #2c3e50;
    font-weight: 600;
}
