:root {
    --primary: #8B0000;
    --secondary: #4B6C4B;
    --dark: #1E1E1E;
    --light: #F0F0F0;
    --accent: #C41E3A;
    --grid-bg: #2D2D2D;
    --border: #555;
    --on-color: #FF5555;
    --off-color: #444;
    --scrollbar-bg: #2D2D2D;
    --scrollbar-thumb: #555;
    --scrollbar-thumb-hover: #777;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a1a, #0d0d0d);
    color: var(--light);
    line-height: 1.6;
    padding: 15px;
    min-height: 100vh;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(30, 30, 30, 0.8);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    padding: 20px;
    border: 1px solid var(--border);
}

header {
    text-align: center;
    padding: 15px 0;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--accent);
}

h1 {
    color: var(--accent);
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(255, 85, 85, 0.5);
}

.subtitle {
    color: #aaa;
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.panel {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    background: rgba(40, 40, 40, 0.7);
    padding: 15px;
    border: 1px solid var(--border);
}

.controls,
.size-controls,
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.controls {
    flex: 2;
}

.size-controls {
    flex: 1;
    justify-content: center;
}

.stats {
    flex: 1;
    justify-content: flex-end;
    font-weight: bold;
    color: var(--accent);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    border: 1px solid #600;
}

button:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: var(--dark);
    border: 1px solid var(--border);
}

button.secondary:hover {
    background: #333;
}

input[type="number"] {
    width: 70px;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--dark);
    color: white;
    text-align: center;
}

input[type="text"] {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--dark);
    color: white;
    flex: 1;
}

label {
    margin-right: 5px;
    color: #ccc;
}

.main-content {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.preview-container {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

.grid-container {
    background: var(--grid-bg);
    padding: 15px;
    border: 1px solid var(--border);
    overflow: auto;
    text-align: center;
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.grid {
    display: inline-grid;
    grid-template-columns: repeat(var(--cols, 10), 40px);
    grid-template-rows: repeat(var(--rows, 10), 40px);
    gap: 2px;
}

.cell {
    width: 40px;
    height: 40px;
    background: var(--off-color);
    border: 1px solid #333;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    background-image: url(/image/redstone_lamp_off.png);
    background-repeat: no-repeat;
    background-size: 100%;
}

.cell:hover {
    z-index: 2;
    box-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

.cell.on {
    box-shadow: 0 0 15px rgba(255, 85, 85, 0.7);
    background-image: url(/image/redstone_lamp_on.png);
}

.cell::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    border-radius: 2px;
}

.instructions-container {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    max-height: 500px;
    overflow-y: scroll;
}

.instructions {
    background: rgba(40, 40, 40, 0.7);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.instructions h3 {
    color: var(--accent);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
}

.instructions pre {
    white-space: pre-wrap;
    word-break: break-all;
    color: #ddd;
    line-height: 1.4;
    flex: 1;
    overflow-y: auto;
    background: rgba(20, 20, 20, 0.5);
    padding: 10px;
    border-radius: 4px;
}

.shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.key {
    background: var(--dark);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-family: fantasy;
    color: var(--accent);
}

.counter {
    background: var(--dark);
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.counter span {
    color: var(--accent);
    font-weight: bold;
}

footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    color: #777;
    font-size: 0.9rem;
}

footer p {
    justify-items: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

footer svg,
img {
    width: 2.2em;
    height: 2.2em;
}

/* 设计管理面板样式 */
.designs-panel {
    background: rgba(40, 40, 40, 0.7);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.designs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.designs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.design-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(30, 30, 30, 0.5);
    border-radius: 4px;
    border: 1px solid var(--border);
}

.design-info {
    flex: 1;
}

.design-name {
    font-weight: bold;
    margin-right: 10px;
}

.design-size {
    color: #aaa;
    font-size: 0.9em;
}

.design-lamps {
    color: var(--accent);
    font-weight: bold;
    margin-left: 10px;
}

.design-actions {
    display: flex;
    gap: 5px;
}

.design-form {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.design-form input {
    flex: 1;
}

.design-form button {
    min-width: 80px;
}

@media (max-width: 768px) {
    .panel {
        flex-direction: column;
    }

    .controls,
    .size-controls,
    .stats {
        width: 100%;
        justify-content: center;
    }

    .grid {
        grid-template-columns: repeat(var(--cols, 10), 30px);
        grid-template-rows: repeat(var(--rows, 10), 30px);
    }

    .cell {
        width: 30px;
        height: 30px;
    }

    h1 {
        font-size: 2rem;
    }

    .design-form {
        flex-direction: column;
    }

    .main-content {
        flex-direction: column;
    }

    .preview-container,
    .instructions-container {
        min-height: 300px;
    }
}