:root {
  --bg: #050505;
  --text: #f4f4f4;
  --muted: #8a8a8a;
  --red: #e82127;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
}

.tf-app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 16px 24px 20px;
  gap: 14px;
}

.tf-app > header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tf-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.back-link,
.tf-top h1 {
  font-size: 28px;
  font-weight: 600;
}

.back-link {
  color: #fff;
  text-decoration: none;
  padding: 8px 16px;
  border: 2px solid #fff;
  border-radius: 999px;
  white-space: nowrap;
}

.back-link:active {
  background: #fff;
  color: #000;
}

.hint,
.status {
  text-align: center;
  color: var(--muted);
  font-size: 22px;
}

.status {
  color: #fff;
}

.cards {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-content: center;
}

.card {
  height: 180px;
  border: 0;
  border-radius: 24px;
  background: #161616;
  color: #fff;
  font-size: 64px;
  font-weight: 600;
}

.card.selected {
  background: var(--red);
}

.card:active {
  transform: scale(0.98);
}

.ops {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.op-btn,
.actions button {
  height: 84px;
  border: 0;
  border-radius: 20px;
  background: #1c1c1c;
  color: #fff;
  font-size: 36px;
  font-weight: 600;
}

.op-btn.selected {
  background: var(--red);
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.actions button {
  font-size: 26px;
}

.op-btn:active,
.actions button:active {
  background: #333;
}

.solution {
  text-align: center;
  font-size: 26px;
  min-height: 34px;
  color: #9fe7b0;
}

@media (max-height: 700px) {
  .card { height: 120px; font-size: 44px; }
  .op-btn, .actions button { height: 64px; font-size: 28px; }
  .actions button { font-size: 22px; }
}
