* { box-sizing: border-box; }
[hidden] { display: none !important; } /* makes the menu's Close actually hide it */

/* ---------- Theme colors ----------
   Each theme sets these variables. Add a new block for each new theme. */
body.theme-classic {
  --header-bg: rgba(0, 0, 0, 0.25);
  --tile-bg: #fbf7ea;
  --tile-border: #b9ae94;
  --tile-side: #a99f84;
  --tile-back: repeating-linear-gradient(45deg, #2e7d5b 0 6px, #286f50 6px 12px);
  --title-font: "Segoe UI", system-ui, sans-serif;
}

body.theme-croquet {
  --header-bg: #2c5424;
  --tile-bg: #fffdf5;
  --tile-border: #c9bfa3;
  --tile-side: #8fa77e;
  --tile-back: repeating-linear-gradient(90deg, #3d7a31 0 8px, #4a8a3c 8px 16px);
  --title-font: Georgia, "Times New Roman", serif;
}

body.theme-birds {
  --header-bg: #2d5566;
  --tile-bg: #fffdf7;
  --tile-border: #c6bda5;
  --tile-side: #8fa9b5;
  --tile-back: repeating-linear-gradient(45deg, #3f7088 0 6px, #36627a 6px 12px);
  --title-font: Georgia, "Times New Roman", serif;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: #1f5d3a; /* replaced by the chosen background (game.js) */
  color: #f4f1e6;
  font-family: "Segoe UI", system-ui, sans-serif;
}

header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 16px;
  background: var(--header-bg);
}

h1 { font-size: 24px; margin: 0; font-family: var(--title-font); }

.buttons { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

button {
  font: inherit;
  font-size: 16px;
  padding: 7px 16px;
  border: none;
  border-radius: 6px;
  background: #f4f1e6;
  color: #1f3a2a;
  cursor: pointer;
}
button:hover { background: #fff; }

#status { font-size: 16px; }
#status.win { color: #ffe28a; font-weight: bold; }
#status.stuck { color: #ffb3a7; font-weight: bold; }

#wrap {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}
/* a magnified board sticks out of the window: it scrolls (by mouse or finger), with no scrollbars */
#wrap.magnified { overflow: auto; scrollbar-width: none; }
#wrap.magnified::-webkit-scrollbar { display: none; }
#sizer { position: absolute; width: 1px; height: 1px; }

#board {
  position: absolute;
  transform-origin: top left;
}

/* ---------- Tiles ---------- */
.tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  /* first shadow = the tile's thick side, second = soft drop shadow */
  box-shadow: 4px 4px 0 var(--tile-side), 5px 5px 6px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  user-select: none;
  line-height: 1;
  overflow: hidden;              /* keeps the colored bars inside the rounded corners */
  color: var(--suit, #222);      /* every suit has its own color (set further down) */
}
/* room for the name bar at the bottom and, on match-any tiles, the banner at the top */
.tile:has(.small) { padding-bottom: 16px; }
.tile:has(.tag) { padding-top: 11px; }

/* a big number (or letter) beside one picture of the suit */
.tile .row { display: flex; align-items: center; justify-content: center; gap: 2px; }
.tile .big { font-size: 36px; font-weight: 800; font-family: "Segoe UI", Arial, sans-serif; }
.tile .mini-icon svg { width: 22px; height: 22px; display: block; }
.tile .icon svg { width: 40px; height: 40px; display: block; }
.tile .emoji { font-size: 31px; line-height: 38px; white-space: nowrap; }
.tile .emoji.pair { font-size: 22px; letter-spacing: -3px; }
.tile:has(.tag) .icon svg { width: 34px; height: 34px; }
.tile:has(.tag) .emoji { font-size: 27px; line-height: 33px; }
.tile:has(.tag) .emoji.pair { font-size: 20px; }

/* the name bar: white writing on the suit's color, so color alone tells you the suit */
.tile .small {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: 16px; line-height: 16px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.2px;
  text-align: center; white-space: nowrap;
  color: #fff; background: var(--suit, #555);
}
.tile .small.long { font-size: 9px; letter-spacing: 0; }
/* the banner on tiles where different pictures all match each other */
.tile .tag {
  position: absolute; left: 0; right: 0; top: 0;
  height: 11px; line-height: 11px;
  font-size: 8px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  text-align: center; color: #fff; background: var(--suit, #555);
}

/* the traditional "count the pictures" look */
.tile .pips { display: grid; gap: 1px 2px; margin-top: 10px; }
.tile .pips svg { width: 13px; height: 13px; display: block; }
.tile .pips.few svg { width: 17px; height: 17px; }
.tile .pips.one svg { width: 28px; height: 28px; }
.tile .corner { position: absolute; top: 2px; left: 4px; font-size: 16px; font-weight: 800; line-height: 1; font-family: "Segoe UI", sans-serif; }
.tile .cn { font-size: 26px; margin-top: 8px; font-family: "Microsoft YaHei", "Segoe UI", sans-serif; }
.tile .wan { font-size: 18px; color: #c0262d; font-family: "Microsoft YaHei", sans-serif; margin-top: 2px; }
.tile .row .wan { font-size: 20px; margin: 0; }
.tile .cn-mini { font-size: 19px; font-weight: bold; font-family: "Microsoft YaHei", "Segoe UI", sans-serif; opacity: 0.75; }
.c-red .big, .c-green .big { font-family: "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 38px; }
/* wind letters are wide (W!), so they and their sign are a little smaller */
.c-wind .row { gap: 1px; }
.c-wind .row .big { font-size: 30px; }
.c-wind .cn-mini { font-size: 15px; }

/* paintings fill the tile above the name bar */
.tile .pic { flex: 1; min-height: 0; width: 100%; object-fit: cover; display: block; pointer-events: none; }

.tile.blocked.dim { filter: brightness(0.8); cursor: default; }
.tile.facedown { background: var(--tile-back); border-color: rgba(0, 0, 0, 0.3); }
.tile.selected { background: #ffe28a; border-color: #c9a227; outline: 3px solid #e0b020; }
.tile.hint { background: #a8e6a8; border-color: #3c9a3c; outline: 3px solid #3c9a3c; }

/* ---------- Suit colors ----------
   --suit colors the tile's number, picture and name bar. Keep them dark enough for white writing. */
/* Classic */
.c-dot    { --suit: #1d5fb8; }
.c-bam    { --suit: #177a33; }
.c-crak   { --suit: #b3202a; }
.c-wind   { --suit: #2b2b2b; }
.c-red    { --suit: #c0262d; }
.c-green  { --suit: #177a33; }
.c-white  { --suit: #1d5fb8; }
.c-flower { --suit: #a83d6a; }
.c-season { --suit: #a0661a; }

/* Croquet */
.q-hoop   { --suit: #2f4a6b; }
.q-mallet { --suit: #7a4a22; }
.q-flag   { --suit: #c0262d; }
.q-ball   { --suit: #333; }
.q-ball0  { --suit: #222; }
.q-ball1  { --suit: #e0b20c; }
.q-ball2  { --suit: #dd6b0d; }
.q-ball3  { --suit: #26873a; }
.q-ball1 .small { color: #2a2200; } /* dark writing reads better on yellow */
.q-party  { --suit: #2c5424; }
.q-family { --suit: #b03f68; }
.q-season { --suit: #a0661a; }

/* Bird watching */
.b-egg     { --suit: #2f6f7d; }
.b-feather { --suit: #6a4fa0; }
.b-nest    { --suit: #7a4a22; }
.b-bird    { --suit: #4a3a22; }
.b-farm    { --suit: #a0441e; }
.b-baby    { --suit: #8f6a0c; }

/* ---------- Menu ---------- */
#menu {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
}

.panel {
  width: min(560px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 20px 24px;
  border-radius: 12px;
  background: #fbf7ea;
  color: #1f3a2a;
}

.panel h2 { margin: 0 0 8px; font-family: var(--title-font); }
.panel h3 { margin: 16px 0 6px; font-size: 16px; }
.panel h3 small { font-weight: normal; color: #6b6b5c; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button { background: #e6e0cc; }
.choices button.chosen { background: #2c5424; color: #fff; }

.choices button small { display: block; font-size: 12px; opacity: 0.8; margin-top: 2px; }

/* on/off switches */
.toggles { display: flex; flex-direction: column; gap: 6px; }
.toggle {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #efe9d6;
  cursor: pointer;
}
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  flex: none;
  position: relative;
  width: 42px;
  height: 24px;
  margin-top: 1px;
  border-radius: 12px;
  background: #bbb3a0;
  transition: background 0.15s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.toggle input:checked + .switch { background: #2c5424; }
.toggle input:checked + .switch::after { left: 21px; }
.toggle input:focus-visible + .switch { outline: 2px solid #2c5424; outline-offset: 2px; }
.toggle .text b { display: block; font-size: 15px; }
.toggle .text small { display: block; font-size: 13px; color: #55594c; margin-top: 2px; }

.note { margin: 8px 0 0; font-size: 14px; color: #55594c; }

.menu-actions {
  position: sticky;
  bottom: -20px;
  display: flex;
  gap: 10px;
  margin-top: 12px;
  padding: 12px 0 4px;
  background: #fbf7ea;
}
button.primary { background: #2c5424; color: #fff; }
button.primary:hover { background: #3a6d30; }

/* ---------- Menu tabs ---------- */
.panel { display: flex; flex-direction: column; height: min(690px, 100%); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 2px solid #2c5424; }
.tabs button { border-radius: 6px 6px 0 0; background: #e6e0cc; padding: 7px 12px; }
.tabs button.chosen { background: #2c5424; color: #fff; }
.tab-page { flex: 1; overflow-y: auto; min-height: 0; padding-bottom: 4px; }
.tab-page h3:first-child { margin-top: 12px; }

/* background choices show a little preview */
.choices.backgrounds { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.choices.backgrounds button { padding: 6px; text-align: left; }
.swatch { display: block; height: 42px; margin-bottom: 5px; border-radius: 4px; }
.choices.zooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.choices.zooms button { text-align: left; }

/* ---------- Mini map (when the board is magnified) ---------- */
#minimap {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 50000;
  padding: 4px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* ---------- Mom is sleeping! ---------- */
#btn-sleep {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 6px;
  background: rgba(0, 0, 0, 0.2);
  color: #f4f1e6;
  font-size: 13px;
}
#btn-sleep:hover { background: rgba(0, 0, 0, 0.35); }
.bulb { width: 24px; height: 24px; display: block; }
.bulb .glass { fill: rgba(255, 255, 255, 0.15); stroke: #f4f1e6; stroke-width: 1.5; }
.bulb .base { fill: none; stroke: #c9c3b0; stroke-width: 1.8; stroke-linecap: round; }

/* lights out: everything black except the bulb, which glows very dimly */
#night { position: fixed; inset: 0; z-index: 200000; background: #000; }
#btn-sleep.on { position: relative; z-index: 200001; background: transparent; border-radius: 50%; }
#btn-sleep.on .sleep-text { visibility: hidden; }
#btn-sleep.on .bulb { filter: drop-shadow(0 0 6px rgba(255, 196, 90, 0.45)) drop-shadow(0 0 18px rgba(255, 180, 70, 0.18)); }
#btn-sleep.on .bulb .glass { fill: #8a6a2a; stroke: #6b5426; }
#btn-sleep.on .bulb .base { stroke: #2a2418; }

/* ---------- Layout cards ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.filters button { padding: 4px 14px; font-size: 14px; border-radius: 14px; background: #e6e0cc; }
.filters button.chosen { background: #6b5426; color: #fff; }
.choices.layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.choices.layouts button { padding: 6px 8px; text-align: left; font-size: 15px; }
.choices.layouts button[hidden] { display: none; }
.preview { display: block; width: 120px; height: 62px; margin: 0 auto 4px; }
.stars { color: #c08a12; letter-spacing: 1px; }
.choices button.chosen .stars { color: #ffd76a; }

/* ---------- Winning screen ---------- */
#win {
  position: fixed;
  inset: 0;
  z-index: 150000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.7));
  overflow: hidden;
}
.win-card {
  position: relative;
  width: min(480px, 100%);
  padding: 28px 32px 20px;
  text-align: center;
  color: #3a2e1a;
  background: #fffaf0;
  border-radius: 16px;
  /* a gold frame inside a white edge, like a certificate */
  box-shadow: 0 0 0 6px #fffaf0, 0 0 0 9px #c9a227, 0 18px 50px rgba(0, 0, 0, 0.5);
  animation: win-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.win-flourish { color: #c9a227; letter-spacing: 10px; font-size: 18px; }
.win-card h2 {
  margin: 6px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  line-height: 1.15;
  color: var(--header-bg);
}
.win-stats { margin: 0 0 14px; font-size: 14px; color: #7a6a4a; }
.win-message { margin: 0; font-size: 22px; font-family: Georgia, serif; font-style: italic; }
.win-love { margin: 8px 0 0; font-size: 20px; font-family: "Segoe Script", "Brush Script MT", cursive; color: #a0441e; }
.win-actions { display: flex; justify-content: center; gap: 10px; margin: 20px 0 14px; }
.win-credits {
  line-height: 1.7;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid #e6dcc0;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #9a8a6a;
}
@keyframes win-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#confetti span {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(var(--spin)); opacity: 0; }
}

/* ---------- The clock ---------- */
#clock { font-size: 16px; font-variant-numeric: tabular-nums; opacity: 0.9; white-space: nowrap; }

/* ---------- The score on the winning screen ---------- */
.win-score { margin: 0 0 14px; }
#btn-win-score {
  display: inline-flex; align-items: baseline; gap: 10px;
  padding: 6px 22px 8px;
  border: 2px solid #c9a227; border-radius: 12px;
  background: #fff6d8; color: #3a2e1a;
}
#btn-win-score:hover { background: #ffefb8; }
#btn-win-score span { font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: #8a6a1a; }
#btn-win-score b { font-size: 40px; line-height: 1; font-family: Georgia, "Times New Roman", serif; font-variant-numeric: tabular-nums; }
#win-compare { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; line-height: 1.5; color: #6a5a3a; }

/* ---------- The Scores screen ---------- */
#scores {
  position: fixed;
  inset: 0;
  z-index: 160000; /* above the winning screen, so Details can open on top of it */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.6);
}
.panel.wide { width: min(860px, 100%); height: min(760px, 100%); }
#scores-list, #scores-detail { flex: 1; min-height: 0; overflow-y: auto; padding-right: 4px; }
#scores h2 small { display: block; margin-top: 2px; font-size: 14px; font-weight: normal; color: #6b6b5c; font-family: "Segoe UI", system-ui, sans-serif; }

/* little boxes of "label: value" */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); gap: 8px; }
.facts.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.fact { padding: 8px 10px; border-radius: 8px; background: #efe9d6; }
.fact span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; color: #6b6b5c; }
.fact b { display: block; margin-top: 2px; font-size: 17px; }
.fact b small { display: block; font-size: 12px; font-weight: normal; color: #55594c; }

.table-wrap { overflow-x: auto; border: 1px solid #d8cfb4; border-radius: 8px; background: #fff; }
#scores table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
#scores th, #scores td { padding: 8px 10px; text-align: left; border-bottom: 1px solid #ebe4cc; }
#scores tr:last-child td { border-bottom: none; }
#scores th { position: sticky; top: 0; background: #2c5424; color: #fff; font-size: 13px; white-space: nowrap; user-select: none; }
#scores-table th { cursor: pointer; }
#scores-table th:hover { background: #3a6d30; }
#scores-table tbody tr { cursor: pointer; }
#scores-table tbody tr:hover { background: #f4eed8; }
#scores-table td.score { font-weight: bold; font-size: 16px; }
#scores-table tr.best td.score::after { content: " ★"; color: #c08a12; }
#scores-table td:nth-child(n+3), #scores-table th:nth-child(n+3) { text-align: right; }

/* one game's details */
.detail-score { display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; }
.detail-score b { font-size: 54px; line-height: 1; font-family: Georgia, "Times New Roman", serif; color: #2c5424; font-variant-numeric: tabular-nums; }
.detail-score span { font-size: 18px; }
.detail-score small { font-size: 14px; color: #55594c; }
table.steps td:first-child { font-weight: bold; white-space: nowrap; }
table.steps td:last-child, table.steps th:last-child { text-align: right; font-weight: bold; white-space: nowrap; }
table.steps small { display: block; font-size: 12.5px; color: #6b6b5c; font-weight: normal; }
table.steps .part { display: block; margin-bottom: 4px; }
table.steps tr.total td { background: #fff6d8; font-size: 18px; border-top: 2px solid #c9a227; }
ul.compare { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
ul.compare li { padding: 7px 10px 7px 34px; border-radius: 8px; background: #efe9d6; position: relative; font-size: 15px; }
ul.compare li::before { position: absolute; left: 11px; top: 6px; font-weight: bold; }
ul.compare li.up::before { content: "▲"; color: #1d8a3c; }
ul.compare li.down::before { content: "▼"; color: #c0262d; }
ul.compare li.same::before { content: "●"; color: #9a927a; }

/* ---------- More themes ---------- */
body.theme-garden {
  --header-bg: #2f5d2a;
  --tile-bg: #fffdf6;
  --tile-border: #c4c9a8;
  --tile-side: #9cb58a;
  --tile-back: repeating-linear-gradient(45deg, #4f8a3c 0 6px, #5c9a48 6px 12px);
  --title-font: Georgia, "Times New Roman", serif;
}
body.theme-seaside {
  --header-bg: #1f4f6b;
  --tile-bg: #fbfdff;
  --tile-border: #b5c6cf;
  --tile-side: #8fb0c0;
  --tile-back: repeating-linear-gradient(0deg, #2f7ea6 0 6px, #3a8fb8 6px 12px);
  --title-font: Georgia, "Times New Roman", serif;
}
body.theme-bakery {
  --header-bg: #6b3f2a;
  --tile-bg: #fffaf2;
  --tile-border: #d3bfa6;
  --tile-side: #c9a98f;
  --tile-back: repeating-linear-gradient(45deg, #c9805a 0 6px, #d99a78 6px 12px);
  --title-font: Georgia, "Times New Roman", serif;
}
body.theme-cards {
  --header-bg: #1b4d33;
  --tile-bg: #ffffff;
  --tile-border: #bfc4c0;
  --tile-side: #9aa89f;
  --tile-back: repeating-linear-gradient(45deg, #b3202a 0 5px, #8f1a22 5px 10px);
  --title-font: Georgia, "Times New Roman", serif;
}

/* pictures made of emoji, in the two tile styles */
.tile .mini-icon .emoji { font-size: 20px; line-height: 24px; }
.tile .pips .emoji { font-size: 11px; line-height: 13px; display: block; text-align: center; }
.tile .pips.few .emoji { font-size: 15px; line-height: 17px; }
.tile .pips.one .emoji { font-size: 26px; line-height: 30px; }
/* playing-card signs */
.tile .suit-sign { font-size: 26px; line-height: 24px; font-family: "Segoe UI Symbol", "Arial Unicode MS", sans-serif; }
.tile .pips .suit-sign { font-size: 13px; line-height: 13px; display: block; text-align: center; }
.tile .pips.few .suit-sign { font-size: 17px; line-height: 17px; }
.tile .pips.one .suit-sign { font-size: 30px; line-height: 30px; }

/* Garden */
.g-s0 { --suit: #b3202a; }  /* roses */
.g-s1 { --suit: #177a33; }  /* clovers */
.g-s2 { --suit: #8a6200; }  /* bees */
.g-w  { --suit: #5b4a8a; }  /* garden visitors */
.g-d  { --suit: #1d6f9a; }  /* weather */
.g-a  { --suit: #b0561a; }  /* veggies */
.g-b  { --suit: #55606a; }  /* seasons */

/* Seaside */
.s-s0 { --suit: #b03f78; }  /* shells */
.s-s1 { --suit: #1d5fb8; }  /* fish */
.s-s2 { --suit: #a8680c; }  /* stars */
.s-w  { --suit: #0f6f6a; }  /* sea animals */
.s-d  { --suit: #24386b; }  /* anchor, sailboat, island */
.s-a  { --suit: #7a3fa0; }  /* reef */
.s-b  { --suit: #55606a; }  /* weather */

/* Bakery */
.y-s0 { --suit: #b03f78; }  /* cupcakes */
.y-s1 { --suit: #7a4a22; }  /* cookies */
.y-s2 { --suit: #6a4fa0; }  /* donuts */
.y-w  { --suit: #a0661a; }  /* bakes */
.y-d  { --suit: #2f6f7d; }  /* drinks */
.y-a  { --suit: #b3202a; }  /* fruit */
.y-b  { --suit: #177a33; }  /* candy */

/* Playing cards (four colors, so no two suits look alike) */
.k-heart   { --suit: #c0262d; }
.k-spade   { --suit: #222; }
.k-diamond { --suit: #1d5fb8; }
.k-club    { --suit: #177a33; }
.k-extra   { --suit: #6a4fa0; }
.k-jackpot { --suit: #a0661a; }
.k-luck    { --suit: #0f6f6a; }

/* theme buttons show three sample tiles */
.choices.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.choices.themes button { padding: 10px 8px 8px; }
.sample { display: flex; justify-content: center; gap: 6px; margin: 0 0 8px; pointer-events: none; }
.sample .tile { position: relative; flex: none; width: 53px; height: 71px; background: #fffdf6; border-color: #c9bfa3;
  box-shadow: 2px 2px 0 #a99f84, 3px 3px 4px rgba(0, 0, 0, 0.3); }

/* ---------- Polish ---------- */
/* tiles: a soft sheen on the face and a thicker, layered edge so they look like real pieces */
.tile {
  background: linear-gradient(155deg, #ffffff 0%, var(--tile-bg) 42%, color-mix(in srgb, var(--tile-bg) 90%, #6b5a3a) 100%);
  border-radius: 7px;
  box-shadow: 1px 1px 0 var(--tile-side), 2px 2px 0 var(--tile-side), 3px 3px 0 var(--tile-side),
              4px 4px 0 color-mix(in srgb, var(--tile-side) 70%, #000), 6px 7px 9px rgba(0, 0, 0, 0.42);
  transition: transform 0.08s ease-out, filter 0.08s ease-out;
}
/* a tile you can pick lifts a little under the mouse */
#board .tile:not(.blocked):hover { transform: translate(-1px, -2px); filter: brightness(1.05); }
.tile.selected {
  background: linear-gradient(155deg, #fffbe0, #ffe07a);
  box-shadow: 1px 1px 0 #c9a227, 2px 2px 0 #c9a227, 3px 3px 0 #c9a227, 4px 4px 0 #9a7a12,
              0 0 0 3px #e0b020, 0 0 20px 6px rgba(255, 205, 50, 0.8);
  outline: none;
}
.tile.hint {
  background: linear-gradient(155deg, #e9ffe9, #a8e6a8);
  outline: 3px solid #3c9a3c;
  animation: hint-pulse 1s ease-in-out infinite;
}
@keyframes hint-pulse { 50% { outline-color: #8fe08f; box-shadow: 0 0 18px 7px rgba(90, 210, 90, 0.75); } }

/* matched tiles pop and fade instead of just vanishing (they are copies shown above the board) */
#fx { position: absolute; transform-origin: top left; pointer-events: none; }
#fx .tile { animation: tile-gone 0.32s ease-out forwards; }
@keyframes tile-gone {
  0%   { transform: scale(1); opacity: 1; }
  40%  { transform: scale(1.14); opacity: 1; filter: brightness(1.25); }
  100% { transform: scale(0.7); opacity: 0; }
}

/* header and buttons */
header { box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); position: relative; }
h1 { display: flex; align-items: center; letter-spacing: 0.3px; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
h1::before { /* a little tile as the logo */
  content: "M";
  flex: none; width: 25px; height: 32px; margin-right: 9px;
  border-radius: 5px; background: linear-gradient(155deg, #fff, #f6efdc); color: #c0262d;
  font: 800 19px/32px "Segoe UI", Arial, sans-serif; text-align: center; text-shadow: none;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35), 3px 4px 5px rgba(0, 0, 0, 0.3);
}
button {
  border-radius: 8px;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 2px 3px rgba(0, 0, 0, 0.28);
  transition: transform 0.06s, box-shadow 0.06s, background 0.12s;
}
button:active { transform: translateY(1px); box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3); }
button:focus-visible { outline: 3px solid #ffd84a; outline-offset: 2px; }
.choices button, .filters button, .tabs button { box-shadow: none; font-weight: normal; }
.choices button.chosen, .filters button.chosen { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.15) inset; }
#btn-sleep { box-shadow: none; font-weight: normal; }
#status, #clock { padding: 5px 13px; border-radius: 999px; background: rgba(0, 0, 0, 0.24); }
#status:empty { display: none; }

/* calmer for people who prefer little or no motion */
@media (prefers-reduced-motion: reduce) {
  .tile, button { transition: none; }
  .tile.hint { animation: none; }
  #fx .tile { animation: none; display: none; }
  #confetti { display: none; }
}

/* emoji pictures are wider than drawn ones, so the number and picture are a touch smaller beside them
   (the widest number, 4, must still fit on the tile) */
.tile .row:has(.mini-icon .emoji) { gap: 1px; }
.tile .row:has(.mini-icon .emoji) .big { font-size: 33px; }
.tile .mini-icon .emoji { font-size: 17px; line-height: 22px; }

/* keep the header on one row on a normal laptop screen */
header { gap: 8px 10px; padding: 10px 14px; }
.buttons { gap: 6px; }
.buttons button { padding: 7px 11px; }
#status, #clock { padding: 5px 11px; font-size: 15px; }

/* ================= Tile views =================
   The view's class (style-clear, style-giant, style-solid, style-corners, style-pictures) sits on the
   board, and on each little sample in the menu, so every sample can show its own view. */
/* numbers and letters: the suit's color, unless the player picked their own (--ink, see Colors in the menu) */
.tile .big, .tile .giant, .tile .corner { color: var(--ink, var(--suit, #222)); }

/* Giant numbers: just the number, as large as the tile allows */
.tile .giant { font: 800 52px/1 "Segoe UI", Arial, sans-serif; letter-spacing: -1px; }
.c-wind .giant, .k-club .giant { font-size: 46px; }

/* Card corners: the number in two corners (the second upside down, like a playing card) and one big picture */
.tile .corner.br { top: auto; left: auto; right: 4px; bottom: 18px; transform: rotate(180deg); }
.style-corners .tile .corner { font-size: 18px; }
.tile .icon.mid svg { width: 30px; height: 30px; }
.tile .icon.mid .emoji { font-size: 25px; line-height: 30px; }
.tile .icon.mid .suit-sign { font-size: 34px; line-height: 30px; }
.tile .icon.mid .wan { font-size: 27px; margin: 0; }
.tile .icon.mid .cn-mini { font-size: 27px; opacity: 1; }

/* Bold colors: the whole tile is the suit's color, with white writing */
.style-solid .tile:not(.facedown) {
  background: linear-gradient(155deg, color-mix(in srgb, var(--suit, #555) 78%, #fff) 0%, var(--suit, #555) 50%, color-mix(in srgb, var(--suit, #555) 80%, #000) 100%);
  border-color: rgba(0, 0, 0, 0.4);
}
.style-solid .tile .big, .style-solid .tile .giant, .style-solid .tile .corner { color: var(--ink, #fff); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.style-solid .tile .small, .style-solid .tile .tag { background: rgba(0, 0, 0, 0.34); color: #fff; }
.style-solid .tile .mini-icon, .style-solid .tile .icon { background: #fff; border-radius: 7px; padding: 2px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }
.style-solid .tile .row .big { font-size: 32px; }
.style-solid .tile .row:has(.mini-icon .emoji) .big { font-size: 30px; }
.style-solid .tile .mini-icon svg { width: 19px; height: 19px; }
.style-solid .tile .mini-icon .emoji { font-size: 15px; line-height: 19px; }
.style-solid .tile .mini-icon .suit-sign { font-size: 21px; line-height: 19px; display: block; }
.style-solid .tile .mini-icon .wan { font-size: 17px; }
.style-solid .tile .mini-icon .cn-mini { font-size: 14px; }

/* ================= Colors the player can change =================
   game.js sets these on <body> when a color is picked in the menu: --tile-bg (tile face), --ink (numbers
   and letters), --sel (picked tiles), --shade (blocked tiles), --tile-back (face-down tiles). */
.tile.selected,
.style-solid .tile.selected:not(.facedown) {
  background: linear-gradient(155deg, color-mix(in srgb, var(--sel, #ffd23f) 40%, #fff), var(--sel, #ffd23f));
  border-color: color-mix(in srgb, var(--sel, #ffd23f) 60%, #000);
  box-shadow: 1px 1px 0 color-mix(in srgb, var(--sel, #ffd23f) 70%, #000), 2px 2px 0 color-mix(in srgb, var(--sel, #ffd23f) 70%, #000),
              3px 3px 0 color-mix(in srgb, var(--sel, #ffd23f) 70%, #000), 4px 4px 0 color-mix(in srgb, var(--sel, #ffd23f) 50%, #000),
              0 0 0 3px color-mix(in srgb, var(--sel, #ffd23f) 72%, #000), 0 0 20px 7px var(--sel, #ffd23f);
  outline: none;
}
.style-solid .tile.selected .big, .style-solid .tile.selected .giant, .style-solid .tile.selected .corner { color: var(--ink, var(--suit, #222)); text-shadow: none; }

/* blocked tiles: a see-through shade over the tile (instead of simply darkening it), in a color you can pick */
.tile.blocked.dim { filter: none; }
.tile.blocked.dim::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: var(--shade, #000); opacity: var(--shade-strength, 0.22);
}

/* menu samples follow the chosen colors too */
.sample .tile { background: linear-gradient(155deg, #fff, var(--tile-bg)); border-color: var(--tile-border); box-shadow: 2px 2px 0 var(--tile-side), 3px 3px 4px rgba(0, 0, 0, 0.3); }
.choices.views { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.choices.views button { padding: 10px 8px 8px; }

/* ---------- Colors tab ---------- */
.color-row { padding: 10px 12px; margin-bottom: 8px; border-radius: 8px; background: #efe9d6; }
.color-row b { display: block; font-size: 15px; }
.color-row small { display: block; font-size: 13px; color: #55594c; margin: 2px 0 8px; }
.swatches { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.swatches button { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.25); box-shadow: none; }
.swatches button.chosen { outline: 3px solid #2c5424; outline-offset: 2px; }
.swatches button.own { width: auto; height: 34px; padding: 0 14px; border-radius: 17px; background: #fbf7ea; font-size: 14px; font-weight: normal; }
.swatches label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; margin-left: 4px; }
.swatches input[type="color"] { width: 44px; height: 34px; padding: 0; border: 2px solid rgba(0, 0, 0, 0.25); border-radius: 8px; background: none; cursor: pointer; }
.color-sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.color-sets button { padding: 8px; font-size: 14px; background: #e6e0cc; box-shadow: none; font-weight: normal; }
.color-sets .sample { margin-bottom: 6px; }
.warn { margin: 6px 0 0; padding: 6px 10px; border-radius: 6px; background: #ffe9c2; color: #6b4200; font-size: 14px; }

/* ---------- Sound tab ---------- */
.volume { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 8px 0; border-radius: 8px; background: #efe9d6; }
.volume input[type="range"] { flex: 1; height: 28px; accent-color: #2c5424; }
.volume output { min-width: 48px; text-align: right; font-weight: bold; font-variant-numeric: tabular-nums; }
.sound-tests { display: flex; flex-wrap: wrap; gap: 8px; }
.sound-tests button { background: #e6e0cc; box-shadow: none; font-weight: normal; font-size: 15px; }
.panel { width: min(680px, 100%); }
/* Bold colors: the widest tiles (the W wind, and the two Siblings faces) need a little less room */
.style-solid .c-wind .row .big { font-size: 26px; }
.style-solid .c-wind .mini-icon .cn-mini { font-size: 12px; }
.style-solid .tile .emoji.pair { font-size: 16px; letter-spacing: -2px; }

/* ---------- Pause ---------- */
#btn-pause.on { background: #ffd23f; color: #222; }
#clock.paused { opacity: 0.55; } /* the clock looks faded while it is stopped */
/* the board fades while paused; tiles can still be clicked (if "Clicking a tile carries on" is on) */
body.paused #board { opacity: 0.4; filter: grayscale(0.6); transition: opacity 0.2s; }
#paused {
  position: fixed; left: 0; right: 0; top: 50%; z-index: 40000;
  display: flex; justify-content: center; padding: 0 16px;
  transform: translateY(-50%);
  pointer-events: none; /* clicks go through to the tiles, except on the card itself */
}
#paused[hidden] { display: none; }
.paused-card {
  pointer-events: auto;
  max-width: 340px; padding: 18px 22px; border-radius: 14px; text-align: center;
  background: rgba(20, 20, 20, 0.86); color: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.paused-card b { display: block; font-size: 24px; margin-bottom: 6px; }
.paused-card p { margin: 0 0 14px; font-size: 16px; line-height: 1.4; }
.paused-card button { font-size: 18px; padding: 9px 26px; }
#paused.nudge .paused-card { animation: nudge 0.4s; }
@keyframes nudge {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
