:root {
    --primary: #00a36c;
    --primary-light: #00c885;
    --bg-gradient-start: #7ebcb9;
    --bg-gradient-end: #5b8db5;
    --card-bg: #e9eff5;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --accent: #0ea5e9;
    --danger: #ef4444;
    --item-bg: #ffffff;
    --glass-border: rgba(255, 255, 255, 0.6);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
    line-height: 1.6;
}

.app-container {
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    animation: fadeInDown 0.8s ease-out;
    position: relative;
}

.logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0 auto 10px auto;
    background-color: #2563eb; /* 진한 파란색 배경 */
    padding: 8px 16px;
    border-radius: 4px;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    letter-spacing: 2px;
    color: #ffffff; /* 흰색 텍스트 */
    text-shadow: none;
}

.icon {
    font-size: 2rem;
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 1.2rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.glass-card.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    color: var(--text-main);
}

.counter {
    background: var(--item-bg);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--primary);
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 1.5rem;
}

.handy-input {
    cursor: pointer;
    background: var(--item-bg);
}

.handy-input:hover {
    border-color: var(--primary);
}

input {
    background: var(--item-bg);
    border: 1px solid rgba(0,0,0,0.05);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 163, 108, 0.1);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    border: none;
    border-radius: 12px;
    padding: 12px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.add-player-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 2px;
}

.btn-add-player {
    width: auto;
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 700;
    border-radius: 12px;
    box-shadow: 0 3px 10px rgba(0, 163, 108, 0.2);
}

.btn-large {
    width: 100%;
    padding: 18px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    border: none;
    cursor: pointer;
    margin-top: 1rem;
    box-shadow: 0 4px 15px rgba(0, 163, 108, 0.2);
}

.btn-large:disabled {
    background: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
    box-shadow: none;
}

.player-list-container {
    margin-bottom: 1rem;
}

#player-list {
    list-style: none;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--item-bg);
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
    animation: slideIn 0.3s ease-out;
}

.player-info {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-weight: 600;
    color: var(--text-main);
}

.player-handy, .player-handy-btn {
    font-size: 0.8rem;
    color: var(--primary);
    background: rgba(0, 163, 108, 0.08);
    padding: 2px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    width: fit-content;
    margin-top: 2px;
}

.player-handy-btn:hover {
    background: rgba(0, 163, 108, 0.18);
    transform: scale(1.03);
}

.player-handy-btn:active {
    transform: scale(0.96);
}

.player-handy-btn small {
    font-size: 0.7rem;
    opacity: 0.8;
}

.player-item.inactive {
    opacity: 0.6;
    background: #f1f5f9;
}

.player-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.participation-toggle-group {
    display: inline-flex;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 20px;
    gap: 2px;
}

.btn-part {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-part.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 163, 108, 0.3);
}

.btn-part.inactive {
    background: #94a3b8;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    line-height: 1;
}

.step-guide-tip {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.6);
    padding: 6px 12px;
    border-radius: 10px;
    margin-bottom: 1.2rem;
    text-align: center;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.rooms-grid {
    display: grid;
    gap: 1.2rem;
}

.room-card {
    background: var(--item-bg);
    border-radius: 14px;
    padding: 0.8rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
    border: 2px solid transparent;
    transition: all 0.25s ease;
}

.room-card.drag-over {
    border-color: var(--primary);
    background: #f0fdf4;
    transform: scale(1.01);
    box-shadow: 0 8px 25px rgba(0, 163, 108, 0.18);
}

.room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.room-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.room-title {
    font-size: 1rem;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
}

.room-player-badge {
    background: rgba(0, 163, 108, 0.1);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
}

