:root {
    --bg-color: #f5f7fa;
    --text-color: #333;
    --card-bg: #fff;
    --card-border: #e0e0e0;
    --primary-color: #4a90e2;
    --accent-color: #e74c3c;
    --small-card-color: #2c3e50;
    --big-card-color: #2c3e50; /* Changed from #c0392b to black */
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --hover-shadow: 0 8px 12px rgba(0,0,0,0.15);
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

header {
    background-color: #fff;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

h1 { margin: 0; font-size: 1.5rem; }

nav button {
    background: none;
    border: none;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-color);
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
}

nav button:hover {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

main {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.content-section {
    background: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.rule-block {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.rule-block:last-child { border-bottom: none; }

h2, h3 { margin-top: 0; color: var(--primary-color); }

ul { list-style-type: disc; padding-left: 1.5rem; }

.highlight-box {
    background-color: #fff8e1;
    padding: 1rem;
    border-radius: 4px;
    border-left: 4px solid #ffc107;
    margin: 1rem 0;
}

.example-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

.example-cards .card {
    width: 30px;
    height: 60px;
    font-size: 1rem;
    cursor: default;
}

.example-cards .card:hover {
    transform: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Table Styles */
.huxi-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.huxi-table th, .huxi-table td {
    border: 1px solid #eee;
    padding: 0.8rem;
    text-align: center;
    white-space: normal !important; /* Ensure text wraps */
}

.huxi-table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

/* Card Styling */
.card {
    width: 36px;
    height: 72px;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-family: 'Kaiti', 'STKaiti', serif; /* Traditional look */
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    position: relative;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--hover-shadow);
}

.card.small { color: var(--small-card-color); }
.card.big { color: var(--big-card-color); }
.card.red-card { color: var(--accent-color); }

.card.card-back {
    color: transparent !important;
    background: repeating-linear-gradient(
      45deg,
      #607d8b,
      #607d8b 5px,
      #546e7a 5px,
      #546e7a 10px
    );
    border-color: #455a64;
}

.inline-card {
    display: inline-flex !important; /* Force inline display */
    width: 20px !important;
    height: 28px !important;
    font-size: 0.7em !important;
    padding: 0 2px !important;
    margin: 0 2px !important;
    vertical-align: middle !important;
    line-height: 1 !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1) !important;
    cursor: default !important;
    transform: none !important;
    flex-shrink: 0;
    white-space: nowrap;
}

.inline-card:hover {
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.calculator-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.card-palette {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.palette-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Selected Slots */
.selection-area {
    background-color: #fafafa;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.slots-result-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.slots-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    min-height: 80px;
}
/* ... existing styles ... */
/* Result */
.result-box {
    text-align: center;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 0.8rem 1.2rem; /* Adjusted padding */
    background-color: #e8f5e9;
    color: #2e7d32;
    border-radius: 8px;
    margin-top: 0; /* Remove top margin as it is handled by wrapper gap */
    min-width: 150px;
}
.slot {
    width: 40px;
    height: 80px;
    border: 2px dashed #ccc;
    border-radius: 4px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(255,255,255,0.5);
    transition: all 0.3s;
}

.slot.filled {
    border: none;
    background: none;
}

.slot .card {
    width: 40px;
    height: 80px;
    font-size: 1.4rem;
}

/* Dark Mode Overlay for Card */
.card.is-dark::after {
    content: "" !important; /* Removed '暗' text */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    color: white;
    font-size: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 4px;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.action-btn {
    padding: 0.8rem 2rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.action-btn:hover { background-color: #357abd; }

.secondary-btn {
    padding: 0.8rem 1.5rem;
    background-color: transparent;
    color: #666;
    border: 1px solid #ccc;
    border-radius: 25px;
    cursor: pointer;
}

.secondary-btn:hover { background-color: #eee; }

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.toggle-switch input { display: none; }

.slider {
    position: relative;
    width: 40px;
    height: 20px;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(20px); }

.label-text { font-size: 0.9rem; font-weight: 500; }

footer {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-size: 0.9rem;
}

/* Special Effect for 'Mandatory' text */
.special-effect {
    display: inline-block;
    background: linear-gradient(135deg, #ff416c, #ff4b2b);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    margin-left: 5px;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(255, 75, 43, 0.3);
    animation: pop-pulse 2s infinite;
}

@keyframes pop-pulse {

    0%, 100% { transform: scale(1); }

    50% { transform: scale(1.05); box-shadow: 0 4px 8px rgba(255, 75, 43, 0.5); }

}



/* Table Card Examples */

.table-cards {

    display: flex;

    justify-content: center;

    gap: 2px;

    margin-top: 5px;

}



.table-cards .card {

    width: 20px;

    height: 40px;

    font-size: 0.8rem;

    line-height: 40px; /* Center text vertically */

    border-radius: 2px;

    border: 1px solid #ccc;

    box-shadow: none; /* Simplify shadow for small cards */

}

.group-divider {
    width: 2px;
    background-color: #ddd;
    margin: 0 15px;
    border-radius: 1px;
}

/* Winning Examples Styles */
.winning-examples {
    margin-top: 1rem;
}

.winning-row {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.winning-row h4 {
    margin: 0 0 0.8rem 0;
    font-size: 1rem;
    color: var(--primary-color);
}

.hand-items {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end; /* Align bottom */
}

.hand-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.3rem;
}

.group-label {
    font-size: 0.8rem;
    color: #666;
    font-weight: bold;
}

.group-cards {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Special highlight for Winning card group */
.hand-group:last-child .group-label {
    color: var(--accent-color);
}
