:root {
  color-scheme: light;
  --ink: #103f36;
  --green: #1f7564;
  --green-soft: #dcece6;
  --coral: #d95d50;
  --bone: #fffdf7;
  --paper: #f2f4ef;
  --muted: #60706a;
  --line: rgba(16, 63, 54, 0.14);
  --shadow: 0 12px 26px rgba(5, 34, 28, 0.13);
  font-family: Inter, Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 12%, rgba(217, 93, 80, 0.12), transparent 24rem),
    linear-gradient(145deg, #edf3ee 0%, #f9f7ef 58%, #e8f0eb 100%);
}

button { font: inherit; }

.game-app {
  width: min(1180px, 100%);
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 34px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: clamp(14px, 2.4vw, 24px);
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.title-group { max-width: 670px; }

.eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.15em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.title-group p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, 1fr));
  gap: 8px;
  margin: 0;
}

.scoreboard div {
  min-width: 78px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.8);
  box-shadow: 0 6px 18px rgba(5, 34, 28, 0.06);
}

.scoreboard dt {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scoreboard dd {
  margin: 3px 0 0;
  font-size: 1.2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.play-area {
  min-height: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
}

.board {
  --columns: 8;
  width: min(100%, 920px);
  min-height: 300px;
  padding: clamp(10px, 1.8vw, 18px);
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: clamp(6px, 1vw, 11px);
  align-content: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: clamp(20px, 3vw, 32px);
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--ink);
  background-size: 28px 28px;
  box-shadow: 0 24px 55px rgba(5, 34, 28, 0.2);
}

.board.slide-board {
  --columns: 4;
  width: min(74svh, 620px, 100%);
  aspect-ratio: 1;
}

.tile,
.slide-cell {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.78;
  border: 0;
  border-radius: clamp(8px, 1.2vw, 14px);
}

.tile {
  padding: 5px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: linear-gradient(145deg, #ffffff 0%, #fffaf0 100%);
  box-shadow: inset 0 -4px 0 rgba(16, 63, 54, 0.1), 0 6px 12px rgba(0, 0, 0, 0.16);
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 180ms ease;
}

.tile:hover:not(:disabled) { transform: translateY(-3px); box-shadow: inset 0 -4px 0 rgba(16, 63, 54, 0.11), 0 10px 18px rgba(0, 0, 0, 0.18); }
.tile:focus-visible { outline: 4px solid #ffcc64; outline-offset: 2px; }
.tile.selected { transform: translateY(-5px); box-shadow: 0 0 0 4px var(--coral), 0 12px 22px rgba(0, 0, 0, 0.23); }
.tile.hinted { animation: hint-pulse 760ms ease 2; }
.tile.locked { opacity: 0.48; cursor: not-allowed; filter: saturate(0.55); }
.tile.empty { visibility: hidden; pointer-events: none; }

.tile-face {
  display: grid;
  justify-items: center;
  gap: 3px;
  line-height: 1;
}

.tile-mark {
  color: var(--green);
  font-family: Georgia, serif;
  font-size: clamp(1rem, 2.8vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.16em;
}

.tile[data-suit="flower"] .tile-mark { color: var(--coral); }
.tile[data-suit="compass"] .tile-mark { color: #d18b24; }
.tile[data-suit="bamboo"] .tile-mark { color: #267c67; letter-spacing: 0.03em; }

.tile-label {
  color: #435b54;
  font-size: clamp(0.45rem, 0.9vw, 0.66rem);
  font-weight: 850;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.slide-cell {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
}

.slide-cell .tile { width: 100%; height: 100%; aspect-ratio: auto; }
.slide-cell .tile-mark { font-size: clamp(1.4rem, 5vw, 3.4rem); }
.slide-cell .tile-label { font-size: clamp(0.56rem, 1.2vw, 0.82rem); }

.status {
  min-height: 1.4em;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.status.success { color: var(--green); font-weight: 750; }
.status.error { color: #a63f35; font-weight: 750; }

.game-controls {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.button-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.button-row button {
  min-width: 104px;
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 253, 247, 0.86);
  font-weight: 800;
  cursor: pointer;
}

.button-row button:hover { background: #fff; box-shadow: 0 7px 16px rgba(5, 34, 28, 0.1); }
.button-row button:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; }
.button-row .primary { color: white; border-color: var(--ink); background: var(--ink); }
.button-row .primary:hover { background: #17584b; }

#instructions { margin: 0; color: #435b54; font-size: 0.85rem; text-align: center; }
.privacy-note { margin: 0; color: #71817b; font-size: 0.68rem; letter-spacing: 0.03em; text-align: center; }

@keyframes hint-pulse {
  50% { transform: translateY(-5px) scale(1.05); box-shadow: 0 0 0 5px #ffcc64, var(--shadow); }
}

@media (max-width: 720px) {
  .game-app { padding: 14px; gap: 12px; }
  .game-header { align-items: start; flex-direction: column; gap: 12px; }
  .scoreboard { width: 100%; }
  .scoreboard div { padding: 8px 10px; }
  .board { min-height: 260px; gap: 5px; padding: 9px; border-radius: 18px; }
  .tile { border-radius: 7px; padding: 3px; box-shadow: inset 0 -3px 0 rgba(16, 63, 54, 0.1), 0 3px 7px rgba(0, 0, 0, 0.16); }
  .tile-label { letter-spacing: 0.02em; }
  .privacy-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
