* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4a90e2;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --error-color: #e74c3c;
    --background: #f5f7fa;
    --card-background: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #e1e8ed;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1em;
}

.calculator-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 30px;
    margin-bottom: 30px;
}

.input-section {
    background: var(--card-background);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    height: fit-content;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.input-group select,
.input-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.3s;
    background: white;
}

.input-group select:focus,
.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.calculate-button {
    width: 100%;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    margin-top: 10px;
}

.calculate-button:hover {
    background: #357abd;
    transform: translateY(-2px);
}

.calculate-button:active {
    transform: translateY(0);
}

.calculate-button:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
}

.results-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-card {
    background: var(--card-background);
    padding: 25px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s;
}

.result-card:hover {
    box-shadow: var(--shadow-hover);
}

.result-card h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.result-content {
    min-height: 100px;
}

.result-content .placeholder {
    color: var(--text-secondary);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.materials-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.materials-table th,
.materials-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.materials-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-primary);
}

.materials-table tr:hover {
    background: var(--background);
}

.total-row {
    font-weight: 600;
    background: var(--background);
}

.coin-value {
    color: var(--success-color);
    font-weight: 600;
}

.loading {
    text-align: center;
    padding: 30px;
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-top: 20px;
}

.loading.hidden {
    display: none;
}

.spinner {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: #fee;
    color: var(--error-color);
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
    border-left: 4px solid var(--error-color);
}

.error.hidden {
    display: none;
}

.production-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.stat-item {
    background: var(--background);
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.stat-label {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--text-primary);
}

.roi-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--background);
    border-radius: 8px;
    text-align: center;
}

.roi-positive {
    color: var(--success-color);
}

.roi-negative {
    color: var(--error-color);
}

/* Crafting Recipe Styles */
.crafting-recipe-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.crafting-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    background: #8B7355;
    padding: 12px;
    border-radius: 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    max-width: 300px;
}

.crafting-slot {
    aspect-ratio: 1;
    background: #C4A484;
    border: 2px solid #8B6F47;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px;
    position: relative;
    min-height: 60px;
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.crafting-slot.empty {
    background: #C4A484;
    opacity: 0.5;
}

.crafting-slot.has-item {
    background: linear-gradient(135deg, #E8D5B7 0%, #C4A484 100%);
}

.item-name {
    font-size: 0.75em;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

.item-amount {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: 4px;
}

.recipe-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-top: 10px;
}

.recipe-arrow {
    font-size: 2em;
    color: var(--primary-color);
    margin: 10px 0;
}

.result-slot {
    background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
    border: 3px solid #2c5a8a;
    border-radius: 8px;
    padding: 15px;
    min-width: 100px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.result-slot .item-name {
    color: white;
    font-size: 0.85em;
}

.result-slot .item-amount {
    color: #FFD700;
    font-size: 1em;
}

@media (max-width: 768px) {
    .calculator-section {
        grid-template-columns: 1fr;
    }

    header h1 {
        font-size: 2em;
    }

    .production-stats {
        grid-template-columns: 1fr;
    }

    .crafting-grid {
        max-width: 100%;
    }
}