.btn-delete-room {
    background: none;
    border: 1px solid #fecaca;
    color: var(--danger);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-delete-room:hover {
    background: #fee2e2;
}

.room-players-list {
    min-height: 48px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.room-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 4px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 0;
    transition: all 0.2s ease;
    cursor: grab;
    user-select: none;
}

.room-player:last-child {
    border-bottom: none;
}

.room-player:active {
    cursor: grabbing;
}

.room-player.dragging {
    opacity: 0.35;
    transform: scale(0.98);
    border: 2px dashed var(--primary);
    background: #f0fdf4;
}

.drag-handle {
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    opacity: 0.6;
    transition: opacity 0.2s;
    touch-action: none;
}

.drag-handle:hover {
    opacity: 1;
    color: var(--primary);
}

.room-player .player-name {
    flex-grow: 1;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
}

.player-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-handy-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(0, 163, 108, 0.1);
    padding: 4px 8px;
    border-radius: 8px;
    min-width: 45px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.player-handy-badge:hover {
    background: rgba(0, 163, 108, 0.22);
    transform: scale(1.04);
}

.player-handy-badge:active {
    transform: scale(0.96);
}

.player-handy-badge small {
    font-size: 0.65rem;
    opacity: 0.8;
}

.score-input {
    width: 65px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
    background: #ffffff;
    cursor: pointer;
}

.room-empty-placeholder {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(248, 250, 252, 0.6);
}

.touch-drag-avatar {
    position: fixed;
    pointer-events: none;
    z-index: 9999;
    transform: translate(-50%, -50%) rotate(2deg);
    background: var(--item-bg);
    color: var(--text-main);
    border: 2px solid var(--primary);
    border-radius: 24px;
    padding: 8px 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
}

.touch-drag-avatar span {
    color: var(--primary);
}

.touch-drag-avatar small {
    color: var(--text-muted);
    font-weight: 600;
}

.btn-add-room {
    width: 100%;
    margin-top: 1rem;
    padding: 12px;
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-add-room:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(0, 163, 108, 0.05);
}

.leaderboard-container {
    overflow-x: auto;
    background: var(--item-bg);
    border-radius: 16px;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

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

th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 12px 8px;
    border-bottom: 2px solid #f1f5f9;
    text-transform: uppercase;
}

td {
    padding: 14px 8px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
    color: var(--text-main);
}

/* Rank column */
th:nth-child(1), td:nth-child(1) {
    width: 40px;
    text-align: center;
}

/* Name column */
th:nth-child(2), td:nth-child(2) {
    white-space: nowrap;
    padding-left: 10px;
    font-weight: 600;
}

/* Numeric columns */
th:nth-child(3), th:nth-child(4), th:nth-child(5),
td:nth-child(3), td:nth-child(4), td:nth-child(5) {
    width: 55px;
    text-align: center;
}

#leaderboard tr.rank-1 td:first-child { color: var(--primary); font-weight: 800; font-size: 1.1rem; }
#leaderboard tr.rank-2 td:first-child { color: var(--accent); font-weight: 700; }
#leaderboard tr.rank-3 td:first-child { color: #f59e0b; font-weight: 700; }

.btn-back {
    background: #ffffff;
    border: 2px solid var(--accent);
    color: var(--accent);
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 800;
    padding: 8px 18px;
    border-radius: 10px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
}

.btn-back:hover {
    background: var(--accent);
    color: white;
    transform: translateX(-3px);
}

.btn-outline {
    width: 100%;
    padding: 14px;
    background: var(--item-bg);
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 700;
    border-radius: 16px;
    cursor: pointer;
    margin-top: 1rem;
    transition: all 0.2s;
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.sync-status {
    display: none;
    align-items: center;
    margin-top: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1.2;
    max-width: 100%;
    white-space: nowrap;
}

.sync-status.visible {
    display: inline-flex;
}

.sync-status.saved,
.sync-status.online {
    color: var(--primary);
}

.sync-status.saving,
.sync-status.checking {
    color: #0369a1;
}

.sync-status.offline {
    color: #b45309;
}

.sync-status.error {
    color: var(--danger);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    flex: 0 0 auto;
}

.status-dot.online,
.status-dot.saved {
    background: var(--primary);
}

.status-dot.saving,
.status-dot.checking {
    background: var(--accent);
}

.status-dot.offline {
    background: #f59e0b;
}

.status-dot.error {
    background: var(--danger);
}

footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 600;
}

.btn-refresh {
    display: inline-block;
    margin-top: 8px;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    padding: 5px 12px;
    font-size: 0.78rem;
    font-weight: 800;
    color: #334155;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.btn-refresh:disabled {
    opacity: 0.6;
    cursor: default;
}

#app-version {
    display: inline-block;
    margin-left: 0.35rem;
    color: #94a3b8;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-history {
    background: var(--item-bg);
    border: none;
    color: var(--text-main);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    position: absolute;
    right: 0;
    top: 5px;
    margin-top: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.btn-history:hover {
    background: #f1f5f9;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
    animation: fadeIn 0.25s ease-out;
}

.modal-card {
    background: var(--card-bg);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    padding: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    animation: fadeInDown 0.3s ease-out;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 12px;
}

.modal-header h3 {
    font-size: 1.15rem;
    color: var(--text-main);
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.modal-description {
    font-size: 0.88rem;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
}

.input-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.input-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-main);
}

.server-status-box {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    line-height: 1.4;
    margin-bottom: 16px;
}

