:root {
  color-scheme: light;
  --paper: #efe8dc;
  --ink: #1c1915;
  --tile: #f7f3ec;
  --line: #d8d0c3;
  --muted: #6d665c;
  --pressed: #1c1915;
  --pressed-ink: #f6f1e8;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
}

body {
  margin: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.3 "Segoe UI", system-ui, sans-serif;
}

.top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 6px;
}

h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.link-state {
  margin: 0;
  color: var(--muted);
}

#sound-toggle,
.menu-actions button {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}

#sound-toggle {
  margin-left: auto;
}

#sound-toggle.is-on {
  background: var(--ink);
  color: var(--pressed-ink);
  border-color: var(--ink);
}

.grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 6px;
  padding: 6px 10px 12px;
}

.tile {
  position: relative;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tile);
  color: var(--ink);
  font: inherit;
  font-size: clamp(18px, 6vw, 28px);
  font-weight: 500;
  cursor: pointer;
}

.tile.is-down {
  background: var(--pressed);
  border-color: var(--pressed);
  color: var(--pressed-ink);
}

.tile.has-sound::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.tile.is-down.has-sound::after {
  background: #cfc6b8;
}

dialog {
  border: 0;
  border-radius: 16px;
  padding: 16px;
  width: min(320px, calc(100% - 24px));
  color: var(--ink);
  background: var(--tile);
}

dialog::backdrop {
  background: rgb(28 25 21 / 40%);
}

.menu-title {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.menu-sound {
  margin: 6px 0 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.menu-actions button {
  width: 100%;
}

#menu-remove[hidden] {
  display: none;
}
