:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #183c30;
  background: #edf7f0;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  padding: 24px 16px;
  background:
    radial-gradient(ellipse at top left, #d8f0e0 0, transparent 45%),
    #edf7f0;
}

button { font: inherit; }

.game { width: 100%; max-width: 850px; margin: 0 auto; }
.header { margin-bottom: 24px; }
.brand { display: flex; align-items: center; gap: 14px; }

.brand-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 18px;
  background: #d5efdd;
  font-size: 32px;
}

h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 36px);
  letter-spacing: -1px;
}

.brand p { margin: 6px 0 0; color: #648073; font-size: 15px; }

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat {
  min-width: 0;
  padding: 16px 10px;
  text-align: center;
  background: #fff;
  border: 1px solid #dfede3;
  border-radius: 16px;
  box-shadow: 0 4px 14px #234c3010;
}

.stat-label { display: block; margin-bottom: 8px; color: #6d8779; font-size: 12px; }
.stat strong { display: block; font-size: clamp(16px, 3vw, 22px); overflow-wrap: anywhere; }
#timer { color: #16784b; font-variant-numeric: tabular-nums; }
#timer.urgent { color: #d64545; }

.progress-section { margin-bottom: 20px; }
.progress-track { height: 9px; overflow: hidden; border-radius: 20px; background: #d7e8dc; }

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #36a96c, #73cf91);
  transition: width 250ms ease;
}

.board-section {
  padding: 16px;
  background: #ffffffb8;
  border: 1px solid #deede3;
  border-radius: 22px;
  box-shadow: 0 10px 32px #234c300d;
}

.board {
  display: grid;
  grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1 / 1;
  place-items: center;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid #b9dfc5;
  border-radius: 16px;
  background: #dff3e5;
  color: #245c3c;
  box-shadow: 0 4px 0 #c4e2cc;
  transition: transform 180ms ease, background 180ms ease,
    border-color 180ms ease, box-shadow 180ms ease;
  -webkit-tap-highlight-color: transparent;
}

.card:hover:not(:disabled) { transform: translateY(-2px); border-color: #63b780; }
.card:focus-visible, .button:focus-visible { outline: 3px solid #287fc0; outline-offset: 3px; }

.card-back {
  font-size: clamp(23px, 5vw, 38px);
  transition: transform 180ms ease;
}

.card-back::after {
  content: "?";
  position: absolute;
  top: 50%;
  left: 50%;
  color: #43885b;
  font-size: clamp(26px, 5vw, 38px);
  font-weight: 800;
  transform: translate(-50%, -50%);
}


.card-front { font-size: clamp(30px, 6vw, 50px); line-height: 1; animation: reveal 180ms ease; }

.card.is-open {
  background: #fff;
  border-color: #6cbf87;
  box-shadow: 0 4px 0 #d8eadc;
}

.card.is-matched {
  cursor: default;
  background: #d5f1dc;
  border-color: #53ad70;
  box-shadow: 0 4px 0 #b7dfc2;
}

.card:disabled { opacity: 1; }

.card.is-matched::after {
  position: absolute;
  top: 5px;
  right: 7px;
  content: "✓";
  color: #27804b;
  font-size: 15px;
  font-weight: 800;
}

.rules { margin: 18px 0; color: #597665; text-align: center; font-size: 14px; line-height: 1.7; }
.rules strong { color: #236b43; }

.message {
  margin-top: 20px;
  padding: 26px 18px;
  text-align: center;
  background: #fff;
  border: 1px solid #dcebe0;
  border-radius: 20px;
  box-shadow: 0 8px 24px #234c3010;
}

.message[hidden], .button[hidden] { display: none; }
.message-icon { margin-bottom: 10px; font-size: 40px; }
.message h2 { margin: 0 0 10px; font-size: 25px; }
.message p { margin: 0 0 18px; color: #638071; line-height: 1.6; }


.button {
  min-height: 48px;
  padding: 12px 24px;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  background: #23824e;
  color: #fff;
  font-weight: 700;
  transition: background 160ms ease, transform 160ms ease;
}

.button:hover { background: #17683d; }
.button:active { transform: scale(0.98); }
.footer { padding: 24px 0 4px; color: #789282; text-align: center; font-size: 13px; }

@keyframes reveal {
  from { opacity: 0; transform: scale(0.7); }
  to { opacity: 1; transform: scale(1); }
}

@media (min-width: 700px) {
  .board { gap: 14px; }
  .board-section { padding: 22px; }
}

@media (max-width: 480px) {
  body { padding: 18px 10px; }
  .dashboard { gap: 7px; }
  .stat { padding: 12px 5px; border-radius: 12px; }
  .stat-label { font-size: 11px; }
  .board-section { padding: 10px; border-radius: 16px; }
  .board { gap: 9px; }
  .card { border-radius: 12px; }
  .footer { font-size: 12px; }
}

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