.server-status-box.success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.server-status-box.warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.server-status-box.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.server-status-box.info {
    background: #f0f9ff;
    color: #075985;
    border: 1px solid #bae6fd;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.modal-actions button {
    flex: 1;
}

.btn-secondary {
    background: var(--item-bg);
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 12px;
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f8fafc;
}

.server-help-details {
    background: var(--item-bg);
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.server-help-details summary {
    font-weight: 700;
    cursor: pointer;
    color: var(--primary);
    user-select: none;
}

.server-help-details ol {
    margin-top: 10px;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    line-height: 1.5;
}

.server-help-details code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--text-main);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 5px;
}

.history-item {
    background: var(--item-bg);
    border-radius: 16px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.history-date-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.history-winner-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
}

.history-winner-preview span {
    color: var(--primary);
}

.toggle-icon {
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

.history-item.expanded .toggle-icon {
    transform: rotate(180deg);
}

.history-players-list {
    display: none;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
    animation: fadeIn 0.3s ease-out;
}

.history-item.expanded .history-players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-player-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 8px 0;
    border-bottom: 1px solid #f8fafc;
}

.history-player-row.winner {
    background: rgba(0, 163, 108, 0.05);
    border-radius: 8px;
    padding: 8px 12px;
    margin: -4px -12px;
}

.history-player-row:last-child {
    border-bottom: none;
}

.history-player-row .rank {
    font-weight: 700;
    min-width: 42px;
    color: var(--text-muted);
}

.history-player-row .rank.place-1 { color: var(--primary); font-weight: 800; }
.history-player-row .rank.place-2 { color: var(--accent); }
.history-player-row .rank.place-3 { color: #f59e0b; }

.history-player-row .name {
    flex-grow: 1;
    font-weight: 600;
    color: var(--text-main);
}

.history-player-row .stats {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-player-row .net {
    font-weight: 700;
    color: var(--primary);
}

.history-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}

.history-stats + .history-list {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    padding-top: 14px;
    margin-top: 12px;
}

.stats-acc-body {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.28s ease;
}

.stats-acc.open > .stats-acc-body {
    grid-template-rows: 1fr;
}

.stats-acc-inner {
    overflow: hidden;
    min-height: 0;
}

.stats-acc-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 10px;
}

.stats-acc-head {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: none;
    background: transparent;
    padding: 0;
    font-family: inherit;
    color: var(--text-main);
    text-align: left;
    cursor: pointer;
    min-height: 44px;
    -webkit-tap-highlight-color: transparent;
}

