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

body {
    font-family: 'Noto Sans Thai', sans-serif;
    background: #0a0a0f;
    color: #e0e0e0;
    min-height: 100vh;
    overflow-x: hidden;
}

.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, #1a1a2e 0%, #0a0a0f 70%);
    z-index: -1;
}

.bg-animation::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, #ff6b35, transparent, #00d4ff, transparent);
    animation: rotate 20s linear infinite;
    opacity: 0.03;
}

@keyframes rotate {
    100% { transform: rotate(360deg); }
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #ff6b35, #00d4ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(255, 107, 53, 0.3);
}

.subtitle {
    color: #888;
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

.input-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

#nameInput {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid #2a2a3e;
    border-radius: 12px;
    background: #1a1a2e;
    color: #fff;
    font-size: 1.1rem;
    font-family: inherit;
    transition: all 0.3s;
}

#nameInput:focus {
    outline: none;
    border-color: #ff6b35;
    box-shadow: 0 0 20px rgba(255, 107, 53, 0.2);
}

#pressBtn {
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

#pressBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 53, 0.4);
}

#pressBtn:active {
    transform: translateY(0) scale(0.98);
}

#pressBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 1.4rem;
}

.message {
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 600;
    display: none;
}

.message.success {
    display: block;
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.message.error {
    display: block;
    background: rgba(255, 107, 53, 0.1);
    color: #ff6b35;
    border: 1px solid rgba(255, 107, 53, 0.3);
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat {
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: #00d4ff;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #888;
    margin-top: 0.25rem;
}

.table-section {
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    border-radius: 16px;
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #2a2a3e;
}

.table-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #00ff88;
    font-weight: 600;
}

.dot {
    width: 8px;
    height: 8px;
    background: #00ff88;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.table-wrapper {
    max-height: 400px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    background: #1a1a2e;
    z-index: 10;
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.85rem;
    color: #888;
    font-weight: 600;
    border-bottom: 1px solid #2a2a3e;
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #2a2a3e;
    font-size: 0.95rem;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

tr.empty-row td {
    text-align: center;
    color: #666;
    padding: 2rem;
}

.rank-1 td:first-child { color: #ffd700; font-weight: 800; }
.rank-2 td:first-child { color: #c0c0c0; font-weight: 800; }
.rank-3 td:first-child { color: #cd7f32; font-weight: 800; }

.diff-fast { color: #00ff86; }
.diff-medium { color: #ffaa00; }
.diff-slow { color: #ff6b35; }

.admin-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    padding: 0.5rem 1rem;
    background: #2a2a3e;
    border: 1px solid #3a3a4e;
    border-radius: 8px;
    color: #888;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.admin-toggle:hover {
    background: #3a3a4e;
    color: #fff;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 350px;
}

.modal-content h3 {
    margin-bottom: 1rem;
    text-align: center;
}

.modal-content input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #2a2a3e;
    border-radius: 8px;
    background: #0a0a0f;
    color: #fff;
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
}

.modal-content input:focus {
    outline: none;
    border-color: #ff6b35;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
}

.modal-buttons button {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login {
    background: linear-gradient(135deg, #ff6b35, #ff8c42);
    color: #fff;
}

.btn-cancel {
    background: #2a2a3e;
    color: #888;
}

.btn-cancel:hover {
    background: #3a3a4e;
    color: #fff;
}

.admin-section {
    display: none;
    margin-top: 2rem;
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    border-radius: 16px;
    padding: 1.5rem;
}

.admin-section.active {
    display: block;
}

.admin-section h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.admin-actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #ff4444, #cc0000);
    color: #fff;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(255, 68, 68, 0.4);
}

.btn-delete {
    padding: 0.4rem 0.75rem;
    border: none;
    border-radius: 6px;
    background: rgba(255, 68, 68, 0.2);
    color: #ff4444;
    font-family: inherit;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete:hover {
    background: rgba(255, 68, 68, 0.4);
}

.admin-presses {
    max-height: 300px;
    overflow-y: auto;
}

.admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #2a2a3e;
}

@media (max-width: 600px) {
    header h1 { font-size: 2rem; }
    .input-section { flex-direction: column; }
    #pressBtn { justify-content: center; }
    .stats-bar { grid-template-columns: 1fr; }
}
