/* ================================================================
   MATCH MANAGER — Style Sheet
   Primary : #1E7272 (teal)
   Font-title : 케리커스 케듀체 OTF Line  → var(--font-title)
   Font-body  : YoonChildfundkoreaMinGuk → var(--font-body)
   ================================================================ */

/* ===== FONTS ===== */
@font-face {
    font-family: 'YoonMinGuk';
    src: url('../fonts/YoonChildfundkoreaMinGuk.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'CariCadou';
    src: url('../fonts/KERISKEDU_Line.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
}

/* ===== VARIABLES ===== */
:root {
    --clr-teal:        #1E7272;
    --clr-teal-mid:    #2E8C8C;
    --clr-teal-pale:   #C0DADA;
    --clr-teal-alpha:  rgba(30, 114, 114, 0.10);
    --clr-bg:          #E9EDE8;
    --clr-white:       #FFFFFF;
    --clr-text:        #1E7272;
    --clr-placeholder: rgba(30, 114, 114, 0.35);

    --font-body:  'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
    --font-yoon:  'YoonMinGuk', 'Pretendard', sans-serif;
    --font-title: 'CariCadou', 'Pretendard', cursive;

    --radius-pill: 999px;
    --radius-card: 18px;
    --radius-sm:   10px;

    --shadow-card: 0 2px 12px rgba(30, 114, 114, 0.08);
    --shadow-btn:  0 6px 20px rgba(30, 114, 114, 0.30);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* ===== BODY ===== */
body {
    font-family: var(--font-body);
    background-color: var(--clr-bg);
    background-image:
        linear-gradient(var(--clr-teal-alpha) 1px, transparent 1px),
        linear-gradient(90deg, var(--clr-teal-alpha) 1px, transparent 1px);
    background-size: 28px 28px;
    min-height: 100vh;
    color: var(--clr-text);
    display: flex;
    flex-direction: column;
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 56px 32px 96px;
}

/* ===== HEADER ===== */
header {
    text-align: center;
    margin-bottom: 48px;
}

.header-inner {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.header-title-img {
    width: auto;
    max-width: 100%;
    height: 160px;
    object-fit: contain;
}

.subtitle {
    font-family: var(--font-yoon);
    font-size: 17px;
    color: var(--clr-text);
    letter-spacing: 0.02em;
    margin-top: 4px;
}

/* ===== INFO BOX ===== */
.info-box {
    background: rgba(255, 255, 255, 0.65);
    border: 1.5px solid var(--clr-teal-pale);
    border-radius: var(--radius-card);
    padding: 14px 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
}

.info-box h3 {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--clr-teal);
    margin-bottom: 8px;
}

.grade-legend {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.info-text {
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--clr-text);
    opacity: 0.72;
    line-height: 1.65;
}

/* ===== INPUT SECTION ===== */
.input-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.input-header h2 {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--clr-teal);
}

.count-badge {
    background: var(--clr-teal);
    color: var(--clr-white);
    font-family: var(--font-body);
    font-size: 12px;
    padding: 3px 12px;
    border-radius: var(--radius-pill);
}

/* ===== PLAYER LIST ===== */
.player-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 32px;
}

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

/* 원형 번호 뱃지 */
.player-num {
    width: 50px;
    height: 50px;
    background: var(--clr-teal);
    color: var(--clr-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-title);
    font-size: 22px;
    flex-shrink: 0;
    user-select: none;
}

/* 이름 입력 — pill */
.player-name-input {
    flex: 1;
    min-width: 0;
    height: 50px;
    padding: 0 22px;
    background: var(--clr-white);
    border: 2px solid var(--clr-teal-mid);
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--clr-text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.player-name-input::placeholder { color: var(--clr-placeholder); }

.player-name-input:focus {
    border-color: var(--clr-teal);
    box-shadow: 0 0 0 3px rgba(30, 114, 114, 0.12);
}

/* 등급 셀렉트 — teal pill */
.grade-select {
    width: 84px;
    height: 50px;
    background: var(--clr-teal);
    color: var(--clr-white);
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 18px;
    font-weight: bold;
    text-align: center;
    text-align-last: center;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    padding: 0 24px 0 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='white' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    outline: none;
    transition: box-shadow 0.2s;
}

.grade-select:focus {
    box-shadow: 0 0 0 3px rgba(30, 114, 114, 0.2);
}

/* 수치 입력 — white pill */
.value-input {
    width: 88px;
    height: 50px;
    padding: 0 10px;
    background: var(--clr-white);
    border: 2px solid var(--clr-teal);
    border-radius: var(--radius-pill);
    font-family: var(--font-body);
    font-size: 18px;
    text-align: center;
    color: var(--clr-text);
    outline: none;
    transition: box-shadow 0.2s;
    -moz-appearance: textfield;
}

.value-input:focus {
    box-shadow: 0 0 0 3px rgba(30, 114, 114, 0.12);
}

.value-input::-webkit-inner-spin-button,
.value-input::-webkit-outer-spin-button {
    opacity: 1;
}

/* 삭제 버튼 */
.btn-remove {
    width: 34px;
    height: 34px;
    border: none;
    background: transparent;
    color: var(--clr-placeholder);
    font-size: 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.btn-remove:hover {
    background: rgba(30, 114, 114, 0.10);
    color: var(--clr-teal);
}

/* ===== 액션 버튼 그룹 ===== */
.btn-group {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 36px;
}

.btn-group .btn {
    background: none;
    border: none;
    color: var(--clr-teal);
    font-family: var(--font-yoon);
    font-size: 15px;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    position: relative;
    white-space: nowrap;
}

.btn-group .btn::after {
    content: '';
    position: absolute;
    right: 0;
    top: 22%;
    height: 56%;
    width: 1.5px;
    background: var(--clr-teal-pale);
}

.btn-group .btn:last-child::after { display: none; }

.btn-group .btn:hover {
    background: rgba(30, 114, 114, 0.08);
    border-radius: var(--radius-sm);
}

/* ===== 엑셀 섹션 ===== */
.excel-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.excel-label {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--clr-text);
    opacity: 0.8;
}

.btn-excel-dl,
.btn-excel-ul {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 18px;
    border: 2px solid var(--clr-teal);
    border-radius: var(--radius-pill);
    background: var(--clr-white);
    color: var(--clr-teal);
    font-family: var(--font-body);
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.btn-excel-dl:hover,
.btn-excel-ul:hover {
    background: var(--clr-teal);
    color: var(--clr-white);
}

.excel-msg {
    font-family: var(--font-body);
    font-size: 14px;
    margin-top: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    text-align: center;
}

.excel-msg.hidden          { display: none; }
.excel-msg-success { background: #e6f4f0; color: #1a6b4a; border: 1px solid #a8d5c2; }
.excel-msg-error   { background: #fce8e8; color: #c0392b; border: 1px solid #f0a8a8; }
.excel-msg-loading { background: rgba(30,114,114,0.07); color: var(--clr-teal); border: 1px solid var(--clr-teal-pale); }

/* ===== 유효성 메시지 ===== */
.validation-msg {
    text-align: center;
    color: #c0392b;
    font-family: var(--font-body);
    font-size: 14px;
    margin-bottom: 16px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: #fce8e8;
    border: 1px solid #f0a8a8;
}

.validation-msg.hidden { display: none; }

/* ===== 코트 수 스테퍼 ===== */
.court-setting {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}

.court-label {
    font-family: var(--font-body);
    font-size: 16px;
    color: var(--clr-teal);
}

.court-stepper {
    display: flex;
    align-items: center;
    background: var(--clr-white);
    border: 2px solid var(--clr-teal);
    border-radius: var(--radius-pill);
    overflow: hidden;
}

.stepper-btn {
    width: 46px;
    height: 46px;
    border: none;
    background: transparent;
    color: var(--clr-teal);
    font-size: 24px;
    line-height: 1;
    transition: background 0.15s;
    flex-shrink: 0;
}

.stepper-btn:hover {
    background: rgba(30, 114, 114, 0.10);
}

.stepper-val {
    min-width: 64px;
    text-align: center;
    font-family: var(--font-body);
    font-size: 17px;
    font-weight: bold;
    color: var(--clr-teal);
    padding: 0 4px;
    user-select: none;
}

/* ===== 대진표 생성 버튼 ===== */
.btn-generate {
    display: block;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    height: 72px;
    background: var(--clr-teal);
    color: var(--clr-white);
    border: none;
    border-radius: var(--radius-pill);
    font-family: var(--font-title);
    font-size: 32px;
    letter-spacing: 2px;
    box-shadow: var(--shadow-btn);
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
}

.btn-generate:hover {
    background: #175e5e;
    box-shadow: 0 8px 28px rgba(30, 114, 114, 0.38);
}

.btn-generate:active {
    transform: translateY(2px);
    box-shadow: 0 2px 8px rgba(30, 114, 114, 0.20);
}

/* ===== 급수 뱃지 ===== */
.grade-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    color: var(--clr-white);
    flex-shrink: 0;
}

.grade-s { background: #7B2FA6; }
.grade-a { background: #1E7272; }
.grade-b { background: #28886A; }
.grade-c { background: #439652; }
.grade-d { background: #7EA230; }
.grade-e { background: #B8882A; }
.grade-f { background: #C06040; }

/* ===== 점수 태그 ===== */
.score-tag {
    display: inline-block;
    background: rgba(30, 114, 114, 0.10);
    color: var(--clr-teal);
    font-size: 11px;
    padding: 1px 7px;
    border-radius: var(--radius-pill);
}

/* ===== 모달 ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--clr-bg);
    background-image:
        linear-gradient(var(--clr-teal-alpha) 1px, transparent 1px),
        linear-gradient(90deg, var(--clr-teal-alpha) 1px, transparent 1px);
    background-size: 28px 28px;
    border-radius: var(--radius-card);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1.5px solid var(--clr-teal-pale);
    flex-shrink: 0;
}

.modal-header h2 {
    font-family: var(--font-title);
    font-size: 28px;
    color: var(--clr-teal);
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--clr-teal);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.modal-close:hover { background: var(--clr-teal-alpha); }

.modal-body {
    overflow-y: auto;
    padding: 24px 28px;
    flex: 1;
}

.modal-footer {
    padding: 16px 28px;
    border-top: 1.5px solid var(--clr-teal-pale);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

/* ===== 코트 섹션 ===== */
.court-section {
    background: rgba(255, 255, 255, 0.80);
    border: 1.5px solid var(--clr-teal-pale);
    border-radius: var(--radius-card);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-card);
}

.court-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.court-header h2 {
    font-family: var(--font-body);
    font-size: 17px;
    color: var(--clr-teal);
}

.player-count {
    background: var(--clr-teal);
    color: var(--clr-white);
    font-family: var(--font-body);
    font-size: 11px;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
}

.court-players {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--clr-teal-pale);
}

.player-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    max-width: 100%;
    overflow-wrap: anywhere;
    background: var(--clr-white);
    border: 1.5px solid var(--clr-teal-pale);
    border-radius: var(--radius-pill);
    padding: 4px 12px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--clr-text);
}

/* ===== 게임 그리드 ===== */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
    gap: 14px;
}

.game-card {
    background: var(--clr-white);
    border: 1.5px solid var(--clr-teal-pale);
    border-radius: var(--radius-card);
    padding: 14px;
    box-shadow: var(--shadow-card);
}

.game-title {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: bold;
    color: var(--clr-teal);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.balance-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-weight: normal;
}

.balance-ok   { background: #e6f4f0; color: #1a6b4a; }
.balance-warn { background: #fff4e0; color: #c07020; }

.match-area {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

.team {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.team-label {
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: bold;
    color: var(--clr-teal);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.team-score {
    background: var(--clr-teal);
    color: var(--clr-white);
    padding: 1px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: normal;
}

.vs-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-title);
    font-size: 17px;
    color: var(--clr-teal);
    padding: 0 2px;
    margin-top: 22px;
    flex-shrink: 0;
}

.team-player {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow-wrap: anywhere;
    background: rgba(30, 114, 114, 0.04);
    border: 1.5px solid var(--clr-teal-pale);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--clr-text);
    min-height: 34px;
}

.team-player.team-a { border-left: 3px solid var(--clr-teal); }
.team-player.team-b { border-left: 3px solid var(--clr-teal-mid); }

/* ===== 드래그앤드롭 ===== */
.dnd-item {
    cursor: grab;
    transition: background 0.15s, transform 0.1s;
}

.dnd-item:hover { background: rgba(30, 114, 114, 0.10) !important; }

.dnd-dragging {
    opacity: 0.45;
    cursor: grabbing;
    transform: scale(0.96);
}

.dnd-over {
    background: rgba(30, 114, 114, 0.16) !important;
    border-color: var(--clr-teal) !important;
}

.dnd-empty {
    background: rgba(30, 114, 114, 0.03);
    border: 1.5px dashed var(--clr-teal-pale) !important;
    color: var(--clr-placeholder);
    min-height: 34px;
}

/* ===== 대기 영역 ===== */
.waiting-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--clr-teal-pale);
    flex-wrap: wrap;
}

.waiting-label {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--clr-placeholder);
    background: var(--clr-teal-pale);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    white-space: nowrap;
}

.waiting-slot {
    border-style: dashed !important;
    background: rgba(30, 114, 114, 0.03) !important;
}

/* ===== 모달 푸터 버튼 ===== */
.btn-print,
.btn-regenerate,
.btn-close {
    padding: 10px 22px;
    border-radius: var(--radius-pill);
    border: 2px solid var(--clr-teal);
    font-family: var(--font-body);
    font-size: 14px;
    background: var(--clr-white);
    color: var(--clr-teal);
    transition: background 0.15s, color 0.15s;
}

.btn-print:hover,
.btn-regenerate:hover {
    background: var(--clr-teal);
    color: var(--clr-white);
}

.btn-close {
    background: var(--clr-teal);
    color: var(--clr-white);
}

.btn-close:hover { background: #175e5e; }

/* ===== 반응형 ===== */
@media (max-width: 600px) {
    .container { padding: 32px 16px 64px; }

    header h1  { font-size: 42px; }
    .header-icon { width: 60px; height: 60px; }
    .subtitle  { font-size: 14px; }

    .player-row { gap: 8px; }
    .player-num { width: 40px; height: 40px; font-size: 18px; }
    .player-name-input { height: 44px; font-size: 14px; padding: 0 16px; }
    .grade-select { width: 70px; height: 44px; font-size: 16px; }
    .value-input  { width: 76px; height: 44px; font-size: 16px; }

    .btn-group .btn { font-size: 13px; padding: 8px 12px; }
    .btn-generate   { font-size: 24px; height: 60px; }

    .excel-section { gap: 6px; }
    .excel-label   { font-size: 12px; }
    .btn-excel-dl,
    .btn-excel-ul  { font-size: 12px; padding: 7px 12px; }

    .court-setting {
        display: grid;
        grid-template-columns: auto auto;
        justify-content: center;
        align-items: center;
        gap: 12px 14px;
    }

    .modal        { padding: 12px; }
    .modal-body   { padding: 16px 12px; }
    .modal-header { padding: 16px 18px; }
    .modal-header h2 { font-size: 22px; }
    .modal-footer { padding: 12px 14px; gap: 8px; flex-wrap: wrap; justify-content: center; }
    .btn-print,
    .btn-regenerate,
    .btn-close    { font-size: 13px; padding: 8px 14px; }
    .games-grid   { grid-template-columns: 1fr; }

    .court-section { padding: 14px; }
    .match-area    { flex-direction: column; gap: 6px; }
    .vs-badge      { margin-top: 0; padding: 2px 0; }
}

/* ===== 푸터 ===== */
.site-footer {
    margin-top: auto;
    padding: 28px 24px;
    background: #175e5e;
    border-top: 2px solid rgba(0,0,0,0.12);
}

.footer-inner {
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

.footer-brand {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.18em;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
}

.footer-divider {
    width: 1px;
    height: 28px;
    background: rgba(255,255,255,0.15);
    flex-shrink: 0;
}

.footer-info {
    display: grid;
    grid-template-columns: auto auto;
    gap: 6px 20px;
}

.footer-row {
    display: contents;
}

.footer-item {
    font-size: 12px;
    color: rgba(255,255,255,0.45);
    display: flex;
    align-items: center;
    gap: 6px;
}

.footer-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.07);
    padding: 2px 7px;
    border-radius: 4px;
}

@media (max-width: 480px) {
    .footer-inner { flex-direction: column; align-items: flex-start; gap: 12px; }
    .footer-divider { display: none; }
    .footer-info { grid-template-columns: 1fr; }
    .footer-item { flex-wrap: wrap; overflow-wrap: anywhere; }
}

/* ===== 인쇄 ===== */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    body { background: white; background-image: none; }
    .container { display: none; }
    .modal {
        position: relative;
        background: none;
        padding: 0;
        display: flex !important;
    }
    .modal.hidden { display: flex !important; }
    .modal-content {
        box-shadow: none;
        max-height: none;
        background: white;
        background-image: none;
    }
    .modal-header { border-bottom: 2px solid #ccc; }
    .modal-footer { display: none; }
    .site-footer   { display: none; }
}
