/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #2c2c2c;
    line-height: 1.6;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
}

.screen.active {
    display: block;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
}

/* Logo */
.logo {
    display: block;
    max-width: 600px;
    width: 100%;
    height: auto;
    margin: 0 auto 2rem auto;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    color: #1a1a1a;
    text-align: center;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    color: #2c2c2c;
}

h3 {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #3c3c3c;
}

/* Buttons */
button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.primary-btn {
    background-color: #4a4a4a;
    color: white;
}

.primary-btn:hover {
    background-color: #2c2c2c;
}

.secondary-btn {
    background-color: #d0d0d0;
    color: #2c2c2c;
}

.secondary-btn:hover {
    background-color: #b8b8b8;
}

.control-btn {
    background-color: #e8e8e8;
    color: #2c2c2c;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.control-btn:hover:not(:disabled) {
    background-color: #d0d0d0;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Rules Screen */
.rules-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
}

.rules-content section {
    margin-bottom: 2rem;
}

.rules-content ul, .rules-content ol {
    margin-left: 2rem;
    margin-top: 0.5rem;
}

.rules-content li {
    margin-bottom: 0.5rem;
}

#start-btn {
    display: block;
    margin: 0 auto;
    font-size: 1.2rem;
    padding: 1rem 3rem;
}

.version-info {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    font-size: 1rem;
    color: #666;
    font-weight: 400;
}

.emporium-name {
    font-size: 1rem;
    font-weight: 400;
    color: #666;
    margin-left: 0.5rem;
}

/* Puzzle Selection */
.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.puzzle-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.puzzle-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.puzzle-card h3 {
    margin-bottom: 0.5rem;
}

.puzzle-card .difficulty {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.difficulty.easy {
    background-color: #e8e8e8;
    color: #4a4a4a;
}

.difficulty.medium {
    background-color: #c0c0c0;
    color: #2c2c2c;
}

.difficulty.hard {
    background-color: #8a8a8a;
    color: white;
}

.difficulty.extreme {
    background-color: #4a4a4a;
    color: white;
    font-weight: 700;
}

.puzzle-card .meta {
    color: #666;
    font-size: 0.9rem;
}

/* Game Screen Layout */
.game-container {
    max-width: 1400px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.score-warning {
    background-color: #ff6b6b;
    color: white;
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    margin-bottom: 1rem;
    font-size: 0.95rem;
    border: 2px solid #ff5252;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
    animation: warningPulse 2s ease-in-out infinite;
}

@keyframes warningPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.85;
    }
}

.score-display {
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background-color: #f5f5f5;
    border-radius: 6px;
}

.game-layout {
    display: grid;
    grid-template-columns: 300px 350px 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Shape Bank Section (Column 1) */
.shape-bank-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Shape Editor Section (Column 2) */
.shape-editor-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Grid Section (Column 3) */
.grid-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.game-grid {
    display: grid;
    gap: 2px;
    background-color: #999;
    padding: 2px;
    margin: 0 auto 2rem auto;
    width: fit-content;
    border-radius: 4px;
}

.grid-cell {
    width: 50px;
    height: 50px;
    background-color: #f8f8f8;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.15s;
    border-radius: 4px;
}

.grid-cell:hover {
    background-color: #f0f0f0;
    border-color: #d0d0d0;
}

.grid-cell.filled {
    border-width: 2px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.grid-cell.preview {
    background-color: #b8b8b8;
    opacity: 0.6;
}

.grid-cell.invalid {
    background-color: #d88;
}

.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.validation-message {
    padding: 1rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 500;
    min-height: 3rem;
}

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

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

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

.shape-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.trim-instructions {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    margin: 0.5rem 0 0 0;
    font-style: italic;
}

.removal-instructions {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    margin: 0.5rem 0;
    font-style: italic;
}

.shape-bank {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.shape-item {
    padding: 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.shape-item:hover {
    border-color: #999;
    background-color: #fafafa;
}

.shape-item.selected {
    border-color: #4a4a4a;
    background-color: #f0f0f0;
}

.shape-item.used {
    opacity: 0.4;
    cursor: not-allowed;
}

.shape-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.shape-name {
    font-weight: 600;
    color: #2c2c2c;
}

.shape-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #4a4a4a;
}

.shape-preview {
    display: grid;
    gap: 2px;
    width: fit-content;
}

.shape-cell {
    width: 24px;
    height: 24px;
    background-color: #6a6a6a;
    border: 2px solid #555;
    border-radius: 3px;
    transition: all 0.2s;
}

.shape-cell:hover {
    opacity: 0.8;
    transform: scale(0.95);
}

.shape-cell.trimmed {
    background-color: #f0f0f0 !important;
    border: 2px dashed #999 !important;
    opacity: 0.4;
}

.shape-info {
    padding: 1.5rem;
    background-color: #fafafa;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    color: #666;
    font-size: 0.95rem;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .game-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .shape-bank-section,
    .shape-editor-section {
        max-width: 600px;
        margin: 0 auto;
    }

    .grid-cell {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }

    .game-header {
        flex-direction: column;
        gap: 1rem;
    }

    .puzzle-grid {
        grid-template-columns: 1fr;
    }

    .grid-cell {
        width: 35px;
        height: 35px;
    }

    .shape-cell {
        width: 20px;
        height: 20px;
    }
}
