* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px 8px;
    background: #141414;
    color: #f2f2f2;
    font-family: Arial, "Microsoft JhengHei", sans-serif;
    font-size: 13.2px;
}

.container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

.top-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 420px) minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    margin-bottom: 12px;
}

h1 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin: 0;
    color: #ffffff;
    font-size: 26.4px;
}

.title-date {
    color: #f0d58c;
    font-size: 19.2px;
    font-weight: 700;
}

h2 {
    margin: 0 0 6px;
    color: #ffffff;
    font-size: 18px;
}

.sub-title {
    margin: 4px 0 0;
    color: #f0d58c;
    font-size: 14.4px;
    font-weight: 700;
}


.top-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    justify-self: end;
    gap: 7px;
}

.player-search {
    width: 100%;
    padding: 8px;
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    background: #242424;
}

.player-search-label {
    display: block;
    margin-bottom: 5px;
    color: #f0d58c;
    text-align: center;
    font-size: 13.2px;
    font-weight: 700;
}

.player-search-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
}

.player-search-input {
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #5a5a5a;
    border-radius: 6px;
    outline: none;
    background: #303030;
    color: #ffffff;
    font-family: inherit;
    font-size: 13.2px;
}

.player-search-input:focus {
    border-color: #f0d58c;
    box-shadow: 0 0 0 2px rgba(240, 213, 140, 0.18);
}

.player-search-input::placeholder {
    color: #999999;
}

.player-search-button {
    padding: 8px 13px;
    border: 0;
    border-radius: 6px;
    background: #9b7b2f;
    color: #ffffff;
    font-family: inherit;
    font-size: 13.2px;
    font-weight: 700;
    cursor: pointer;
}

.player-search-button:hover {
    background: #bd963a;
}


.new-member-button,
.member-edit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border: 0;
    border-radius: 7px;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.new-member-button {
    background: #318a59;
}

.new-member-button:hover {
    background: #3da96d;
}

.member-edit-button {
    background: #6b58b5;
}

.member-edit-button:hover {
    background: #816bd4;
}

.leave-request-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border: 0;
    border-radius: 7px;
    background: #b94a48;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.leave-request-button:hover {
    background: #d05a57;
}

.admin-schedule-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    border: 0;
    border-radius: 7px;
    background: #9b7b2f;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.admin-schedule-button:hover {
    background: #bd963a;
}

.refresh-button {
    padding: 6px 10px;
    border: 0;
    border-radius: 5px;
    background: #505050;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.refresh-button:hover {
    background: #6a6a6a;
}

.refresh-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.information-card,
.legend-card,
.group-card,
.waiting-card,
.leave-card {
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid #414141;
    border-radius: 7px;
    background: #242424;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.information-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.information-item {
    padding: 7px;
    border-radius: 5px;
    background: #303030;
}

.information-label {
    display: block;
    margin-bottom: 3px;
    color: #aaaaaa;
    font-size: 10.8px;
}

.legend-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.job-tag {
    display: inline-block;
    min-width: 40px;
    padding: 3px 7px;
    border-radius: 12px;
    text-align: center;
    font-size: 10.8px;
    font-weight: 700;
}

