/* Tower of Hanoi */

.th-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    user-select: none;
    width: 100%;
}

.th-hud {
    display: flex;
    gap: 1.5rem;
    font-weight: 600;
    color: var(--color-text-light);
    font-variant-numeric: tabular-nums;
    flex-wrap: wrap;
    justify-content: center;
}

.th-pegs {
    --th-discs: 4;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: min(520px, 96vw);
    align-items: end;
}

.th-peg {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    /* Room for every disc plus one, so a full peg never overflows. */
    height: calc((var(--th-discs) + 1) * 26px);
    border: none;
    background: transparent;
    padding: 0 0 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    border-radius: var(--radius-md);
}

.th-peg.active { background: rgba(255, 217, 61, 0.35); }

.th-peg:focus-visible {
    outline: 3px solid var(--color-text);
    outline-offset: 2px;
}

/* The rod sits behind the discs; the stack is the flow that positions them. */
.th-rod {
    position: absolute;
    bottom: 10px;
    width: 8px;
    height: calc((var(--th-discs) + 1) * 26px - 10px);
    background: #b08a5a;
    border-radius: 4px;
    z-index: 0;
}

.th-base {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 10px;
    background: #8a6a42;
    border-radius: 4px;
}

.th-stack {
    position: relative;
    z-index: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
}

.th-disc {
    height: 22px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* The disc currently picked up, raised so the selection is unmistakable. */
.th-disc.lifted {
    transform: translateY(-8px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    outline: 3px solid var(--color-text);
}

.th-sizes {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: center;
}

.th-size,
.th-btn {
    padding: 0.5rem 1rem;
    font-size: 0.95rem;
    font-weight: 600;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-card-bg);
    color: var(--color-text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.th-size { min-width: 2.6rem; }

.th-btn {
    background: var(--color-primary);
    border-color: var(--color-primary-dark);
    padding: 0.75rem 2rem;
    font-size: 1.05rem;
}

.th-size:hover { border-color: var(--color-primary-dark); }
.th-size.active {
    background: var(--color-primary);
    border-color: var(--color-primary-dark);
}

.th-size:focus-visible,
.th-btn:focus-visible {
    outline: 3px solid var(--color-text);
    outline-offset: 2px;
}

.th-feedback {
    min-height: 1.4em;
    margin: 0;
    font-weight: 600;
    color: var(--color-text-light);
    text-align: center;
}
