/* games.myc.li shared chrome (canonical copy -- synced to each game's
   static/shell.css via tools/sync-shared.sh). Loaded BETWEEN theme.css and the
   game's own style.css, so game files may override anything here.
   Owns: site header, mode switch, game shell/intro, board card + header +
   actions, status messages, modal system, rankings, account card, toast,
   focus rings, dialog motion. Games keep only board/tile/play-specific rules. */

/* ---- base ---- */
* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-height: 100vh; overflow-x: clip; color: var(--t-ink); background: var(--t-bg); font-family: "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--t-ink); }
:where(a, button, input, [tabindex]) :focus-visible, :where(a, button, input, select, [tabindex]):focus-visible { outline: 2px solid var(--t-ink); outline-offset: 2px; border-radius: 4px; }

/* ---- site header ---- */
.site-header { width: min(960px, calc(100% - 40px)); height: 64px; margin: auto; display: grid; grid-template-columns: 1fr auto auto 1fr; column-gap: 16px; align-items: center; border-bottom: 1px solid var(--t-line); }
.site-header a { color: inherit; text-decoration: none; }
.back-link { width: max-content; color: var(--t-muted) !important; font-size: 14px; }
.back-link:hover { color: var(--t-ink) !important; }
.wordmark { font-size: 17px; font-weight: 700; letter-spacing: -.03em; display: inline-flex; align-items: center; gap: 8px; }
.site-header nav { justify-self: end; display: flex; align-items: center; gap: 6px; }
.header-button { min-height: 40px; border: 1px solid var(--t-line-strong, var(--t-line)); border-radius: 5px; padding: 0 14px; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; background: transparent; font-size: 14px; font-weight: 600; cursor: pointer; transition: border-color var(--t-speed) ease, background-color var(--t-speed) ease, color var(--t-speed) ease; }
.header-button:hover:not(:disabled) { border-color: var(--t-dim); background: var(--t-panel); }
.header-button:disabled { opacity: .45; cursor: default; }
.header-button-primary { border-color: var(--t-ink); color: var(--t-panel); background: var(--t-ink); }
.header-button-primary:hover:not(:disabled) { color: #191918; background: var(--t-accent); border-color: var(--t-accent); }

.mode-switch { display: flex; border: 1px solid var(--t-line-strong, var(--t-line)); padding: 3px; border-radius: 999px; background: transparent; }
.mode-switch button { border: 0; background: transparent; border-radius: 999px; padding: 7px 12px; cursor: pointer; color: var(--t-muted); font-size: 13px; font-weight: 600; transition: background-color var(--t-speed) ease, color var(--t-speed) ease; }
.mode-switch button.active { background: var(--t-ink); color: var(--t-bg); }

/* ---- shell + intro ---- */
.game-shell { width: min(720px, calc(100% - 32px)); margin: 54px auto 70px; }
.game-intro { margin-bottom: 25px; display: flex; align-items: end; justify-content: space-between; gap: 40px; }
.game-intro > div > p { margin: 0 0 8px; color: var(--t-muted); font: 500 12px "DM Mono", monospace; text-transform: uppercase; letter-spacing: .1em; }
.game-intro h1 { margin: 0; font-size: clamp(26px, 5vw, 34px); font-weight: 500; letter-spacing: -.045em; }
.game-intro h1 strong { font: 500 .9em "DM Mono", monospace; letter-spacing: -.04em; }
.rule-copy { max-width: 255px; margin: 0; color: var(--t-muted); font-size: 14px; line-height: 1.5; }

/* ---- board card ---- */
.game-board { border: 1px solid var(--t-line); border-radius: 8px; background: var(--t-panel); box-shadow: 0 12px 35px rgb(0 0 0 / 6%); overflow: hidden; }
.board-header { min-height: 68px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-bottom: 1px solid var(--t-line); background: var(--t-panel); }
.board-header.has-connection { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.board-header > div { padding: 12px 15px; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid var(--t-line); min-width: 0; }
.board-header > div:last-child { border-right: 0; }
.board-header span { color: var(--t-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
.board-header strong { margin-top: 4px; font: 500 17px "DM Mono", monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.connection, .board-header .connection, .board-header > .connection { display: none; place-items: center; padding: 0 15px; color: var(--t-warn); font-size: 12px; font-weight: 600; }
.connection.offline, .board-header .connection.offline { display: grid; }

.game-message { min-height: 19px; margin: 0 20px 14px; color: var(--t-muted); font-size: 13px; transition: opacity var(--t-speed) ease; }
.game-message.error { color: var(--t-danger); font-weight: 600; }
.game-message.success { color: var(--t-success); font-weight: 600; }
.game-message.warning { color: var(--t-warn); font-weight: 600; }

.board-actions { padding: 0 20px 19px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board-actions > div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.board-actions button { min-height: 38px; border: 1px solid var(--t-line); border-radius: 4px; padding: 0 13px; color: var(--t-muted); background: transparent; font-size: 13px; font-weight: 600; cursor: pointer; transition: border-color var(--t-speed) ease, background-color var(--t-speed) ease; }
.board-actions button:hover:not(:disabled) { border-color: var(--t-dim); background: var(--t-panel); }
.board-actions button:active:not(:disabled) { transform: scale(.98); }
.board-actions button:disabled { opacity: .35; cursor: default; }

/* ---- modal system (scoped to native <dialog>; games that build div overlays keep their own sizing) ---- */
dialog.modal { width: min(460px, calc(100% - 28px)); padding: 0; border: 0; border-radius: var(--t-radius); color: var(--t-ink); background: transparent; box-shadow: 0 24px 80px rgb(0 0 0 / 25%); }
.modal::backdrop { background: rgb(0 0 0 / 45%); backdrop-filter: blur(2px); }
.modal-card { padding: 25px; background: var(--t-panel); border-radius: var(--t-radius); }
.modal-heading { margin-bottom: 22px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.modal-heading p, .win-card > p:first-child { margin: 0 0 6px; color: var(--t-muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.modal h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.close-button { border: 0; padding: 6px; color: var(--t-muted); background: transparent; font-size: 13px; cursor: pointer; border-radius: 4px; }
.close-button:hover { color: var(--t-ink); }
.modal fieldset { margin: 0; padding: 17px 0; border: 0; border-top: 1px solid var(--t-line); }
.modal legend { padding: 0; font-size: 14px; font-weight: 600; }
.modal fieldset > p { margin: 4px 0 13px; color: var(--t-muted); font-size: 13px; }
.settings-error { min-height: 18px; margin: 14px 0 7px; color: var(--t-danger); font-size: 13px; }
.primary-button, .secondary-button, .danger-button, .confirm-card button { min-height: 44px; border: 1px solid var(--t-ink); border-radius: 4px; padding: 0 15px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background-color var(--t-speed) ease, color var(--t-speed) ease, border-color var(--t-speed) ease; }
.primary-button { width: 100%; color: var(--t-panel); background: var(--t-ink); }
.primary-button:hover:not(:disabled) { color: #191918; background: var(--t-accent); border-color: var(--t-accent); }
.secondary-button { width: 100%; margin-top: 6px; background: transparent; color: var(--t-ink); }
.secondary-button:hover:not(:disabled) { background: var(--t-panel-deep); }
.danger-button { background: transparent; color: var(--t-danger); border-color: var(--t-danger); }
dialog.modal-small, .modal-small { width: min(360px, calc(100% - 28px)); }
.confirm-card p, .win-card > p { color: var(--t-muted); font-size: 14px; margin: 4px 0; }
.confirm-card > div { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.confirm-card button { background: transparent; }
.confirm-card .primary-button { width: auto; grid-column: 1 / -1; }
.win-card { text-align: center; }
.win-stats { margin: 19px 0; display: grid; grid-template-columns: 1fr 1fr; border-block: 1px solid var(--t-line); }
.win-stats div { padding: 12px; }
.win-stats div + div { border-left: 1px solid var(--t-line); }
.win-stats strong, .win-stats span { display: block; }
.win-stats strong { font: 500 18px "DM Mono", monospace; }
.win-stats span { margin-top: 2px; color: var(--t-muted); font-size: 12px; text-transform: uppercase; }

/* rules + examples */
.rules { margin: 0 0 20px; padding: 0; list-style: none; counter-reset: rule; }
.rules li { padding: 12px 0; display: grid; grid-template-columns: 24px 1fr; gap: 10px; border-top: 1px solid var(--t-line); }
.rules li > span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--t-panel-deep); font: 500 12px "DM Mono", monospace; }
.rules p { margin: 1px 0 0; color: var(--t-muted); font-size: 14px; line-height: 1.5; }
.rule-example { margin-bottom: 12px; padding: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--t-panel-deep); border-radius: 6px; }
.rule-note { margin: 0 0 20px; color: var(--t-muted); font-size: 13px; line-height: 1.5; }

/* ---- account ---- */
.account-card { max-width: 540px; }
.account-form { display: grid; gap: 10px; }
.account-form input { padding: 12px; border: 1px solid var(--t-line); background: transparent; border-radius: 4px; }
.account-form input:focus-visible { outline: 2px solid var(--t-ink); outline-offset: 0; border-color: transparent; }
.account-actions, .account-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.account-form button, .account-tabs button, .account-form .google { padding: 10px 12px; border: 1px solid var(--t-line); background: transparent; cursor: pointer; border-radius: 4px; color: var(--t-ink); }
.account-form .google { display: block; width: 100%; text-align: center; text-decoration: none; font-weight: 600; }
.account-form .google:hover { border-color: var(--t-ink); }
.account-item { padding: 12px 0; border-top: 1px solid var(--t-line); }
.account-item b, .account-item span { display: block; }
.account-item span { color: var(--t-muted); margin-top: 3px; }
.account-error { color: var(--t-danger); min-height: 20px; font-size: 13px; }
.eyebrow { margin: 0 0 4px; font: 500 10px "DM Mono", monospace; letter-spacing: .13em; text-transform: uppercase; color: var(--t-muted); }
.account-section { padding: 16px 0; border-top: 1px solid var(--t-line); }
.account-section h3 { margin: 0 0 10px; text-transform: capitalize; }
.account-section > p { margin: 0; }
.account-section pre { white-space: pre-wrap; word-break: break-all; }
.account-line { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 9px 0; color: var(--t-muted); }
.account-line b { color: var(--t-ink); }
.account-line .thumb { width: 28px; height: 28px; border-radius: 50%; margin-right: 10px; }
.account-line > span { display: flex; align-items: center; min-width: 0; }
.account-note, .account-notice { color: var(--t-muted); font-size: 13px; }
.friend-search { display: flex; gap: 8px; margin-bottom: 8px; }
.friend-search input { flex: 1; padding: 10px; border: 1px solid var(--t-line); background: transparent; border-radius: 4px; }
.friend-search button, .account-line button, .avatar-picker button, .theme-picker button { padding: 8px 12px; border: 1px solid var(--t-line); background: transparent; color: var(--t-ink); border-radius: 4px; cursor: pointer; font-size: 13px; font-weight: 600; }
.avatar-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.avatar-picker button { border-width: 2px; padding: 3px; border-color: transparent; }
.avatar-picker button.active { border-color: var(--t-accent); }
.avatar-picker img { width: 100%; display: block; }
.theme-picker { display: flex; gap: 8px; }
.theme-picker button { flex: 1; }
.theme-picker button.active { background: var(--t-accent); border-color: var(--t-accent); color: var(--t-bg); }

/* ---- rankings ---- */
.rankings { width: min(720px, calc(100% - 32px)); margin: 34px auto 0; border-top: 1px solid var(--t-line); padding-top: 24px; }
.rankings > header { display: flex; justify-content: space-between; align-items: end; gap: 12px; }
.rankings header p { margin: 0; text-transform: uppercase; font: 500 11px "DM Mono", monospace; color: var(--t-muted); }
.rankings h2 { margin: 5px 0 0; font-size: 20px; letter-spacing: -.03em; }
.rankings button { border: 1px solid var(--t-line); background: transparent; padding: 8px 12px; cursor: pointer; border-radius: 4px; color: var(--t-ink); font-weight: 600; font-size: 13px; }
.ranking-row { display: grid; grid-template-columns: 48px 1fr auto auto; gap: 18px; padding: 13px 4px; border-top: 1px solid var(--t-line); align-items: center; }
.ranking-row b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-row strong { font: 500 15px "DM Mono", monospace; white-space: nowrap; }
.ranking-row small { color: var(--t-muted); }
.ranking-row .rank-pos { color: var(--t-muted); font: 500 13px "DM Mono", monospace; }

/* ---- dialog motion (applies to the shared .modal system) ---- */
@media (prefers-reduced-motion: no-preference) {
  dialog.modal { opacity: 0; transform: translateY(10px) scale(.98); }
  dialog.modal[open] { animation: modal-in 200ms cubic-bezier(.2, .7, .3, 1) forwards; }
  .modal::backdrop { opacity: 0; animation: backdrop-in 200ms ease forwards; }
  @keyframes modal-in { to { opacity: 1; transform: none; } }
  @keyframes backdrop-in { to { opacity: 1; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- mobile chrome ---- */
@media (max-width: 600px) {
  .site-header { width: calc(100% - 28px); height: auto; grid-template-columns: 1fr auto; grid-template-rows: auto auto; row-gap: 8px; padding-block: 10px; padding-inline: 14px; }
  .back-link { display: none; }
  .wordmark { grid-column: 1; }
  .site-header nav { grid-column: 2; }
  .mode-switch { grid-row: 2; grid-column: 1 / -1; }
  .header-button { padding-inline: 10px; font-size: 13px; }
  .mode-switch { padding: 2px; }
  .mode-switch button { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  .rankings { width: calc(100% - 20px); }
  .rankings .ranking-row { grid-template-columns: 35px minmax(0, 1fr) auto auto; gap: 8px; }
}
@media (max-width: 360px) {
  .site-header { width: calc(100% - 20px); padding-inline: 10px; row-gap: 6px; }
  .site-header nav { gap: 6px; overflow: hidden; }
  .site-header { grid-template-columns: minmax(40px, auto) minmax(0, 1fr); }
  .site-header nav { flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
  .wordmark { font-size: 15px; white-space: nowrap; }
  .header-button { min-height: 34px; padding-inline: 8px; font-size: 12px; }
  .mode-switch { padding: 2px; gap: 2px; }
  .mode-switch button { min-height: 30px; padding: 5px 8px; font-size: 11px; }
}
