body {
    margin: 0;
    font-family: Arial, sans-serif;
    text-align: center;
    background: radial-gradient(circle at top, #fbf7ef 0%, #efe7db 45%, #e7ddcf 100%);
    color: #2b241d;
    min-height: 100vh;
}

.page-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
}

h1 {
    margin: 0;
    letter-spacing: 0.08em;
}

/* Wrapper that sizes both the wheel and the SVG ring overlay */
#wheel-area {
    position: relative;
    width: min(90vw, 600px);
    height: min(90vw, 600px);
    margin: 20px auto;
}

#wheel {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #f0ece4;
    transform-origin: center;
    /* Keep the rotating board in one compositor layer so its text is not
       repainted separately on every timer update. */
    will-change: transform;
}

#wheel.is-rotating {
    animation: wheel-rotation var(--wheel-rotation-duration) linear forwards;
}

/* Keep the letters readable while the coloured circles move underneath them. */
#wheel.is-rotating .tile-letter {
    animation: tile-letter-counter-rotation var(--wheel-rotation-duration) linear forwards;
}

@keyframes wheel-rotation {
    from { transform: rotate(0deg); }
    to { transform: rotate(-360deg); }
}

@keyframes tile-letter-counter-rotation {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tile {
    position: absolute;
    width: 18%;
    height: 18%;
    border-radius: 50%;
    /* rotation set per-tile in JS */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: min(6vw, 54px);
    color: white;
    box-shadow: 0 0 0 5px #2a1a0a;
    user-select: none;
    cursor: pointer;
    /* borders for letter fonts */
    text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000;
}

.tile-letter {
    display: block;
    transform-origin: center;
}

/* Outer hexagon: 6 tiles at 60° steps starting from top */
.tile:nth-child(1) { --angle: 90deg; }
.tile:nth-child(2) { --angle: 30deg; }
.tile:nth-child(3) { --angle: -30deg; }
.tile:nth-child(4) { --angle: -90deg; }
.tile:nth-child(5) { --angle: -150deg; }
.tile:nth-child(6) { --angle: 150deg; }

/* Inner triangle: 3 tiles at 120° steps */
.tile:nth-child(7) { --angle: 60deg; }
.tile:nth-child(8) { --angle: -60deg; }
.tile:nth-child(9) { --angle: -180deg; }

.outer {
    left: calc(50% + cos(var(--angle)) * 37%);
    top: calc(50% - sin(var(--angle)) * 37%);
}

.inner {
    left: calc(50% + cos(var(--angle)) * 14%);
    top: calc(50% - sin(var(--angle)) * 14%);
}

/* SVG ring overlay — sits over the wheel edge */
#timer-ring {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
}

#timer-track {
    fill: none;
    stroke: #d0c8b8;
    stroke-width: 2;
}

#timer-arc {
    fill: none;
    stroke: #322e4e;
    stroke-width: 2;
    /* stroke-linecap: round; */
}

/* Timer controls below the wheel */
#timer-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin: 12px 0 6px;
    font-size: 18px;
}

#timer-display {
    font-size: 36px;
    color: #b3b3b3;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    min-width: 70px;
}

#duration-input {
    width: 48px;
    font-size: 18px;
    text-align: center;
    border: 2px solid #a09880;
    border-radius: 4px;
    padding: 2px 4px;
}

#timer-message {
    font-size: 22px;
    font-weight: bold;
    color: #c62828;
    min-height: 30px;
    margin: 4px 0 8px;
}

#shuffle-btn {
    margin: 8px auto;
    padding: 18px 60px;
    font-size: 28px;
    font-weight: bold;
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}


#shuffle-btn.is-idle {
    background: #2e7d32;
}

#shuffle-btn.is-running {
    background: #c62828;
}

.help-btn {
    width: 34px;
    height: 34px;
    border: 2px solid #2a1a0a;
    border-radius: 50%;
    background: #fff8eb;
    color: #2a1a0a;
    font-size: 22px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 0 rgba(42, 26, 10, 0.2);
}

.help-btn:hover {
    background: #f6ead3;
}

.help-btn:focus-visible,
#shuffle-btn:focus-visible,
.modal-close:focus-visible {
    outline: 3px solid #1a73e8;
    outline-offset: 3px;
}

.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 16, 10, 0.55);
}

.modal-panel {
    position: relative;
    z-index: 1;
    width: min(92vw, 460px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    padding: 28px 26px 22px;
    border-radius: 18px;
    background: #fffaf3;
    color: #2b241d;
    text-align: left;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.modal-panel h2 {
    margin: 0 0 14px;
    font-size: 28px;
}

#solver-link-title {
    cursor: default;
    user-select: none;
}

.modal-panel p {
    margin: 0 0 14px;
    line-height: 1.5;
}

.modal-panel ul {
    margin: 0;
    padding-left: 20px;
    line-height: 1.55;
}

.modal-panel li + li {
    margin-top: 8px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #eee4d4;
    color: #2b241d;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
