/* ===========================
   테마 변수 (유닛 선택에 따라 JS가 값을 바꿔줌)
=========================== */

:root {
    --accent: #000000;
    --accent-hover: #262626;
    --accent-contrast: #ffffff;
    --accent-text: #000000;
    --accent-light: #f0f0f0;
    --accent-light-hover: #d9d9d9;
    --accent-border: #bdbdbd;
}

/* ===========================
   기본 설정
=========================== */

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

body {
    background: #ffffff;
    font-family:
        "Pretendard",
        "Noto Sans KR",
        sans-serif;
    color: #222;
}

.wrapper {
    width: 100%;
    min-height: 100vh;
    padding: 32px 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
}

.scale-wrap {
    margin: 0 auto;
    overflow: hidden;
    position: relative;
}

.capture-area {
    margin: 0 auto;
    padding: 28px 50px 34px;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .08);
    transform-origin: top left;
}

/* 덴페스/공수 취향표 모두 인원수(표 폭 / 컬럼 수)에 맞춰
   JS(getRpsCaptureWidth / getLrCaptureWidth)가 실제 폭을 계산해서
   인라인 스타일로 넣어준다. 여기 값은 JS 실행 전 잠깐 보이는 기본값일 뿐이다. */
#captureArea {
    width: 1100px;
}

#captureAreaLr {
    width: 1100px;
}

/* 전체(유닛 미선택) 덴페스 취향표는 인원이 많아 캡처 폭이 넓어진 만큼
   위쪽/좌우 여백도 같이 넉넉하게 늘린다. 이 좌우 padding 값(80px * 2)은
   JS의 RPS_PADDING_X_ALL과 반드시 같아야 표가 잘리지 않는다. */
body:not(.unit-selected) #captureArea {
    padding: 56px 80px 34px;
}

/* 전체(유닛 미선택) 공수 취향표는 로고/제목이 커진 만큼 위쪽 여백도 늘린다. */
body:not(.unit-selected) #captureAreaLr {
    padding-top: 56px;
}

/* ===========================
   탭 전환
=========================== */

.tab-wrap {
    display: flex;
    gap: 8px;
    background: var(--accent-light);
    padding: 6px;
    border-radius: 999px;
    margin-bottom: 18px;
}

.tab-btn {
    border: none;
    background: transparent;
    padding: 10px 22px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-text);
    cursor: pointer;
    transition: .2s;
}

.tab-btn:hover {
    color: var(--accent);
}

.tab-btn.active {
    background: var(--accent);
    color: var(--accent-contrast);
}

/* ===========================
   상단
=========================== */

.logo {
    display: block;
    width: 300px;
    height: auto;
    margin: 0 auto 38px;
}

h1 {
    text-align: center;
    font-size: 34px;
    line-height: 1.15;
    font-weight: 900;
    color: var(--accent-text);
    margin: 0 0 38px;
}

/* 유닛 로고(unevermet/yesw8are/itsnot5ver) 이미지 자체에 여백이 있어서
   기본값(위 0 / 아래 38px)을 그대로 쓰면 위쪽엔 붕 뜨고 제목과는 멀어 보인다.
   유닛이 선택된 덴페스 취향표에서만 로고를 조금 더 내리고, 로고-제목 거리가
   제목-표 거리(h1 margin-bottom 38px)와 비슷해지도록 아래 여백을 줄인다. */
.unit-selected #logoRps {
    margin-top: 30px;
    margin-bottom: 6px;
}

/* 공수 취향표(전체/유닛 공통)는 로고와 제목 사이는 좁히고,
   제목과 프로필 사이는 넓혀서 제목이 로고 쪽에 붙어 보이게 한다. */
#logoLr {
    margin: 0 auto 16px;
}

#captureAreaLr h1 {
    margin: 0 0 54px;
}

/* 전체(유닛 미선택) 공수 취향표는 캡처 폭이 훨씬 넓어졌으니,
   프로필 사진(128px)/칸 크기에 맞춰 로고와 제목도 같은 비율로 키운다. */
