* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 600px;
    width: 100%;
}

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

.connection-status {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.connection-status.connected {
    color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    border-color: rgba(76, 175, 80, 0.3);
}

.connection-status.disconnected {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    border-color: rgba(244, 67, 54, 0.3);
}

.slot-container {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.slot-machine {
    position: relative;
    width: 300px;
    height: 400px;
    background: #222;
    border-radius: 20px;
    border: 4px solid #333;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.slot-viewport {
    width: 250px;
    height: 80px;
    overflow: hidden;
    background: #111;
    border-radius: 10px;
    position: relative;
    border: 2px solid #444;
}

.slot-reel {
    width: 100%;
    transition: transform 3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slot-reel.spinning {
    transition: none;
}

.slot-item {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    color: white;
    border-bottom: 1px solid #444;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.slot-item:nth-child(odd) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.slot-item:nth-child(3n) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.slot-item:nth-child(5n) {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.slot-pointer {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 260px;
    height: 4px;
    background: #ff4444;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.6);
    z-index: 10;
}

.slot-pointer::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 12px solid #ff4444;
}

.slot-pointer::after {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 12px solid #ff4444;
}

@keyframes slotSpin {
    0% {
        transform: translateY(0);
    }
    100% {
        transform: translateY(-100%);
    }
}

.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

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

.btn.primary {
    background: #4CAF50;
    color: white;
}

.btn.primary:hover {
    background: #45a049;
}

.btn.secondary {
    background: #2196F3;
    color: white;
}

.btn.secondary:hover {
    background: #0b7dda;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.name-input {
    display: none;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.name-input input {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    margin-right: 10px;
    width: 200px;
}

.name-input input:focus {
    outline: none;
    border-color: #4CAF50;
}

.names-list {
    margin-bottom: 20px;
}

.names-list h3 {
    margin-bottom: 15px;
    color: #333;
}

#names-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.name-item {
    background: #e3f2fd;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    color: #1976d2;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    transform: translateX(0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.name-item:hover {
    background: #bbdefb;
}

.name-item.slide-delete {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
}

.name-item.deleting {
    animation: slideOut 0.5s ease-out forwards;
}

@keyframes slideOut {
    0% {
        transform: translateX(0);
        opacity: 1;
    }
    100% {
        transform: translateX(-100%);
        opacity: 0;
    }
}

.name-text {
    flex: 1;
}

.delete-btn {
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-weight: bold;
    line-height: 1;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    min-width: 20px;
    min-height: 20px;
}

.delete-btn:hover {
    background: #cc0000;
    transform: scale(1.1);
}

.delete-btn:active {
    transform: scale(0.9);
}

.result {
    text-align: center;
    background: #fff3e0;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #ff9800;
}

.result h2 {
    color: #e65100;
    margin-bottom: 10px;
}

#result-text {
    font-size: 18px;
    color: #333;
    font-weight: bold;
}

/* タブレット対応 */
@media (max-width: 768px) {
    .container {
        padding: 25px;
        max-width: 90%;
    }
    
    h1 {
        font-size: 2.2em;
        margin-bottom: 25px;
    }
    
    .slot-machine {
        width: 280px;
        height: 380px;
    }
    
    .slot-viewport {
        width: 230px;
        height: 75px;
    }
    
    .slot-item {
        height: 75px;
        font-size: 17px;
    }
    
    .slot-pointer {
        width: 240px;
    }
    
    .controls {
        gap: 12px;
    }
    
    .btn {
        padding: 14px 28px;
        font-size: 17px;
    }
    
    .name-input input {
        width: 220px;
        padding: 12px;
        font-size: 17px;
    }
    
    .name-item {
        padding: 10px 18px;
        font-size: 15px;
    }
    
    .delete-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
        min-width: 28px;
        min-height: 28px;
    }
}

/* スマホ対応 */
@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        max-width: 100%;
        border-radius: 15px;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
    
    .slot-machine {
        width: 250px;
        height: 320px;
    }
    
    .slot-viewport {
        width: 200px;
        height: 60px;
    }
    
    .slot-item {
        height: 60px;
        font-size: 14px;
    }
    
    .slot-pointer {
        width: 210px;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .btn {
        padding: 12px 24px;
        font-size: 16px;
        width: 200px;
    }
    
    .name-input {
        padding: 15px;
    }
    
    .name-input input {
        width: 180px;
        margin-bottom: 10px;
        padding: 10px;
        font-size: 16px;
    }
    
    .name-input .btn {
        width: 80px;
        margin: 0 5px;
    }
    
    #names-container {
        justify-content: center;
    }
    
    .name-item {
        padding: 8px 14px;
        font-size: 14px;
        min-width: 80px;
    }
    
    .delete-btn {
        width: 26px;
        height: 26px;
        font-size: 14px;
        min-width: 26px;
        min-height: 26px;
    }
    
    .result {
        padding: 15px;
    }
    
    #result-text {
        font-size: 16px;
    }
}

/* 極小画面対応 */
@media (max-width: 320px) {
    .container {
        padding: 10px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .slot-machine {
        width: 220px;
        height: 280px;
    }
    
    .slot-viewport {
        width: 180px;
        height: 50px;
    }
    
    .slot-item {
        height: 50px;
        font-size: 12px;
    }
    
    .slot-pointer {
        width: 190px;
    }
    
    .btn {
        width: 180px;
        font-size: 14px;
    }
    
    .name-input input {
        width: 160px;
        font-size: 14px;
    }
    
    .name-item {
        font-size: 12px;
        padding: 6px 12px;
    }
}