.monk { background: #087b55; color: #ffffff; }
.exorcist { background: #08a15c; color: #ffffff; }
.praise { background: #d9f2c3; color: #202020; }
.mage { background: #bde2f3; color: #202020; }
.blacksmith { background: #934600; color: #ffffff; }
.hunter { background: #ffe19a; color: #202020; }
.knight { background: #d10000; color: #ffffff; }
.cross { background: #fd0000 !important; color: #ffffff !important; }
.assassin { background: #e0c5ec; color: #202020; }
.gunslinger { background: #896b00; color: #ffffff; }
.unknown-job { background: #666666; color: #ffffff; }

/* 主戰／副戰職業統計：橫向長條圖 */
.statistics-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.statistics-card {
    padding: 10px;
    border: 1px solid #414141;
    border-radius: 7px;
    background: #242424;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.main-statistics-card {
    border-left: 4px solid #d05a47;
}

.sub-statistics-card {
    border-left: 4px solid #4d86cc;
}

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

.statistics-header h2 {
    margin: 0;
}

.statistics-total {
    color: #cccccc;
    font-size: 12px;
}

.statistics-list {
    display: grid;
    gap: 5px;
}

.statistics-bar-row {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr) 88px;
    align-items: center;
    gap: 7px;
}

.statistics-job-label {
    min-width: 0;
}

.statistics-job-label .job-tag {
    width: 100%;
    min-width: 0;
    padding: 2px 5px;
    border-radius: 7px;
    font-size: 10.8px;
    line-height: 1.15;
}

.statistics-bar-track {
    height: 15px;
    overflow: hidden;
    border: 1px solid #4b4b4b;
    border-radius: 8px;
    background: #161616;
}

.statistics-bar-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.35s ease;
}

.statistics-bar-value {
    color: #dddddd;
    font-size: 10.8px;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

.schedule-section {
    margin-bottom: 12px;
}

.section-title {
    margin-bottom: 8px;
}

.section-title p {
    margin: 0;
    color: #aaaaaa;
    font-size: 12px;
}

.main-group {
    border-left: 4px solid #d05a47;
}

.sub-group {
    border-left: 4px solid #4d86cc;
}

.other-group {
    border-left: 4px solid #888888;
}

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

.group-name {
    margin: 0;
    font-size: 19.2px;
}

.group-count,
.count-text {
    color: #cccccc;
    font-size: 12px;
}

.teams-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.team-card {
    overflow: hidden;
    border: 1px solid #4b4b4b;
    border-radius: 5px;
    background: #2b2b2b;
}

.team-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 7px;
    background: #383838;
}

.team-title {
    margin: 0;
    color: #ffffff;
    font-size: 14.4px;
}

.team-count {
    color: #c5c5c5;
    font-size: 10.8px;
}

.team-table,
.waiting-table,
.leave-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.team-table th,
.waiting-table th,
.leave-table th {
    padding: 4px 3px;
    border: 1px solid #555555;
    background: #444444;
    color: #ffffff;
    white-space: nowrap;
    font-size: 10.8px;
}

.team-table td,
.waiting-table td,
.leave-table td {
    padding: 4px 3px;
    border: 1px solid #484848;
    color: #eeeeee;
    text-align: center;
    font-size: 10.8px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.team-table th:nth-child(1),
.team-table td:nth-child(1) {
    width: 14%;
}

.team-table th:nth-child(2),
.team-table td:nth-child(2) {
    width: 38%;
}

.team-table th:nth-child(3),
.team-table td:nth-child(3) {
    width: 30%;
}

.team-table th:nth-child(4),
.team-table td:nth-child(4) {
    width: 18%;
}

.order-cell {
    font-weight: 700;
}

.empty-slot td {
    color: #707070;
}

.status-battle {
    color: #72d68b;
    font-weight: 700;
}

.status-unknown {
    color: #bbbbbb;
    font-weight: 700;
}

.waiting-card {
    border-left: 4px solid #d49a32;
}

.status-waiting {
    color: #f0d58c;
    font-weight: 700;
}

.leave-card {
    border-left: 4px solid #c94b4b;
}

.table-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
}

.waiting-table th:nth-child(1),
.waiting-table td:nth-child(1) {
    width: 14%;
}

.waiting-table th:nth-child(2),
.waiting-table td:nth-child(2) {
    width: 44%;
}

.waiting-table th:nth-child(3),
.waiting-table td:nth-child(3) {
    width: 27%;
}

.waiting-table th:nth-child(4),
.waiting-table td:nth-child(4) {
    width: 15%;
}

.leave-table th:nth-child(1),
.leave-table td:nth-child(1) {
    width: 16%;
}

.leave-table th:nth-child(2),
.leave-table td:nth-child(2) {
    width: 52%;
}

.leave-table th:nth-child(3),
.leave-table td:nth-child(3) {
    width: 32%;
}

.empty-message {
    margin-bottom: 0;
    color: #aaaaaa;
    text-align: center;
    font-size: 10.8px;
}

footer {
    padding: 5px;
    color: #888888;
    text-align: center;
    font-size: 10.8px;
}

.player-highlight td {
    background: #5a481a !important;
    color: #ffffff !important;
}

.player-highlight {
    outline: 3px solid #f0d58c;
    outline-offset: -2px;
    animation: playerPulse 0.7s ease-in-out 3;
}

@keyframes playerPulse {
    0%, 100% {
        filter: brightness(1);
    }

    50% {
        filter: brightness(1.5);
    }
}

@media (max-width: 1200px) {
    .top-area {
        grid-template-columns: 1fr auto;
    }

    .player-search {
        grid-column: 1 / -1;
        grid-row: 2;
        max-width: 560px;
        justify-self: center;
    }

    .teams-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 700px) {
    .statistics-section {
        grid-template-columns: 1fr;
    }

    .statistics-bar-row {
        grid-template-columns: 52px minmax(0, 1fr) 78px;
        gap: 5px;
    }

    .statistics-bar-value {
        font-size: 9.8px;
    }

    body {
        padding: 10px 6px;
    }

    .top-area {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .player-search {
        grid-column: auto;
        grid-row: auto;
        max-width: none;
    }

    .top-actions {
        justify-self: stretch;
    }

    .top-actions {
        width: 100%;
        flex-direction: column;
    }

    .new-member-button,
    .member-edit-button,
    .leave-request-button,
    .top-actions .new-member-button,
    .top-actions .member-edit-button,
    .top-actions .leave-request-button,
    .top-actions .admin-schedule-button,
    .top-actions .refresh-button {
        flex: 1;
    }

    .refresh-button {
        width: auto;
    }

    .information-card {
        grid-template-columns: 1fr;
    }

    .teams-grid {
        grid-template-columns: 1fr;
    }

    .team-card {
        overflow-x: auto;
    }

    .team-table {
        min-width: 300px;
    }
}


/* 排班重複警示 */
.duplicate-warning-card {
    margin-bottom: 12px;
    padding: 10px;
    border: 2px solid #ff4d4f;
    border-radius: 7px;
    background: rgba(120, 18, 20, 0.32);
    box-shadow: 0 0 14px rgba(255, 77, 79, 0.3);
}

.duplicate-warning-card[hidden] {
    display: none !important;
}

.duplicate-warning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 7px;
}

.duplicate-warning-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.duplicate-warning-title h2 {
    margin: 0;
    color: #ff9a9b;
}

.warning-light {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border-radius: 50%;
    background: #ff1f23;
    box-shadow: 0 0 0 3px rgba(255, 31, 35, 0.2), 0 0 14px #ff1f23;
    animation: warningBlink 0.85s ease-in-out infinite;
}

.duplicate-warning-count {
    color: #ffb5b6;
    font-weight: 700;
}

.duplicate-warning-list {
    margin: 0;
    padding-left: 22px;
    color: #ffd6d6;
    line-height: 1.6;
}

.duplicate-warning-row td {
    background: rgba(195, 32, 38, 0.35) !important;
    border-color: #ff5a5d !important;
}

.duplicate-team-card {
    border-color: #ff4d4f;
    box-shadow: 0 0 12px rgba(255, 77, 79, 0.35);
}

.duplicate-status {
    color: #ff9294 !important;
    font-weight: 700;
}

.duplicate-badge {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 4px;
    border: 1px solid #ff6b6d;
    border-radius: 8px;
    background: #8f1f22;
    color: #ffffff;
    font-size: 9px;
    font-weight: 700;
    white-space: nowrap;
}

@keyframes warningBlink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.35;
        transform: scale(0.82);
    }
}

/* 十字職業：與 Google 試算表相同的亮紅色 */
.statistics-bar-fill.cross {
    background: #fd0000 !important;
}
