:root {
    font-family: "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--color-text);
    background-color: var(--color-bg);
    --color-text: #1f2a37;
    --color-bg: #f5f6f8;
    --color-panel: #ffffff;
    --color-panel-muted: #f8fafc;
    --color-border: rgba(125, 138, 174, 0.32);
    --color-border-strong: rgba(99, 115, 155, 0.42);
    --color-primary: #0f172a;
    --color-primary-contrast: #ffffff;
    --color-muted: #64748b;
    --color-secondary-text: #475569;
    --color-muted-strong: #94a3b8;
    --color-table-head: #f1f5f9;
    --color-neutral-bg: #e2e8f0;
    --color-danger: #dc2626;
    --color-marker-dark: #0f172a;
    --color-control-bg: #ffffff;
    --color-inline-btn: #0f172a;
}

@font-face {
    font-family: "CPPeriod";
    src: url("./fonts/cp_period.ttf") format("truetype");
    font-display: swap;
}

:root[data-theme="dark"] {
    --color-text: #e2e8f0;
    --color-bg: #0f172a;
    --color-panel: #1e293b;
    --color-panel-muted: #14213d;
    --color-border: rgba(148, 170, 220, 0.42);
    --color-border-strong: rgba(168, 190, 235, 0.48);
    --color-primary: #f8fafc;
    --color-primary-contrast: #0f172a;
    --color-muted: #cbd5f5;
    --color-secondary-text: #cbd5f5;
    --color-muted-strong: #94a3b8;
    --color-table-head: #1f2937;
    --color-neutral-bg: #1f2937;
    --color-danger: #f87171;
    --color-marker-dark: #f8fafc;
    --color-control-bg: #0f172a;
    --color-inline-btn: #f8fafc;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--color-bg);
    color: var(--color-text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.app {
    width: 100%;
    margin: 0;
    padding: 24px 16px 32px;
}

.app-branding {
    text-align: center;
    padding-bottom: 16px;
}

.brand-logo {
    font-family: "CPPeriod", "Noto Sans JP", system-ui, sans-serif;
    font-size: 2.9rem;
    letter-spacing: 0.08em;
    color: var(--color-text);
    text-align: center;
    display: inline-block;
    position: relative;
    padding-right: 72px;
}

.brand-text {
    display: inline-block;
}

.brand-icon {
    width: 60px;
    height: 60px;
    object-fit: contain;
    display: none;
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
}

:root:not([data-theme="dark"]) .brand-icon-light {
    display: inline-block;
}

:root[data-theme="dark"] .brand-icon-dark {
    display: inline-block;
}
.app-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
}

.toolbar-start {
    grid-column: 1;
    justify-self: flex-start;
}

.app-toolbar .brand-logo {
    grid-column: 2;
    justify-self: center;
}

.toolbar-actions {
    display: flex;
    gap: 12px;
    grid-column: 3;
    justify-self: end;
}

@media (max-width: 640px) {
    .app-toolbar {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .toolbar-start {
        grid-column: 1;
        justify-self: center;
    }

    .app-toolbar .brand-logo {
        grid-column: 1;
    }

    .toolbar-actions {
        grid-column: 1;
        justify-self: center;
        flex-wrap: wrap;
        justify-content: center;
    }
}

.export-btn {
    border: 2px solid var(--color-border-strong);
    background: var(--color-panel);
    border-radius: 50%;
    cursor: pointer;
    width: 45px;
    height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.18);
}

.export-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.export-icon {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: brightness(0) saturate(100%);
}

.export-btn:hover .export-icon {
    filter: brightness(0) saturate(100%) invert(1);
}

.export-btn:hover .export-icon {
    filter: brightness(0) saturate(100%) invert(1);
}

:root[data-theme="dark"] .export-btn {
    background: #0f1a38;
    border-color: rgba(255, 255, 255, 0.8);
}

:root[data-theme="dark"] .export-icon {
    filter: brightness(0) saturate(100%) invert(1);
}

:root[data-theme="dark"] .export-btn:hover {
    background: #ffffff;
    border-color: #ffffff;
}

:root[data-theme="dark"] .export-btn:hover .export-icon {
    filter: brightness(0) saturate(100%) invert(19%) sepia(28%) saturate(1060%) hue-rotate(192deg) brightness(88%) contrast(92%);
}

:root[data-theme="dark"] .export-btn:hover .export-icon {
    filter: none;
    filter: brightness(0) saturate(100%) invert(20%) sepia(13%) saturate(2910%) hue-rotate(200deg) brightness(90%) contrast(90%);
}

.toolbar-icon {
    width: 44px;
    height: 44px;
    cursor: pointer;
    object-fit: contain;
    display: inline-block;
    transition: filter 0.2s ease;
    filter: brightness(0) saturate(100%);
}

.help-icon {
    width: 35px;
    height: 35px;
    filter: brightness(0) saturate(100%);
}

.download-icon {
    width: 54px;
    height: 54px;
    filter: brightness(0) saturate(100%);
}

:root[data-theme="dark"] .help-icon,
:root[data-theme="dark"] .download-icon {
    filter: invert(1) contrast(110%);
}

.theme-toggle {
    width: 82px;
    height: 45px;
    border-radius: 999px;
    border: 2px solid var(--color-border-strong);
    background: var(--color-panel);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.18);
    position: relative;
    padding: 0;
}

