:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #ffffff;
    --text-dim: #b0b0b0;
    --accent-lucky: #bb86fc;
    --accent-win: #03dac6;
    --accent-foul: #cf6679;
    --border-color: #333;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 500px;
    padding: 20px;
    box-sizing: border-box;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

h1 {
    font-size: 1.5rem;
    margin: 0;
}

.status-online {
    font-size: 0.8rem;
    color: var(--accent-win);
    background: rgba(3, 218, 198, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
    border: 1px solid var(--accent-win);
}

/* General Steps */
.step {
    display: none;
    animation: fadeIn 0.3s ease-in;
}
.step.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-content {
    text-align: center;
    padding: 40px 0;
}

.welcome-emoji {
    font-size: 5rem;
    margin-bottom: 20px;
}

.step-desc {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 20px;
    text-align: center;
}

.btn-primary {
    width: 100%;
    background: var(--accent-win);
    color: black;
    padding: 15px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    font-size: 1.1rem;
    margin-top: 20px;
}

.btn-secondary {
    width: 100%;
    background: #444;
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    margin-top: 20px;
}

.hidden {
    display: none;
}

.settings-panel {
    text-align: center;
}

.settings-inner {
    background: var(--bg-color);
    padding: 20px;
    border-radius: 12px;
    margin-top: 15px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.btn-close {
    width: 100%;
    background: #666;
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    margin-top: 10px;
}

/* Scoreboard */
.player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
}

.player-card {
    text-align: center;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.player-name {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 5px;
}

.player-score {
    font-size: 2rem;
    font-weight: bold;
}

/* Controls */
.target-selector {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.target-selector label {
    font-size: 1rem;
}

.target-selector select {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-color);
    color: white;
    border: 1px solid var(--border-color);
    font-size: 1rem;
}

.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.action-buttons .btn-win {
    grid-column: span 2;
}

.btn {
    border: none;
    padding: 15px 5px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.1s, opacity 0.2s;
    color: #000;
}

.btn:active {
    transform: scale(0.95);
}

.btn-lucky { background-color: var(--accent-lucky); }
.btn-win { background-color: var(--accent-win); }
.btn-foul { background-color: var(--accent-foul); }
.btn-lucky-bao { background-color: #ffcc00; color: black; }
.btn-foul-lucky { background-color: #9932cc; color: white; }

/* Player Management */
.player-mgmt {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.player-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.player-input-row input {
    flex: 1;
    padding: 10px;
    border-radius: 8px;
    background: var(--bg-color);
    color: white;
    border: 1px solid var(--border-color);
}

.btn-remove-player {
    background: var(--accent-foul);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    font-weight: bold;
}

.mgmt-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-add {
    flex: 1;
    background: var(--accent-win);
    color: black;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-weight: bold;
    cursor: pointer;
}

.btn-save-players {
    flex: 1;
    background: white;
    color: black;
    border: none;
    border-radius: 12px;
    padding: 12px;
    font-weight: bold;
    cursor: pointer;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    gap: 10px;
}

.score-edit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    gap: 10px;
}

.score-edit-row label {
    font-size: 0.9rem;
    color: var(--text-dim);
    flex: 1;
}

.score-edit-row input {
    width: 80px;
    padding: 8px;
    border-radius: 6px;
    background: var(--bg-color);
    color: white;
    border: 1px solid var(--border-color);
    text-align: center;
}

.config-row label {
    font-size: 0.9rem;
    color: var(--text-dim);
    width: 60px;
}

.config-row .input-group {
    display: flex;
    gap: 5px;
    flex: 1;
}

.config-row input {
    width: 100%;
    padding: 8px;
    border-radius: 6px;
    background: var(--bg-color);
    color: white;
    border: 1px solid var(--border-color);
    text-align: center;
}

.btn-save {
    width: 100%;
    background: white;
    color: black;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    margin-bottom: 10px;
}

.btn-reset {
    width: 100%;
    background: var(--accent-foul);
    color: white;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
}

/* Stats Table */
#stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

#stats-table th, #stats-table td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
}

#stats-table th {
    color: var(--text-dim);
}

/* History */
#history-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#history-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.85rem;
    color: var(--text-dim);
}

#history-list li b {
    color: var(--text-main);
}
