/* game-core core.css — shared game-shell styles for the DOM the package
   drives (connect bar, below-game controls) and the scaffold both games use
   verbatim (score, status line, a11y primitives). Synced into lib/ and linked
   BEFORE the game stylesheet, so a game can override anything.

   Contract: the tokens used here — --ink --paper --line --wash --wash-hover
   --muted --focus — are defined below with defaults; a game MAY override any
   of them in its own :root (the game stylesheet is linked after this file).
   Board styles and board breakpoints stay game-owned. */

:root {
    --ink: #1a1a2e;
    --paper: #ffffff;
    /* WCAG 1.4.11: control borders must be >=3:1 vs the white background,
       so this is darker than a typical hairline. */
    --line: rgba(0, 0, 0, 0.45);
    --wash: rgba(0, 0, 0, 0.04);
    --wash-hover: rgba(0, 0, 0, 0.09);
    --muted: #5f5f6b;   /* >=4.5:1 on white for secondary text (Exit) */
    --focus: #0b57d0;   /* visible focus ring */
}

* {
    box-sizing: border-box;
}

/* Visually hidden but available to assistive tech. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* WCAG 2.4.7: a clear, consistent focus indicator on every control. */
:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
    border-radius: 6px;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--paper);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

main {
    width: 100%;
    max-width: 860px;
    padding: 24px;
    position: relative;
}

.exit {
    padding: 12px;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.15s ease;
}

.exit:hover {
    color: var(--ink);
}

.score {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-bottom: 24px;
}

.score-nums {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    font-size: 50px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

#score-player {
    text-align: right;
}

#score-opponent {
    text-align: left;
}

.score-colon {
    padding: 0 0.2em;
}

.play {
    margin: 28px 0 0;
    font-size: 20px;
    min-height: 30px;
}

/* Out of the layout flow so the centered game block sits in the same place
   whether or not these controls are shown (no shift when a friend joins) —
   they float a bit below the status line instead. One positioned wrapper for
   .again/.exit means they stack in a column instead of ever overlapping,
   however many of the two happen to be visible at once. */
.below-game {
    position: absolute;
    top: calc(100% + 24px);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.links {
    display: grid;
    grid-template-columns: 34px 110px 34px;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.pill {
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 42px;
    max-width: calc(100vw - 32px);
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--wash);
    color: var(--ink);
    font-size: 15px;
    padding: 0 20px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.icon {
    width: 16px;
    height: 16px;
    flex: none;
}

.icon-check {
    color: #1a9e5c;
}

button.pill:hover:not(:disabled) {
    background: var(--wash-hover);
}

.pill:disabled {
    cursor: default;
    opacity: 0.55;
}

.connect-icon-button,
.icon-button {
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
}

.connect-icon-button {
    width: 34px;
    height: 34px;
    padding: 0;
}

.connect-code-slot {
    display: grid;
    align-items: center;
    width: 110px;
    height: 34px;
    overflow: hidden;
    color: var(--ink);
    font-size: 15px;
    font-variant-numeric: tabular-nums;
    text-align: center;
}

#invite-code,
#join-code {
    grid-area: 1 / 1;
    width: 100%;
}

#join-code {
    height: 34px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-align: center;
    cursor: text;
}

.hidden {
    display: none !important;
}

.top-controls {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.top-controls .icon-button {
    width: 34px;
    height: 34px;
    padding: 0;
}

.game-switcher {
    position: relative;
}

.game-switcher-toggle {
    font-size: 22px;
    line-height: 1;
}

.lang-toggle img {
    display: block;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.game-switcher-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    display: grid;
    grid-template-columns: repeat(3, 46px);
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.14);
    text-align: left;
}

.game-switcher-menu a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 42px;
    color: var(--ink);
    font-size: 19px;
    line-height: 1.2;
    text-decoration: none;
}

.game-menu-image {
    width: 27px;
    height: 27px;
    object-fit: contain;
}

.game-switcher-menu a:hover {
    background: var(--wash-hover);
}

@media (max-width: 399px) {
    .links { grid-template-columns: 34px 96px 34px; }
    .connect-code-slot { width: 96px; }
}

@media (min-width: 576px) {
    .score-nums { font-size: 60px; }
}

@media (min-width: 768px) {
    .score { margin-bottom: 30px; }
    .score-nums { font-size: 70px; }
    .play { margin-top: 30px; font-size: 24px; }
}

@media (min-width: 992px) {
    .score { margin-bottom: 40px; }
    .score-nums { font-size: 90px; }
    .play { margin-top: 40px; }
}

@media (min-width: 1200px) {
    .score { margin-bottom: 45px; }
    .score-nums { font-size: 100px; }
    .play { margin-top: 45px; }
}

/* WCAG 2.3.3: honour a reduced-motion preference. Games add their own rules
   for board-specific animated states. */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}