.theme-toggle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 8px;
    width: 31px;
    height: 31px;
    border-radius: 50%;
    background: #0f172a;
    transform: translate(0, -50%);
    transition: transform 0.25s ease, background 0.25s ease;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.35);
    z-index: 1;
}

.theme-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    pointer-events: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    z-index: 0;
}

.theme-icon-light {
    right: 8px;
    width: 32px;
    height: 32px;
    filter: brightness(0) saturate(100%);
}

.theme-icon-dark {
    left: 14px;
    filter: brightness(0) saturate(100%) invert(1);
}

:root:not([data-theme="dark"]) .theme-icon-light {
    display: block;
}

:root[data-theme="dark"] .theme-icon-dark {
    display: block;
}

.theme-toggle:hover {
    border-color: var(--color-primary);
}

:root[data-theme="dark"] .theme-toggle {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.8);
}

:root[data-theme="dark"] .theme-toggle::after {
    background: #ffffff;
    transform: translate(36px, -50%);
}

.main-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr) 336px;
    gap: 16px;
}

.panel {
    background: var(--color-panel);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--color-border-strong);
}

.players-panel {
    font-size: 0.9rem;
}

.players-panel input,
.players-panel button,
.players-panel .player-card,
.players-panel .player-edit-input {
    font-size: 0.9rem;
}

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

.count {
    font-size: 0.9rem;
    color: var(--color-muted);
}

.player-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-row input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--color-control-bg);
    color: var(--color-text);
}

.input-row input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.bulk-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
    resize: vertical;
    font-family: inherit;
    background: var(--color-control-bg);
    color: var(--color-text);
}

.players-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.players-list + .input-row {
    margin-top: 12px;
}

.player-card {
    border: 1px solid var(--color-border-strong);
    border-radius: 6px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    background: var(--color-panel);
}

.player-card.empty {
    text-align: center;
    color: var(--color-muted-strong);
    display: block;
}

.player-edit-input {
    flex: none;
    width: calc(100% - 40px);
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 1rem;
    background: var(--color-control-bg);
    color: var(--color-text);
}

.player-card-actions {
    display: none;
    gap: 8px;
}

.player-card.editing {
    cursor: default;
}

.player-card.editing .player-card-actions {
    display: flex;
    margin-left: auto;
}

.player-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.player-actions button {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.player-card-actions button {
    background: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.player-actions button:hover {
    opacity: 0.85;
}

.player-card-actions button:hover {
    background: var(--color-danger);
    color: var(--color-primary-contrast);
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--color-panel);
    border-radius: 10px;
    padding: 20px;
    width: min(420px, 100%);
    box-shadow: 0 15px 40px rgba(15, 23, 42, 0.2);
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid var(--color-border-strong);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.35rem;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}

.modal-description {
    margin: 0;
    font-size: 0.95rem;
    color: var(--color-secondary-text);
}

.modal-field-label {
    font-size: 0.85rem;
    color: var(--color-secondary-text);
}

.modal-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: vertical;
    background: var(--color-control-bg);
    color: var(--color-text);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-actions button {
    background: var(--color-neutral-bg);
    color: var(--color-text);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.modal-actions button.primary {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
}

.modal-actions button:hover {
    opacity: 0.85;
}

.help-modal {
    width: min(900px, 100%);
    max-height: calc(100vh - 96px);
    overflow-y: auto;
}

.help-intro {
    margin: 0;
    font-size: 0.95rem;
    color: var(--color-secondary-text);
}

.help-list {
    margin: 0;
    padding: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.help-section h4 {
    margin: 0 0 4px;
    font-size: 1.15rem;
    color: var(--color-secondary-text);
}

.help-section p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--color-text);
    line-height: 1.5;
}

.help-section-image {
    width: 100%;
    max-width: 820px;
    border-radius: 8px;
    margin-top: 8px;
    border: 1px solid var(--color-border);
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
}

.co-table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
}

.co-table {
    width: auto;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--color-panel);
}

.co-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--color-table-head);
    color: var(--color-text);
}

.co-table th,
.co-table td {
    border: 1px solid var(--color-border);
    padding: 8px;
    text-align: center;
    font-size: 0.8rem;
}

.zero-day-empty {
    background: var(--color-panel-muted);
}

.co-table td.disabled-cell {
    background: var(--color-neutral-bg);
    opacity: 0.7;
}

.co-table td.disabled-cell select {
    background: transparent;
}

.co-table th {
    background: var(--color-table-head);
    font-weight: 600;
}

.co-table select {
    width: 100%;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.75rem;
    background: var(--color-control-bg);
    color: var(--color-text);
}

.co-cell-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.marker-toggle {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--color-secondary-text);
    background: #ffffff;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1;
    transition: box-shadow 0.2s ease;
}

