* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    min-height: 100vh;
}

.app {
    max-width: 700px;
    margin: 0 auto;
    padding: 24px 16px 60px;
}

header {
    text-align: center;
    margin-bottom: 28px;
}

header h1 {
    font-size: 2.4rem;
    background: linear-gradient(135deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.subtitle {
    color: #888;
    font-size: 0.95rem;
}

/* Tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 24px;
}

.tab {
    padding: 8px 14px;
    border: 1px solid #2a2a3e;
    background: #1a1a2e;
    color: #aaa;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.tab:hover {
    border-color: #4a4a6e;
    color: #fff;
}

.tab.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
}

/* Panels */
.panel {
    display: none;
    background: #1a1a2e;
    border-radius: 16px;
    padding: 28px;
    border: 1px solid #2a2a3e;
    margin-bottom: 20px;
}

.panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Controls */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.controls label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: #aaa;
    flex: 1;
    min-width: 120px;
}

.controls input[type="number"],
.controls select {
    padding: 10px 12px;
    background: #12121e;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    width: 100%;
}

.controls textarea {
    padding: 10px 12px;
    background: #12121e;
    border: 1px solid #333;
    border-radius: 8px;
    color: #fff;
    font-size: 0.95rem;
    resize: vertical;
    width: 100%;
    font-family: inherit;
}

.controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #667eea;
}

.controls label:has(input[type="checkbox"]) {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: auto;
}