body:not(.unit-selected) #logoLr {
    width: 380px;
    margin: 0 auto 20px;
}

body:not(.unit-selected) #captureAreaLr h1 {
    font-size: 44px;
    margin: 0 0 68px;
}

.capture-id-bottom {
    display: block;
    text-align: center;
    margin: 26px 0 0;
    color: #bbb;
    font-size: 14px;
    font-weight: 600;
}

.chart-date {
    display: inline-block;
    margin-left: 10px;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    vertical-align: middle;
}

/* ===========================
   표
=========================== */

.table-wrap {
    position: relative;
    margin-top: 0;
}

.table-nav {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    max-width: 980px;
    margin: 0 auto 8px;
}

.nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--accent-light);
    color: var(--accent-text);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: .15s;
}

.nav-btn:hover:not(:disabled) {
    background: var(--accent-light-hover);
    transform: none;
}

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

/* 표 칸 크기를 유닛/전체 인원수와 무관하게 항상 일정하게 유지한다.
   인원이 적은 유닛(예: 3유닛)은 표가 좁게 가운데 정렬되고,
   전체(20명)처럼 칸을 다 채우면 감당 못 하는 경우에는 표가 컨테이너보다
   넓어지면서 이 래퍼가 가로 스크롤(드래그)되도록 한다. */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: max-content;
    margin: 0 auto;
    border-collapse: collapse;
    table-layout: fixed;
    overflow: hidden;
    border-radius: 16px;
}

th {
    background: var(--accent);
    color: var(--accent-contrast);
    width: 118px;
    height: 68px;
    font-size: 23px;
    font-weight: 800;
    border: 1px solid rgba(255,255,255,.45);
}

th:first-child,
td:first-child {
    width: 140px;
}

.clickable-header {
    cursor: pointer;
    transition: .15s;
}

.clickable-header:hover {
    background: var(--accent-hover);
}

td {
    width: 118px;
    height: 68px;
    text-align: center;
    font-size: 23px;
    font-weight: 700;
    background: #fff;
    border: 1px solid #e3e3e3;
    cursor: pointer;
    transition: .15s;
}

td:hover {
    transform: scale(1.025);
    position: relative;
    z-index: 2;
}

/* ===========================
   범례
=========================== */

.legend {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
    margin-top: 25px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 22px;
    font-weight: 700;
}

.color {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    border: 2px solid #d8d8d8;
}

.color.dashed {
    border-style: dashed;
    border-color: #bbb;
    background: #fff !important;
}

/* ===========================
   왼른 취향표
=========================== */

/* JS(getLrColumns)가 유닛별 인원을 이미 컬럼 단위로 나눠주기 때문에,
   여기서는 나눠진 컬럼들을 가로로 나란히, 각 컬럼 내부는 세로로 쌓기만 하면 된다. */
.lr-grid {
    display: flex;
    align-items: flex-start;
    gap: 50px;
}

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

.lr-row {
    display: flex;
    align-items: flex-start;
    gap: 22px;
}

.lr-avatar {
    position: relative;
    width: 128px;
    height: 128px;
    border-radius: 50%;
    overflow: hidden;
    flex: 0 0 auto;
    cursor: pointer;
    border: 4px solid var(--accent-light);
    background: var(--accent-light);
}

.lr-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.lr-avatar .avatar-edit {
    position: absolute;
    inset: auto 0 0 0;
    height: 22px;
    background: rgba(0,0,0,.5);
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: .15s;
}

.lr-avatar:hover .avatar-edit {
    opacity: 1;
}

.lr-content {
    flex: 1;
    min-width: 0;
}

.lr-bar-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.lr-label-l,
.lr-label-r {
    font-size: 17px;
    font-weight: 800;
    color: var(--accent-text);
    flex: 0 0 auto;
}

