:root {
  --bg: #fff;
  --ink: #000;
  --soft: #6b6b66;
  --miss: #e4e4df;
  --line: #d6d6d0;
  --sign: #ffc72c;
  --hit: #2f9e4f;
  --near-bg: #ffc72c;
  --near-fg: #000;
  --hit-fg: #fff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000;
    --ink: #f0f0ec;
    --soft: #8f8f88;
    --miss: #2a2a27;
    --line: #333330;
    --hit: #3aa65a;
  }
}

:root[data-theme="dark"] {
  --bg: #000;
  --ink: #f0f0ec;
  --soft: #8f8f88;
  --miss: #2a2a27;
  --line: #333330;
  --hit: #3aa65a;
}

:root {
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: inherit;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font:
    16px/1.4 "Familjen Grotesk",
    system-ui,
    sans-serif;
  font-variant-numeric: tabular-nums;
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 14px;
}

header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 0 12px;
  border-bottom: 2px solid var(--ink);
}

.logo {
  font-weight: 700;
  font-size: 2rem;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
  display: flex;
}

.logo span {
  display: inline-block;
}

.logo.wobble span {
  animation: wob 0.9s ease-in-out both;
}

@keyframes wob {
  0%,
  100% {
    transform: none;
  }
  25% {
    transform: translateY(-4px) rotate(-6deg);
  }
  60% {
    transform: translateY(2px) rotate(5deg);
  }
}

.tag {
  font-size: 0.95rem;
  color: var(--soft);
  margin-right: auto;
}

.tag a {
  color: inherit;
}

.icon {
  background: none;
  border: 0;
  color: var(--ink);
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font: 600 1.15rem inherit;
}

.icon svg {
  width: 22px;
  height: 22px;
}

.cols,
.tiles {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

.cols {
  font-size: 0.72rem;
  color: var(--soft);
  padding: 10px 0 4px;
}

.cols span {
  text-align: center;
}

.row {
  padding: 6px 0 4px;
}

.row .nm {
  font-weight: 600;
  font-size: 0.95rem;
  height: 1.4em;
  margin-bottom: 2px;
}

.row.empty .nm {
  color: var(--line);
}

.t {
  min-height: 50px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 3px 2px;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.1;
  background: var(--miss);
  border-radius: 2px;
  overflow-wrap: anywhere;
}

.row.empty .t {
  background: none;
  outline: 1.5px solid var(--line);
  outline-offset: -1.5px;
}

.t.h {
  background: var(--hit);
  color: var(--hit-fg);
  font-weight: 700;
}

.t.n {
  background: var(--near-bg);
  color: var(--near-fg);
  font-weight: 600;
}

.t i {
  font-style: normal;
  font-size: 0.7rem;
  display: block;
}

.row.new .t {
  animation: flip 0.5s both;
}

@keyframes flip {
  from {
    transform: rotateX(90deg);
  }
  to {
    transform: none;
  }
}

.bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 2px solid var(--ink);
  padding: 10px 0 14px;
  margin-top: 10px;
}

.field {
  position: relative;
  display: flex;
  gap: 6px;
}

input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 1.05rem;
  padding: 12px;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
}

button.go {
  font: inherit;
  font-weight: 700;
  padding: 0 20px;
  border: 0;
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--sign);
  outline-offset: 2px;
}

.sugg {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--bg);
  border: 2px solid var(--ink);
  max-height: 290px;
  overflow: auto;
}

.sugg li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
}

.sugg li small {
  color: var(--soft);
}

.sugg li[aria-selected="true"] {
  background: var(--sign);
  color: #000;
}

.sugg li[aria-selected="true"] small {
  color: #000;
}

.toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 70px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  z-index: 9;
  max-width: 90vw;
  text-align: center;
}

.toast.on {
  opacity: 1;
}

.again {
  padding: 6px 0 0;
  font-size: 0.95rem;
}

.again button {
  font: inherit;
  background: none;
  border: 0;
  padding: 0;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
}

dialog {
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 22px;
  width: min(420px, calc(100% - 24px));
  background: var(--bg);
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
}

dialog h2 {
  margin: 0 0 4px;
  font-size: 1.7rem;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

dialog p {
  margin: 8px 0;
}

.x {
  position: absolute;
  top: 8px;
  right: 8px;
}

.spec {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 14px;
  margin: 12px 0;
  font-size: 0.95rem;
}

.spec dt {
  color: var(--soft);
}

.spec dd {
  margin: 0;
  font-weight: 600;
}

.nums {
  display: flex;
  gap: 18px;
  margin: 14px 0 10px;
}

.nums div {
  font-size: 0.78rem;
  color: var(--soft);
}

.nums b {
  display: block;
  font-size: 1.6rem;
  color: var(--ink);
  line-height: 1;
}

.dist {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 3px 8px;
  align-items: center;
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.dist i {
  display: block;
  background: var(--miss);
  font-style: normal;
  padding: 2px 6px;
  text-align: right;
  min-width: 22px;
}

.dist i.me {
  background: var(--hit);
  color: #fff;
  font-weight: 700;
}

.acts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.acts button {
  font: inherit;
  font-weight: 700;
  padding: 11px 16px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}

.acts button.alt {
  background: none;
  color: var(--ink);
}

.soft {
  color: var(--soft);
  font-size: 0.9rem;
}

.ex {
  display: grid;
  grid-template-columns: repeat(3, 72px);
  gap: 3px;
  margin: 10px 0;
}

@media (max-width: 460px) {
  .t {
    font-size: 0.74rem;
    min-height: 46px;
  }
  .cols {
    font-size: 0.64rem;
  }
  .logo {
    font-size: 1.7rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .row.new .t,
  .logo.wobble span {
    animation: none;
  }
}

.arch {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  max-height: 60vh;
  overflow: auto;
}

.arch li {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  padding: 10px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.arch li:hover,
.arch li:focus-visible {
  background: var(--miss);
  outline: none;
}

.arch .won {
  color: var(--hit);
  font-weight: 700;
}

.arch .lost {
  color: var(--soft);
}
