/* ============================================================
   style.css — Bridge Deal Practice App
   ============================================================ */

:root {
    --bg:          #f0efe9;
    --bg-card:     #ffffff;
    --bg-sidebar:  #1e3a2f;
    --bg-sidebar2: #264d3e;
    --text:        #2c2c2c;
    --text-light:  #6b6b6b;
    --text-sidebar:#e8e6df;
    --accent:      #1a6b4a;
    --accent2:     #2e8b65;
    --border:      #d4d0c8;
    --spades:      #1a3a5c;
    --hearts:      #c0392b;
    --diamonds:    #e67e22;
    --clubs:       #27ae60;
    --shadow:      0 2px 8px rgba(0,0,0,0.08);
    --radius:      8px;
    --deal-bg:     #0c1829;
}

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

body {
    font-family: 'Work Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
}

/* ---- Layout ---- */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: 320px;
    min-width: 320px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.main-area {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.main-area > * {
    width: 100%;
    max-width: 900px;
}

/* ---- Sidebar ---- */
.sidebar h1 {
    font-size: 1.3em;
    margin-bottom: 4px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar h1 .logo {
    font-size: 1.6em;
}

.sidebar .subtitle {
    font-size: 0.8em;
    color: #a8c4b5;
    margin-bottom: 8px;
}

.sidebar-section {
    background: var(--bg-sidebar2);
    border-radius: var(--radius);
    padding: 14px;
}

.sidebar-section h3 {
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #a8c4b5;
    margin-bottom: 10px;
}

.sidebar label {
    display: block;
    font-size: 0.85em;
    margin-bottom: 4px;
    color: #c8ddd2;
}

.sidebar select,
.sidebar input[type="number"] {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 5px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 0.9em;
    margin-bottom: 8px;
}

.sidebar select option {
    background: #1e3a2f;
    color: #fff;
}

.sidebar input[type="number"] {
    -moz-appearance: textfield;
}

.topic-description {
    font-size: 0.78em;
    color: #a8c4b5;
    font-style: italic;
    padding: 6px 0 4px;
    line-height: 1.4;
}

/* Topic list */
.selected-topics {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 6px;
}

.topic-tag {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255,255,255,0.1);
    border-radius: 5px;
    padding: 6px 10px;
    font-size: 0.82em;
}

.topic-tag .remove-topic {
    cursor: pointer;
    color: #e74c3c;
    font-weight: bold;
    padding: 0 4px;
    font-size: 1.1em;
}

.topic-tag .remove-topic:hover {
    color: #ff6b6b;
}

/* Buttons */
.btn {
    padding: 9px 16px;
    border: none;
    border-radius: 5px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent2);
    color: #fff;
    width: 100%;
}