.lr-bar {
    flex: 1;
    display: flex;
    height: 32px;
    border: 2px solid var(--accent-border);
    border-radius: 8px;
    overflow: hidden;
}

.lr-cell {
    flex: 1;
    height: 100%;
    background: #fff;
    border-right: 1px solid var(--accent-light);
    cursor: pointer;
    transition: .1s;
}

.lr-cell:last-child {
    border-right: none;
}

.lr-cell:hover {
    background: var(--accent-light-hover);
}

.lr-cell.filled {
    background: var(--accent);
}

.lr-text-wrap {
    position: relative;
}

.lr-text {
    width: 100%;
    min-height: 150px;
    resize: none;
    overflow: hidden;
    border: 2px solid var(--accent-border);
    border-radius: 10px;
    padding: 12px 14px 26px;
    font-size: 17px;
    line-height: 1.5;
    font-family: inherit;
    word-break: break-word;
    color: #222;
    outline: none;
}

.lr-text:focus {
    border-color: var(--accent);
}

.lr-text::placeholder {
    color: #b7cdb0;
}

.lr-char-count {
    position: absolute;
    right: 12px;
    bottom: 8px;
    font-size: 12px;
    color: #b7cdb0;
    font-weight: 600;
    pointer-events: none;
}

/* ===========================
   버튼 / 안내
=========================== */

.button-wrap {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-top: 22px;
}

button {
    border: none;
    border-radius: 14px;
    font-size: 21px;
    font-weight: 800;
    cursor: pointer;
    transition: .2s;
}

button:hover {
    transform: translateY(-2px);
}

#saveBtn,
#resetBtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: auto;
    height: 48px;
    padding: 0 26px;
    border-radius: 999px;
    font-size: 16px;
}

#saveBtn {
    background: var(--accent);
    color: var(--accent-contrast);
}

#saveBtn:hover {
    background: var(--accent-hover);
}

#resetBtn {
    background: #fff;
    color: #666;
    border: 1.5px solid #ddd;
}

#resetBtn:hover {
    background: #f5f5f5;
}

.btn-icon {
    font-size: 16px;
    line-height: 1;
}

.date-toggle-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin-top: 20px;
}

.date-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 700;
    color: #777;
    cursor: pointer;
    user-select: none;
}

.date-toggle input {
    width: 17px;
    height: 17px;
    accent-color: var(--accent-text);
    cursor: pointer;
}

/* ===========================
   유닛 선택 체크박스
=========================== */

.unit-toggle-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin-top: 10px;
}

.unit-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    user-select: none;
}

.unit-toggle input {
    width: 17px;
    height: 17px;
    cursor: pointer;
}

.unit-toggle-1 {
    color: #f18b02;
}

.unit-toggle-1 input {
    accent-color: #f18b02;
}

.unit-toggle-2 {
    color: #1ab017;
}

.unit-toggle-2 input {
    accent-color: #1ab017;
}

.unit-toggle-3 {
    color: #1661cc;
}

.unit-toggle-3 input {
    accent-color: #1661cc;
}

.guide-list {
    text-align: center;
    margin: 0 0 18px;
}

.guide-list p {
    margin: 0;
    color: #999;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.7;
}

/* 이미지 저장(캡처) 시 안내 문구 / 이전-이후 버튼을 숨기는 상태.
   h1의 margin-bottom(18px)만 남아 제목과 표 사이 간격이
   너무 좁거나 멀지 않게 유지된다. */
.capturing .guide-list,
.capturing .table-nav {
    display: none;
}

