/* ==========================================================================
   owainj.co.uk – home page arcade, toolbox and extras
   ========================================================================== */

/* --- Jump links under the title --- */
.jump-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1rem 0 0;
    padding: 0;
    list-style: none;
}
.jump-links a {
    display: inline-block;
    min-height: 40px;
    padding: 0.45rem 0.95rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.95rem;
    box-shadow: 0 2px 4px var(--shadow);
}
.jump-links a:hover {
    border-color: var(--accent);
    text-decoration: underline;
}
html {
    scroll-behavior: smooth;
}
section[id], .card[id] {
    scroll-margin-top: 1rem;
}

/* --- Accolade --- */
.accolade {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin: 0 0 1rem;
    padding: 0.6rem 0.9rem;
    border: 1px solid var(--radio-border);
    border-radius: 8px;
    background: linear-gradient(135deg, var(--radio-1) 0%, var(--radio-2) 100%);
    color: var(--text);
}
.accolade-icon { font-size: 1.35rem; line-height: 1; }
.accolade strong { color: var(--ink); }

/* --- Local time --- */
.owain-clock {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin: 0 0 1rem;
    padding: 0.6rem 0.9rem;
    border: 1px dashed var(--border-strong);
    border-radius: 8px;
    color: var(--text-muted);
}
.owain-clock strong {
    font-size: 1.35rem;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}

/* --- Section intro --- */
.card-intro {
    margin-top: -0.25rem;
    color: var(--text-muted);
}

/* --- Tabs --- */
.tab-list {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-soft);
}
.tab-list [role="tab"] {
    min-height: 44px;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    cursor: pointer;
}
.tab-list [role="tab"]:hover {
    border-color: var(--accent);
}
.tab-list [role="tab"][aria-selected="true"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--on-accent);
    font-weight: 700;
}
[role="tabpanel"]:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 4px;
    border-radius: 4px;
}
[role="tabpanel"] h3 {
    margin: 0 0 0.25rem;
    color: var(--ink);
}

/* --- Shared game bits --- */
.game-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin: 0 0 0.75rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.game-bar b {
    color: var(--ink);
}
.game-btn {
    min-height: 44px;
    padding: 0.5rem 1.1rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.game-btn:hover {
    background: var(--accent-hover);
}
.game-btn--quiet {
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--border-strong);
    font-weight: 400;
}
.game-btn--quiet:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}
.game-btn.is-copied {
    background: var(--success);
    border-color: var(--success);
    color: var(--surface);
}
.game-hint,
.tool-note {
    font-size: 0.85rem;
    color: var(--text-subtle);
    margin: 0.6rem 0 0;
}
.game-status {
    min-height: 1.6em;
    margin: 0.75rem 0 0;
    color: var(--ink);
    font-weight: 700;
}

/* --- Snake --- */
.snake-wrap {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1;
}
#snake-canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    border: 2px solid var(--border-strong);
    touch-action: none;
}
.snake-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.78);
    color: #f1f5f9;
    text-align: center;
}
.snake-overlay p {
    margin: 0;
    font-size: 1.05rem;
}
.dpad {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(2, 52px);
    gap: 6px;
    justify-content: center;
    margin: 0.9rem auto 0;
}
.dpad button {
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation;
}
.dpad button:active {
    background: var(--accent);
    color: var(--on-accent);
}
.dpad [data-snake-dir="0,-1"] { grid-column: 2; grid-row: 1; }
.dpad [data-snake-dir="-1,0"] { grid-column: 1; grid-row: 2; }
.dpad [data-snake-dir="0,1"] { grid-column: 2; grid-row: 2; }
.dpad [data-snake-dir="1,0"] { grid-column: 3; grid-row: 2; }
/* Keyboard users on big screens don't need the pad */
@media (hover: hover) and (pointer: fine) and (min-width: 700px) {
    .dpad { display: none; }
}

/* --- Reaction test --- */
.react-pad {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 220px;
    padding: 1rem;
    border: none;
    border-radius: 14px;
    font: inherit;
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: background-color 0.1s;
}
.react-pad.is-idle,
.react-pad.is-result {
    background: var(--accent);
    color: var(--on-accent);
}
.react-pad.is-waiting {
    background: #b91c1c;
    color: #ffffff;
}
.react-pad.is-go {
    background: #15803d;
    color: #ffffff;
    font-size: 2.2rem;
}
.react-pad.is-early {
    background: #b45309;
    color: #ffffff;
}