/* Buttons */
.btn-primary {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 20px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-small {
    padding: 4px 12px;
    border: 1px solid #444;
    background: transparent;
    color: #888;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn-small:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

/* Result area */
.result-area {
    min-height: 60px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.result-area:empty {
    display: none;
}

/* Dice */
.dice {
    width: 80px;
    height: 80px;
    background: linear-gradient(145deg, #fff, #e6e6e6);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    font-weight: 800;
    color: #1a1a2e;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: diceRoll 0.4s ease-out;
}

@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(0.5); opacity: 0; }
    50% { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

.dice-total {
    width: 100%;
    text-align: center;
    font-size: 1.1rem;
    color: #feca57;
    font-weight: 600;
}

/* Numbers */
.number-ball {
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, #48dbfb, #0abde3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1;
    color: #fff;
    box-shadow: 0 4px 12px rgba(72, 219, 251, 0.3);
    animation: popIn 0.3s ease-out;
}

@keyframes popIn {
    0% { transform: scale(0); }
    70% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Coin */
.coin {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    animation: coinFlip 0.5s ease-out;
}

.coin.heads {
    background: linear-gradient(145deg, #ffd700, #daa520);
    color: #333;
}

.coin.tails {
    background: linear-gradient(145deg, #c0c0c0, #808080);
}

@keyframes coinFlip {
    0% { transform: rotateY(0deg) scale(0.5); }
    50% { transform: rotateY(540deg) scale(1.1); }
    100% { transform: rotateY(720deg) scale(1); }
}

.coin-stats {
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    color: #aaa;
    margin-top: 4px;
}

/* Names */
.winner-name {
    background: linear-gradient(135deg, #ff9ff3, #f368e0);
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    animation: popIn 0.4s ease-out;
    text-align: center;
    box-shadow: 0 4px 16px rgba(243, 104, 224, 0.3);
}

/* Cards */
.card {
    width: 80px;
    height: 112px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    animation: popIn 0.3s ease-out;
    gap: 2px;
}

.card .card-value {
    font-size: 1.3rem;
}

.card .card-suit {
    font-size: 1.6rem;
}

.card.red {
    color: #e74c3c;
}

.card.black {
    color: #2d3436;
}

/* Teams */
.team-block {
    background: #12121e;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #333;
    flex: 1;
    min-width: 200px;
    animation: popIn 0.3s ease-out;
}

.team-block h4 {
    margin-bottom: 10px;
    font-size: 1rem;
}

.team-block ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.team-block li {
    padding: 6px 10px;
    background: #1a1a2e;
    border-radius: 6px;
    font-size: 0.9rem;
}

/* Wheel */
.wheel-container {
    position: relative;
    display: flex;
    justify-content: center;
    margin-bottom: 16px;
}

.wheel-pointer {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    color: #ff6b6b;
    z-index: 10;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

#wheelCanvas {
    max-width: 100%;
    height: auto;
}

/* History */
.history-section {
    margin-top: 20px;
    background: #1a1a2e;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #2a2a3e;
}

.history-section h3 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 1rem;
    color: #888;
}

#history {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.history-item {
    padding: 8px 12px;
    background: #12121e;
    border-radius: 8px;
    font-size: 0.82rem;
    color: #aaa;
    display: flex;
    justify-content: space-between;
}

.history-item .type {
    color: #667eea;
    font-weight: 600;
    margin-right: 8px;
}

.history-item .time {
    color: #555;
    font-size: 0.75rem;
}

/* Upload zone */
.upload-zone {
    border: 2px dashed #333;
    border-radius: 14px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s;
    background: #12121e;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.06);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.upload-text {
    color: #aaa;
    font-size: 0.95rem;
    margin-bottom: 6px;
}

.upload-link {
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
}

.upload-hint {
    color: #555;
    font-size: 0.78rem;
}

/* Table loaded state */
.table-loaded {
    animation: fadeIn 0.3s ease;
}

.table-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #12121e;
    border: 1px solid #2a2a3e;
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 18px;
    font-size: 0.85rem;
}

.table-file-info span:first-child {
    color: #667eea;
    font-weight: 600;
}

.table-file-info span:nth-child(2) {
    color: #888;
    flex: 1;
}

/* Table preview */
.table-preview-wrapper {
    max-height: 260px;
    overflow: auto;
    border-radius: 10px;
    border: 1px solid #2a2a3e;
    margin-bottom: 18px;
}

.table-preview {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.table-preview th {
    background: #1f1f36;
    color: #aaa;
    font-weight: 600;
    padding: 9px 12px;
    text-align: left;
    position: sticky;
    top: 0;
    z-index: 2;
    border-bottom: 2px solid #333;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.table-preview th:hover {
    color: #fff;
    background: #2a2a4a;
}

.table-preview th.selected-col {
    color: #fff;
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.table-preview td {
    padding: 7px 12px;
    border-bottom: 1px solid #1e1e34;
    color: #ccc;
    white-space: nowrap;
}

.table-preview td.selected-col {
    background: rgba(102, 126, 234, 0.1);
    color: #fff;
    font-weight: 500;
}

.table-preview tr:hover td {
    background: rgba(255,255,255,0.03);
}

.table-preview .row-num {
    color: #444;
    font-size: 0.72rem;
    text-align: right;
    padding-right: 8px;
    width: 30px;
    user-select: none;
}

/* Winner card from table */
.winner-card {
    background: linear-gradient(135deg, #667eea22, #764ba222);
    border: 1px solid #667eea55;
    border-radius: 12px;
    padding: 16px 20px;
    width: 100%;
    animation: popIn 0.4s ease-out;
    margin-bottom: 6px;
}

.winner-card .winner-main {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.winner-card .winner-main .winner-badge {
    background: linear-gradient(135deg, #ff9ff3, #f368e0);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
}

.winner-card .winner-details {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 0.8rem;
    color: #aaa;
}

.winner-card .winner-details span {
    color: #667eea;
    font-weight: 600;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: #12121e;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 3px;
}

/* Responsive */
@media (max-width: 500px) {
    .app { padding: 16px 10px 40px; }
    header h1 { font-size: 1.8rem; }
    .tab { padding: 6px 10px; font-size: 0.78rem; }
    .panel { padding: 20px 16px; }
    .dice { width: 60px; height: 60px; font-size: 1.6rem; }
    .number-ball { width: 55px; height: 55px; font-size: 1.3rem; }
    .coin { width: 75px; height: 75px; }
}
