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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.container {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 520px;
    width: 100%;
    overflow-x: hidden;
}

.edit-trigger {
    position: absolute;
    top: 12px;
    right: 16px;
    padding: 4px 10px;
    font-size: 12px;
    color: #999;
    background: transparent;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.4;
}
.edit-trigger:hover {
    opacity: 0.8;
    color: #666;
}

.edit-reset {
    display: none;
    position: absolute;
    top: 12px;
    left: 16px;
    padding: 4px 10px;
    font-size: 12px;
    color: #999;
    background: transparent;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.4;
}
.edit-reset:hover {
    opacity: 0.8;
    color: #c0392b;
}
.container.edit-mode .edit-reset {
    display: inline-block;
}

.edit-view {
    display: none;
    max-width: 100%;
    min-width: 0;
}
.container.edit-mode .play-view {
    display: none;
}
.container.edit-mode .edit-view {
    display: block;
}

.edit-view-title {
    font-size: 20px;
    color: #333;
    margin-bottom: 20px;
}

.edit-player-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.edit-player-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    min-width: 0;
}

.edit-player-row .edit-player-id {
    font-size: 13px;
    font-weight: 700;
    color: #666;
    min-width: 20px;
    text-align: right;
}

.edit-player-row input[type="text"] {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    font-size: 16px;
}

.edit-color-picker-wrap {
    flex-shrink: 0;
}

.edit-player-row .edit-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid rgba(0,0,0,0.15);
    cursor: pointer;
    padding: 0;
    display: block;
}

.edit-color-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 0;
}
.edit-color-overlay[hidden] {
    display: none;
}

.edit-color-overlay-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.edit-color-panel {
    position: relative;
    z-index: 31;
    width: calc(100% - 32px);
    max-width: none;
    margin: 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: 10px;
    max-height: calc(100% - 32px);
    overflow-y: auto;
}

.edit-color-cell {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.edit-color-cell:hover {
    filter: brightness(1.1);
}
.edit-color-cell--selected {
    border: 3px solid #333;
    box-shadow: 0 0 0 2px #fff;
}
.edit-color-cell--selected::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
}

.edit-player-row .edit-remove-btn {
    padding: 6px 12px;
    font-size: 13px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.edit-player-row .edit-remove-btn:hover {
    background: #c0392b;
}

.edit-add-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 12px;
}
.edit-add-btn:hover {
    background: #2980b9;
}

.edit-done-btn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background: #2ecc71;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}
.edit-done-btn:hover {
    background: #27ae60;
}

@media (max-width: 380px) {
    .container {
        padding: 16px;
    }
    .edit-player-row {
        gap: 6px;
        padding: 8px 10px;
    }
    .edit-player-row .edit-remove-btn {
        padding: 6px 8px;
        font-size: 12px;
    }
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 8px;
    font-size: 20px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 24px;
    font-size: 16px;
}

.controls {
    display: flex;
    flex-direction: column;
}

.control-group {
    margin-bottom: 0;
}

.section-label {
    display: block;
    margin-bottom: 12px;
    color: #555;
    font-weight: 600;
    font-size: 18px;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.player-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: background-color 0.2s;
    background: #f5f5f5;
    flex: 1;
    min-width: 0;
}

.checkbox-label:hover {
    background-color: #eee;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    flex-shrink: 0;
}

.player-color-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.checkbox-label .player-name {
    font-size: 16px;
    font-weight: 500;
}

.player-id-badge {
    display: none;
    margin-right: 6px;
    font-size: 14px;
    font-weight: 700;
    color: #666;
}
.id-mode .player-id-badge {
    display: inline;
}
.id-mode .player-id-badge::after {
    content: '.';
}

.stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.stepper-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    background: #e9ecef;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #495057;
}

.stepper-btn:hover {
    background: #dee2e6;
}

.stepper-btn:active {
    background: #ced4da;
}

.stepper-value {
    min-width: 28px;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    padding: 0 4px;
    background: #fff;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
}

/* Wheel section */
.wheel-section {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
}

.wheel-pointer {
    position: relative;
    z-index: 10;
    width: 0;
    height: 0;
    border-left: 16px solid transparent;
    border-right: 16px solid transparent;
    border-top: 24px solid #e74c3c;
    margin-bottom: -8px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.wheel-container {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    overflow: hidden;
    border: 6px solid #333;
    -webkit-tap-highlight-color: transparent;
}
.wheel-container:focus {
    outline: none;
}
.wheel-container:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px #fff, 0 8px 24px rgba(0, 0, 0, 0.3);
}

.wheel-container--clickable {
    cursor: pointer;
}

.wheel-container--spinning {
    pointer-events: none;
}

.wheel {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transition: transform 0.1ms linear;
    will-change: transform;
}

.wheel.spinning {
    transition: transform 4s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}

.wheel-segments {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

.wheel-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.wheel-segment-label {
    position: absolute;
    left: 50%;
    top: 50%;
    transform-origin: 50% 50%;
    font-weight: 700;
    font-size: 20px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
    white-space: nowrap;
    pointer-events: none;
}

.wheel-segment {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.wheel-segment-inner {
    position: absolute;
    width: 200%;
    height: 200%;
    transform-origin: 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.4);
}

/* Winner section - always in layout to prevent jump */
.winner-section {
    text-align: center;
    padding: 20px;
    border-radius: 12px;
    min-height: 76px;
    box-sizing: border-box;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 3px solid #dee2e6;
}

.winner-section:not(.winner-section--empty) {
    border-color: #2ecc71;
    animation: winnerPop 0.5s ease-out;
}

.winner-name {
    font-size: 28px;
    font-weight: 800;
    min-height: 1.2em;
    color: #2ecc71;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.winner-section--empty .winner-name {
    color: transparent;
}

@keyframes winnerPop {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .wheel-container {
        width: 260px;
        height: 260px;
    }
    
}
