:root {
  --bg: #fff8ef;
  --ink: #1d1a2b;
  --muted: #6b6578;
  --card-ink: #1d1a2b;
  --line: #1d1a2b;
  --shadow: #1d1a2b;
  --field: #ffffff;
  --accent: #ff5a36;
  --ok: #1f9d55;
  --err: #d6336c;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151f;
    --ink: #f4f0ff;
    --muted: #a59fb5;
    --line: #f4f0ff;
    --shadow: #000000;
    --field: #221f2e;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Bricolage Grotesque", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }

.top { padding: 40px 16px 8px; text-align: center; }
.top h1 { font-size: clamp(2.2rem, 7vw, 4.2rem); margin: 0; font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.top h1 span { color: var(--accent); }
.subtitle { color: var(--muted); margin: 12px 0 20px; }

.search, .field {
  font: inherit;
  width: 100%;
  max-width: 420px;
  padding: 12px 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--field);
  color: var(--ink);
}

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.tile {
  --c: #ffd43b;
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  border: 3px solid #1d1a2b;
  border-radius: 20px;
  background: var(--c);
  color: var(--card-ink);
  font: inherit;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.15;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 5px 5px 0 var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease;
  word-break: break-word;
}
.tile:hover { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--shadow); }
.tile:active, .tile.playing { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--shadow); }
.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.tile .icon {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: #1d1a2b;
  color: var(--c);
  display: grid; place-items: center;
  font-size: 1rem;
}
.tile .key { position: absolute; top: 12px; right: 14px; font-size: .8rem; opacity: .55; }
.tile .progress {
  position: absolute; left: 0; bottom: 0; height: 6px;
  width: 0; background: #1d1a2b;
}
.tile.playing .icon { animation: pulse .6s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.foot { display: flex; gap: 12px; justify-content: center; padding: 24px 16px 32px; flex-wrap: wrap; }
.ghost, .btn {
  font: inherit; font-weight: 700;
  border: 2px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
}
.ghost:hover { background: var(--ink); color: var(--bg); }
.btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn:disabled { opacity: .5; cursor: wait; }

@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .tile { font-size: 1rem; padding: 12px; }
}
