:root {
  color-scheme: light;
  --paper: #f7f3e9;
  --surface: #fffdf7;
  --ink: #172843;
  --muted: #516078;
  --line: #dcdedc;
  --blue: #2454bd;
  --blue-dark: #193c91;
  --coral: #ea765d;
  --serif: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
  font: 16px/1.55 var(--sans);
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--blue-dark); }
button, select, textarea { font: inherit; }
button, select { min-height: 44px; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #a84a29; outline-offset: 4px; }
h1, h2 { margin: 0; line-height: 1.08; }
h1 { font: 700 clamp(3.2rem, 7vw, 6rem)/.97 var(--serif); letter-spacing: -.065em; }
h2 { font: 700 1.55rem/1.12 var(--serif); letter-spacing: -.025em; }
p { margin: 0 0 1em; }
.shell { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 52px); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 16px 28px; padding: 19px 0; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-size: 1.18rem; font-weight: 800; letter-spacing: -.045em; text-decoration: none; white-space: nowrap; }
.brand img { width: 36px; height: 36px; display: block; }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 9px; }
.site-nav a { padding: 6px 10px; border-radius: 7px; color: var(--muted); font-size: .86rem; font-weight: 650; text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current] { background: #e6ecfb; color: var(--blue-dark); }
.eyebrow, .metric-label { display: block; font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.eyebrow { color: var(--blue-dark); margin-bottom: 10px; }

.hero {
  min-height: 196px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 22px;
  padding: clamp(24px, 4vw, 42px);
  margin-bottom: 23px;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid #c9d6f5;
  background: radial-gradient(ellipse at 78% 50%, #f7fbff 0%, transparent 63%), #e4ecfd;
}
.hero h1 span { color: var(--blue); }
.hero p:last-child { margin: 12px 0 0; color: #3c5377; }
.hero-cards { display: flex; flex: 0 0 auto; padding: 0 16px; }
.hero-cards img { display: block; width: clamp(72px, 9vw, 112px); height: auto; aspect-ratio: 1; object-fit: cover; border: 5px solid var(--surface); border-radius: 13px; box-shadow: 0 10px 20px #17284336; transform: translate(8px, 4px) rotate(-15deg); }
.hero-cards img:nth-child(2) { transform: translateY(-10px) rotate(4deg); z-index: 1; }
.hero-cards img:nth-child(3) { transform: translate(-8px, 6px) rotate(14deg); }

.play-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 310px); grid-template-rows: auto 1fr; gap: 18px; align-items: start; }
.panel { padding: 20px; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); }
.play-panel { grid-column: 2; }
.settings { display: grid; gap: 12px; margin: 16px 0 14px; }
.settings label { display: grid; gap: 5px; font-size: .79rem; font-weight: 750; }
select { width: 100%; border: 1px solid #aab6cb; border-radius: 8px; padding: 6px 10px; background: #fff; color: var(--ink); font-size: .91rem; }
.setup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.setup-actions .primary { flex: 1; justify-content: space-between; }
.primary, .quiet, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 13px; border: 1px solid transparent; border-radius: 8px;
  min-height: 44px; font-size: .85rem; font-weight: 750; text-decoration: none;
}
.primary, .button { background: var(--blue); color: #fff; }
.primary:not(:disabled):hover, .button:hover { background: var(--blue-dark); }
.quiet { background: #edf1f7; color: var(--ink); }
.quiet:not(:disabled):hover, .quiet[aria-pressed="true"] { background: #dbe5f9; }
.primary:disabled, .quiet:disabled { opacity: .54; }
.set-note { display: grid; gap: 4px; margin-bottom: 12px; color: var(--muted); font-size: .82rem; }
#capacity { font-weight: 700; }
.text-link { display: inline-block; font-size: .86rem; font-weight: 750; text-underline-offset: 3px; }

.game {
  grid-column: 1; grid-row: 1 / span 2; min-width: 0;
  padding: clamp(12px, 2.35vw, 26px);
  border: 1px solid #1d304f; border-radius: 19px;
  background: radial-gradient(ellipse at 50% -10%, #2a456a, transparent 65%), #172843;
  color: #fffdf6;
}
.game-heading { margin-bottom: 14px; }
.game .eyebrow { color: #b7c9f0; margin-bottom: 5px; }
.game h2 { font-size: clamp(1.3rem, 3.1vw, 1.95rem); }
.scorebar { display: grid; grid-template-columns: 1fr 1.15fr .85fr 1.35fr; margin-bottom: 15px; border-radius: 10px; background: #0e1d33; }
.scorebar > div { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; padding: 9px clamp(6px, 1.4vw, 15px); }
.scorebar > div + div { border-left: 1px solid #314464; }
.metric-label { color: #b6c7e6; font-size: clamp(.54rem, 1.5vw, .69rem); letter-spacing: .06em; }
.scorebar strong { font-size: clamp(.97rem, 2.6vw, 1.4rem); font-variant-numeric: tabular-nums; }
.best strong { font-size: clamp(.73rem, 2vw, 1rem); line-height: 1.15; }
.board-scroll { overflow: auto; max-width: 100%; border-radius: 10px; padding: 4px 4px 6px; scrollbar-color: #97ade0 #1b3154; }
#board {
  --n: 4;
  --gap: clamp(6px, 1.2vw, 10px);
  display: grid; grid-template-columns: repeat(var(--n), minmax(44px, 1fr)); gap: var(--gap);
  width: min(100%, 510px); min-width: calc(var(--n) * 44px + (var(--n) - 1) * var(--gap)); margin: 0 auto;
}
.card {
  position: relative; display: grid; place-items: center; overflow: hidden;
  padding: 0; aspect-ratio: 1; min-height: 44px; border: 1px solid #8fa9e1;
  border-radius: clamp(7px, 1vw, 12px); background: #2b54ae; box-shadow: 0 3px 0 #07162f;
  transition: transform .15s, background-color .15s;
}
.card:not(.revealed) {
  background-image: repeating-linear-gradient(45deg, #a4bdff16 0 1px, transparent 1px 9px), repeating-linear-gradient(-45deg, #a4bdff16 0 1px, transparent 1px 9px);
}
.card:not(.revealed):not(:disabled):hover { background-color: #3c69c9; transform: translateY(-2px); }
.card:focus-visible { outline-color: #ffba91; outline-offset: 2px; z-index: 1; }
.back { display: block; position: relative; width: 36%; aspect-ratio: 1; }
.back::before, .back::after { content: ""; position: absolute; width: 59%; height: 79%; border: 1px solid #cbdcff; border-radius: 21%; }
.back::before { left: 10%; top: 10%; transform: rotate(-20deg); background: #2c53a8; }
.back::after { right: 8%; top: 8%; transform: rotate(16deg); background: radial-gradient(circle, #f2a48f 0 13%, transparent 15%), #375db5; }
.card.revealed { background: var(--surface); border-color: #cbd7ed; }
.card.matched { border: 2px solid #a8edc9; box-shadow: none; }
.card.matched::after { content: "✓"; position: absolute; right: 3px; bottom: 3px; border-radius: 50%; width: 18px; height: 18px; line-height: 18px; font-size: 12px; background: #b7f1ce; color: #183d31; }
.card img, .face-number { position: absolute; inset: 0; width: 100%; height: 100%; }
.card img { object-fit: cover; }
.face-number { display: grid; place-items: center; font-size: 1.35rem; color: #fff; }
.round-status { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding-top: 12px; }
.round-status p { margin: 0; font-size: .82rem; color: #d5e1fa; }
.round-status .quiet { background: #3a5277; color: #fff; flex: 0 0 auto; }
.round-status .quiet:not(:disabled):hover { background: #4b6793; }
kbd { border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; font-size: .7rem; }
.result { padding: 10px 13px; border-radius: 8px; margin-bottom: 10px; background: #dcf5e7; color: #143d2b; font-size: .88rem; }
.rating { margin-top: 16px; padding: clamp(12px, 2vw, 18px); border: 1px solid #6b86b4; border-radius: 12px; background: #20395e; }
.rating-header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rating-header h3 { margin: 0; font: 700 1.25rem/1.1 var(--serif); }
.rating-header strong { color: #b7f1ce; font-size: 1.38rem; }
.rating-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin: 12px 0; }
.rating-stats div { padding: 9px 10px; border-radius: 7px; background: #152843; }
.rating dt { color: #c4d3ed; font-size: .72rem; }
.rating dd { margin: 0; font-weight: 750; }
.rating p, .rating details { font-size: .82rem; color: #d5e1fa; }
.rating details p { margin: 8px 0 0; }
.rating summary { cursor: pointer; }

.daily-panel { grid-column: 2; background: #fff2d9; border-color: #e5cfa5; }
.daily-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.daily-heading h2 { font-size: 1.4rem; }
.daily-heading time { font-size: .76rem; color: #614b36; }
.daily-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 10px; color: #532a20; background: #ffc1a9; font-size: 1.4rem; }
.daily-panel p { margin-bottom: 8px; font-size: .85rem; }
.daily-panel .daily-note { font-size: .77rem; color: #614b36; }
.daily-actions { display: grid; gap: 7px; margin-top: 12px; }
.daily-actions textarea { width: 100%; min-height: 100px; }
#share-status { font-size: .76rem; }
#share-status:empty { display: none; }

.how { padding: 25px 0; }
.how ol { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 0; margin: 14px 0; list-style: none; }
.how li { padding: 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: .86rem; }
.site-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; border-top: 1px solid var(--line); padding: 15px 0 24px; font-size: .84rem; color: var(--muted); }
.site-footer .brand { font-size: 1rem; }
.site-footer .brand img { width: 28px; height: 28px; }
#sponsor { margin-top: 18px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
#sponsor small { display: block; }

.page-main { padding: 10px 0 36px; }
.page-heading { padding: clamp(20px, 5vw, 45px); border-radius: 18px; background: #e4ecfd; margin-bottom: 22px; }
.page-heading h1, .prose h1 { font-size: clamp(2.45rem, 6vw, 4.8rem); }
.page-heading p:last-child { margin: 12px 0 0; color: var(--muted); max-width: 65ch; }
.collection-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 224px), 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.tile-cover { display: block; overflow: hidden; background: #e5edfc; }
.tile-cover img { display: block; width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; }
.tile-body { display: flex; flex: 1; flex-direction: column; gap: 8px; padding: 15px; }
.tile-body p { margin: 0; color: var(--muted); font-size: .84rem; }
.tile-body .eyebrow { color: var(--blue-dark); font-size: .65rem; }
.tile h2 a { color: var(--ink); text-decoration: none; }
.tile h2 a:hover { text-decoration: underline; }
.tile .text-link { align-self: start; margin-top: auto; padding-top: 4px; }
.collection-lead { display: grid; grid-template-columns: 1fr minmax(140px, 210px); align-items: center; gap: 20px; }
.collection-lead img { width: 100%; height: auto; aspect-ratio: 1; object-fit: contain; border: 6px solid var(--surface); border-radius: 14px; box-shadow: 0 6px 16px #233a642a; }
.collection-lead p { margin: 14px 0; }
.prose { max-width: 76ch; margin: 0 auto; padding: clamp(18px, 4vw, 40px); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.prose h1 { margin-bottom: 20px; }
.prose h2 { margin: 24px 0 8px; }
.prose h2:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }
.contact-card { max-width: 760px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.contact-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px; padding: 14px 18px; font-size: .9rem; }
.contact-frame { display: block; width: 100%; height: 930px; border: 0; }

@media (max-width: 760px) {
  .site-header { flex-wrap: wrap; gap: 6px; padding: 12px 0; }
  .site-nav { gap: 3px; }
  .site-nav a { padding: 6px 7px; }
  .play-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; gap: 12px; }
  .play-panel, .game, .daily-panel { grid-column: auto; grid-row: auto; }
  .settings { grid-template-columns: 1fr 1fr; }
  .setup-actions { grid-column: 1 / -1; }
  .how ol { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 520px) {
  .hero { min-height: 0; gap: 7px; padding: 17px 14px; margin-bottom: 12px; }
  .hero h1 { font-size: clamp(2.05rem, 9.25vw, 3.25rem); }
  .hero p:last-child { font-size: .81rem; margin-top: 6px; }
  .hero .eyebrow { font-size: .58rem; margin-bottom: 5px; }
  .hero-cards { padding: 0 3px 0 0; }
  .hero-cards img { width: clamp(36px, 11vw, 53px); border-width: 2px; border-radius: 6px; }
  .hero-cards img:nth-child(2) { transform: translateY(-3px) rotate(4deg); }
  .hero-cards img:nth-child(3) { display: none; }
  .panel { padding: 14px; }
  .collection-lead { grid-template-columns: 1fr minmax(78px, 26%); gap: 10px; }
  .round-status .quiet { font-size: .73rem; }
  .round-status kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