/* --- Memory match --- */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    max-width: 380px;
    margin: 0 auto;
}
.memory-card {
    aspect-ratio: 1;
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: var(--on-accent);
    font-size: clamp(1.4rem, 7vw, 2rem);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.2s ease;
}
.memory-card:hover:not(:disabled) {
    transform: translateY(-2px);
}
.memory-card.is-up {
    background: var(--surface-2);
    color: var(--ink);
    transform: rotateY(0);
    animation: memory-flip 0.25s ease-out;
}
.memory-card.is-matched {
    border-color: var(--success);
    opacity: 0.75;
    cursor: default;
}
@keyframes memory-flip {
    from { transform: rotateY(90deg); }
    to { transform: rotateY(0); }
}

/* --- Noughts & crosses --- */
.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: min(100%, 300px);
    margin: 0 auto;
}
.ttt-cell {
    aspect-ratio: 1;
    border: 2px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 2.4rem;
    font-weight: 700;
    cursor: pointer;
}
.ttt-cell:hover:not(:disabled) {
    border-color: var(--accent);
}
.ttt-cell:disabled {
    cursor: default;
    opacity: 1;
}
.ttt-cell.is-x { color: var(--accent); }
.ttt-cell.is-o { color: var(--error); }
.ttt-cell.is-win {
    background: var(--accent);
    color: var(--on-accent);
    border-color: var(--accent);
}
.ttt-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}
.ttt-controls select,
.tool-row select,
.tool-row input[type="number"] {
    min-height: 44px;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
}

/* --- Toolbox --- */
.tool-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.6rem;
    margin: 0.5rem 0 0.75rem;
}
.tool-row label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.tool-row input[type="number"] {
    width: 6rem;
}
.tool-out {
    min-height: 4.5rem;
    padding: 0.75rem;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.tool-out > :first-child { margin-top: 0; }
.tool-out > :last-child { margin-bottom: 0; }
.tool-label {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-subtle);
}
.tool-result {
    margin: 0.5rem 0 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ink);
}
.tool-result.is-error {
    color: var(--error);
    font-size: 1rem;
}
.dice-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.die {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    height: 3rem;
    padding: 0 0.4rem;
    border-radius: 10px;
    background: var(--surface);
    border: 2px solid var(--border-strong);
    color: var(--ink);
    font-size: 1.4rem;
    font-weight: 700;
}
.die--pips {
    font-size: 2.6rem;
    line-height: 1;
}
.coin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3.4rem;
    height: 3.4rem;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #fde68a, #d97706);
    color: #3b2604;
    font-size: 1.5rem;
    font-weight: 700;
    border: 3px solid #b45309;
}
.coin--tails {
    background: radial-gradient(circle at 35% 35%, #e5e7eb, #6b7280);
    border-color: #4b5563;
    color: #111827;
}
.tool-out.is-rolling .die,
.tool-out.is-rolling .coin {
    animation: tool-roll 0.45s ease-out;
}
@keyframes tool-roll {
    0% { transform: rotate(-200deg) scale(0.6); opacity: 0.2; }
    100% { transform: none; opacity: 1; }
}
.history {
    margin: 0.75rem 0 0;
    padding-left: 1.3rem;
    font-size: 0.85rem;
    color: var(--text-subtle);
}
.history:empty { display: none; }

#picker-input {
    width: 100%;
    min-height: 7.5rem;
    padding: 0.6rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    resize: vertical;
}
.preset-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0.4rem 0 0;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-subtle);
}
.preset-row .fun-btn {
    min-height: 36px;
    font-size: 0.85rem;
}
.picker-winner {
    margin: 0.25rem 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent);
    overflow-wrap: anywhere;
    animation: fun-pop-in 0.35s ease-out;
}
.picker-list {
    margin: 0.4rem 0 0;
    padding-left: 1.5rem;
    color: var(--ink);
}
.teams {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
}
.team {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.team h4 {
    margin: 0 0 0.25rem;
    color: var(--ink);
}
.team ul {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text-muted);
}