.marker-toggle[data-color="black"] {
    background: #0f172a;
}

.marker-toggle:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.role-cell {
    position: relative;
    padding: 4px 8px;
}

.role-inline-actions {
    display: flex;
    gap: 0;
    margin-left: 0;
    margin-right: 0;
}

.role-inline-btn {
    background: var(--color-panel);
    color: var(--color-inline-btn);
    border: 1px solid var(--color-inline-btn);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.role-inline-btn.remove {
    color: var(--color-inline-btn);
    border-color: var(--color-inline-btn);
}

.role-inline-btn:hover,
.role-inline-btn.remove:hover {
    background: var(--color-inline-btn);
    color: var(--color-primary-contrast);
}

.role-add-inline {
    background: var(--color-primary);
    color: var(--color-primary-contrast);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.role-add-inline:hover {
    opacity: 0.85;
}

.voting-panel {
    margin-top: 24px;
}

.voting-controls {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 8px;
}

.voting-controls button {
    background: var(--color-neutral-bg);
    color: var(--color-secondary-text);
    border: none;
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.voting-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voting-controls button:not(:disabled):hover {
    opacity: 0.85;
}

.voting-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--color-border-strong);
    margin-bottom: 12px;
}

.voting-tab {
    padding: 8px 16px;
    border: none;
    border-radius: 6px 6px 0 0;
    background: var(--color-neutral-bg);
    cursor: pointer;
    font-weight: 600;
    color: var(--color-secondary-text);
}

.voting-tab.active {
    background: var(--color-panel);
    border: 2px solid var(--color-border-strong);
    border-bottom: none;
    color: var(--color-text);
}

.voting-tab-content {
    border: 2px solid var(--color-border-strong);
    border-top: none;
    border-radius: 0 6px 6px 6px;
    padding: 16px;
    background: var(--color-panel);
}

.voting-empty {
    text-align: center;
    color: var(--color-muted-strong);
    padding: 12px 0;
}

.voting-layout {
    display: grid;
    grid-template-columns: 2.2fr 1.3fr;
    gap: 24px;
}

.voting-visual {
    position: relative;
    padding: 0 48px;
}

.voting-lines {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.voting-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voting-row {
    display: grid;
    grid-template-columns: 0.9fr 80px 0.9fr;
    align-items: center;
    gap: 16px;
}

.voting-header {
    font-weight: 600;
    color: var(--color-secondary-text);
}

.voting-column-title {
    text-align: left;
}

.voter-title {
    display: flex;
    justify-content: flex-end;
    padding-right: 24px;
}

.target-title {
    display: flex;
    justify-content: flex-start;
    padding-left: 24px;
}
.co-table th:first-child {
    text-align: left;
    width: 300px;
    min-width: 300px;
}

.co-table th:not(:first-child),
.co-table td:not(:first-child) {
    width: 170px;
    min-width: 170px;
}

.voting-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.voting-item-left {
    flex-direction: row-reverse;
    text-align: right;
}

.vote-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid #0f172a;
    display: inline-block;
    background: #ffffff;
    transition: transform 0.1s ease, box-shadow 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.vote-name {
    flex: 1;
    font-size: 0.95rem;
    color: var(--color-text);
}

:root[data-theme="dark"] .vote-dot {
    background: transparent;
    border-color: #ffffff;
}

:root[data-theme="dark"] .vote-dot.pending,
:root[data-theme="dark"] .voting-item.has-vote .vote-dot,
:root[data-theme="dark"] .voting-item.targeted .vote-dot {
    background: #ffffff;
    border-color: #ffffff;
}

.vote-dot.pending,
.voting-item.has-vote .vote-dot,
.voting-item.targeted .vote-dot {
    background: #0f172a;
    border-color: #0f172a;
}

.vote-connection {
    stroke-width: 3;
    stroke-linecap: round;
    opacity: 0.9;
    stroke: #0f172a;
}

:root[data-theme="dark"] .vote-connection {
    stroke: #ffffff;
}


.voting-summary h3 {
    margin-top: 0;
    font-size: 0.9rem;
    color: var(--color-text);
}

.voting-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.voting-summary-table th,
.voting-summary-table td {
    border: 1px solid var(--color-border);
    padding: 8px;
    text-align: left;
}

.voting-summary-table th {
    background: var(--color-table-head);
    font-weight: 600;
}

.role-cell-menu {
    cursor: pointer;
}

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

.role-name {
    flex: 1;
    min-width: 0;
    text-align: left;
    margin-right: 0;
}

.role-name.role-name-medium {
    font-size: 0.9rem;
}

.role-name.role-name-small {
    font-size: 0.8rem;
}

.role-assignment-select {
    flex: 0 0 50%;
    min-width: 120px;
    padding: 4px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.9rem;
    margin-left: 0;
}

@media (max-width: 800px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
}

.memo-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.memo-textarea {
    width: 100%;
    min-height: 720px;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.85rem;
    resize: vertical;
    font-family: inherit;
    background: var(--color-panel);
    color: var(--color-text);
}
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