.stats-acc-head:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.stats-root-head {
    background: var(--item-bg);
    border-radius: 16px;
    padding: 12px 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.stats-acc-copy {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.stats-acc-title {
    font-size: 0.98rem;
    font-weight: 800;
    line-height: 1.3;
}

.stats-acc-summary {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.stats-acc.open > .stats-acc-head .stats-acc-summary {
    display: none;
}

.stats-chevron {
    flex: 0 0 auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: transform 0.28s ease;
}

.stats-acc.open > .stats-acc-head .stats-chevron {
    transform: rotate(180deg);
}

.stats-card {
    background: var(--item-bg);
    border-radius: 16px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.stats-card.stats-acc {
    padding: 0;
    overflow: hidden;
}

.stats-card.stats-acc > .stats-acc-head {
    padding: 10px 14px;
}

.stats-acc-content {
    padding: 0 14px 12px;
}

@media (prefers-reduced-motion: reduce) {
    .stats-acc-body,
    .stats-chevron {
        transition: none;
    }
}

.stats-month-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.stats-nav-btn {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.stats-nav-btn:active:not(:disabled) {
    transform: scale(0.96);
    background: #e2e8f0;
}

.stats-nav-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.stats-month-label {
    text-align: center;
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1.2;
}

.stats-month-count {
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
}

.stats-kicker {
    font-size: 0.68rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.stats-highlights {
    display: grid;
    grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.92fr);
    gap: 8px;
}

.stats-spot {
    min-width: 0;
    border-radius: 14px;
    padding: 12px 11px 11px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.stats-spot.mvp {
    background:
        radial-gradient(110px 56px at 100% 0%, rgba(251, 191, 36, 0.32), transparent 72%),
        linear-gradient(180deg, #fffaf0 0%, #ffffff 72%);
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.16);
}

.stats-spot.play {
    background:
        radial-gradient(90px 48px at 100% 0%, rgba(0, 163, 108, 0.2), transparent 72%),
        linear-gradient(180deg, #f3fbf7 0%, #ffffff 72%);
    box-shadow: inset 0 0 0 1px rgba(0, 163, 108, 0.16);
}

.stats-spot-name {
    margin-top: 6px;
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-spot.mvp .stats-spot-name {
    color: #9a6700;
}

.stats-spot.play .stats-spot-name {
    color: var(--primary);
}

.stats-spot-main {
    margin-top: auto;
    padding-top: 8px;
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.04em;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

.stats-spot-main span {
    margin-left: 2px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0;
    color: var(--text-muted);
}

.stats-spot-sub,
.stats-spot-tie {
    margin-top: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-spot-empty {
    margin-top: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1.35;
}

.stats-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 2px;
}

.stats-title {
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text-main);
}

.stats-scope {
    display: flex;
    background: #f1f5f9;
    border-radius: 999px;
    padding: 2px;
    flex: 0 0 auto;
}

.stats-scope button {
    border: none;
    background: transparent;
    border-radius: 999px;
    padding: 6px 12px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.stats-scope button.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stats-scope-note {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stats-rank-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.stats-rank-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 1.8rem 4.35rem;
    column-gap: 6px;
    align-items: center;
    min-height: 44px;
    padding: 6px 8px;
    border-radius: 12px;
    background: #f8fafc;
}

.stats-rank-labels {
    min-height: 0;
    padding: 0 8px 2px;
    background: transparent;
    font-size: 0.64rem;
    font-weight: 800;
    color: var(--text-muted);
    line-height: 1.2;
}

.stats-rank-labels span:nth-child(n + 3) {
    text-align: right;
}

.stats-place {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    justify-self: center;
    background: #e8eef5;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
}

.stats-place.medal {
    background: transparent;
    font-size: 1.2rem;
}

.stats-rank-name {
    font-size: 0.92rem;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-rank-wins,
.stats-rank-avg {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    white-space: nowrap;
}

.stats-rank-wins {
    font-size: 1rem;
    color: var(--primary);
}

.stats-rank-avg {
    font-size: 0.82rem;
    color: var(--text-main);
}

.stats-rank-row.tier-1 {
    background: linear-gradient(90deg, #fff6df 0%, #fffdf8 100%);
    box-shadow: inset 0 0 0 1px rgba(217, 119, 6, 0.16);
}

.stats-rank-row.tier-2 {
    background: linear-gradient(90deg, #f2f5fa 0%, #fbfcfe 100%);
    box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.14);
}

.stats-rank-row.tier-3 {
    background: linear-gradient(90deg, #fbf3ec 0%, #fffdfb 100%);
    box-shadow: inset 0 0 0 1px rgba(180, 120, 70, 0.16);
}

.stats-rank-row.tier-1 .stats-rank-name {
    color: #9a6700;
}

.stats-more {
    width: 100%;
    margin-top: 8px;
    border: none;
    background: #f8fafc;
    border-radius: 10px;
    padding: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--accent);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.stats-more:active {
    background: #e2e8f0;
}

.stats-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 8px 4px 4px;
}

/* ===== Custom Score Keypad ===== */
#keypad-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#keypad-overlay.active {
    opacity: 1;
}

.keypad-modal {
    background: var(--card-bg);
    border-radius: 24px 24px 0 0;
    width: 100%;
    max-width: 320px;
    padding: 16px 18px 22px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

#keypad-overlay.active .keypad-modal {
    transform: translateY(0);
}

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

.keypad-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
}

.keypad-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.keypad-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.keypad-display {
    background: var(--item-bg);
    border-radius: 12px;
    padding: 12px 16px;
    text-align: center;
    margin-bottom: 10px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
    min-height: 40px;
}

.keypad-display span {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 2px;
    transition: color 0.2s;
}

.keypad-display span.negative {
    color: var(--danger);
}

.keypad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 10px;
}

.keypad-btn {
    background: var(--item-bg);
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 12px;
    padding: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.keypad-btn:active {
    transform: scale(0.94);
    background: #e2e8f0;
}

.keypad-minus {
    background: rgba(239, 68, 68, 0.08);
    color: var(--danger);
    font-weight: 800;
    font-size: 1.2rem;
    border-color: rgba(239, 68, 68, 0.15);
}

.keypad-minus:active {
    background: rgba(239, 68, 68, 0.18);
}

.keypad-delete {
    background: rgba(100, 116, 139, 0.08);
    color: var(--text-muted);
    font-size: 1.1rem;
}

.keypad-delete:active {
    background: rgba(100, 116, 139, 0.18);
}

.keypad-confirm {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 163, 108, 0.25);
    transition: transform 0.15s, opacity 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.keypad-confirm:active {
    transform: scale(0.98);
    opacity: 0.9;
}

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Better Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}
