.tq-wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 18px 56px;
}

.tq-hero {
  margin-bottom: 18px;
}

.tq-hero-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
  margin-bottom: 10px;
}

.tq-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.18;
  letter-spacing: -0.02em;
}

.tq-hero p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
  max-width: 72ch;
}

.tq-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 14px;
}

.tq-tabs-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.tq-share-wrap {
  position: relative;
}

.tq-share-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.tq-share-toggle:hover,
.tq-share-toggle[aria-expanded="true"] {
  border-color: var(--accent);
}

.tq-share-toggle[aria-expanded="true"] .tq-share-chev {
  transform: rotate(180deg);
}

.tq-share-chev {
  transition: transform 0.16s ease;
}

.tq-share-pop {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  background: #ffffff;
  color: #1e1b24;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.18);
}

.tq-share-desc {
  margin: 0 0 12px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.tq-share-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.tq-share-url {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.tq-copy-link-btn {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 10px;
  background: #27272a;
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.tq-copy-link-btn:hover {
  background: #18181b;
}

.tq-mode-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border-radius: 12px;
  border: 1px solid var(--line);
}

.tq-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.tq-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.tq-options-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
}

.tq-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.tq-select-wrap .field {
  min-width: 152px;
  padding: 7px 10px;
  font-size: 14px;
}

.tq-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.tq-check input {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

.tq-hud {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 16px 16px;
  margin-bottom: 18px;
  overflow: hidden;
}

.tq-hud-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tq-hud-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.tq-hud-val {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.2;
}

.tq-hud-val small {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.tq-mono {
  font-family: var(--tech), ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.tq-hud-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.tq-hud-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #10b981);
  transition: width 0.25s ease;
}

.tq-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(310px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.tq-map-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.05);
}

.tq-map-question {
  display: none;
}

.tq-pan-tip {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.tq-map-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.tq-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.tq-leg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tq-dot {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  border: 1px solid rgba(15, 23, 42, 0.22);
}

.tq-dot-idle { background: #f8fafc; }
.tq-dot-target { background: #3b82f6; border-color: #1d4ed8; }
.tq-dot-correct { background: #10b981; border-color: #047857; }
.tq-dot-retry { background: #eab308; border-color: #a16207; }
.tq-dot-wrong { background: #f43f5e; border-color: #be123c; }

.tq-zoom-btns {
  display: inline-flex;
  gap: 4px;
}

.tq-zoom-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.tq-zoom-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tq-map-viewport {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #9cc7da;
  background: #d4ebf5;
  touch-action: manipulation;
}

.tq-map-viewport[data-zoomed] {
  touch-action: none;
  cursor: grab;
}

.tq-map-viewport[data-dragging],
.tq-map-viewport[data-dragging] .tq-county {
  cursor: grabbing;
}

#tq-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 680px;
  user-select: none;
}

.tq-insets,
.tq-compass,
.tq-coastline {
  pointer-events: none;
}

.tq-inset-box {
  fill: rgba(255, 255, 255, 0.34);
  stroke: #5690ad;
  stroke-width: 1.25;
  stroke-dasharray: 4 3;
}

.tq-inset-label {
  font-size: 10px;
  font-weight: 700;
  fill: #1b4b66;
}

.tq-coastline {
  fill: #e2eff5;
  stroke: #5c97b5;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.tq-county {
  fill: #f9fbf8;
  stroke: #467891;
  stroke-width: 0.9;
  stroke-linejoin: round;
  stroke-linecap: round;
  cursor: pointer;
  transition: fill 0.16s ease, stroke 0.16s ease, stroke-width 0.16s ease;
}

.tq-county[data-region="北部"] { fill: #f5faf6; }
.tq-county[data-region="中部"] { fill: #f9faee; }
.tq-county[data-region="南部"] { fill: #fdf7f0; }
.tq-county[data-region="東部"] { fill: #f1f9f7; }
.tq-county[data-region="離島"] {
  fill: #f6f8fc;
  pointer-events: bounding-box;
}

.tq-county:hover,
.tq-county:focus-visible {
  fill: #dbeafe;
  stroke: #1d4ed8;
  stroke-width: 1.6;
  outline: none;
}

.tq-county[data-state="target"] {
  fill: #3b82f6;
  stroke: #1e3a8a;
  stroke-width: 1.8;
  animation: tq-pulse 1.35s ease-in-out infinite;
}

.tq-county[data-state="correct"] {
  fill: #10b981;
  stroke: #065f46;
  stroke-width: 1.1;
}

.tq-county[data-state="retry"] {
  fill: #eab308;
  stroke: #854d0e;
  stroke-width: 1.15;
}

.tq-county[data-state="wrong"] {
  fill: #f43f5e;
  stroke: #9f1239;
  stroke-width: 1.2;
}

.tq-county[data-state="selected"] {
  fill: #6366f1;
  stroke: #312e81;
  stroke-width: 1.7;
}

@keyframes tq-pulse {
  0%, 100% { fill: #3b82f6; }
  50% { fill: #60a5fa; }
}

.tq-halo-outer {
  fill: none;
  stroke: #d97706;
  stroke-width: 2;
  stroke-opacity: 0.75;
  pointer-events: none;
  animation: tq-ring 1.5s ease-out infinite;
}

.tq-halo-inner {
  fill: none;
  stroke: #b45309;
  stroke-width: 1.6;
  pointer-events: none;
}

@keyframes tq-ring {
  0% { r: 10; stroke-opacity: 0.9; }
  100% { r: 28; stroke-opacity: 0; }
}

.tq-map-label {
  font-size: 9.5px;
  font-weight: 800;
  fill: #0f172a;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 2.6px;
  stroke-linejoin: round;
  pointer-events: none;
}

.tq-hover-tip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.9);
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  transform: translate(-50%, -120%);
  z-index: 4;
}

.tq-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tq-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}

.tq-prompt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.tq-step-badge {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  padding: 4px 10px;
  border-radius: 999px;
}

.tq-type-pill {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  padding: 4px 10px;
  border-radius: 999px;
}

.tq-prompt-title {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.3;
}

.tq-prompt-sub {
  margin: 0 0 14px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.tq-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tq-input {
  width: 100%;
  font-size: 17px;
  font-weight: 700;
  padding: 12px 14px;
  border-radius: 12px;
}

.tq-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tq-pick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  margin: 10px 0 14px;
}

.tq-pick-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 6px;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  text-align: center;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.tq-pick-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.tq-pick-btn.done-ok {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
  opacity: 0.7;
  cursor: default;
}

.tq-pick-btn.done-retry {
  background: #fefce8;
  border-color: #fde047;
  color: #854d0e;
  opacity: 0.8;
  cursor: default;
}

.tq-pick-btn.done-err {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #9f1239;
  opacity: 0.7;
  cursor: default;
}

.tq-target-display {
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 900;
  color: var(--accent);
  margin: 6px 0 12px;
  letter-spacing: 0.02em;
}

.tq-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.tq-feedback[data-kind="ok"] {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.tq-feedback[data-kind="err"] {
  background: #fff1f2;
  color: #9f1239;
  border: 1px solid #fecdd3;
}

.tq-feedback[data-kind="hint"] {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.tq-exp-meta {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
}

.tq-exp-note {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink);
}

.tq-summary-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  background: #ecfdf5;
  color: #065f46;
  margin-bottom: 8px;
}

.tq-sum-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 16px;
}

.tq-sum-stats div {
  background: color-mix(in srgb, var(--ink) 4%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.tq-sum-stats span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.tq-sum-stats strong {
  font-size: 18px;
  font-weight: 800;
}

.tq-sum-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tq-sum-chip {
  font-size: 12.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
}

.tq-sum-chip.ok {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.tq-sum-chip.retry {
  background: #fefce8;
  color: #854d0e;
  border-color: #fde047;
}

.tq-sum-chip.err {
  background: #fff1f2;
  color: #9f1239;
  border-color: #fecdd3;
}

.tq-fact-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.tq-fact-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--muted);
}

.tq-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.tq-history-head strong {
  font-size: 15px;
}

.tq-clear-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
}

.tq-clear-btn:hover {
  color: #e11d48;
}

.tq-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tq-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 7px 10px;
  border-radius: 9px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.tq-history-meta {
  color: var(--muted);
  font-size: 12px;
}

.tq-score-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.tq-nick-input {
  flex: 1 1 170px;
  min-width: 0;
  padding: 9px 12px;
  font-size: 14px;
}

.tq-board-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.tq-board-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.tq-board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tq-board-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  background: color-mix(in srgb, var(--ink) 4%, transparent);
}

.tq-board-row.mine {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}

.tq-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  background: color-mix(in srgb, var(--ink) 10%, transparent);
  color: var(--ink);
}

.tq-rank-1 { background: #fef3c7; color: #92400e; }
.tq-rank-2 { background: #e2e8f0; color: #334155; }
.tq-rank-3 { background: #ffedd5; color: #9a3412; }

.tq-board-nick {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.tq-board-val {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.tq-ref {
  margin-top: 28px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}

.tq-ref h2 {
  margin: 0 0 6px;
  font-size: 20px;
}

.tq-ref-desc {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--muted);
}

.tq-guide h3 {
  margin: 18px 0 4px;
  font-size: 16px;
}

.tq-guide p {
  max-width: 72ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

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

.tq-ref-group h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.tq-ref-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tq-ref-chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.tq-ref-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tq-license {
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--muted);
}

.tq-license a {
  color: var(--accent);
}

@media (max-width: 860px) {
  .tq-stage {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .tq-map-question:not([hidden]) {
    display: block;
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 19px;
    font-weight: 800;
  }

  .tq-zoom-btn {
    min-width: 44px;
    height: 44px;
  }

  .tq-map-toolbar,
  .tq-prompt-head {
    margin-bottom: 6px;
  }

  #tq-panel-type .tq-prompt-title,
  #tq-panel-pick .tq-prompt-title {
    font-size: 16px;
  }

  .tq-stage[data-keyboard] #tq-svg {
    max-height: var(--tq-keyboard-map-height);
  }

  .tq-stage[data-keyboard] #tq-panel-type:not([hidden]) {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .tq-stage[data-keyboard] .tq-form {
    order: -1;
  }

  .tq-hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tq-ref-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .tq-wrap {
    padding: 14px 12px 40px;
  }

  .tq-card {
    padding: 16px;
  }

  .tq-tab {
    padding: 7px 10px;
    font-size: 13px;
  }

  .tq-sum-stats {
    grid-template-columns: 1fr;
  }
}