.btn-primary:hover { background: #36a073; }

.btn-add {
    background: rgba(255,255,255,0.12);
    color: #c8ddd2;
    width: 100%;
    border: 1px dashed rgba(255,255,255,0.25);
}

.btn-add:hover { background: rgba(255,255,255,0.18); }

.btn-export {
    background: #2c5f8a;
    color: #fff;
}

.btn-export:hover { background: #3672a4; }

.btn-small {
    padding: 5px 12px;
    font-size: 0.8em;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* ---- Custom Constraints Panel ---- */
.constraint-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.constraint-grid .constraint-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.constraint-grid .constraint-item label {
    font-size: 0.75em;
    color: #a8c4b5;
}

.constraint-grid .constraint-item .range-inputs {
    display: flex;
    gap: 4px;
    align-items: center;
}

.constraint-grid .constraint-item input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 0.8em;
    text-align: center;
}

.constraint-grid .constraint-item .range-sep {
    color: #a8c4b5;
    font-size: 0.8em;
}

.direction-tab {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.direction-tab button {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: transparent;
    color: #a8c4b5;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
}

.direction-tab button.active {
    background: var(--accent2);
    color: #fff;
    border-color: var(--accent2);
}

/* ---- Main Area ---- */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.top-bar h2 {
    font-size: 1.2em;
    color: var(--text);
}

.deal-title {
    font-size: 1.25em;
    font-weight: 700;
    color: #1a3f7a;
    padding: 8px 0 2px;
    letter-spacing: 0.01em;
}
.deal-title.hidden { display: none; }

.deal-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 8px 0 4px;
    min-height: 40px;
}

.deal-dot {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #c5c0b5;
    background: #f5f5f0;
    color: #555;
    font-size: 0.78em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    padding: 0;
    line-height: 1;
}

.deal-dot.active {
    background: #1a3f7a;
    border-color: #1a3f7a;
    color: #fff;
}

.deal-dot:hover:not(.active) {
    background: #e0ddd5;
    border-color: #999;
    color: #333;
}

/* ============================================================
   Deal Board (dark theme)
   ============================================================ */
.deal-display {
    background: var(--deal-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    color: #fff;
    max-width: 900px;
}

.deal-board {
    display: grid;
    grid-template-areas:
        "compass  north    ."
        "west     center   east"
        "summary  south    dd";
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 14px;
    width: 100%;
    min-height: 340px;
}

/* ---- Compass ---- */
.compass-area {
    grid-area: compass;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 4px;
}

.compass-container {
    position: relative;
    width: 140px;
    height: 140px;
}

.compass-diamond {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 76px;
    height: 76px;
    transform: translate(-50%, -50%) rotate(45deg);
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.35);
}

.compass-diamond .quad {
    position: absolute;
    width: 50%;
    height: 50%;
}

/* When rotated 45deg: NW corner→top=N, NE→right=E, SE→bottom=S, SW→left=W */
.compass-diamond .quad-n { top: 0; left: 0; }
.compass-diamond .quad-e { top: 0; right: 0; }
.compass-diamond .quad-s { bottom: 0; right: 0; }
.compass-diamond .quad-w { bottom: 0; left: 0; }

.compass-diamond .quad.vul { background: #cc2222; }
.compass-diamond .quad.notvul { background: #e8e0d0; }

.compass-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #152238;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    z-index: 1;
    border: 1px solid rgba(255,255,255,0.3);
}

.compass-label {
    position: absolute;
    font-weight: 700;
    font-size: 16px;
    color: #ccc;
}

.compass-label-n { top: 0; left: 50%; transform: translateX(-50%); }
.compass-label-e { right: 0; top: 50%; transform: translateY(-50%); }
.compass-label-s { bottom: 0; left: 50%; transform: translateX(-50%); }
.compass-label-w { left: 0; top: 50%; transform: translateY(-50%); }

.compass-label.dealer { font-size: 22px; font-weight: 800; color: #fff; }
.compass-label.vul-text { color: #e74c3c; }
.compass-label.dealer.vul-text { color: #ff6b6b; }

/* ---- Hand Boxes ---- */
.hand-box {
    border: 2px solid rgba(255,255,255,0.18);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s;
    background: #fff;
}

.hand-box.active-player {
    border-color: #c0392b;
    border-width: 3px;
}

.hand-box.north { grid-area: north; }
.hand-box.east  { grid-area: east; }
.hand-box.south { grid-area: south; }
.hand-box.west  { grid-area: west; }

.hand-box-header {
    color: #fff;
    padding: 6px 14px;
    font-weight: 700;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.hand-box-header.header-notvul { background: #1a3f7a; }
.hand-box-header.header-vul    { background: #b71c1c; }

.dealer-badge {
    font-size: 0.9em;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-left: 7px;
    background: rgba(255,255,255,0.18);
    padding: 1px 6px;
    border-radius: 8px;
}

.hand-edit-icon {
    font-size: 0.9em;
    opacity: 0.5;
}

.hand-box:hover .hand-edit-icon { opacity: 0.9; }

.hand-box-body {
    padding: 6px 12px;
}

.hand-suit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.9;
}

.hand-suit-sym {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.5em;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.hand-suit-sym.spades { color: var(--spades); }
.hand-suit-sym.hearts { color: var(--hearts); }
.hand-suit-sym.diamonds { color: var(--diamonds); }
.hand-suit-sym.clubs { color: var(--clubs); }

/* Inline editable input replaces both card display and separate input */
.hand-suit-input {
    flex: 1;
    padding: 2px 4px;
    font-size: 1.5em;
    font-weight: 600;
    font-family: 'Work Sans', 'Segoe UI', sans-serif;
    background: transparent;
    color: #2c2c2c;
    border: 1px solid transparent;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    outline: none;
    min-width: 0;
}

.hand-suit-input::placeholder {
    color: rgba(0,0,0,0.15);
    letter-spacing: 0;
    font-weight: 400;
}

.hand-suit-input:focus {
    border-color: rgba(0,0,0,0.15);
    background: rgba(0,0,0,0.03);
}

/* ---- Inline Constraints ---- */
.btn-toggle-constraints {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 1em;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-toggle-constraints:hover {
    color: #fff;
}

/* ---- Constraint Table (open state) ---- */
.constraint-table-wrap {
    border-top: 1px solid #eee;
    margin-top: 4px;
    padding-top: 4px;
}

.constraint-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7em;
}

.constraint-table thead th {
    font-weight: 600;
    color: #888;
    padding: 1px 2px;
    text-align: center;
    font-size: 0.9em;
}

.constraint-table thead th:first-child {
    width: 20px;
}

.ct-suit {
    text-align: center;
    padding: 1px 2px;
}

.ct-suit .hand-suit-sym {
    font-size: 1.1em;
}

.ct-range {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 1px 2px;
}

.ct-hcp-row {
    border-top: 1px solid #eee;
}

.ct-hcp-label {
    font-weight: 600;
    color: #666;
    font-size: 0.95em;
}

.ic-input {
    width: 30px;
    padding: 1px 2px;
    font-size: 1em;
    font-family: 'Work Sans', sans-serif;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #f5f5f5;
    color: #333;
    -moz-appearance: textfield;
}

.ic-input::-webkit-inner-spin-button,
.ic-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ic-input:focus {
    border-color: #5b9bd5;
    outline: none;
    background: #fff;
}

.ic-sep {
    color: #999;
    font-size: 0.9em;
}

/* ---- Closed-state constraint badges (inline per suit row) ---- */
.ic-closed-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    margin-left: auto;
    gap: 0;
    line-height: 1.15;
}

.ic-closed-badge .cb-line {
    font-size: 0.55em;
    font-weight: 600;
    color: #5b9bd5;
    background: #eef4fb;
    border-radius: 2px;
    padding: 0 3px;
    white-space: nowrap;
}

.ic-hcp-badge {
    font-size: 0.6em;
    font-weight: 600;
    color: #5b9bd5;
    background: #eef4fb;
    border-radius: 2px;
    padding: 1px 5px;
    margin-top: 2px;
    text-align: right;
}

/* ---- Center: Unassigned Cards ---- */
.center-cards {
    grid-area: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
}

.center-suit-row {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.8;
}

.center-suit-sym {
    font-family: 'Noto Serif JP', serif;
    font-size: 1.5em;
    width: 24px;
    text-align: center;
}

/* Bright suit colors on dark deal board */
.center-suit-sym.spades { color: #5b9bd5; }
.center-suit-sym.hearts { color: #e74c3c; }
.center-suit-sym.diamonds { color: #e67e22; }
.center-suit-sym.clubs { color: #2ecc71; }

.center-suit-cards {
    color: #fff;
    font-size: 1.5em;
    font-weight: 700;
}

/* ---- Board Summary Table ---- */
.board-summary {
    grid-area: summary;
    align-self: end;
    padding-bottom: 4px;
}

.board-summary table {
    border-collapse: collapse;
    font-size: 0.85em;
    color: #2c2c2c;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
}

.board-summary th,
.board-summary td {
    padding: 5px 10px;
    text-align: center;
    border: 1px solid #ddd;
}

.board-summary th {
    font-weight: 600;
    color: #666;
    white-space: nowrap;
}

.board-summary .dir-header {
    font-weight: 700;
    color: #2c2c2c;
}

.board-summary .count-ok {
    background: #27ae60;
    color: #fff;
    font-weight: 700;
}

.board-summary .count-bad {
    background: #c0392b;
    color: #fff;
    font-weight: 700;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.empty-state .empty-icon {
    font-size: 3em;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: var(--text);
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; min-width: unset; }
    .deal-board {
        grid-template-columns: 1fr;
        grid-template-areas:
            "compass"
            "north"
            "west"
            "center"
            "east"
            "south"
            "summary"
            "dd";
    }
    .editor-bottom { flex-direction: column; }
}

/* ---- Scrollbar ---- */
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }


.hidden { display: none !important; }

/* ---- Balanced checkbox ---- */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
}

.checkbox-row input[type="checkbox"] {
    accent-color: var(--accent2);
}

.checkbox-row label {
    display: inline;
    margin: 0;
    font-size: 0.82em;
}

/* ---- Deal topic badge ---- */
.topic-badge {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 0.78em;
    font-weight: 600;
}

/* ---- Double Dummy Results (inside deal grid) ---- */
.dd-section {
    grid-area: dd;
    background: #fff;
    border-radius: 6px;
    padding: 10px 12px;
    align-self: end;
}

.dd-section h3 {
    font-size: 0.78em;
    color: #666;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dd-table {
    border-collapse: collapse;
    font-size: 0.85em;
    width: 100%;
    color: #2c2c2c;
}

.dd-table th,
.dd-table td {
    padding: 4px 8px;
    text-align: center;
    border: 1px solid #ddd;
}

.dd-table th {
    background: #f5f4ef;
    font-weight: 600;
    color: #666;
}

.dd-table td {
    font-weight: 500;
}

.dd-table .strain-header {
    font-size: 1.05em;
}

.dd-computing {
    color: #666;
    font-size: 0.85em;
    font-style: italic;
    padding: 8px 0;
}

.dd-table .suit-symbol {
    font-family: 'Noto Serif JP', serif;
}

.dd-table .suit-symbol.spades   { color: var(--spades); }
.dd-table .suit-symbol.hearts   { color: var(--hearts); }
.dd-table .suit-symbol.diamonds { color: var(--diamonds); }
.dd-table .suit-symbol.clubs    { color: var(--clubs); }

/* ---- Convention Editor Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 680px;
    max-width: 95vw;
    max-height: 95vh;
    overflow-y: auto;
    padding: 28px;
}

.modal h2 {
    font-size: 1.15em;
    margin-bottom: 16px;
    color: var(--text);
}

.modal-row {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.modal-row label {
    font-size: 0.82em;
    font-weight: 600;
    color: var(--text-light);
    min-width: 80px;
    padding-top: 6px;
}

.modal-row input,
.modal-row select,
.modal-row textarea {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-size: 0.9em;
    font-family: inherit;
}

.modal-row textarea {
    min-height: 60px;
    resize: vertical;
}

.modal-dir-tabs {
    display: flex;
    gap: 4px;
    margin: 12px 0 8px;
}

.modal-dir-tabs button {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #f5f4ef;
    color: var(--text);
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
}

.modal-dir-tabs button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.modal-constraint-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.modal-constraint-grid .c-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.modal-constraint-grid .c-item label {
    font-size: 0.8em;
    min-width: 60px;
    padding: 0;
}

.modal-constraint-grid .c-item input {
    width: 52px;
    padding: 4px 6px;
    text-align: center;
    font-size: 0.85em;
}

.modal-constraint-grid .c-sep {
    font-size: 0.8em;
    color: var(--text-light);
}

/* Section headers inside the constraint grid */
.c-section-header {
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    border-top: 1px solid rgba(255,255,255,0.1);
    padding-top: 8px;
    margin-top: 2px;
}

/* Suit-exclude row inside constraint grid */
.c-xexclude-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.c-xexclude-label {
    font-size: 0.75em;
    color: var(--text-light);
    margin-right: 2px;
}
.c-xexclude-suit {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.9em;
    cursor: pointer;
}

/* Two-suited constraint panel */
.c-twosuit-wrap {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.04);
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.12);
}

.c-twosuit-row {
    display: flex;
    align-items: center;
    gap: 7px;
}

.c-twosuit-row label {
    font-size: 0.8em;
    min-width: 80px;
    color: var(--text-light);
}

.c-twosuit-row input[type="number"] {
    width: 52px;
    padding: 4px 6px;
    text-align: center;
    font-size: 0.85em;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.c-twosuit-row select {
    font-size: 0.82em;
    padding: 4px 6px;
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.modal-actions .btn {
    min-width: 100px;
}

.btn-secondary {
    background: #e8e5dc;
    color: var(--text);
}

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

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

.btn-danger:hover { background: #c0392b; }

/* Convention tree in sidebar */
.conv-tree {
    font-size: 0.82em;
}

.conv-tree-group {
    margin-bottom: 4px;
}

.conv-tree-group-label {
    font-weight: 600;
    color: #c8ddd2;
    padding: 4px 0;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.conv-tree-group-label:hover {
    color: #fff;
}

.conv-tree-group-label .toggle {
    font-size: 0.7em;
    transition: transform 0.15s;
}

.conv-tree-group-label.collapsed .toggle {
    transform: rotate(-90deg);
}

.conv-tree-items {
    padding-left: 12px;
}

.conv-tree-items.collapsed {
    display: none;
}

.conv-tree-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    color: #a8c4b5;
}

.conv-tree-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.conv-tree-item .conv-edit-btn {
    opacity: 0;
    font-size: 0.75em;
    padding: 1px 5px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 3px;
    background: transparent;
    color: #a8c4b5;
    cursor: pointer;
}

.conv-tree-item:hover .conv-edit-btn {
    opacity: 1;
}

.conv-tree-item .conv-edit-btn:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ============================================================
   Editor Bottom: Card Picker + Actions + DD
   ============================================================ */
.editor-bottom {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    max-width: 900px;
}

/* ---- Card Picker Grid ---- */
.card-picker {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.card-picker-row {
    display: flex;
    gap: 3px;
    align-items: center;
}

.picker-suit-sym {
    font-family: 'Noto Serif JP', serif;
    width: 30px;
    font-size: 1.3em;
    font-weight: bold;
    text-align: center;
    flex-shrink: 0;
}

.picker-suit-sym.spades { color: var(--spades); }
.picker-suit-sym.hearts { color: var(--hearts); }
.picker-suit-sym.diamonds { color: var(--diamonds); }
.picker-suit-sym.clubs { color: var(--clubs); }

.card-tile {
    width: 48px;
    height: 56px;
    border: 2px solid;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    transition: transform 0.08s;
    gap: 0;
}

.card-tile:hover { transform: scale(1.06); }

.card-tile .tile-rank {
    font-family: 'Work Sans', sans-serif;
    font-size: 1.05em;
    font-weight: 700;
    line-height: 1.2;
}

.card-tile .tile-suit {
    font-family: 'Noto Serif JP', serif;
    font-size: 0.75em;
    line-height: 1;
}

/* Suit-colored tile suits */
.card-tile .tile-suit.spades { color: var(--spades); }
.card-tile .tile-suit.hearts { color: var(--hearts); }
.card-tile .tile-suit.diamonds { color: var(--diamonds); }
.card-tile .tile-suit.clubs { color: var(--clubs); }

/* Unassigned: white bg, suit-colored border */
.card-tile.unassigned {
    background: #fff;
    color: #333;
}

.card-tile.unassigned.suit-spades { border-color: var(--spades); }
.card-tile.unassigned.suit-hearts { border-color: var(--hearts); }
.card-tile.unassigned.suit-diamonds { border-color: var(--diamonds); }
.card-tile.unassigned.suit-clubs { border-color: var(--clubs); }

/* Assigned: grey overlay */
.card-tile.assigned {
    background: #e8e8e8;
    color: #aaa;
    border-color: #ccc;
}

.card-tile.assigned .tile-suit {
    color: #bbb;
}

/* Assigned to active player: highlighted */
.card-tile.assigned.active-owner {
    background: #d6eaff;
    color: #444;
    border-width: 3px;
}

.card-tile.assigned.active-owner.suit-spades { border-color: var(--spades); }
.card-tile.assigned.active-owner.suit-hearts { border-color: var(--hearts); }
.card-tile.assigned.active-owner.suit-diamonds { border-color: var(--diamonds); }
.card-tile.assigned.active-owner.suit-clubs { border-color: var(--clubs); }

.card-tile.assigned.active-owner .tile-suit.spades { color: var(--spades); }
.card-tile.assigned.active-owner .tile-suit.hearts { color: var(--hearts); }
.card-tile.assigned.active-owner .tile-suit.diamonds { color: var(--diamonds); }
.card-tile.assigned.active-owner .tile-suit.clubs { color: var(--clubs); }

/* ---- Editor Right Panel ---- */
.editor-right-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 170px;
}

.editor-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-action {
    padding: 8px 16px;
    font-size: 0.82em;
    font-weight: 600;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    width: 100%;
    text-align: center;
}

.btn-action:active { transform: scale(0.97); }
.btn-action:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-fill { background: #3498db; color: #fff; }
.btn-fill:hover { background: #2980b9; }

.btn-clear-deal { background: #e74c3c; color: #fff; }
.btn-clear-deal:hover { background: #c0392b; }

.btn-restore { background: #95a5a6; color: #fff; }
.btn-restore:hover { background: #7f8c8d; }

.btn-apply { background: var(--accent2); color: #fff; }
.btn-apply:hover { background: #36a073; }

.btn-rotate { background: #f39c12; color: #fff; }
.btn-rotate:hover { background: #e67e22; }

.btn-save { background: #27ae60; color: #fff; }
.btn-save:hover { background: #1e8449; }

/* ---- Saved Deals List ---- */
.saved-deals-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow-y: auto;
}

.saved-deal-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    font-size: 0.78em;
    color: #c8ddd2;
}

.saved-deal-item:hover {
    background: rgba(255,255,255,0.12);
}

.saved-deal-item .saved-deal-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-deal-item .saved-deal-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.saved-deal-item button {
    padding: 2px 7px;
    font-size: 0.85em;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    background: transparent;
    color: #a8c4b5;
    cursor: pointer;
}

.saved-deal-item button:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

.saved-deal-item button.del-btn:hover {
    background: rgba(231,76,60,0.3);
    color: #e74c3c;
}

/* ---- Error Modal ---- */
.error-modal {
    width: 440px;
}

.error-modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.error-modal-header h2 {
    margin: 0;
    font-size: 1.1em;
    color: #c0392b;
}

.error-modal-icon {
    font-size: 1.6em;
    color: #e67e22;
    line-height: 1;
}

.error-modal-body {
    font-size: 0.88em;
    color: var(--text);
    line-height: 1.6;
}

.error-modal-body .error-item {
    padding: 6px 10px;
    margin-bottom: 4px;
    background: #fef3f0;
    border-left: 3px solid #e74c3c;
    border-radius: 3px;
    font-family: 'Work Sans', sans-serif;
}

/* ---- Constraint active dot indicator (collapsed state) ---- */
.constraint-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3498db;
    display: inline-block;
    margin-left: 6px;
    flex-shrink: 0;
}

/* Responsive mobile for editor bottom */
@media (max-width: 900px) {
    .hand-box.north,
    .hand-box.south { padding-left: 12px; }
}

/* ---- Wizard Choice Cards ---- */
.wizard-choice-cards {
    display: flex;
    gap: 16px;
    margin: 24px 0;
}
.wizard-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.wizard-card:hover {
    border-color: #5b9bd5;
    background: #eef4fb;
    transform: translateY(-2px);
}
.wizard-card-icon {
    font-size: 2em;
}
.wizard-card-title {
    font-weight: 700;
    font-size: 1em;
    color: #2c3e50;
}
.wizard-card-desc {
    font-size: 0.8em;
    color: #7f8c8d;
    text-align: center;
}
.modal-phase { }

/* ---- AI Input Phase ---- */
.ai-input-row {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}
.ai-input-row input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95em;
}
.ai-input-row input:focus {
    border-color: #5b9bd5;
    outline: none;
}
.ai-spinner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    color: #5b9bd5;
    font-size: 0.9em;
}
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e0e0e0;
    border-top-color: #5b9bd5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.ai-error {
    color: #e74c3c;
    font-size: 0.85em;
    padding: 8px 0;
}

/* ---- Q&A Preferences Phase ---- */
.ai-qa-subtitle {
    font-size: 0.88em;
    color: #666;
    margin: 0 0 14px;
}
.ai-qa-item {
    margin-bottom: 14px;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}
.ai-qa-question {
    font-size: 0.88em;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 8px;
}
.ai-qa-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}
.ai-qa-option {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.84em;
    cursor: pointer;
    color: #444;
}
.ai-qa-custom-fields {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 2px;
}
.ai-qa-custom-fields input[type="number"] {
    width: 50px;
    padding: 2px 5px;
    border: 1px solid #bbb;
    border-radius: 4px;
    font-size: 0.84em;
    text-align: center;
}
.ai-qa-custom-sep {
    font-size: 0.84em;
    color: #888;
}

/* ---- Convention tree error banner ---- */
.conv-tree-error {
    color: #e74c3c;
    font-size: 0.85em;
    padding: 8px;
    background: rgba(231, 76, 60, 0.1);
    border-radius: 4px;
    margin: 8px 0;
}

/* ── Scenario tabs in convention editor modal ── */
.modal-scenario-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
    align-items: center;
}

.modal-scenario-tab {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 4px 4px 0 0;
    background: #2a3a2e;
    border: 1px solid #3a5a3e;
    border-bottom: none;
    cursor: pointer;
    font-size: 0.82em;
    color: #a8c4b5;
    transition: background 0.15s;
}

.modal-scenario-tab.active {
    background: #1a2e1e;
    color: #e8f4ec;
    border-color: #5a8a6e;
}

.modal-scenario-tab:hover:not(.active) {
    background: #344a38;
}

.scenario-tab-name {
    cursor: text;
}

.scenario-tab-name-input {
    width: 90px;
    font-size: 0.82em;
    padding: 1px 4px;
    background: #0d1f11;
    border: 1px solid #5a8a6e;
    color: #e8f4ec;
    border-radius: 3px;
}

.scenario-tab-del {
    background: none;
    border: none;
    color: #7a9a8a;
    cursor: pointer;
    font-size: 0.9em;
    padding: 0 2px;
    line-height: 1;
}

.scenario-tab-del:hover { color: #e74c3c; }

.scenario-tab-add {
    padding: 4px 10px;
    background: #1a3a1e;
    border: 1px dashed #3a5a3e;
    border-radius: 4px;
    color: #7a9a8a;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.15s;
}

.scenario-tab-add:hover {
    background: #2a4a2e;
    color: #e8f4ec;
}

/* ── Pre-generation scenario selection modal ── */
.modal-box h3.modal-title {
    margin: 0 0 16px 0;
    color: #e8f4ec;
    font-size: 1.1em;
    font-weight: 600;
}

.modal-box {
    background: #1a2e1e;
    border: 1px solid #3a5a3e;
    border-radius: 8px;
    padding: 24px;
    min-width: 320px;
    max-width: 500px;
    width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.scenario-modal-topic {
    padding: 12px 0;
    border-bottom: 1px solid #2a3a2e;
}

.scenario-modal-topic:last-child { border-bottom: none; }

.scenario-modal-topic-name {
    font-weight: 600;
    color: #e8f4ec;
    margin-bottom: 8px;
}

.scenario-mode-radios {
    display: flex;
    gap: 20px;
    margin-bottom: 8px;
    font-size: 0.88em;
}

.scenario-mode-radios label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #c8ddd0;
}

.scenario-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    transition: opacity 0.2s;
}

.scenario-check-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.84em;
    color: #a8c4b5;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 3px;
    border: 1px solid #2a3a2e;
}

.scenario-check-label:hover { border-color: #5a8a6e; }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
