@font-face {
  font-family: 'Coiny';
  src: url('../fonts/coiny-latin.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  font-family: 'Coiny', ui-rounded, 'Trebuchet MS', system-ui, sans-serif;
  font-weight: 400;
  color: #540b38;
  background: #fff4e4;
  --pink: #bd1056;
  --edge: clamp(12px, 2vw, 32px);
  --board-width: min(72vw, 1120px);
}

* { box-sizing: border-box; }
html, body, .game {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-x pan-y;
}
img, svg {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: none;
}
::selection { color: inherit; background: transparent; }
body { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: pan-x pan-y; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px dashed #761045; outline-offset: 2px; }
.game {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: clamp(8px, 1.6vh, 18px);
  padding: clamp(10px, 2vh, 25px) var(--edge);
  background: radial-gradient(ellipse at center, #fffaf0, #fff2df 95%);
}
.game:fullscreen { overflow: auto; }
.game:-webkit-full-screen { overflow: auto; }
html:fullscreen, html:-webkit-full-screen { width: 100%; height: 100%; }
html:fullscreen .game, html:-webkit-full-screen .game { width: 100%; height: 100%; }
.intro { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 12px; text-align: center; }
.intro h1 { margin: 0; color: #63073d; font-size: clamp(2.15rem, 5.4vw, 6.15rem); line-height: 1; font-weight: 400; letter-spacing: -.055em; }
.intro h1 span { color: #f85884; font-size: .48em; vertical-align: .24em; }
.intro p { grid-column: 1 / -1; margin: .26em 0 0; font-size: clamp(1rem, 2.7vw, 2.7rem); line-height: 1.12; letter-spacing: -.035em; }
.stat {
  justify-self: start;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: .23em;
  padding: .23em .48em;
  border-radius: 999px;
  border: 1px solid #f2d9ce;
  box-shadow: inset 0 2px 5px #fff9, inset 0 -3px 4px #c0867526, 0 4px 8px #9e62453b;
  background: #fff0e8;
  font-size: clamp(1rem, 3.1vw, 3rem);
  font-variant-numeric: tabular-nums;
  font-weight: 400;
  letter-spacing: -.035em;
}
#timer { min-width: 3.35em; justify-content: center; font-size: 1.9rem; }
.stat svg, .stat img { width: 1.24em; height: 1.24em; flex: none; }
.score { justify-self: end; }
.urgent { color: #b00045; background: #ffdee8; }
.hearts { position: absolute; z-index: -1; inset: 17% var(--edge) 8%; pointer-events: none; }
.hearts img { position: absolute; width: clamp(32px, 6.6vw, 106px); opacity: .84; }
.hearts img:nth-child(1) { top: 3%; left: 1%; transform: rotate(-24deg); }
.hearts img:nth-child(2) { top: 44%; left: 2%; transform: rotate(-14deg) scale(.72); }
.hearts img:nth-child(3) { bottom: 3%; left: 1%; transform: rotate(18deg); }
.hearts img:nth-child(4) { top: 5%; right: 2%; transform: rotate(22deg) scale(.82); }
.hearts img:nth-child(5) { top: 44%; right: 0; transform: rotate(13deg) scale(1.12); }
.hearts img:nth-child(6) { bottom: 0; right: 2%; transform: rotate(23deg) scale(.72); }

.panel { grid-row: 3; display: grid; grid-template-rows: minmax(0, 1fr); gap: clamp(6px, 1vh, 11px); width: var(--board-width); justify-self: center; min-width: 0; }
.board-wrap { position: relative; display: grid; min-height: 0; }
.board-wrap > [hidden] { display: none !important; }
.board-wrap > .board:not([hidden]) { position: absolute; inset: 50% auto auto 50%; width: 100%; height: 100%; transform: translate(-50%, -50%); }
.board { display: grid; grid-template: repeat(5, minmax(0, 1fr)) / repeat(5, minmax(0, 1fr)); align-content: center; justify-content: center; gap: clamp(5px, 1vw, 15px); }
.tile {
  display: grid;
  place-items: center;
  text-align: center;
  text-indent: 0;
  font-kerning: none;
  display: grid;
  place-items: center;
  vertical-align: middle;
  font-variant-numeric: lining-nums tabular-nums;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  --light: #d5dbff;
  --dark: #b8c4f8;
  --border: #a5afe3;
  min-width: 0;
  padding: .16em 0 0;
  border: 1px solid var(--border);
  border-radius: clamp(10px, 2.5vw, 31px);
  background: linear-gradient(155deg, var(--light), var(--dark));
  box-shadow: inset 0 3px 4px #fff9, inset 0 -4px 6px #4a255530, 0 4px 7px #703f343b;
  font-size: clamp(1.35rem, min(7vw, 10svh), 6.2rem);
  line-height: 1;
  font-weight: 400;
  transition: transform .12s, filter .12s;
}
.tile:nth-child(4n + 2) { --light: #d0f9db; --dark: #a8ecc8; --border: #a2dabc; }
.tile:nth-child(4n + 3) { --light: #fff7b9; --dark: #ffea87; --border: #ead58a; }
.tile:nth-child(4n + 4) { --light: #ffd4e5; --dark: #fab6d0; --border: #f0a9c5; }
.tile:disabled { cursor: default; }
.tile[aria-pressed="true"] { --light: #ffc4df; --dark: #ff9ec4; --border: #dd0054; box-shadow: inset 0 0 0 clamp(2px, .55vw, 7px) #dd0054, 0 4px 7px #703f343b; }
.tile.wrong { --light: #ffe0d4; --dark: #ffbbad; --border: #af342a; box-shadow: inset 0 0 0 3px #af342a, 0 4px 7px #703f343b; }
.tile.matched { --light: #ffe2ed; --dark: #ffc4db; --border: #f46690; color: var(--pink); }
.tile.matched:hover { cursor: default; filter: none; transform: none; }
.tile.matched img { display: block; width: 43%; height: 43%; object-fit: contain; }
.tile.fresh { animation: pop .28s ease-out; }
@keyframes pop { 45% { transform: scale(.91); filter: brightness(1.22); } }
.track { grid-row: 2; width: var(--board-width); justify-self: center; height: 4px; border-radius: 9px; overflow: hidden; background: #f4dfd7; }
#progress { height: 100%; background: #ed5682; border-radius: inherit; }
.board-wrap > .start { position: absolute; z-index: 1; left: 50%; top: 50%; min-width: min(65%, 320px); min-height: 58px; padding: .65em 1.3em; transform: translate(-50%, -50%); font-size: clamp(1.05rem, 2.2vw, 1.65rem); box-shadow: 0 5px 12px #703f3440; }
.board-wrap > .start[hidden] { display: none; }
.round-result { align-self: center; justify-self: center; display: flex; flex-direction: column; align-items: center; text-align: center; color: #63073d; }
.round-result[hidden] { display: none; }
.round-result .result-heart { width: clamp(48px, 8vh, 76px); height: clamp(48px, 8vh, 76px); object-fit: contain; }
.round-result h2 { margin: .06em 0; font-size: clamp(1.8rem, 5.2vh, 3.4rem); letter-spacing: -.045em; }
.round-result p { margin: .25em 0 0; font-size: clamp(.95rem, 2.7vh, 1.5rem); }
.round-result > strong { display: block; font-size: clamp(4rem, 15vh, 9.5rem); line-height: .96; letter-spacing: -.07em; font-weight: 500; font-variant-numeric: tabular-nums; }
.round-result > small { color: #784356; font-size: clamp(.9rem, 2.5vh, 1.4rem); }
.round-result .replay { position: static; left: auto; top: auto; min-width: min(72vw, 320px); margin-top: clamp(12px, 2.5vh, 24px); transform: none; }
.controls { position: fixed; z-index: 2; right: var(--edge); bottom: var(--edge); display: flex; justify-content: flex-end; align-items: center; gap: 5px; }
.control, .start { border-radius: 999px; min-height: 36px; padding: .28em .82em; font-size: clamp(.79rem, 1.5vw, 1.04rem); }
.control { justify-self: start; border: 2px solid #eccbc4; background: #fff8ed; }
.start { display: inline-flex; align-items: center; justify-content: center; gap: .42em; text-align: center; border: 1px solid transparent; color: #fff; background: var(--pink); }
.button-heart { display: inline-block; vertical-align: -.16em; width: 1.15em; height: 1.08em; object-fit: contain; }
.start:not(:disabled):hover { background: #9a0e49; }
.start:disabled { background: #f7dbe1; color: #76455d; cursor: default; }
.utilities { justify-self: end; display: flex; gap: 4px; }
.icon { display: grid; place-items: center; width: 36px; padding: 0; }
.icon svg { width: 19px; height: 19px; }
#sound .mute, #sound[aria-pressed="false"] .waves { display: none; }
#sound[aria-pressed="false"] .mute { display: inline; }
.fullscreen-status { grid-column: 1 / -1; margin: 0; text-align: center; color: #784356; font-size: .85rem; }
.fullscreen-status:empty { display: none; }
.audio-status { grid-column: 1 / -1; margin: 0; text-align: center; color: #784356; font-size: .85rem; }
.audio-status:empty { display: none; }

@media (max-width: 720px) {
  :root { --edge: 10px; --board-width: 100%; }
  .game { gap: clamp(5px, 1vh, 10px); padding: clamp(7px, 1.4vh, 14px) var(--edge); }
  .intro { grid-template-columns: 1fr 1fr; column-gap: 6px; row-gap: 4px; }
  .intro h1 { font-size: clamp(1.55rem, 8vw, 3.2rem); letter-spacing: -.06em; }
  .intro p { font-size: clamp(.88rem, 4vw, 1.35rem); }
  .stat { gap: .16em; margin-top: 6px; padding: .18em .38em; font-size: clamp(.82rem, 4vw, 1.25rem); }
  .stat svg, .stat img { width: 1.1em; height: 1.1em; }
  .panel { gap: 6px; }
  .board-wrap > .board:not([hidden]) {
    inset: 0 auto auto 50%;
    width: min(100%, calc(100dvh - 170px));
    height: auto;
    aspect-ratio: 1;
    transform: translateX(-50%);
  }
  .board { grid-template-rows: repeat(5, minmax(0, 1fr)); gap: clamp(4px, 1.3vw, 8px); }
  .tile { min-height: 0; border-radius: clamp(9px, 2.5vw, 17px); font-size: clamp(1.12rem, min(8vw, 7.5svh), 3rem); }
  .tile:not(.matched) { padding: .1em 0 0; }
  @supports (text-box: trim-both cap alphabetic) {
    .tile:not(.matched) { padding: 0; }
    .tile-number { text-box: trim-both cap alphabetic; }
  }
  .track { height: 3px; }
  .controls { min-height: 32px; }
  .icon { width: 32px; min-height: 32px; }
  .icon svg { width: 17px; height: 17px; }
  .intro h1 { grid-column: 1 / -1; grid-row: 1; }
  .intro p { grid-row: 2; margin: 0; }
  .hearts { display: none; }
  .round-result > strong { font-size: clamp(4rem, 18vw, 7rem); }
}

@media (hover: hover) and (pointer: fine) {
  .tile:not(:disabled):hover { filter: brightness(1.035); transform: translateY(-2px); }
  .control:hover { background: #ffe9ed; }
}

@media (max-height: 680px) {
  .game { gap: clamp(5px, 1vh, 10px); padding-top: clamp(6px, 1vh, 12px); padding-bottom: clamp(6px, 1vh, 12px); }
  .intro h1 { font-size: min(5.4vw, 8vh); }
  .intro p { font-size: min(2.7vw, 4vh); }
  .stat { font-size: min(3.1vw, 5vh); }
  .board { grid-template-rows: repeat(5, minmax(0, 1fr)); gap: clamp(4px, .7vw, 9px); }
  .tile { font-size: clamp(1rem, min(6vw, 8vh), 4.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  .tile { transition: none; }
  .tile.fresh { animation: none; }
}
