.talent-tree {
    display: grid;
    grid-template-columns: 1fr 40px 1fr 40px 1fr 40px 1fr;
    grid-template-rows: repeat(5, auto 40px) auto;
    gap: 0;
    width: 100%;
    max-width: 100%;
    margin: 20px auto;
    padding: 20px;
    background: #fdf5e6; /* Parchment-like background */
    border: 1px solid #d2b48c;
    box-sizing: border-box;
}

.talent-box {
    position: relative;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background: transparent;
    border: none;
    padding: 0;
    overflow: visible; /* Allow star to extend outside */
    isolation: isolate; /* Create a stacking context for z-index: -1 */
}

/* The clipped background and border layer */
.talent-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    clip-path: polygon(0 0, calc(100% - 15px) 0, 100% 15px, 100% calc(100% - 15px), calc(100% - 15px) 100%, 15px 100%, 0 calc(100% - 15px));
    z-index: -1;
}

.talent-box.active::before {
    background: #8a0000;
}

.talent-header {
    background: transparent; /* Background is now the ::before layer */
    color: white;
    padding: 5px 15px 5px 10px;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    text-transform: uppercase;
    z-index: 1;
    margin: 0 3px; /* Leave room for border on sides */
    /* Clip only the top-right corner to match parent */
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 0 100%);
}

.checkbox {
    width: 16px;
    height: 16px;
    background: white;
    margin-right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.purchased .checkbox::after {
    content: "\2713";
    color: black;
    font-size: 14px;
    position: absolute;
    top: -4px;
}

.talent-body {
    padding: 6px 12px;
    font-size: 0.65rem;
    color: #333;
    flex-grow: 1;
    background: white;
    margin: 0 3px 3px 3px;
    /* Adjusted clip-path to match parent's bottom diagonals */
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 12px 100%, 0 calc(100% - 12px));
    z-index: 0;
}

.talent-cost {
    position: absolute;
    bottom: 0px;
    right: 3px;
    background: #1a1a1a;
    color: white;
    font-size: 0.7rem;
    padding: 2px 10px;
    font-weight: bold;
    clip-path: polygon(15% 0%, 85% 0%, 100% 50%, 85% 100%, 15% 100%, 0% 50%);
    z-index: 10;
}

.active .talent-cost {
    background: #8a0000;
}

.force-star {
    position: absolute;
    top: -12px;
    left: -12px;
    width: 32px;
    height: 32px;
    z-index: 20;
    filter: drop-shadow(0 0 2px rgba(0,0,0,0.5));
}

.force-pip {
    display: inline-block;
    width: 14px;
    height: 14px;
    vertical-align: middle;
    margin-bottom: 2px;
    background: linear-gradient(90deg, #fff 50%, #000 50%);
    border: 1px solid #000;
    border-radius: 50%;
    position: relative;
}

/* Connectors */
.line-v {
    width: 6px;
    background: #1a1a1a;
    justify-self: center;
}

.line-h {
    height: 6px;
    width: 100%;
    background: #1a1a1a;
    align-self: center;
}

/* Grid Positioning for 4x5 tree */
.row1 { grid-row: 1; }
.row2 { grid-row: 3; }
.row3 { grid-row: 5; }
.row4 { grid-row: 7; }
.row5 { grid-row: 9; }

.col1 { grid-column: 1; }
.col2 { grid-column: 3; }
.col3 { grid-column: 5; }
.col4 { grid-column: 7; }

/* Connector positioning */
.v1-2 { grid-row: 2; }
.v2-3 { grid-row: 4; }
.v3-4 { grid-row: 6; }
.v4-5 { grid-row: 8; }

.h1-2 { grid-column: 2; }
.h2-3 { grid-column: 4; }
.h3-4 { grid-column: 6; }

/* Special Handling for Force Powers with Basic Power row */
.talent-tree.has-basic {
    grid-template-rows: auto 40px repeat(4, auto 40px) auto;
}

.has-basic .row-basic { grid-row: 1; }
.has-basic .row1 { grid-row: 3; }
.has-basic .row2 { grid-row: 5; }
.has-basic .row3 { grid-row: 7; }
.has-basic .row4 { grid-row: 9; }
.has-basic .row5 { grid-row: 11; }

.has-basic .v-basic-1 { grid-row: 2; }
.has-basic .v1-2 { grid-row: 4; }
.has-basic .v2-3 { grid-row: 6; }
.has-basic .v3-4 { grid-row: 8; }
/* Force Power Specific Theme (Green) */
.talent-tree.force-power .talent-box::before,
.talent-tree.force-power .talent-box.active::before {
    background: #1b4d3e; /* Uniform Deep Forest Green */
}

.talent-tree.force-power .talent-cost,
.talent-tree.force-power .active .talent-cost {
    background: #1b4d3e;
}

.talent-tree.force-power .line-v,
.talent-tree.force-power .line-h {
    background: #1b4d3e;
}
d3e;
}
