/* Chain Tile Memory — game-specific styles on the Buttonberry design system.
   Accessibility: colour is never the only cue — every face-up tile shows its
   rule symbol and word (accessibility pack §6.4 / §15.3). */

:root {
  --accent: #4f46e5;
  --warm: #d97706;
  --t-red: #dc2626;
  --t-blue: #2563eb;
  --t-yellow: #eab308;
  --t-green: #16a34a;
}

/* ---------- rule banner ---------- */

.rulebar { display: flex; align-items: center; gap: 13px; }
.rulebar .now {
  width: 52px; height: 52px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px;
  background: var(--subtle); color: var(--muted);
  border: 2px solid var(--border-strong);
}
.rulebar .now.red { background: var(--t-red); border-color: var(--t-red); color: #fff; }
.rulebar .now.blue { background: var(--t-blue); border-color: var(--t-blue); color: #fff; }
.rulebar .now.yellow { background: var(--t-yellow); border-color: var(--t-yellow); color: #3b2f04; }
.rulebar .now.green { background: var(--t-green); border-color: var(--t-green); color: #fff; }
.rulebar h2 { font-size: 15.5px; }

/* ---------- tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  max-width: 380px;
  margin: 0 auto;
}
:root[data-board="large"] .tiles { max-width: 100%; }

.tile {
  aspect-ratio: 1;
  border: none;
  border-radius: 14px;
  display: grid;
  place-items: center;
  position: relative;
  font: 800 clamp(22px, 7vw, 34px) var(--font);
  color: #fff;
  cursor: pointer;
  padding: 0 0 10px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .14);
  transition: filter .12s ease, transform .12s ease;
}
.tile:not(:disabled):hover { filter: brightness(1.07); }
.tile:not(:disabled):active { transform: scale(.97); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } }

.tile.facedown {
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 82%, #000), var(--accent));
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14);
}
.tile.facedown::after { content: "◆"; font-size: 13px; opacity: .4; }
.tile .crown {
  position: absolute; top: 5px; right: 7px; font-size: 15px;
}

.tile.red { background: var(--t-red); }
.tile.blue { background: var(--t-blue); }
.tile.yellow { background: var(--t-yellow); color: #3b2f04; }
.tile.green { background: var(--t-green); }

.tile.current { outline: 3px solid var(--warm); outline-offset: 2px; }
.tile.used { opacity: .4; cursor: default; }
.tile.used .order {
  position: absolute; top: 6px; right: 6px;
  font-size: 11px; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 7px;
  background: rgba(0, 0, 0, .16);
}
.tile.used.crowned { opacity: .85; }
.tile.crowned .order { font-size: 12.5px; }
.tile.temp-reveal { outline: 3px solid var(--bad); outline-offset: 2px; }

/* symbol + rule word so colour is never the only cue */
.tile .rule-cue {
  position: absolute; bottom: 7px; left: 6px; right: 6px;
  font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; opacity: .85; line-height: 1.15;
}
.tile .sym {
  position: absolute; top: 6px; left: 6px;
  font-size: 12px; font-weight: 800; line-height: 1;
  padding: 3px 6px; border-radius: 7px;
  background: rgba(0, 0, 0, .16);
}
.tile .crown { filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .3)); }

@keyframes tile-pop { 0% { transform: scale(1); } 50% { transform: scale(1.07); } 100% { transform: scale(1); } }
.tile.win { animation: tile-pop .35s ease; }
@media (prefers-reduced-motion: reduce) { .tile.win { animation: none; } }

/* ---------- illegal-move alert ---------- */

#feedback.alert {
  background: color-mix(in srgb, var(--bad) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  color: var(--bad);
  font-weight: 700;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  animation: alert-in .18s ease;
}
@keyframes alert-in {
  0% { transform: translateY(-3px); opacity: .4; }
  100% { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) { #feedback.alert { animation: none; } }

/* ---------- board mode toggle ---------- */

.seg-sm button { padding: 6px 13px; font-size: 12.5px; }

/* ---------- controls / hint ---------- */

.ctl { flex: 1; padding: 11px 10px; font-size: 13.5px; }

.hintbox {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13.5px;
  margin-top: 12px;
}

/* ---------- completion ---------- */

.done-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
  text-align: center;
}

/* ---------- help dialog rule key ---------- */

.rule-key { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 12px; font-size: 13.5px; }
.rule-key span { display: inline-flex; align-items: center; gap: 7px; }
.key-dot {
  width: 26px; height: 26px; border-radius: 8px; flex: none;
  display: grid; place-items: center;
  font: 800 11px var(--font); font-style: normal; color: #fff;
}
.key-dot.red { background: var(--t-red); }
.key-dot.blue { background: var(--t-blue); }
.key-dot.yellow { background: var(--t-yellow); color: #3b2f04; }
.key-dot.green { background: var(--t-green); }

/* ---------- achievements list (shared with stats dialog) ---------- */

.ach-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.ach-row { display: flex; align-items: center; gap: 11px; font-size: 13.5px; }
.ach-row .ach-icon {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-size: 16px;
  background: var(--subtle); border: 1.5px solid var(--warm);
}
.ach-row.locked .ach-icon { border-color: var(--border); filter: grayscale(1); opacity: .5; }
.ach-row.locked { color: var(--muted); }
.ach-row .ach-name { font-weight: 600; }
.ach-row .ach-desc { color: var(--muted); font-size: 12.5px; }

@media (min-width: 720px) {
  .tiles { max-width: 480px; }
}
