.tf-shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 16px 24px;
  color: var(--cg-ink);
  font-family: Inter, Arial, sans-serif;
}

.tf-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.tf-statline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.tf-stat,
.tf-hud-card {
  min-width: 74px;
  padding: 8px 10px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
}

.tf-stat span,
.tf-hud-card span {
  display: block;
  color: var(--cg-muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.tf-stat strong,
.tf-hud-card strong {
  display: block;
  margin-top: 2px;
  color: var(--cg-ink);
  font-size: 19px;
  line-height: 1;
}

.tf-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tf-btn,
.tf-close {
  min-height: 44px;
  min-width: 44px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tf-btn {
  padding: 0 14px;
}

.tf-btn:hover,
.tf-close:hover {
  transform: translateY(-1px);
  border-color: rgba(18, 122, 137, 0.45);
}

.tf-btn:focus-visible,
.tf-close:focus-visible,
.tf-canvas:focus-visible {
  outline: 3px solid rgba(49, 95, 157, 0.35);
  outline-offset: 3px;
}

.tf-primary {
  border-color: transparent;
  background: var(--cg-teal);
  color: #fff;
}

.tf-icon-btn {
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.tf-icon-btn svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tf-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  box-shadow: var(--cg-shadow);
  touch-action: manipulation;
}

.tf-canvas {
  display: block;
  width: 100%;
  height: min(72vh, 640px);
  min-height: 460px;
  cursor: pointer;
}

.tf-hud {
  position: absolute;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 8px;
  transform: translateX(-50%);
  pointer-events: none;
}

.tf-hud-card {
  min-width: 78px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.tf-start,
.tf-result {
  position: absolute;
  left: 50%;
  display: grid;
  gap: 6px;
  width: min(82%, 280px);
  padding: 16px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--cg-ink);
  text-align: center;
  box-shadow: var(--cg-shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(10px);
}

.tf-start {
  bottom: 22px;
  pointer-events: none;
}

.tf-start strong,
.tf-result strong {
  font-size: 22px;
  line-height: 1.1;
}

.tf-start span,
.tf-result span,
.tf-result p {
  margin: 0;
  color: var(--cg-muted);
  font-size: 14px;
}

.tf-result {
  top: 50%;
  width: min(88%, 320px);
  transform: translate(-50%, -50%);
  animation: tf-pop 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes tf-pop {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.94); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.tf-final-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 4px 0 2px;
}

.tf-final-cell {
  padding: 6px 2px;
  border: 1px solid var(--cg-line);
  border-radius: 7px;
  background: rgba(246, 247, 242, 0.9);
}

.tf-final-cell span {
  display: block;
  color: var(--cg-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.tf-final-cell strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.tf-result-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.tf-result-actions .tf-btn {
  flex: 1 1 0;
}

.tf-mult {
  position: absolute;
  top: 50%;
  right: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, #f7d774, #c47a17);
  color: #2b1d05;
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.28);
  transform: translateY(-50%);
  pointer-events: none;
}

.tf-below {
  display: flex;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.tf-seg {
  display: flex;
  padding: 4px;
  border: 1px solid var(--cg-line);
  border-radius: 10px;
  background: var(--cg-panel);
  gap: 4px;
  box-shadow: 0 8px 20px rgba(33, 43, 40, 0.08);
}

.tf-seg-off {
  opacity: 0.5;
}

.tf-seg-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--cg-muted);
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.tf-seg-btn:hover:not(:disabled) {
  background: rgba(18, 122, 137, 0.1);
  color: var(--cg-ink);
}

.tf-seg-btn[aria-pressed="true"] {
  background: var(--cg-teal);
  color: #fff;
}

.tf-seg-btn:disabled {
  cursor: default;
}

.tf-seg-btn:focus-visible {
  outline: 3px solid rgba(49, 95, 157, 0.35);
  outline-offset: 2px;
}

.tf-note {
  margin: 10px 0 0;
  color: var(--cg-muted);
  font-size: 13px;
  line-height: 1.45;
}

.tf-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 37, 40, 0.32);
}

.tf-modal-card {
  position: relative;
  width: min(100%, 430px);
  padding: 22px;
  border: 1px solid var(--cg-line);
  border-radius: 8px;
  background: var(--cg-panel);
  color: var(--cg-ink);
  box-shadow: 0 24px 70px rgba(30, 37, 40, 0.22);
}

.tf-modal-card h2 {
  margin: 0 48px 12px 0;
  font-size: 24px;
  line-height: 1.1;
}

.tf-modal-card p {
  margin: 10px 0 0;
  color: var(--cg-muted);
  line-height: 1.45;
}

.tf-close {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.tf-hide {
  display: none !important;
}

@media (max-width: 560px) {
  .tf-shell {
    padding: 0 10px 18px;
  }

  .tf-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .tf-statline,
  .tf-actions {
    justify-content: center;
  }

  .tf-stat {
    flex: 1 1 72px;
    text-align: center;
  }

  .tf-canvas {
    height: min(68vh, 560px);
    min-height: 420px;
  }

  .tf-hud {
    top: 8px;
    gap: 5px;
  }

  .tf-hud-card {
    min-width: 0;
    padding: 6px 7px;
  }

  .tf-hud-card span {
    font-size: 9px;
  }

  .tf-hud-card strong {
    font-size: 15px;
  }

  .tf-below {
    gap: 8px;
  }

  .tf-seg {
    flex: 1 1 100%;
    justify-content: center;
  }

  .tf-seg-btn {
    flex: 1 1 0;
    padding: 0 6px;
    font-size: 13px;
  }
}