/* ===========================
   색상 선택 모달
=========================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.hidden {
    display: none;
}

.modal-box {
    width: 440px;
    background: #fff;
    border-radius: 24px;
    padding: 34px 26px 26px;
    position: relative;
    box-shadow: 0 18px 50px rgba(0,0,0,.18);
}

.close-btn {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 40px;
    height: 40px;
    background: none !important;
    border: none;
    font-size: 34px;
    cursor: pointer;
    color: #555;
}

.modal-title {
    text-align: center;
    font-size: 21px;
    font-weight: 900;
    color: #111;
    margin-bottom: 22px;
}

.option-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px 10px;
}

.option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 2px;
    border-radius: 14px;
    cursor: pointer;
    transition: .15s;
}

.option-card:hover {
    background: #f4f4f4;
}

.option-dot {
    display: inline-block;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid #e2e2e2;
}

.option-dot.dashed {
    border-style: dashed;
    border-color: #bbb;
    background: #fff !important;
}

.option-label {
    font-size: 12.5px;
    font-weight: 700;
    color: #333;
    text-align: center;
}

.option-dot-wrap {
    display: inline-block;
    position: relative;
    width: 46px;
    height: 46px;
}

.option-dot-wrap .option-dot {
    width: 100%;
    height: 100%;
}

.color-edit-btn {
    position: absolute;
    right: -6px;
    bottom: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    cursor: pointer;
    line-height: 1;
}

.color-edit-btn:hover {
    background: #f4f4f4;
}

.color-edit-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.reset-colors-link {
    text-align: center;
    margin-top: 16px;
    font-size: 12.5px;
    font-weight: 700;
    color: #999;
    text-decoration: underline;
    cursor: pointer;
}

.reset-colors-link:hover {
    color: var(--accent-text);
}

.modal-extra {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.hide-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-top: 16px;
    font-size: 13px;
    font-weight: 700;
    color: #666;
    cursor: pointer;
    user-select: none;
}

.hide-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-text);
    cursor: pointer;
}

.clear-card .option-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f3f3 !important;
    border: 2px solid #e2e2e2;
    font-size: 20px;
}

/* ===========================
   저장 완료 모달
=========================== */

.save-box {
    width: 620px;
    max-height: 92vh;
    overflow: auto;
    background: #fff;
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 18px 50px rgba(0,0,0,.18);
}

.save-box h2 {
    font-size: 32px;
    line-height: 1.25;
    word-break: keep-all;
}

.save-box p {
    font-size: 18px;
    color: #777;
    margin: 8px 0 20px;
}

#previewImage {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    margin: 18px auto 20px;
    border-radius: 12px;
}

#closeSaveModal {
    width: 180px;
    background: #111;
    color: #fff;
}

/* ===========================
   반응형
=========================== */

