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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #121212;
    color: #e0e0e0;
    padding: 15px;
    max-width: 1600px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #1e1e1e;
    border-radius: 6px;
    border-bottom: 2px solid #ff9800;
}

h1 {
    color: #ff9800;
    margin-bottom: 5px;
    font-size: 1.8rem;
}

/* Grid layout for slices */
#slices-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(650px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.slice-container {
    margin-bottom: 0;
    background-color: #1e1e1e;
    border-radius: 6px;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    border-left: 3px solid #ff9800;
    overflow: visible; /* Allow children like zoomed tiles to overflow */
}

.slice-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #444;
    flex-wrap: wrap;
}

.slice-title {
    font-size: 1.2rem;
    color: #ff9800;
    margin-right: 15px;
}

/* Slice statistics styles */
.slice-stats {
    display: flex;
    flex-direction: row;
    gap: 15px;
    margin-left: auto;
    align-items: center;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.9rem;
    gap: 4px;
    font-weight: bold;
    min-width: 40px;
    justify-content: center;
}

.resources {
    background-color: #ffcc00;
    color: #000;
    border-radius: 20px;
    padding: 3px 10px;
}

.influence {
    background-color: #4682b4;
    color: #fff;
    border-radius: 20px;
    padding: 3px 10px;
}

.stats-summary-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-label {
    font-weight: bold;
    min-width: 70px;
    text-align: right;
}

.tech-specialties {
    display: flex;
    gap: 3px;
    margin-top: 5px;
}

.wormholes {
    display: flex;
    gap: 3px;
    margin-top: 5px;
}

.resource-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: #a52a2a;
    border-radius: 50%;
    margin-right: 5px;
}

.influence-icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: #fff;
    border: 2px solid #4682b4;
    border-radius: 50%;
    margin-right: 5px;
}

.tech-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin: 0 1px;
}

.tech-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wormhole-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1rem;
    background-color: #333;
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.tiles-row {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start; /* Align tiles to left for better space usage */
    gap: 8px;
    overflow-x: auto;
    overflow-y: visible; /* Allow stats to be visible above */
    padding: 35px 0 25px; /* Reduced padding */
    margin: 0 -5px;
    scrollbar-width: thin;
    scrollbar-color: #ff9800 #2a2a2a;
}

/* Custom scrollbar for WebKit browsers */
.tiles-row::-webkit-scrollbar {
    height: 8px;
}

.tiles-row::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 4px;
}

.tiles-row::-webkit-scrollbar-thumb {
    background-color: #ff9800;
    border-radius: 4px;
}

.tile {
    position: relative;
    width: 120px;
    min-height: 120px;
    background-color: #2a2a2a;
    border-radius: 6px;
    overflow: visible; /* Changed from hidden to visible to show position labels */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 5px 25px; /* Reduced margins */
    padding-bottom: 15px; /* Reduced padding */
    flex-shrink: 0; /* Prevent tiles from shrinking */
}

.tile img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: pointer;
}

.tile-id {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.position-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    background-color: #ff9800;
    color: #121212;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: bold;
    z-index: 10;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    border: 1px solid #fff;
    font-family: 'Arial', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
}

footer {
    text-align: center;
    margin-top: 40px;
    padding: 20px;
    background-color: #1e1e1e;
    border-radius: 8px;
    border-top: 3px solid #ff9800;
}

footer a {
    color: #ff9800;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Tile stats styles */
.tile-stats {
    position: absolute;
    top: -25px; /* Reduced space above */
    left: 50%; /* Center horizontally */
    transform: translateX(-50%); /* Center horizontally */
    display: flex;
    gap: 4px;
    align-items: center;
}

.tile-stats-text {
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 3px 6px;
    border-radius: 10px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 3px;
    font-weight: bold;
}

.tile-resource {
    color: #ffcc00;
    font-weight: bold;
}

.tile-influence {
    color: #4682b4;
    font-weight: bold;
}

.tile-resource-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ffcc00;
    margin-right: 2px;
}

.tile-influence-icon {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #4682b4;
    margin-right: 2px;
}

.tile-stat-separator {
    margin: 0 2px;
    color: #999;
}

/* Special tile indicators */
.anomaly-text {
    color: #ff5555;
    font-style: italic;
    font-size: 0.8rem;
}

.wormhole-text {
    color: #aa55ff;
    font-weight: bold;
    font-size: 1.2rem;
}

.empty-text {
    color: #999999;
    font-style: italic;
    font-size: 0.8rem;
}

.tile-tech-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 2px;
}

.tile-tech-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Wormhole icon styles for tiles */
.wormhole-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    color: #aa55ff;
    font-weight: bold;
    font-size: 1rem;
    margin: 0 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.tile-wormhole-icon {
    background-color: #333;
    color: white;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Controls Panel and Menu */
.controls-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.menu-toggle {
    background-color: #2c3e50;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

.menu-toggle:hover {
    background-color: #34495e;
}

.menu {
    display: none;
    position: absolute;
    right: 0;
    background-color: #1e1e1e;
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    padding: 15px;
    margin-top: 10px;
    min-width: 300px;
    color: #e0e0e0;
    backdrop-filter: blur(10px);
}

.menu.show {
    display: block;
}

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

.menu-section:last-child {
    border-bottom: none;
}

.menu-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    color: #ff9800;
    font-size: 1.1rem;
}

.action-button {
    background: linear-gradient(135deg, #4a7bd8 0%, #6a4c93 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

.action-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.action-button.secondary {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.action-button.secondary:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.action-description {
    font-size: 12px;
    color: #aaa;
    margin-top: -5px;
    margin-bottom: 10px;
}

/* Taken slice states */
.slice-container.taken {
    opacity: 0.4;
    background-color: #2a2a2a;
    border-left-color: #666;
    position: relative;
}

.slice-container.taken::before {
    content: "TAKEN";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: bold;
    font-size: 1.2rem;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

.slice-container.taken .tiles-row {
    pointer-events: none;
}

.slice-container.taken .slice-header {
    opacity: 0.6;
}

/* Take slice button */
.take-slice-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 10px;
}

.take-slice-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: scale(1.05);
}

.take-slice-btn.taken {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
}

.take-slice-btn.taken:hover {
    background: linear-gradient(135deg, #219a52, #27ae60);
}

/* Share modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: rgba(30, 30, 50, 0.95);
    margin: 15% auto;
    padding: 20px;
    border: 1px solid rgba(255, 152, 0, 0.5);
    border-radius: 10px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 0 25px rgba(255, 152, 0, 0.3);
    backdrop-filter: blur(10px);
    color: #fff;
}

.close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-button:hover,
.close-button:focus {
    color: #ff9800;
    text-decoration: none;
}

.shareable-link-container {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.shareable-link-container input {
    flex: 1;
    padding: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #333;
    color: #fff;
    font-size: 14px;
}

.shareable-link-container button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #4a7bd8 0%, #6a4c93 100%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.shareable-link-container button:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* Floating magnified tile overlay */
.tile-magnifier {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    width: 300px;
    height: 300px;
    background-color: #2a2a2a;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    border: 2px solid #ff9800;
    display: none;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.tile-magnifier img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tile-magnifier .magnifier-tile-id {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
}

.tile-magnifier .magnifier-stats {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    align-items: center;
}

.tile-magnifier .magnifier-stats-text {
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
}

.tile-magnifier .magnifier-tech-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-magnifier .magnifier-tech-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.8));
}

.tile-magnifier .magnifier-wormhole-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.8);
    color: #aa55ff;
    font-weight: bold;
    font-size: 1.2rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
