/* Solitaire Classic — Paris café: cream paper panels, bordeaux accents, serif headings. Big, calm, readable. */
:root {
  --paper: #f7f3e9;
  --paper2: #efe7d6;
  --ink: #2b2620;
  --ink2: #6b6154;
  --bordeaux: #7b1e2b;
  --bordeaux2: #9a2a3a;
  --sage: #5f7d5a;
  --gold: #c9a24a;
  --bar: rgba(22, 20, 17, 0.62);
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --sans: "Nunito", "Baloo 2", system-ui, "Noto Sans", sans-serif;
  --fs: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #22301f; font-family: var(--sans); color: var(--ink); font-size: var(--fs); }
body.large { --fs: 19px; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font-family: inherit; font-size: inherit; cursor: pointer; color: inherit; }
.hidden { display: none !important; }

/* ------------------------------------------------------------ bars */
.bar { position: fixed; left: 0; right: 0; z-index: 5; display: flex; align-items: center; color: #fbf6ea; }
.bar.top { top: 0; height: 46px; padding: 0 max(8px, env(safe-area-inset-right)) 0 max(8px, env(safe-area-inset-left)); gap: 8px;
  background: linear-gradient(var(--bar), rgba(22, 20, 17, 0.25)); }
.bar.bottom { bottom: 0; height: calc(58px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom); justify-content: center; gap: 4px;
  background: linear-gradient(rgba(22, 20, 17, 0.2), var(--bar)); }
.title { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; flex: 1; }
.title b { font-family: var(--serif); font-size: 1.12em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: .01em; }
.title small { font-size: .74em; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats { display: flex; gap: 12px; font-size: .92em; white-space: nowrap; }
.stat i { font-style: normal; opacity: .75; font-size: .85em; }
.stat b { font-variant-numeric: tabular-nums; }
.ibtn { background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); color: inherit; border-radius: 10px; min-width: 38px; height: 36px; font-size: 1.1em; }
.ibtn:hover { background: rgba(255, 255, 255, 0.2); }
.tbtn { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 60px; max-width: 110px; flex: 1; height: 50px;
  background: transparent; border: 0; border-radius: 12px; color: #fbf6ea; font-size: .8em; font-weight: 700; transition: background .15s, transform .1s; }
.tbtn .ic { font-size: 1.45em; line-height: 1; }
.tbtn:hover { background: rgba(255, 255, 255, 0.12); }
.tbtn:active { transform: scale(.94); }
.tbtn:disabled { opacity: .38; }
.tbtn.hot { background: rgba(201, 162, 74, 0.35); animation: glow 1.4s ease-in-out infinite; }
.tbtn .dot { position: absolute; top: 6px; right: 22%; width: 9px; height: 9px; border-radius: 50%; background: #e0574a; box-shadow: 0 0 0 2px rgba(0,0,0,.3); }
@keyframes glow { 50% { background: rgba(201, 162, 74, 0.6); } }
@media (max-width: 520px) {
  .stats { gap: 7px; font-size: .8em; }
  .stat i { font-size: .8em; }
  .tbtn { min-width: 48px; font-size: .72em; }
}
@media (max-width: 380px) { .stat i { display: none; } .title small { font-size: .66em; } }

/* ------------------------------------------------------------ overlays & panels */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 12px;
  background: rgba(15, 14, 12, 0.5); backdrop-filter: blur(2px); animation: fade .18s ease-out; }
.overlay.solid { background: #22301f; }
@keyframes fade { from { opacity: 0; } }
.panel { background: var(--paper); border-radius: 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(123, 30, 43, 0.15);
  width: min(560px, 100%); max-height: calc(100dvh - 24px); overflow: auto; padding: 16px 18px 18px; animation: pop .22s cubic-bezier(.2, 1.3, .5, 1); }
.panel.wide { width: min(820px, 100%); }
.panel.narrow { width: min(420px, 100%); }
@keyframes pop { from { transform: translateY(10px) scale(.97); opacity: 0; } }
.phead { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; position: sticky; top: -16px; background: var(--paper); padding: 4px 0; z-index: 1; }
.phead h2 { flex: 1; }
.panel .ibtn { background: var(--paper2); border-color: rgba(0,0,0,.1); color: var(--ink); }
h2 { font-family: var(--serif); font-weight: 700; font-size: 1.45em; margin: 0; color: var(--bordeaux); }
h3 { font-family: var(--serif); margin: 12px 0 6px; font-size: 1.1em; color: var(--ink); }
.sub { color: var(--ink2); margin: 4px 0 10px; }
.fine { color: var(--ink2); font-size: .8em; margin: 10px 2px 0; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.mbtn { text-align: left; background: #fff; border: 1px solid rgba(0,0,0,.08); border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 1.02em; }
.mbtn:hover { background: #fffaf0; border-color: rgba(123,30,43,.3); }
.btn { border: 0; border-radius: 12px; padding: 11px 18px; font-weight: 800; font-size: 1em; background: var(--paper2); color: var(--ink); transition: transform .1s, filter .15s; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--bordeaux); color: #fff8ee; }
.btn.sage { background: var(--sage); color: #fff; }
.btn.small { padding: 7px 12px; font-size: .9em; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
input[type=number] { font: inherit; font-size: 1.2em; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(0,0,0,.2); width: 9em; background: #fff; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: thin; }
.tab { flex: none; border: 1px solid rgba(0,0,0,.1); background: #fff; border-radius: 999px; padding: 7px 13px; font-weight: 700; font-size: .9em; white-space: nowrap; }
.tab.on { background: var(--bordeaux); color: #fff; border-color: var(--bordeaux); }

/* game picker */
.games-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.gcard { background: #fff; border-radius: 14px; padding: 12px; border: 1px solid rgba(0,0,0,.08); display: flex; flex-direction: column; gap: 6px; position: relative; }
.gcard.cur { border-color: var(--bordeaux); box-shadow: 0 0 0 2px rgba(123,30,43,.25); }
.gcard .gh { display: flex; align-items: center; gap: 8px; }
.gcard .gi { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 1.3em; background: var(--paper2); flex: none; }
.gcard b { font-family: var(--serif); font-size: 1.12em; }
.gcard p { margin: 0; color: var(--ink2); font-size: .86em; line-height: 1.3; flex: 1; }
.gcard .gs { font-size: .8em; color: var(--sage); font-weight: 700; }
.chips { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { border: 1px solid rgba(0,0,0,.15); background: var(--paper); border-radius: 999px; padding: 4px 10px; font-size: .82em; font-weight: 700; }
.chip.on { background: var(--sage); color: #fff; border-color: var(--sage); }
.gcard .gbtns { display: flex; gap: 6px; }
.gcard .gbtns .btn { flex: 1; padding: 9px 10px; }

/* daily calendar */
.cal-head { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.cal-head b { flex: 1; text-align: center; font-family: var(--serif); font-size: 1.15em; text-transform: capitalize; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow { text-align: center; font-size: .75em; color: var(--ink2); font-weight: 700; padding-bottom: 2px; }
.cal .day { height: clamp(38px, 6.5vh, 52px); border-radius: 10px; border: 1px solid rgba(0,0,0,.08); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; font-size: .95em; position: relative; }
.cal .day.done { background: #e9f1e4; border-color: var(--sage); color: var(--sage); }
.cal .day.done::after { content: '✓'; font-size: .8em; }
.cal .day.today { outline: 2px solid var(--bordeaux); outline-offset: -2px; }
.cal .day.future { opacity: .35; cursor: default; }
.cal .day.empty { background: transparent; border: 0; }
.cal button.day:hover:not(.future) { border-color: var(--bordeaux); }
.badges { display: flex; gap: 8px; justify-content: center; margin: 10px 0 4px; flex-wrap: wrap; }
.badge { padding: 5px 11px; border-radius: 999px; font-size: .84em; font-weight: 800; background: var(--paper2); color: var(--ink2); }
.badge.got.bronze { background: #e6c7a3; color: #6a3f14; }
.badge.got.silver { background: #dfe3e8; color: #3e4652; }
.badge.got.gold { background: #f3d77a; color: #6a4c00; }
.daily-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 4px; }

/* stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sbox { background: #fff; border-radius: 12px; padding: 10px 12px; border: 1px solid rgba(0,0,0,.07); }
.sbox small { display: block; color: var(--ink2); font-size: .8em; }
.sbox b { font-size: 1.4em; font-family: var(--serif); }

/* trophies */
.tro-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.tro { display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 12px; padding: 9px 11px; border: 1px solid rgba(0,0,0,.07); }
.tro .ti { font-size: 1.6em; width: 42px; height: 42px; display: grid; place-items: center; background: #fbf1d4; border-radius: 50%; flex: none; }
.tro.lock { opacity: .55; }
.tro.lock .ti { filter: grayscale(1); background: var(--paper2); }
.tro b { display: block; font-size: .95em; }
.tro small { color: var(--ink2); font-size: .8em; line-height: 1.25; display: block; }

/* settings */
.set-list { display: flex; flex-direction: column; gap: 2px; }
.set-list h3 { margin: 14px 0 4px; font-size: 1em; color: var(--bordeaux); }
.srow { display: flex; align-items: center; gap: 12px; padding: 9px 4px; border-bottom: 1px solid rgba(0,0,0,.06); }
.srow .sl { flex: 1; }
.srow .sl small { display: block; color: var(--ink2); font-size: .8em; }
.switch { width: 50px; height: 28px; border-radius: 999px; background: #cfc6b5; border: 0; position: relative; flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.switch.on { background: var(--sage); }
.switch.on::after { transform: translateX(22px); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0 10px; }
.swatch { width: 72px; border: 2px solid transparent; border-radius: 10px; padding: 0; background: none; text-align: center; font-size: .74em; font-weight: 700; color: var(--ink2); overflow-wrap: anywhere; hyphens: auto; line-height: 1.2; }
.swatch canvas, .swatch img, .swatch .sw { width: 100%; height: 48px; border-radius: 8px; display: block; object-fit: cover; background: #ccc; }
.swatch.back canvas { height: 84px; }
.swatch.on { border-color: var(--bordeaux); color: var(--bordeaux); }
.swatch.lock { opacity: .45; }

.rules-body { line-height: 1.5; }
.rules-body p { margin: 6px 0; }
.rules-body ul { padding-left: 1.2em; margin: 6px 0; }

.langs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.langs .tab { border-radius: 10px; padding: 10px; }

.dialog { text-align: center; }
.dialog h2 { font-size: 1.8em; }
.dialog .actions { justify-content: center; }
.dlg-body { color: var(--ink2); }
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.res-grid .sbox b { font-size: 1.25em; }
.newbest { display: inline-block; background: #f3d77a; color: #6a4c00; font-weight: 800; font-size: .7em; border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }

/* toast */
.toast { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: rgba(28, 24, 20, 0.9); color: #fbf6ea;
  padding: 10px 18px; border-radius: 999px; font-weight: 700; box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: calc(100vw - 24px); text-align: center; animation: fade .2s; }

/* loader */
.loader { display: flex; flex-direction: column; align-items: center; gap: 18px; color: #fbf6ea; }
.logo { display: flex; flex-direction: column; align-items: center; font-family: var(--serif); line-height: 1; }
.logo .l1 { font-size: 2.6em; font-style: italic; }
.logo .l2 { font-size: 1.1em; letter-spacing: .4em; text-transform: uppercase; opacity: .8; margin-top: 6px; }
.spin { width: 30px; height: 30px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--gold); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .panel, .overlay, .tbtn.hot { animation: none; } }
/* touch screens: every control at least ~44px tall (older players, big thumbs) */
@media (pointer: coarse) {
  .ibtn { min-width: 44px; height: 44px; }
  .chip { min-height: 40px; padding: 6px 14px; font-size: .9em; }
  .tab, .btn.small { min-height: 42px; }
  .switch { width: 54px; height: 32px; }
  .switch::after { width: 26px; height: 26px; }
  .switch.on::after { transform: translateX(22px); }
}
.srow:has(.switch) { cursor: pointer; }
