.qmdjv4-wrapper {
    width: 100%;
    max-width: none;
    margin: 20px auto;
    font-family: sans-serif;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    background: #fafafa;
    overflow-x: auto;
}

.qmdjv4-header {
    text-align: center;
    margin-bottom: 20px;
}

.qmdjv4-header h3 {
    margin-top: 0;
    color: #333;
}

.qmdjv4-form {
    background: #eaeaea;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.qmdjv4-form h4 {
    margin-top: 0;
    margin-bottom: 10px;
}

.qmdjv4-form-row {
    margin-bottom: 10px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.qmdjv4-form-row label {
    font-size: 0.9em;
    font-weight: bold;
}

.qmdjv4-btn {
    background: #0073aa;
    color: #fff;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}

.qmdjv4-btn:hover {
    background: #005177;
}

.qmdjv4-pillars {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 10px 0;
    font-weight: bold;
}

.qmdjv4-info {
    font-size: 0.9em;
    color: #666;
}

.qmdjv4-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    background: #ccc;
    border: 5px solid #ccc;
    border-radius: 5px;
}

.qmdjv4-palace {
    background: #fff;
    padding: 10px 10px 18px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    min-height: 200px;
    box-sizing: border-box;
    word-break: break-word;
    font-size: 18px;
}

/* Dual language text adjustments */
.qmdjv4-palace .zh {
    font-family: 'KaiTi', 'Kaiti SC', 'STKaiti', 'BiauKai', serif;
    font-size: 1.15em;
    line-height: 1.2;
    /* Make Chinese larger */
}

.qmdjv4-palace .py {
    font-size: 0.8em;
    color: #777;
    margin-top: 2px;
}

/* Center Palace */
.qmdjv4-palace.p-5 {
    background: #f0f0f0;
}

/* Layer Base Styles */
.layer-top,
.layer-mid,
.layer-bot {
    width: 100%;
}

/* Polarity Marker */
.polarity {
    margin-left: 2px;
    font-size: 0.9em;
}

.layer-mid .item-ml {
    background: #fdfdfd;
    padding: 2px 4px;
    border-radius: 2px;
}

.layer-bot .item-bl {
    color: #5bc0de;
}

.layer-bot .item-br {
    color: #008000;
}

.layer-sub {
    background: #fdfdfd;
    border-radius: 4px;
    margin-top: 8px;
}

.qmdjv4-footer {
    text-align: center;
    margin-top: 20px;
    color: #aaa;
}

/* Clickable Palace Hover Effect */
.qmdjv4-palace-link:hover .qmdjv4-palace {
    transform: translateY(-4px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.15);
    border-color: #999 !important;
    z-index: 10;
}

.qmdjv4-palace-link {
    transition: all 0.2s ease-in-out;
    display: block;
    border-radius: 4px;
}