@media (max-width: 768px) {
    .wrapper {
        padding: 16px 12px 24px;
    }

    /* 모바일에서는 JS 축소(transform: scale) 대신
       실제 레이아웃 폭을 화면에 맞춰 다시 짜기 때문에
       scale-wrap / capture-area 모두 폭을 100%로 풀어준다. */
    .scale-wrap {
        width: 100% !important;
        height: auto !important;
        overflow: visible;
    }

    .capture-area {
        padding: 20px 14px 22px;
        border-radius: 16px;
        box-shadow: 0 6px 20px rgba(0, 0, 0, .08);
    }

    /* 모바일에서는 두 영역 모두 화면 폭에 맞춰 100%로 (JS가 넣어준
       데스크톱 전용 인라인 폭도 fitCaptureArea에서 비워준다) */
    #captureArea,
    #captureAreaLr {
        width: 100%;
    }

    .logo {
        width: 130px;
        margin: 0 auto 14px;
    }

    h1 {
        font-size: 19px;
        margin: 0 0 14px;
    }

    #logoLr {
        margin: 0 auto 8px;
    }

    #captureAreaLr h1 {
        margin: 0 0 22px;
    }

    /* 전체(유닛 미선택) 전용 데스크톱 확대 규칙(80px 좌우 padding, 380px 로고,
       44px 제목 등)이 body:not(.unit-selected) #id 형태로 되어 있어 우선순위가
       매우 높다. 이 규칙들은 아래 위(.capture-area, .logo, h1 등) 모바일
       규칙보다 CSS 우선순위가 높기 때문에, 미디어쿼리 안에서도 무시되지 않고
       그대로 적용되어 로고가 커지고 표 옆에 큰 여백이 남는 문제가 있었다.
       같은 선택자로 다시 한 번 모바일 값으로 덮어써서 우선순위를 맞춘다. */
    body:not(.unit-selected) #captureArea {
        padding: 20px 14px 22px;
    }

    body:not(.unit-selected) #captureAreaLr {
        padding-top: 20px;
    }

    body:not(.unit-selected) #logoLr {
        width: 130px;
        margin: 0 auto 8px;
    }

    body:not(.unit-selected) #captureAreaLr h1 {
        font-size: 19px;
        margin: 0 0 22px;
    }

    .chart-date {
        font-size: 11px;
        margin-left: 6px;
    }

    .guide-list {
        margin-bottom: 12px;
    }

    .guide-list p {
        font-size: 11px;
        line-height: 1.5;
    }

    /* 덴페스 취향표 - 칸 크기는 인원수와 무관하게 일정하게 유지하고,
       인원이 많아 화면 폭을 넘어가면 억지로 줄이는 대신 옆으로
       드래그해서 넘겨보는 방식으로 본다. */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        width: auto;
        min-width: 0;
        table-layout: fixed;
    }

    th {
        width: 60px;
        height: 38px;
        font-size: 12px;
        padding: 0 1px;
        word-break: keep-all;
    }

    th:first-child,
    td:first-child {
        width: 76px;
    }

    td {
        width: 60px;
        height: 38px;
        font-size: 12px;
        padding: 0 1px;
    }

    .table-nav {
        margin-bottom: 6px;
    }

    .nav-btn {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }

    .legend {
        gap: 10px 14px;
        margin-top: 16px;
    }

    .legend-item {
        font-size: 11px;
        gap: 5px;
    }

    .color {
        width: 14px;
        height: 14px;
        border-width: 1.5px;
    }

    .capture-id-bottom {
        font-size: 11px;
        margin-top: 14px;
    }

    .tab-wrap {
        margin-bottom: 14px;
    }

    .tab-btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .button-wrap {
        gap: 12px;
        margin-top: 18px;
    }

    #saveBtn,
    #resetBtn {
        height: 42px;
        padding: 0 18px;
        font-size: 14px;
    }

    .date-toggle {
        font-size: 12px;
    }

    .unit-toggle {
        font-size: 12px;
    }

    .save-box {
        width: 75%;
        max-width: 340px;
        padding: 20px;
        border-radius: 18px;
    }

    .save-box h2 {
        font-size: 27px;
    }

    .save-box p {
        font-size: 14px;
        line-height: 1.4;
    }

    .modal-box {
        width: 75%;
        max-width: 340px;
        padding: 26px 18px 18px;
        border-radius: 18px;
    }

    .modal-title {
        font-size: 17px;
        margin-bottom: 16px;
    }

    .option-grid {
        gap: 14px 6px;
    }

    .option-dot {
        width: 38px;
        height: 38px;
    }

    .option-dot-wrap {
        width: 38px;
        height: 38px;
    }

    .color-edit-btn {
        width: 17px;
        height: 17px;
        font-size: 9px;
    }

    .option-label {
        font-size: 11px;
    }

    .lr-grid {
        flex-direction: column;
        align-items: stretch;
        gap: 26px;
    }

    .lr-column {
        gap: 26px;
    }

    .lr-row {
        gap: 14px;
    }

    .lr-avatar {
        width: 110px;
        height: 110px;
        border-width: 3px;
    }

    .lr-bar-wrap {
        gap: 8px;
        margin-bottom: 10px;
    }

    .lr-label-l,
    .lr-label-r {
        font-size: 15px;
    }

    .lr-bar {
        height: 28px;
        border-radius: 8px;
    }

    .lr-text {
        min-height: 120px;
        font-size: 15px;
        padding: 10px 12px 24px;
    }

    .lr-char-count {
        font-size: 11px;
    }
}