.pw-box {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
#pw-output {
    flex: 1 1 14rem;
    min-width: 0;
    min-height: 48px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
    font-family: Consolas, "Courier New", monospace;
    font-size: 1.05rem;
}
.pw-meter {
    height: 8px;
    margin: 0.75rem 0 0.3rem;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
}
#pw-meter {
    display: block;
    height: 100%;
    width: 0;
    transition: width 0.25s ease;
}
#pw-meter.is-weak { background: #dc2626; }
#pw-meter.is-ok { background: #d97706; }
#pw-meter.is-strong { background: #16a34a; }
#pw-meter.is-fortknox { background: linear-gradient(90deg, #16a34a, #3f51b5); }
#pw-strength {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.pw-opts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1.1rem;
    margin: 0.9rem 0 0;
    padding: 0;
    border: none;
}
.pw-opts legend {
    width: 100%;
    margin-bottom: 0.2rem;
    font-size: 0.85rem;
    color: var(--text-subtle);
}
.pw-opts label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-height: 32px;
    cursor: pointer;
}
.pw-opts input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--accent);
}
.pw-opts:disabled {
    opacity: 0.55;
}
.pw-length {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.9rem;
}
.pw-length input {
    flex: 1 1 12rem;
    accent-color: var(--accent);
}

.timer {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    justify-content: center;
}
.timer-ring {
    --p: 0;
    display: grid;
    place-items: center;
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(var(--accent) calc(var(--p) * 360deg), var(--border) 0);
}
.timer-ring::before {
    content: "";
    grid-area: 1 / 1;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: var(--surface);
}
#timer-display {
    grid-area: 1 / 1;
    position: relative;
    font-size: 2.2rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
}
.timer-side {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}
.timer-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

/* --- Trophy cabinet --- */
.trophies {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 0.5rem;
}
.trophies li {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #eab308;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 0.9rem;
}
.trophies li.trophy-empty {
    grid-column: 1 / -1;
    border-style: dashed;
    border-color: var(--border-strong);
    color: var(--text-muted);
}
#trophy-count {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-subtle);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .memory-card.is-up,
    .picker-winner,
    .tool-out.is-rolling .die,
    .tool-out.is-rolling .coin {
        animation: none;
    }
}

/* --- Online leaderboard --- */
.online {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-soft);
}
.online h3 {
    margin: 0 0 0.6rem;
    color: var(--ink);
}
.board {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
}
.board li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.45rem 0.8rem;
    background: var(--surface-2);
    border-top: 1px solid var(--border-soft);
}
.board li:first-child {
    border-top: none;
}
.board li.is-me {
    background: var(--radio-2);
    font-weight: 700;
    box-shadow: inset 4px 0 0 var(--accent);
}
.board li.is-gap {
    border-top: 2px dashed var(--border-strong);
}
.board-rank {
    min-width: 2.2rem;
    font-variant-numeric: tabular-nums;
    color: var(--text-subtle);
}
.board-name {
    flex: 1;
    min-width: 0;
    color: var(--ink);
    overflow-wrap: anywhere;
}
.board-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    white-space: nowrap;
}
.board li.board-empty {
    color: var(--text-muted);
    font-style: italic;
}
.online-bar p {
    margin: 0 0 0.6rem;
    color: var(--text-muted);
}
.online-bar strong {
    color: var(--ink);
}
.online-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.game-btn--discord {
    display: inline-flex;
    align-items: center;
    background: #5865f2;
    color: #ffffff;
    text-decoration: none;
}
.game-btn--discord:hover {
    background: #4752c4;
    text-decoration: underline;
}
.game-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}
.sync-box {
    margin-top: 0.9rem;
    padding: 0.75rem 0.9rem;
    border: 1px dashed var(--border-strong);
    border-radius: 10px;
    background: var(--surface-2);
}
.sync-box p {
    margin: 0 0 0.5rem;
}
.sync-code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: var(--ink);
}
.sync-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem;
}
.sync-form label {
    width: 100%;
    font-size: 0.9rem;
    color: var(--text-muted);
}
.sync-form input {
    flex: 1 1 10rem;
    min-height: 44px;
    padding: 0.4rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-family: Consolas, "Courier New", monospace;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
#online-msg.is-error {
    color: var(--error);
}
